react-native-readium 1.0.0-alpha.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -4
- package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +13 -1
- package/android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt +53 -11
- package/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt +16 -0
- package/android/src/main/java/com/reactnativereadium/reader/BaseReaderFragment.kt +32 -30
- package/android/src/main/java/com/reactnativereadium/reader/ReaderViewModel.kt +2 -0
- package/android/src/main/java/com/reactnativereadium/utils/File.kt +8 -0
- package/ios/ReadiumView.swift +15 -3
- package/ios/ReadiumViewManager.m +1 -0
- package/lib/commonjs/components/BaseReadiumView.js +16 -0
- package/lib/commonjs/components/BaseReadiumView.js.map +1 -0
- package/lib/commonjs/components/ReadiumView.js +94 -0
- package/lib/commonjs/components/ReadiumView.js.map +1 -0
- package/lib/commonjs/index.js +25 -71
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/Link.js +2 -0
- package/lib/commonjs/interfaces/Link.js.map +1 -0
- package/lib/commonjs/interfaces/index.js +13 -0
- package/lib/commonjs/interfaces/index.js.map +1 -1
- package/lib/commonjs/utils/COMPONENT_NAME.js +9 -0
- package/lib/commonjs/utils/COMPONENT_NAME.js.map +1 -0
- package/lib/commonjs/utils/LINKING_ERROR.js +15 -0
- package/lib/commonjs/utils/LINKING_ERROR.js.map +1 -0
- package/lib/commonjs/utils/RANGES.js +16 -0
- package/lib/commonjs/utils/RANGES.js.map +1 -0
- package/lib/commonjs/utils/clamp.js +15 -0
- package/lib/commonjs/utils/clamp.js.map +1 -0
- package/lib/commonjs/utils/createFragment.js +21 -0
- package/lib/commonjs/utils/createFragment.js.map +1 -0
- package/lib/commonjs/utils/getWidthOrHeightValue.js +15 -0
- package/lib/commonjs/utils/getWidthOrHeightValue.js.map +1 -0
- package/lib/commonjs/utils/index.js +91 -24
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/indexOfObjectValue.js +13 -0
- package/lib/commonjs/utils/indexOfObjectValue.js.map +1 -0
- package/lib/module/components/BaseReadiumView.js +6 -0
- package/lib/module/components/BaseReadiumView.js.map +1 -0
- package/lib/module/components/ReadiumView.js +75 -0
- package/lib/module/components/ReadiumView.js.map +1 -0
- package/lib/module/index.js +2 -58
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/Link.js +2 -0
- package/lib/module/interfaces/Link.js.map +1 -0
- package/lib/module/interfaces/index.js +1 -0
- package/lib/module/interfaces/index.js.map +1 -1
- package/lib/module/utils/COMPONENT_NAME.js +2 -0
- package/lib/module/utils/COMPONENT_NAME.js.map +1 -0
- package/lib/module/utils/LINKING_ERROR.js +6 -0
- package/lib/module/utils/LINKING_ERROR.js.map +1 -0
- package/lib/module/utils/RANGES.js +9 -0
- package/lib/module/utils/RANGES.js.map +1 -0
- package/lib/module/utils/clamp.js +6 -0
- package/lib/module/utils/clamp.js.map +1 -0
- package/lib/module/utils/createFragment.js +10 -0
- package/lib/module/utils/createFragment.js.map +1 -0
- package/lib/module/utils/getWidthOrHeightValue.js +5 -0
- package/lib/module/utils/getWidthOrHeightValue.js.map +1 -0
- package/lib/module/utils/index.js +7 -16
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/indexOfObjectValue.js +4 -0
- package/lib/module/utils/indexOfObjectValue.js.map +1 -0
- package/lib/typescript/components/BaseReadiumView.d.ts +14 -0
- package/lib/typescript/components/ReadiumView.d.ts +5 -0
- package/lib/typescript/index.d.ts +2 -15
- package/lib/typescript/interfaces/Link.d.ts +18 -0
- package/lib/typescript/interfaces/Locator.d.ts +4 -4
- package/lib/typescript/interfaces/index.d.ts +1 -0
- package/lib/typescript/utils/COMPONENT_NAME.d.ts +1 -0
- package/lib/typescript/utils/LINKING_ERROR.d.ts +1 -0
- package/lib/typescript/utils/RANGES.d.ts +8 -0
- package/lib/typescript/utils/clamp.d.ts +1 -0
- package/lib/typescript/utils/createFragment.d.ts +1 -0
- package/lib/typescript/utils/getWidthOrHeightValue.d.ts +1 -0
- package/lib/typescript/utils/index.d.ts +7 -10
- package/lib/typescript/utils/indexOfObjectValue.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/BaseReadiumView.tsx +27 -0
- package/src/components/ReadiumView.tsx +71 -0
- package/src/index.tsx +2 -76
- package/src/interfaces/Link.ts +18 -0
- package/src/interfaces/Locator.ts +4 -4
- package/src/interfaces/index.ts +1 -0
- package/src/utils/COMPONENT_NAME.ts +1 -0
- package/src/utils/LINKING_ERROR.ts +7 -0
- package/src/utils/RANGES.ts +8 -0
- package/src/utils/clamp.ts +5 -0
- package/src/utils/createFragment.ts +15 -0
- package/src/utils/getWidthOrHeightValue.ts +5 -0
- package/src/utils/index.ts +7 -18
- package/src/utils/indexOfObjectValue.ts +3 -0
package/README.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# react-native-readium
|
|
2
2
|
|
|
3
|
-
A react-native wrapper for https://readium.org
|
|
3
|
+
A react-native wrapper for https://readium.org/. At a high level this package
|
|
4
|
+
allows you to do things like:
|
|
5
|
+
|
|
6
|
+
- Render an ebook view.
|
|
7
|
+
- Register for location changes (as the user pages through the book).
|
|
8
|
+
- Register for the Table of Contents (so that you can display things like chapters in your app)
|
|
9
|
+
- Control settings of the Reader. Things like:
|
|
10
|
+
- Dark Mode, Light Mode, Sepia Mode
|
|
11
|
+
- Font Size
|
|
12
|
+
- Page Margins
|
|
13
|
+
- More (see the `Settings` documentation in the [API section](#api))
|
|
14
|
+
- Etc. (read on for more details. :book:)
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
4
17
|
|
|
5
18
|
- [Installation](#installation)
|
|
6
19
|
- [Usage](#usage)
|
|
@@ -40,6 +53,11 @@ yarn add react-native-readium
|
|
|
40
53
|
Due to the current state of the `Readium` swift libraries you need to manually
|
|
41
54
|
update your `Podfile` ([see more on that here](https://github.com/readium/swift-toolkit/issues/38)).
|
|
42
55
|
|
|
56
|
+
Additionally, note that the GitHub URL's below are pointing to the `develop`
|
|
57
|
+
branch. [This is currently necessary as a fix for CocoaPods was merged but has
|
|
58
|
+
not yet been released](https://github.com/readium/swift-toolkit/pull/76#issuecomment-1213170966).
|
|
59
|
+
It will land in the next release (after v2.3.0).
|
|
60
|
+
|
|
43
61
|
```rb
|
|
44
62
|
# ./ios/Podfile
|
|
45
63
|
...
|
|
@@ -51,9 +69,9 @@ target 'ExampleApp' do
|
|
|
51
69
|
config = use_native_modules!
|
|
52
70
|
...
|
|
53
71
|
pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/a8edee9790ef0995b2cf620ba1a9b5cf146b7221/GCDWebServer.podspec', modular_headers: true
|
|
54
|
-
pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/
|
|
55
|
-
pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/
|
|
56
|
-
pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/
|
|
72
|
+
pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/develop/Support/CocoaPods/ReadiumShared.podspec'
|
|
73
|
+
pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/develop/Support/CocoaPods/ReadiumStreamer.podspec'
|
|
74
|
+
pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/develop/Support/CocoaPods/ReadiumNavigator.podspec'
|
|
57
75
|
pod 'Minizip', modular_headers: true
|
|
58
76
|
...
|
|
59
77
|
end
|
|
@@ -65,6 +83,23 @@ Finally, install the pods:
|
|
|
65
83
|
|
|
66
84
|
#### Android
|
|
67
85
|
|
|
86
|
+
You might need to [add `jcenter` if you're getting a build failure on android](https://github.com/readium/kotlin-toolkit/issues/31):
|
|
87
|
+
|
|
88
|
+
```groovy
|
|
89
|
+
// android/build.gradle
|
|
90
|
+
...
|
|
91
|
+
|
|
92
|
+
allprojects {
|
|
93
|
+
repositories {
|
|
94
|
+
...
|
|
95
|
+
// required by react-native-readium https://github.com/readium/kotlin-toolkit/issues/31
|
|
96
|
+
jcenter()
|
|
97
|
+
}
|
|
98
|
+
...
|
|
99
|
+
}
|
|
100
|
+
...
|
|
101
|
+
```
|
|
102
|
+
|
|
68
103
|
If you're not using `compileSdkVersion` >= 31 you'll need to update that:
|
|
69
104
|
|
|
70
105
|
```groovy
|
|
@@ -128,6 +163,7 @@ DRM is not supported at this time. However, there is a clear path to [support it
|
|
|
128
163
|
| `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) |
|
|
129
164
|
| `style` | `ViewStyle` | :white_check_mark: | A traditional style object. |
|
|
130
165
|
| `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)|
|
|
166
|
+
| `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. |
|
|
131
167
|
|
|
132
168
|
## Contributing
|
|
133
169
|
|
|
@@ -10,6 +10,7 @@ import com.reactnativereadium.reader.BaseReaderFragment
|
|
|
10
10
|
import com.reactnativereadium.reader.EpubReaderFragment
|
|
11
11
|
import com.reactnativereadium.reader.ReaderViewModel
|
|
12
12
|
import com.reactnativereadium.utils.Dimensions
|
|
13
|
+
import com.reactnativereadium.utils.File
|
|
13
14
|
import org.readium.r2.shared.extensions.toMap
|
|
14
15
|
import org.readium.r2.shared.publication.Locator
|
|
15
16
|
|
|
@@ -17,7 +18,9 @@ class ReadiumView(
|
|
|
17
18
|
val reactContext: ThemedReactContext
|
|
18
19
|
) : FrameLayout(reactContext) {
|
|
19
20
|
var dimensions: Dimensions = Dimensions(0,0)
|
|
21
|
+
var file: File? = null
|
|
20
22
|
var fragment: BaseReaderFragment? = null
|
|
23
|
+
var isViewInitialized: Boolean = false
|
|
21
24
|
|
|
22
25
|
fun updateLocation(locator: Locator) : Boolean {
|
|
23
26
|
if (fragment == null) {
|
|
@@ -42,9 +45,9 @@ class ReadiumView(
|
|
|
42
45
|
.replace(this.id, frag, this.id.toString())
|
|
43
46
|
.commit()
|
|
44
47
|
|
|
48
|
+
val module = reactContext.getJSModule(RCTEventEmitter::class.java)
|
|
45
49
|
// subscribe to reader events
|
|
46
50
|
frag.channel.receive(frag) { event ->
|
|
47
|
-
val module = reactContext.getJSModule(RCTEventEmitter::class.java)
|
|
48
51
|
when (event) {
|
|
49
52
|
is ReaderViewModel.Event.LocatorUpdate -> {
|
|
50
53
|
val json = event.locator.toJSON()
|
|
@@ -55,6 +58,15 @@ class ReadiumView(
|
|
|
55
58
|
payload
|
|
56
59
|
)
|
|
57
60
|
}
|
|
61
|
+
is ReaderViewModel.Event.TableOfContentsLoaded -> {
|
|
62
|
+
val map = event.toc.map { it.toJSON().toMap() }
|
|
63
|
+
val payload = Arguments.makeNativeMap(mapOf("toc" to map))
|
|
64
|
+
module.receiveEvent(
|
|
65
|
+
this.id.toInt(),
|
|
66
|
+
ReadiumViewManager.ON_TABLE_OF_CONTENTS,
|
|
67
|
+
payload
|
|
68
|
+
)
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
}
|
|
60
72
|
}
|
|
@@ -7,6 +7,7 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup
|
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
8
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
9
9
|
import com.reactnativereadium.reader.ReaderService
|
|
10
|
+
import com.reactnativereadium.utils.File
|
|
10
11
|
import kotlinx.coroutines.runBlocking
|
|
11
12
|
import org.json.JSONObject
|
|
12
13
|
import org.readium.r2.shared.publication.Locator
|
|
@@ -24,13 +25,44 @@ class ReadiumViewManager(
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
27
|
-
return MapBuilder.builder<String, Any>()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return MapBuilder.builder<String, Any>()
|
|
29
|
+
.put(
|
|
30
|
+
ON_LOCATION_CHANGE,
|
|
31
|
+
MapBuilder.of(
|
|
32
|
+
"phasedRegistrationNames",
|
|
33
|
+
MapBuilder.of("bubbled", ON_LOCATION_CHANGE)
|
|
34
|
+
)
|
|
32
35
|
)
|
|
33
|
-
|
|
36
|
+
.put(
|
|
37
|
+
ON_TABLE_OF_CONTENTS,
|
|
38
|
+
MapBuilder.of(
|
|
39
|
+
"phasedRegistrationNames",
|
|
40
|
+
MapBuilder.of("bubbled", ON_TABLE_OF_CONTENTS)
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
.build()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun getCommandsMap(): MutableMap<String, Int> {
|
|
47
|
+
return MapBuilder.of("create", COMMAND_CREATE)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun receiveCommand(view: ReadiumView, commandId: String?, args: ReadableArray?) {
|
|
51
|
+
super.receiveCommand(view, commandId, args)
|
|
52
|
+
val reactNativeViewId = args!!.getInt(0)
|
|
53
|
+
val commandIdInt = commandId!!.toInt()
|
|
54
|
+
|
|
55
|
+
when (commandIdInt) {
|
|
56
|
+
COMMAND_CREATE -> {
|
|
57
|
+
view.isViewInitialized = true
|
|
58
|
+
|
|
59
|
+
if (view.file != null) {
|
|
60
|
+
buildForViewIfReady(view)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else -> {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
34
66
|
}
|
|
35
67
|
|
|
36
68
|
@ReactProp(name = "file")
|
|
@@ -44,11 +76,8 @@ class ReadiumViewManager(
|
|
|
44
76
|
initialLocation = Locator.fromJSON(JSONObject(locatorMap.toHashMap()))
|
|
45
77
|
}
|
|
46
78
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
view.addFragment(fragment)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
79
|
+
view.file = File(path, initialLocation)
|
|
80
|
+
this.buildForViewIfReady(view)
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
@ReactProp(name = "location")
|
|
@@ -75,7 +104,20 @@ class ReadiumViewManager(
|
|
|
75
104
|
}
|
|
76
105
|
}
|
|
77
106
|
|
|
107
|
+
private fun buildForViewIfReady(view: ReadiumView) {
|
|
108
|
+
var file = view.file
|
|
109
|
+
if (file != null && view.isViewInitialized) {
|
|
110
|
+
runBlocking {
|
|
111
|
+
svc.openPublication(file.path, file.initialLocation) { fragment ->
|
|
112
|
+
view.addFragment(fragment)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
78
118
|
companion object {
|
|
79
119
|
var ON_LOCATION_CHANGE = "onLocationChange"
|
|
120
|
+
var ON_TABLE_OF_CONTENTS = "onTableOfContents"
|
|
121
|
+
var COMMAND_CREATE = 1
|
|
80
122
|
}
|
|
81
123
|
}
|
|
@@ -2,6 +2,7 @@ package com.reactnativereadium.epub
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.content.SharedPreferences
|
|
5
|
+
import android.graphics.Color
|
|
5
6
|
import androidx.appcompat.app.AppCompatActivity
|
|
6
7
|
import org.json.JSONArray
|
|
7
8
|
import org.readium.r2.navigator.R2BasicWebView
|
|
@@ -79,6 +80,21 @@ class UserSettings(
|
|
|
79
80
|
is Switchable -> updateSwitchableFromKeyValue(property, key, value)
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
// update the resourcePager background to match the newly selected theme
|
|
84
|
+
if (isPropertyModified && property is Enumerable && property.ref == APPEARANCE_REF) {
|
|
85
|
+
when (property.index) {
|
|
86
|
+
0 -> {
|
|
87
|
+
resourcePager.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
88
|
+
}
|
|
89
|
+
1 -> {
|
|
90
|
+
resourcePager.setBackgroundColor(Color.parseColor("#faf4e8"))
|
|
91
|
+
}
|
|
92
|
+
2 -> {
|
|
93
|
+
resourcePager.setBackgroundColor(Color.parseColor("#000000"))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
82
98
|
// apply the changes to the view
|
|
83
99
|
if (isPropertyModified) {
|
|
84
100
|
updateViewCSS(key)
|
|
@@ -10,6 +10,7 @@ import org.readium.r2.navigator.*
|
|
|
10
10
|
import org.readium.r2.shared.publication.Locator
|
|
11
11
|
import com.reactnativereadium.utils.EventChannel
|
|
12
12
|
import kotlinx.coroutines.channels.Channel
|
|
13
|
+
import org.readium.r2.shared.publication.Link
|
|
13
14
|
|
|
14
15
|
/*
|
|
15
16
|
* Base reader fragment class
|
|
@@ -24,37 +25,38 @@ abstract class BaseReaderFragment : Fragment() {
|
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
protected abstract val model: ReaderViewModel
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
protected abstract val navigator: Navigator
|
|
29
|
+
|
|
30
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
31
|
+
setHasOptionsMenu(true)
|
|
32
|
+
super.onCreate(savedInstanceState)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
36
|
+
super.onViewCreated(view, savedInstanceState)
|
|
37
|
+
|
|
38
|
+
val viewScope = viewLifecycleOwner.lifecycleScope
|
|
39
|
+
|
|
40
|
+
channel.send(ReaderViewModel.Event.TableOfContentsLoaded(model.publication.tableOfContents))
|
|
41
|
+
navigator.currentLocator
|
|
42
|
+
.onEach { channel.send(ReaderViewModel.Event.LocatorUpdate(it)) }
|
|
43
|
+
.launchIn(viewScope)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun onHiddenChanged(hidden: Boolean) {
|
|
47
|
+
super.onHiddenChanged(hidden)
|
|
48
|
+
setMenuVisibility(!hidden)
|
|
49
|
+
requireActivity().invalidateOptionsMenu()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun go(locator: Locator, animated: Boolean): Boolean {
|
|
53
|
+
// don't attempt to navigate if we're already there
|
|
54
|
+
val currentLocator = navigator.currentLocator.value
|
|
55
|
+
if (locator.hashCode() == currentLocator.hashCode()) {
|
|
56
|
+
return true
|
|
42
57
|
}
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
setMenuVisibility(!hidden)
|
|
47
|
-
requireActivity().invalidateOptionsMenu()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
fun go(locator: Locator, animated: Boolean): Boolean {
|
|
51
|
-
// don't attempt to navigate if we're already there
|
|
52
|
-
val currentLocator = navigator.currentLocator.value
|
|
53
|
-
if (locator.hashCode() == currentLocator.hashCode()) {
|
|
54
|
-
return true
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return navigator.go(locator, animated)
|
|
58
|
-
}
|
|
59
|
+
return navigator.go(locator, animated)
|
|
60
|
+
}
|
|
59
61
|
|
|
60
62
|
}
|
|
@@ -20,6 +20,7 @@ import org.readium.r2.shared.publication.services.search.SearchIterator
|
|
|
20
20
|
import org.readium.r2.shared.publication.services.search.SearchTry
|
|
21
21
|
import org.readium.r2.shared.Search
|
|
22
22
|
import org.readium.r2.shared.UserException
|
|
23
|
+
import org.readium.r2.shared.publication.Link
|
|
23
24
|
import org.readium.r2.shared.util.Try
|
|
24
25
|
|
|
25
26
|
@OptIn(Search::class, ExperimentalDecorator::class)
|
|
@@ -111,6 +112,7 @@ class ReaderViewModel(
|
|
|
111
112
|
object StartNewSearch : Event()
|
|
112
113
|
class Failure(val error: UserException) : Event()
|
|
113
114
|
class LocatorUpdate(val locator: Locator) : Event()
|
|
115
|
+
class TableOfContentsLoaded(val toc: List<Link>) : Event()
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
sealed class FeedbackEvent {
|
package/ios/ReadiumView.swift
CHANGED
|
@@ -37,6 +37,7 @@ class ReadiumView : UIView, Loggable {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
@objc var onLocationChange: RCTDirectEventBlock?
|
|
40
|
+
@objc var onTableOfContents: RCTDirectEventBlock?
|
|
40
41
|
|
|
41
42
|
func loadBook(url: String) {
|
|
42
43
|
guard let rootViewController = UIApplication.shared.delegate?.window??.rootViewController else { return }
|
|
@@ -99,6 +100,13 @@ class ReadiumView : UIView, Loggable {
|
|
|
99
100
|
|
|
100
101
|
if let e = property as? Enumerable {
|
|
101
102
|
e.index = value as! Int
|
|
103
|
+
|
|
104
|
+
// synchronize background color
|
|
105
|
+
if property.reference == ReadiumCSSReference.appearance.rawValue {
|
|
106
|
+
if let vc = readerViewController as? EPUBViewController {
|
|
107
|
+
vc.setUIColor(for: property)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
102
110
|
} else if let i = property as? Incrementable {
|
|
103
111
|
i.value = value as! Float
|
|
104
112
|
} else if let s = property as? Switchable {
|
|
@@ -128,9 +136,7 @@ class ReadiumView : UIView, Loggable {
|
|
|
128
136
|
private func addViewControllerAsSubview(_ vc: ReaderViewController) {
|
|
129
137
|
vc.publisher.sink(
|
|
130
138
|
receiveValue: { locator in
|
|
131
|
-
|
|
132
|
-
self.onLocationChange!(locator.json)
|
|
133
|
-
}
|
|
139
|
+
self.onLocationChange?(locator.json)
|
|
134
140
|
}
|
|
135
141
|
)
|
|
136
142
|
.store(in: &self.subscriptions)
|
|
@@ -155,5 +161,11 @@ class ReadiumView : UIView, Loggable {
|
|
|
155
161
|
rootView.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
|
|
156
162
|
rootView.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
157
163
|
rootView.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
164
|
+
|
|
165
|
+
self.onTableOfContents?([
|
|
166
|
+
"toc": vc.publication.tableOfContents.map({ link in
|
|
167
|
+
return link.json
|
|
168
|
+
})
|
|
169
|
+
])
|
|
158
170
|
}
|
|
159
171
|
}
|
package/ios/ReadiumViewManager.m
CHANGED
|
@@ -6,5 +6,6 @@ RCT_EXPORT_VIEW_PROPERTY(file, NSDictionary *)
|
|
|
6
6
|
RCT_EXPORT_VIEW_PROPERTY(location, NSDictionary *)
|
|
7
7
|
RCT_EXPORT_VIEW_PROPERTY(settings, NSDictionary *)
|
|
8
8
|
RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTDirectEventBlock)
|
|
9
|
+
RCT_EXPORT_VIEW_PROPERTY(onTableOfContents, RCTDirectEventBlock)
|
|
9
10
|
|
|
10
11
|
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseReadiumView = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
|
|
12
|
+
const BaseReadiumView = _reactNative.UIManager.getViewManagerConfig(_utils.COMPONENT_NAME) != null ? (0, _reactNative.requireNativeComponent)(_utils.COMPONENT_NAME) : () => {
|
|
13
|
+
throw new Error(_utils.LINKING_ERROR);
|
|
14
|
+
};
|
|
15
|
+
exports.BaseReadiumView = BaseReadiumView;
|
|
16
|
+
//# sourceMappingURL=BaseReadiumView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["BaseReadiumView.tsx"],"names":["BaseReadiumView","UIManager","getViewManagerConfig","COMPONENT_NAME","Error","LINKING_ERROR"],"mappings":";;;;;;;AAAA;;AAOA;;AAcO,MAAMA,eAAe,GAC1BC,uBAAUC,oBAAV,CAA+BC,qBAA/B,KAAkD,IAAlD,GACI,yCAA6CA,qBAA7C,CADJ,GAEI,MAAM;AACJ,QAAM,IAAIC,KAAJ,CAAUC,oBAAV,CAAN;AACD,CALA","sourcesContent":["import {\n requireNativeComponent,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport type { Settings, Link, Locator, File, } from '../interfaces';\nimport { COMPONENT_NAME, LINKING_ERROR } from '../utils';\n\nexport type BaseReadiumViewProps = {\n file: File;\n location?: Locator;\n settings?: Partial<Settings>;\n style?: ViewStyle;\n onLocationChange?: (locator: Locator) => void;\n onTableOfContents?: (toc: Link[] | null) => void;\n ref?: any;\n height?: number;\n width?: number;\n};\n\nexport const BaseReadiumView =\n UIManager.getViewManagerConfig(COMPONENT_NAME) != null\n ? requireNativeComponent<BaseReadiumViewProps>(COMPONENT_NAME)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReadiumView = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _interfaces = require("../interfaces");
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
var _BaseReadiumView = require("./BaseReadiumView");
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
24
|
+
const ReadiumView = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
onLocationChange: wrappedOnLocationChange,
|
|
27
|
+
onTableOfContents: wrappedOnTableOfContents,
|
|
28
|
+
settings: unmappedSettings,
|
|
29
|
+
...props
|
|
30
|
+
} = _ref;
|
|
31
|
+
const ref = (0, _react.useRef)(null);
|
|
32
|
+
const [{
|
|
33
|
+
height,
|
|
34
|
+
width
|
|
35
|
+
}, setDimensions] = (0, _react.useState)({
|
|
36
|
+
width: 0,
|
|
37
|
+
height: 0
|
|
38
|
+
}); // set the view dimensions on layout
|
|
39
|
+
|
|
40
|
+
const onLayout = (0, _react.useCallback)(_ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
nativeEvent: {
|
|
43
|
+
layout: {
|
|
44
|
+
width,
|
|
45
|
+
height
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} = _ref2;
|
|
49
|
+
setDimensions({
|
|
50
|
+
width: (0, _utils.getWidthOrHeightValue)(width),
|
|
51
|
+
height: (0, _utils.getWidthOrHeightValue)(height)
|
|
52
|
+
});
|
|
53
|
+
}, []); // wrap the native onLocationChange and extract the raw event value
|
|
54
|
+
|
|
55
|
+
const onLocationChange = (0, _react.useCallback)(event => {
|
|
56
|
+
if (wrappedOnLocationChange) {
|
|
57
|
+
wrappedOnLocationChange(event.nativeEvent);
|
|
58
|
+
}
|
|
59
|
+
}, [wrappedOnLocationChange]);
|
|
60
|
+
const onTableOfContents = (0, _react.useCallback)(event => {
|
|
61
|
+
if (wrappedOnTableOfContents) {
|
|
62
|
+
const toc = event.nativeEvent.toc || null;
|
|
63
|
+
wrappedOnTableOfContents(toc);
|
|
64
|
+
}
|
|
65
|
+
}, [wrappedOnTableOfContents]);
|
|
66
|
+
(0, _react.useEffect)(() => {
|
|
67
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
68
|
+
const viewId = (0, _reactNative.findNodeHandle)(ref.current);
|
|
69
|
+
(0, _utils.createFragment)(viewId);
|
|
70
|
+
}
|
|
71
|
+
}, []);
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
73
|
+
style: styles.container,
|
|
74
|
+
onLayout: onLayout
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_BaseReadiumView.BaseReadiumView, _extends({
|
|
76
|
+
height: height,
|
|
77
|
+
width: width
|
|
78
|
+
}, props, {
|
|
79
|
+
onLocationChange: onLocationChange,
|
|
80
|
+
onTableOfContents: onTableOfContents,
|
|
81
|
+
settings: unmappedSettings ? _interfaces.Settings.map(unmappedSettings) : undefined,
|
|
82
|
+
ref: ref
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
exports.ReadiumView = ReadiumView;
|
|
87
|
+
|
|
88
|
+
const styles = _reactNative.StyleSheet.create({
|
|
89
|
+
container: {
|
|
90
|
+
width: '100%',
|
|
91
|
+
height: '100%'
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=ReadiumView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ReadiumView.tsx"],"names":["ReadiumView","onLocationChange","wrappedOnLocationChange","onTableOfContents","wrappedOnTableOfContents","settings","unmappedSettings","props","ref","height","width","setDimensions","onLayout","nativeEvent","layout","event","toc","Platform","OS","viewId","current","styles","container","Settings","map","undefined","StyleSheet","create"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AACA;;AAEA;;;;;;;;AAIO,MAAMA,WAAmC,GAAG,QAK7C;AAAA,MAL8C;AAClDC,IAAAA,gBAAgB,EAAEC,uBADgC;AAElDC,IAAAA,iBAAiB,EAAEC,wBAF+B;AAGlDC,IAAAA,QAAQ,EAAEC,gBAHwC;AAIlD,OAAGC;AAJ+C,GAK9C;AACJ,QAAMC,GAAG,GAAG,mBAAO,IAAP,CAAZ;AACA,QAAM,CAAC;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAD,EAAoBC,aAApB,IAAqC,qBAAqB;AAC9DD,IAAAA,KAAK,EAAE,CADuD;AAE9DD,IAAAA,MAAM,EAAE;AAFsD,GAArB,CAA3C,CAFI,CAMJ;;AACA,QAAMG,QAAQ,GAAG,wBAAY,SAAmD;AAAA,QAAlD;AAAEC,MAAAA,WAAW,EAAE;AAAEC,QAAAA,MAAM,EAAE;AAAEJ,UAAAA,KAAF;AAASD,UAAAA;AAAT;AAAV;AAAf,KAAkD;AAC9EE,IAAAA,aAAa,CAAC;AACZD,MAAAA,KAAK,EAAE,kCAAUA,KAAV,CADK;AAEZD,MAAAA,MAAM,EAAE,kCAAUA,MAAV;AAFI,KAAD,CAAb;AAID,GALgB,EAKd,EALc,CAAjB,CAPI,CAaJ;;AACA,QAAMR,gBAAgB,GAAG,wBAAac,KAAD,IAAgB;AACnD,QAAIb,uBAAJ,EAA6B;AAC3BA,MAAAA,uBAAuB,CAACa,KAAK,CAACF,WAAP,CAAvB;AACD;AACF,GAJwB,EAItB,CAACX,uBAAD,CAJsB,CAAzB;AAMA,QAAMC,iBAAiB,GAAG,wBAAaY,KAAD,IAAgB;AACpD,QAAIX,wBAAJ,EAA8B;AAC5B,YAAMY,GAAG,GAAGD,KAAK,CAACF,WAAN,CAAkBG,GAAlB,IAAyB,IAArC;AACAZ,MAAAA,wBAAwB,CAACY,GAAD,CAAxB;AACD;AACF,GALyB,EAKvB,CAACZ,wBAAD,CALuB,CAA1B;AAOA,wBAAU,MAAM;AACd,QAAIa,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,YAAMC,MAAM,GAAG,iCAAeX,GAAG,CAACY,OAAnB,CAAf;AACA,iCAAeD,MAAf;AACD;AACF,GALD,EAKG,EALH;AAOA,sBACE,6BAAC,iBAAD;AACE,IAAA,KAAK,EAAEE,MAAM,CAACC,SADhB;AAEE,IAAA,QAAQ,EAAEV;AAFZ,kBAIE,6BAAC,gCAAD;AACE,IAAA,MAAM,EAAEH,MADV;AAEE,IAAA,KAAK,EAAEC;AAFT,KAGMH,KAHN;AAIE,IAAA,gBAAgB,EAAEN,gBAJpB;AAKE,IAAA,iBAAiB,EAAEE,iBALrB;AAME,IAAA,QAAQ,EAAEG,gBAAgB,GAAGiB,qBAASC,GAAT,CAAalB,gBAAb,CAAH,GAAoCmB,SANhE;AAOE,IAAA,GAAG,EAAEjB;AAPP,KAJF,CADF;AAgBD,CAvDM;;;;AAyDP,MAAMa,MAAM,GAAGK,wBAAWC,MAAX,CAAkB;AAC/BL,EAAAA,SAAS,EAAE;AAAEZ,IAAAA,KAAK,EAAE,MAAT;AAAiBD,IAAAA,MAAM,EAAE;AAAzB;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useCallback, useState, useRef, useEffect } from 'react';\nimport { View, Platform, findNodeHandle, StyleSheet } from 'react-native';\n\nimport type { Dimensions } from '../interfaces';\nimport { Settings } from '../interfaces';\nimport { createFragment, getWidthOrHeightValue as dimension } from '../utils';\nimport type { BaseReadiumViewProps } from './BaseReadiumView';\nimport { BaseReadiumView } from './BaseReadiumView';\n\ntype ReadiumProps = BaseReadiumViewProps;\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n onTableOfContents: wrappedOnTableOfContents,\n settings: unmappedSettings,\n ...props\n}) => {\n const ref = useRef(null);\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n // set the view dimensions on layout\n const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}) => {\n setDimensions({\n width: dimension(width),\n height: dimension(height),\n });\n }, []);\n // wrap the native onLocationChange and extract the raw event value\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n const onTableOfContents = useCallback((event: any) => {\n if (wrappedOnTableOfContents) {\n const toc = event.nativeEvent.toc || null;\n wrappedOnTableOfContents(toc);\n }\n }, [wrappedOnTableOfContents]);\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }\n }, [])\n\n return (\n <View\n style={styles.container}\n onLayout={onLayout}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n onTableOfContents={onTableOfContents}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n ref={ref}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { width: '100%', height: '100%' },\n});\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,13 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
|
|
7
|
+
RANGES: true
|
|
8
8
|
};
|
|
9
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "RANGES", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _utils.RANGES;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
10
15
|
|
|
11
|
-
var
|
|
16
|
+
var _enums = require("./enums");
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
Object.keys(_enums).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _enums[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _enums[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
14
29
|
|
|
15
30
|
var _interfaces = require("./interfaces");
|
|
16
31
|
|
|
@@ -26,80 +41,19 @@ Object.keys(_interfaces).forEach(function (key) {
|
|
|
26
41
|
});
|
|
27
42
|
});
|
|
28
43
|
|
|
29
|
-
var
|
|
44
|
+
var _utils = require("./utils");
|
|
30
45
|
|
|
31
|
-
|
|
46
|
+
var _ReadiumView = require("./components/ReadiumView");
|
|
47
|
+
|
|
48
|
+
Object.keys(_ReadiumView).forEach(function (key) {
|
|
32
49
|
if (key === "default" || key === "__esModule") return;
|
|
33
50
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
34
|
-
if (key in exports && exports[key] ===
|
|
51
|
+
if (key in exports && exports[key] === _ReadiumView[key]) return;
|
|
35
52
|
Object.defineProperty(exports, key, {
|
|
36
53
|
enumerable: true,
|
|
37
54
|
get: function () {
|
|
38
|
-
return
|
|
55
|
+
return _ReadiumView[key];
|
|
39
56
|
}
|
|
40
57
|
});
|
|
41
58
|
});
|
|
42
|
-
|
|
43
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
44
|
-
|
|
45
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
46
|
-
|
|
47
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
48
|
-
|
|
49
|
-
const LINKING_ERROR = `The package 'react-native-readium' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
50
|
-
ios: "- You have run 'pod install'\n",
|
|
51
|
-
default: ''
|
|
52
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
53
|
-
const ComponentName = 'ReadiumView';
|
|
54
|
-
const BaseReadiumView = _reactNative.UIManager.getViewManagerConfig(ComponentName) != null ? (0, _reactNative.requireNativeComponent)(ComponentName) : () => {
|
|
55
|
-
throw new Error(LINKING_ERROR);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const ReadiumView = _ref => {
|
|
59
|
-
let {
|
|
60
|
-
onLocationChange: wrappedOnLocationChange,
|
|
61
|
-
settings: unmappedSettings,
|
|
62
|
-
...props
|
|
63
|
-
} = _ref;
|
|
64
|
-
const [{
|
|
65
|
-
height,
|
|
66
|
-
width
|
|
67
|
-
}, setDimensions] = (0, _react.useState)({
|
|
68
|
-
width: 0,
|
|
69
|
-
height: 0
|
|
70
|
-
});
|
|
71
|
-
const onLocationChange = (0, _react.useCallback)(event => {
|
|
72
|
-
if (wrappedOnLocationChange) {
|
|
73
|
-
wrappedOnLocationChange(event.nativeEvent);
|
|
74
|
-
}
|
|
75
|
-
}, [wrappedOnLocationChange]);
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
77
|
-
style: {
|
|
78
|
-
width: '100%',
|
|
79
|
-
height: '100%'
|
|
80
|
-
},
|
|
81
|
-
onLayout: _ref2 => {
|
|
82
|
-
let {
|
|
83
|
-
nativeEvent: {
|
|
84
|
-
layout: {
|
|
85
|
-
width,
|
|
86
|
-
height
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} = _ref2;
|
|
90
|
-
setDimensions({
|
|
91
|
-
width: _reactNative.Platform.OS === 'android' ? _reactNative.PixelRatio.getPixelSizeForLayoutSize(width) : width,
|
|
92
|
-
height: _reactNative.Platform.OS === 'android' ? _reactNative.PixelRatio.getPixelSizeForLayoutSize(height) : height
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, /*#__PURE__*/_react.default.createElement(BaseReadiumView, _extends({
|
|
96
|
-
height: height,
|
|
97
|
-
width: width
|
|
98
|
-
}, props, {
|
|
99
|
-
onLocationChange: onLocationChange,
|
|
100
|
-
settings: unmappedSettings ? _interfaces.Settings.map(unmappedSettings) : undefined
|
|
101
|
-
})));
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
exports.ReadiumView = ReadiumView;
|
|
105
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './enums';\nexport * from './interfaces';\nexport { RANGES } from './utils';\nexport * from './components/ReadiumView';\n"]}
|