Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ target 'ExampleApp' do
config = use_native_modules!
...
pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/3.7.5/GCDWebServer.podspec', modular_headers: true
pod 'ReadiumAdapterGCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumAdapterGCDWebServer.podspec', modular_headers: true
pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumNavigator.podspec'
pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumShared.podspec'
pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumStreamer.podspec'
Expand Down Expand Up @@ -160,7 +161,7 @@ DRM is not supported at this time. However, there is a clear path to [support it
|------|------|----------|-------------|
| `file` | [`File`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/File.ts) | :x: | A file object containing the path to the eBook file on disk. |
| `location` | [`Locator`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Locator.ts) \| [`Link`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Link.ts) | :white_check_mark: | A locator prop that allows you to externally control the location of the reader (e.g. Chapters or Bookmarks). <br/><br/>:warning: If you want to set the `location` of an ebook on initial load, you should use the `File.initialLocation` property (look at the `file` prop). See more [here](https://github.com/5-stones/react-native-readium/issues/16#issuecomment-1344128937) |
| `settings` | [`Partial<Settings>`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Settings.ts) | :white_check_mark: | An object that allows you to control various aspects of the reader's UI (epub only) |
| `preferences` | [`Partial<Preferences>`](https://github.com/readium/swift-toolkit/blob/main/docs/Guides/Navigator%20Preferences.md#appendix-preference-constraints) | :white_check_mark: | An object that allows you to control various aspects of the reader's UI (epub only) |
| `style` | `ViewStyle` | :white_check_mark: | A traditional style object. |
| `onLocationChange` | `(locator: Locator) => void` | :white_check_mark: | A callback that fires whenever the location is changed (e.g. the user transitions to a new page)|
| `onTableOfContents` | `(toc: Link[] \| null) => void` | :white_check_mark: | A callback that fires once the file is parsed and emits the table of contents embedded in the file. Returns `null` or an empty `[]` if no TOC exists. See the [`Link`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Link.ts) interface for more info. |
Expand Down
17 changes: 10 additions & 7 deletions android/src/main/java/com/reactnativereadium/ReadiumView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
import com.reactnativereadium.reader.BaseReaderFragment
import com.reactnativereadium.reader.EpubReaderFragment
import com.reactnativereadium.reader.ReaderViewModel
import com.reactnativereadium.reader.VisualReaderFragment
import com.reactnativereadium.utils.Dimensions
import com.reactnativereadium.utils.File
import com.reactnativereadium.utils.LinkOrLocator
import org.readium.r2.navigator.epub.EpubNavigatorFragment
import org.readium.r2.navigator.epub.EpubPreferences
import org.readium.r2.shared.extensions.toMap

class ReadiumView(
Expand All @@ -21,7 +24,7 @@ class ReadiumView(
var file: File? = null
var fragment: BaseReaderFragment? = null
var isViewInitialized: Boolean = false
var lateInitSettings: Map<String, Any>? = null
var lateInitSerializedUserPreferences: String? = null

fun updateLocation(location: LinkOrLocator) : Boolean {
if (fragment == null) {
Expand All @@ -31,25 +34,25 @@ class ReadiumView(
}
}

fun updateSettingsFromMap(map: Map<String, Any>?) {
if (map == null) {
fun updatePreferencesFromJsonString(preferences: String?) {
if (preferences == null) {
return
} else if (fragment == null) {
lateInitSettings = map
lateInitSerializedUserPreferences = preferences
return
}

if (fragment is EpubReaderFragment) {
(fragment as EpubReaderFragment).updateSettingsFromMap(map)
(fragment as EpubReaderFragment).updatePreferencesFromJsonString(preferences)
}

lateInitSettings = null
lateInitSerializedUserPreferences = null
}

fun addFragment(frag: BaseReaderFragment) {
fragment = frag
setupLayout()
updateSettingsFromMap(lateInitSettings)
updatePreferencesFromJsonString(lateInitSerializedUserPreferences)
val activity: FragmentActivity? = reactContext.currentActivity as FragmentActivity?
activity!!.supportFragmentManager
.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ class ReadiumViewManager(
}
}

@ReactProp(name = "settings")
fun setSettings(view: ReadiumView, settings: ReadableMap) {
val map = mutableMapOf<String, Any>()
settings.toHashMap().forEach { (key, value) -> if (value != null) map[key] = value }
view.updateSettingsFromMap(map)
@ReactProp(name = "preferences")
fun setPreferences(view: ReadiumView, serialisedPreferences: String) {
view.updatePreferencesFromJsonString(serialisedPreferences)
}

@ReactPropGroup(names = ["width", "height"], customType = "Style")
Expand Down
246 changes: 0 additions & 246 deletions android/src/main/java/com/reactnativereadium/epub/UserSettings.kt

This file was deleted.

Loading