react-native-readium 1.2.0 → 2.0.0-rc.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 +28 -23
- package/android/build.gradle +25 -34
- package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +3 -0
- package/android/src/main/res/layout/fragment_fxllayout_double.xml +58 -0
- package/android/src/main/res/layout/fragment_fxllayout_single.xml +52 -0
- package/android/src/main/res/layout/viewpager_fragment_epub.xml +27 -0
- package/android/src/main/res/values/strings.xml +1 -0
- package/lib/src/components/BaseReadiumView.d.ts +2 -0
- package/lib/src/components/BaseReadiumView.js +7 -0
- package/lib/src/components/BaseReadiumView.web.d.ts +1 -0
- package/lib/src/components/BaseReadiumView.web.js +1 -0
- package/lib/src/components/ReadiumView.d.ts +4 -0
- package/lib/src/components/ReadiumView.js +43 -0
- package/lib/src/components/ReadiumView.web.d.ts +5 -0
- package/lib/src/components/ReadiumView.web.js +61 -0
- package/lib/src/enums/Appearance.js +13 -0
- package/lib/src/enums/ColumnCount.js +7 -0
- package/lib/src/enums/FontFamily.js +12 -0
- package/lib/src/enums/TextAlignment.js +6 -0
- package/lib/{module → src}/enums/index.js +0 -1
- package/lib/{module → src}/index.js +0 -1
- package/lib/src/interfaces/BaseReadiumViewProps.d.ts +16 -0
- package/lib/src/interfaces/BaseReadiumViewProps.js +1 -0
- package/lib/src/interfaces/Dimensions.js +1 -0
- package/lib/src/interfaces/File.js +1 -0
- package/lib/src/interfaces/Link.js +1 -0
- package/lib/src/interfaces/Locator.js +1 -0
- package/lib/src/interfaces/Settings.js +61 -0
- package/lib/{typescript → src}/interfaces/index.d.ts +1 -0
- package/lib/{module → src}/interfaces/index.js +1 -1
- package/lib/{module → src}/utils/COMPONENT_NAME.js +0 -1
- package/lib/src/utils/LINKING_ERROR.js +5 -0
- package/lib/src/utils/RANGES.js +8 -0
- package/lib/src/utils/clamp.js +7 -0
- package/lib/src/utils/createFragment.js +10 -0
- package/lib/src/utils/getWidthOrHeightValue.js +4 -0
- package/lib/{module → src}/utils/index.js +0 -1
- package/lib/src/utils/indexOfObjectValue.js +3 -0
- package/lib/web/hooks/useLocationObserver.d.ts +2 -0
- package/lib/web/hooks/useLocationObserver.js +13 -0
- package/lib/web/hooks/useReaderRef.d.ts +3 -0
- package/lib/web/hooks/useReaderRef.js +48 -0
- package/lib/web/hooks/useSettingsObserver.d.ts +2 -0
- package/lib/web/hooks/useSettingsObserver.js +13 -0
- package/package.json +32 -38
- package/src/components/BaseReadiumView.tsx +1 -14
- package/src/components/BaseReadiumView.web.tsx +1 -0
- package/src/components/ReadiumView.tsx +1 -2
- package/src/{web/ReadiumView.tsx → components/ReadiumView.web.tsx} +11 -16
- package/src/interfaces/BaseReadiumViewProps.ts +18 -0
- package/src/interfaces/index.ts +1 -0
- package/{lib/module/web/hooks/index.js → web/hooks/index.ts} +0 -1
- package/{src/web → web}/hooks/useLocationObserver.ts +1 -3
- package/{src/web → web}/hooks/useReaderRef.ts +20 -17
- package/{src/web → web}/hooks/useSettingsObserver.ts +2 -4
- package/lib/commonjs/components/BaseReadiumView.js +0 -16
- package/lib/commonjs/components/BaseReadiumView.js.map +0 -1
- package/lib/commonjs/components/ReadiumView.js +0 -94
- package/lib/commonjs/components/ReadiumView.js.map +0 -1
- package/lib/commonjs/enums/Appearance.js +0 -16
- package/lib/commonjs/enums/Appearance.js.map +0 -1
- package/lib/commonjs/enums/ColumnCount.js +0 -16
- package/lib/commonjs/enums/ColumnCount.js.map +0 -1
- package/lib/commonjs/enums/FontFamily.js +0 -21
- package/lib/commonjs/enums/FontFamily.js.map +0 -1
- package/lib/commonjs/enums/TextAlignment.js +0 -15
- package/lib/commonjs/enums/TextAlignment.js.map +0 -1
- package/lib/commonjs/enums/index.js +0 -58
- package/lib/commonjs/enums/index.js.map +0 -1
- package/lib/commonjs/index.js +0 -59
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/index.web.js +0 -54
- package/lib/commonjs/index.web.js.map +0 -1
- package/lib/commonjs/interfaces/Dimensions.js +0 -2
- package/lib/commonjs/interfaces/Dimensions.js.map +0 -1
- package/lib/commonjs/interfaces/File.js +0 -6
- package/lib/commonjs/interfaces/File.js.map +0 -1
- package/lib/commonjs/interfaces/Link.js +0 -2
- package/lib/commonjs/interfaces/Link.js.map +0 -1
- package/lib/commonjs/interfaces/Locator.js +0 -2
- package/lib/commonjs/interfaces/Locator.js.map +0 -1
- package/lib/commonjs/interfaces/Settings.js +0 -71
- package/lib/commonjs/interfaces/Settings.js.map +0 -1
- package/lib/commonjs/interfaces/index.js +0 -71
- package/lib/commonjs/interfaces/index.js.map +0 -1
- package/lib/commonjs/utils/COMPONENT_NAME.js +0 -9
- package/lib/commonjs/utils/COMPONENT_NAME.js.map +0 -1
- package/lib/commonjs/utils/LINKING_ERROR.js +0 -15
- package/lib/commonjs/utils/LINKING_ERROR.js.map +0 -1
- package/lib/commonjs/utils/RANGES.js +0 -16
- package/lib/commonjs/utils/RANGES.js.map +0 -1
- package/lib/commonjs/utils/clamp.js +0 -15
- package/lib/commonjs/utils/clamp.js.map +0 -1
- package/lib/commonjs/utils/createFragment.js +0 -21
- package/lib/commonjs/utils/createFragment.js.map +0 -1
- package/lib/commonjs/utils/getWidthOrHeightValue.js +0 -15
- package/lib/commonjs/utils/getWidthOrHeightValue.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -97
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/commonjs/utils/indexOfObjectValue.js +0 -13
- package/lib/commonjs/utils/indexOfObjectValue.js.map +0 -1
- package/lib/commonjs/web/ReadiumView.js +0 -106
- package/lib/commonjs/web/ReadiumView.js.map +0 -1
- package/lib/commonjs/web/hooks/index.js +0 -45
- package/lib/commonjs/web/hooks/index.js.map +0 -1
- package/lib/commonjs/web/hooks/useLocationObserver.js +0 -21
- package/lib/commonjs/web/hooks/useLocationObserver.js.map +0 -1
- package/lib/commonjs/web/hooks/useReaderRef.js +0 -63
- package/lib/commonjs/web/hooks/useReaderRef.js.map +0 -1
- package/lib/commonjs/web/hooks/useSettingsObserver.js +0 -21
- package/lib/commonjs/web/hooks/useSettingsObserver.js.map +0 -1
- package/lib/module/components/BaseReadiumView.js +0 -6
- package/lib/module/components/BaseReadiumView.js.map +0 -1
- package/lib/module/components/ReadiumView.js +0 -75
- package/lib/module/components/ReadiumView.js.map +0 -1
- package/lib/module/enums/Appearance.js +0 -9
- package/lib/module/enums/Appearance.js.map +0 -1
- package/lib/module/enums/ColumnCount.js +0 -9
- package/lib/module/enums/ColumnCount.js.map +0 -1
- package/lib/module/enums/FontFamily.js +0 -14
- package/lib/module/enums/FontFamily.js.map +0 -1
- package/lib/module/enums/TextAlignment.js +0 -8
- package/lib/module/enums/TextAlignment.js.map +0 -1
- package/lib/module/enums/index.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.web.js +0 -5
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/interfaces/Dimensions.js +0 -2
- package/lib/module/interfaces/Dimensions.js.map +0 -1
- package/lib/module/interfaces/File.js +0 -2
- package/lib/module/interfaces/File.js.map +0 -1
- package/lib/module/interfaces/Link.js +0 -2
- package/lib/module/interfaces/Link.js.map +0 -1
- package/lib/module/interfaces/Locator.js +0 -2
- package/lib/module/interfaces/Locator.js.map +0 -1
- package/lib/module/interfaces/Settings.js +0 -61
- package/lib/module/interfaces/Settings.js.map +0 -1
- package/lib/module/interfaces/index.js.map +0 -1
- package/lib/module/utils/COMPONENT_NAME.js.map +0 -1
- package/lib/module/utils/LINKING_ERROR.js +0 -6
- package/lib/module/utils/LINKING_ERROR.js.map +0 -1
- package/lib/module/utils/RANGES.js +0 -9
- package/lib/module/utils/RANGES.js.map +0 -1
- package/lib/module/utils/clamp.js +0 -6
- package/lib/module/utils/clamp.js.map +0 -1
- package/lib/module/utils/createFragment.js +0 -10
- package/lib/module/utils/createFragment.js.map +0 -1
- package/lib/module/utils/getWidthOrHeightValue.js +0 -5
- package/lib/module/utils/getWidthOrHeightValue.js.map +0 -1
- package/lib/module/utils/index.js.map +0 -1
- package/lib/module/utils/indexOfObjectValue.js +0 -4
- package/lib/module/utils/indexOfObjectValue.js.map +0 -1
- package/lib/module/web/ReadiumView.js +0 -89
- package/lib/module/web/ReadiumView.js.map +0 -1
- package/lib/module/web/hooks/index.js.map +0 -1
- package/lib/module/web/hooks/useLocationObserver.js +0 -11
- package/lib/module/web/hooks/useLocationObserver.js.map +0 -1
- package/lib/module/web/hooks/useReaderRef.js +0 -50
- package/lib/module/web/hooks/useReaderRef.js.map +0 -1
- package/lib/module/web/hooks/useSettingsObserver.js +0 -11
- package/lib/module/web/hooks/useSettingsObserver.js.map +0 -1
- package/lib/typescript/components/BaseReadiumView.d.ts +0 -14
- package/lib/typescript/components/ReadiumView.d.ts +0 -4
- package/lib/typescript/index.web.d.ts +0 -4
- package/lib/typescript/web/ReadiumView.d.ts +0 -5
- package/lib/typescript/web/hooks/useLocationObserver.d.ts +0 -3
- package/lib/typescript/web/hooks/useReaderRef.d.ts +0 -4
- package/lib/typescript/web/hooks/useSettingsObserver.d.ts +0 -3
- package/src/index.web.tsx +0 -5
- /package/lib/{typescript → src}/enums/Appearance.d.ts +0 -0
- /package/lib/{typescript → src}/enums/ColumnCount.d.ts +0 -0
- /package/lib/{typescript → src}/enums/FontFamily.d.ts +0 -0
- /package/lib/{typescript → src}/enums/TextAlignment.d.ts +0 -0
- /package/lib/{typescript → src}/enums/index.d.ts +0 -0
- /package/lib/{typescript → src}/index.d.ts +0 -0
- /package/lib/{typescript → src}/interfaces/Dimensions.d.ts +0 -0
- /package/lib/{typescript → src}/interfaces/File.d.ts +0 -0
- /package/lib/{typescript → src}/interfaces/Link.d.ts +0 -0
- /package/lib/{typescript → src}/interfaces/Locator.d.ts +0 -0
- /package/lib/{typescript → src}/interfaces/Settings.d.ts +0 -0
- /package/lib/{typescript → src}/utils/COMPONENT_NAME.d.ts +0 -0
- /package/lib/{typescript → src}/utils/LINKING_ERROR.d.ts +0 -0
- /package/lib/{typescript → src}/utils/RANGES.d.ts +0 -0
- /package/lib/{typescript → src}/utils/clamp.d.ts +0 -0
- /package/lib/{typescript → src}/utils/createFragment.d.ts +0 -0
- /package/lib/{typescript → src}/utils/getWidthOrHeightValue.d.ts +0 -0
- /package/lib/{typescript → src}/utils/index.d.ts +0 -0
- /package/lib/{typescript → src}/utils/indexOfObjectValue.d.ts +0 -0
- /package/lib/{typescript/web → web}/hooks/index.d.ts +0 -0
- /package/{src/web/hooks/index.ts → lib/web/hooks/index.js} +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# react-native-readium
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-readium)
|
|
4
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
----
|
|
9
|
+
|
|
10
|
+
## Have A Bug/Feature You Care About?
|
|
11
|
+
|
|
12
|
+
We :heart: open source. We work on the things that are important to us when
|
|
13
|
+
we're able to work on them. Have an issue you care about?
|
|
14
|
+
|
|
15
|
+
- [Dive Into The Code!](CONTRIBUTING.md)
|
|
16
|
+
- [Sponsor Your Issue](https://issuehunt.io/r/5-stones/react-native-readium).
|
|
17
|
+
|
|
18
|
+
[](https://issuehunt.io/r/5-stones/react-native-readium)
|
|
19
|
+
|
|
20
|
+
----
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
3
24
|
A react-native wrapper for https://readium.org/. At a high level this package
|
|
4
25
|
allows you to do things like:
|
|
5
26
|
|
|
@@ -13,7 +34,7 @@ allows you to do things like:
|
|
|
13
34
|
- More (see the `Settings` documentation in the [API section](#api))
|
|
14
35
|
- Etc. (read on for more details. :book:)
|
|
15
36
|
|
|
16
|
-
##
|
|
37
|
+
## Table of Contents
|
|
17
38
|
|
|
18
39
|
- [Installation](#installation)
|
|
19
40
|
- [Usage](#usage)
|
|
@@ -24,7 +45,7 @@ allows you to do things like:
|
|
|
24
45
|
- [License](#license)
|
|
25
46
|
|
|
26
47
|
| Dark Mode| Light Mode |
|
|
27
|
-
|
|
48
|
+
|----------|------------|
|
|
28
49
|
|  |  |
|
|
29
50
|
|
|
30
51
|
## Installation
|
|
@@ -63,10 +84,11 @@ platform :ios, '13.0'
|
|
|
63
84
|
target 'ExampleApp' do
|
|
64
85
|
config = use_native_modules!
|
|
65
86
|
...
|
|
66
|
-
pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/
|
|
67
|
-
pod '
|
|
68
|
-
pod '
|
|
69
|
-
pod '
|
|
87
|
+
pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/3.7.5/GCDWebServer.podspec', modular_headers: true
|
|
88
|
+
pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumNavigator.podspec'
|
|
89
|
+
pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumShared.podspec'
|
|
90
|
+
pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumStreamer.podspec'
|
|
91
|
+
pod 'ReadiumInternal', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumInternal.podspec'
|
|
70
92
|
pod 'Minizip', modular_headers: true
|
|
71
93
|
...
|
|
72
94
|
end
|
|
@@ -78,23 +100,6 @@ Finally, install the pods:
|
|
|
78
100
|
|
|
79
101
|
#### Android
|
|
80
102
|
|
|
81
|
-
You might need to [add `jcenter` if you're getting a build failure on android](https://github.com/readium/kotlin-toolkit/issues/31):
|
|
82
|
-
|
|
83
|
-
```groovy
|
|
84
|
-
// android/build.gradle
|
|
85
|
-
...
|
|
86
|
-
|
|
87
|
-
allprojects {
|
|
88
|
-
repositories {
|
|
89
|
-
...
|
|
90
|
-
// required by react-native-readium https://github.com/readium/kotlin-toolkit/issues/31
|
|
91
|
-
jcenter()
|
|
92
|
-
}
|
|
93
|
-
...
|
|
94
|
-
}
|
|
95
|
-
...
|
|
96
|
-
```
|
|
97
|
-
|
|
98
103
|
If you're not using `compileSdkVersion` >= 31 you'll need to update that:
|
|
99
104
|
|
|
100
105
|
```groovy
|
package/android/build.gradle
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
3
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Readium_kotlinVersion']
|
|
4
|
-
ext.readium_version = '2.
|
|
4
|
+
ext.readium_version = '2.4.1'
|
|
5
5
|
|
|
6
6
|
repositories {
|
|
7
7
|
google()
|
|
8
8
|
mavenCentral()
|
|
9
|
-
jcenter()
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
dependencies {
|
|
@@ -49,21 +48,13 @@ android {
|
|
|
49
48
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
kotlinOptions {
|
|
53
|
-
jvmTarget = "1.8"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
51
|
buildFeatures {
|
|
57
52
|
viewBinding true
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
55
|
|
|
61
56
|
repositories {
|
|
62
|
-
|
|
63
|
-
maven { url 'https://jitpack.io' }
|
|
64
|
-
|
|
65
57
|
mavenCentral()
|
|
66
|
-
jcenter()
|
|
67
58
|
google()
|
|
68
59
|
|
|
69
60
|
def found = false
|
|
@@ -140,51 +131,51 @@ dependencies {
|
|
|
140
131
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
141
132
|
|
|
142
133
|
// readium deps
|
|
143
|
-
implementation "
|
|
144
|
-
implementation "
|
|
145
|
-
implementation ("
|
|
134
|
+
implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
|
|
135
|
+
implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
|
|
136
|
+
implementation ("org.readium.kotlin-toolkit:readium-navigator:$readium_version") {
|
|
146
137
|
// this package doesn't provide audio playback, so remove exoplayer
|
|
147
138
|
// transitive deps to avoid potential collisions with other projects.
|
|
148
139
|
exclude group: "com.google.android.exoplayer"
|
|
149
140
|
}
|
|
150
141
|
|
|
151
142
|
// other deps
|
|
152
|
-
implementation "androidx.core:core-ktx:1.
|
|
153
|
-
implementation "androidx.activity:activity-ktx:1.
|
|
154
|
-
implementation "androidx.appcompat:appcompat:1.
|
|
155
|
-
implementation "androidx.browser:browser:1.
|
|
143
|
+
implementation "androidx.core:core-ktx:1.7.0"
|
|
144
|
+
implementation "androidx.activity:activity-ktx:1.4.0"
|
|
145
|
+
implementation "androidx.appcompat:appcompat:1.4.1"
|
|
146
|
+
implementation "androidx.browser:browser:1.4.0"
|
|
156
147
|
implementation "androidx.cardview:cardview:1.0.0"
|
|
157
|
-
implementation "androidx.constraintlayout:constraintlayout:2.1.
|
|
158
|
-
implementation "androidx.fragment:fragment-ktx:1.
|
|
159
|
-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.
|
|
160
|
-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.
|
|
161
|
-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.
|
|
148
|
+
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
|
|
149
|
+
implementation "androidx.fragment:fragment-ktx:1.4.0"
|
|
150
|
+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
|
|
151
|
+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
|
|
152
|
+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
|
|
162
153
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
|
163
154
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
|
164
|
-
implementation "androidx.paging:paging-runtime-ktx:3.0
|
|
155
|
+
implementation "androidx.paging:paging-runtime-ktx:3.1.0"
|
|
165
156
|
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
|
166
157
|
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
|
167
158
|
implementation "androidx.webkit:webkit:1.4.0"
|
|
168
|
-
implementation "com.google.android.material:material:1.
|
|
169
|
-
implementation "com.jakewharton.timber:timber:
|
|
159
|
+
implementation "com.google.android.material:material:1.5.0"
|
|
160
|
+
implementation "com.jakewharton.timber:timber:5.0.1"
|
|
170
161
|
// AM NOTE: needs to stay this version for now (June 24,2020)
|
|
171
162
|
//noinspection GradleDependency
|
|
172
|
-
implementation "com.squareup.picasso:picasso:2.
|
|
173
|
-
implementation "joda-time:joda-time:2.10.
|
|
174
|
-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.
|
|
163
|
+
implementation "com.squareup.picasso:picasso:2.71828"
|
|
164
|
+
implementation "joda-time:joda-time:2.10.13"
|
|
165
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0"
|
|
175
166
|
// AM NOTE: needs to stay this version for now (June 24,2020)
|
|
176
167
|
//noinspection GradleDependency
|
|
177
|
-
implementation "org.jsoup:jsoup:1.
|
|
168
|
+
implementation "org.jsoup:jsoup:1.14.3"
|
|
178
169
|
|
|
179
170
|
// Room database
|
|
180
|
-
final
|
|
181
|
-
implementation "androidx.room:room-runtime:$
|
|
182
|
-
implementation "androidx.room:room-ktx:$
|
|
183
|
-
annotationProcessor "androidx.room:room-compiler:$
|
|
171
|
+
final roomVersion = "2.4.1"
|
|
172
|
+
implementation "androidx.room:room-runtime:$roomVersion"
|
|
173
|
+
implementation "androidx.room:room-ktx:$roomVersion"
|
|
174
|
+
annotationProcessor "androidx.room:room-compiler:$roomVersion"
|
|
184
175
|
|
|
185
176
|
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
|
186
177
|
//noinspection LifecycleAnnotationProcessorWithJava8
|
|
187
|
-
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.
|
|
178
|
+
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.4.0"
|
|
188
179
|
|
|
189
180
|
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
|
190
181
|
testImplementation "junit:junit:4.13.2"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!--
|
|
2
|
+
FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
|
|
3
|
+
Not sure why it's not being imported from readium-navigator, but if its not here
|
|
4
|
+
the android build throws an error due to UserSettings.kt#updateViewCSS
|
|
5
|
+
|
|
6
|
+
~ Module: r2-navigator-kotlin
|
|
7
|
+
~ Developers: Aferdita Muriqi
|
|
8
|
+
~
|
|
9
|
+
~ Copyright (c) 2018. Readium Foundation. All rights reserved.
|
|
10
|
+
~ Use of this source code is governed by a BSD-style license which is detailed in the
|
|
11
|
+
~ LICENSE file present in the project repository where this source code is maintained.
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<org.readium.r2.navigator.epub.fxl.R2FXLLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
15
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
16
|
+
android:id="@+id/r2FXLLayout"
|
|
17
|
+
android:layout_width="match_parent"
|
|
18
|
+
android:layout_height="match_parent">
|
|
19
|
+
|
|
20
|
+
<ScrollView
|
|
21
|
+
android:layout_width="match_parent"
|
|
22
|
+
android:layout_height="match_parent"
|
|
23
|
+
android:fillViewport="true"
|
|
24
|
+
android:scrollbars="none">
|
|
25
|
+
|
|
26
|
+
<RelativeLayout
|
|
27
|
+
android:layout_width="match_parent"
|
|
28
|
+
android:layout_height="match_parent"
|
|
29
|
+
android:layout_gravity="center">
|
|
30
|
+
|
|
31
|
+
<LinearLayout
|
|
32
|
+
android:layout_width="wrap_content"
|
|
33
|
+
android:layout_height="wrap_content"
|
|
34
|
+
android:layout_centerInParent="true"
|
|
35
|
+
android:gravity="center_horizontal"
|
|
36
|
+
android:orientation="horizontal"
|
|
37
|
+
tools:ignore="UselessParent">
|
|
38
|
+
|
|
39
|
+
<org.readium.r2.navigator.R2BasicWebView
|
|
40
|
+
android:id="@+id/firstWebView"
|
|
41
|
+
android:layout_width="0dp"
|
|
42
|
+
android:layout_height="wrap_content"
|
|
43
|
+
android:layout_gravity="end"
|
|
44
|
+
android:layout_weight="1"
|
|
45
|
+
android:layerType="hardware" />
|
|
46
|
+
|
|
47
|
+
<org.readium.r2.navigator.R2BasicWebView
|
|
48
|
+
android:id="@+id/secondWebView"
|
|
49
|
+
android:layout_width="0dp"
|
|
50
|
+
android:layout_height="wrap_content"
|
|
51
|
+
android:layout_gravity="start"
|
|
52
|
+
android:layout_weight="1"
|
|
53
|
+
android:layerType="hardware" />
|
|
54
|
+
|
|
55
|
+
</LinearLayout>
|
|
56
|
+
</RelativeLayout>
|
|
57
|
+
</ScrollView>
|
|
58
|
+
</org.readium.r2.navigator.epub.fxl.R2FXLLayout>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!--
|
|
2
|
+
FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
|
|
3
|
+
Not sure why it's not being imported from readium-navigator, but if its not here
|
|
4
|
+
the android build throws an error due to UserSettings.kt#updateViewCSS
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
~ Module: r2-navigator-kotlin
|
|
8
|
+
~ Developers: Aferdita Muriqi
|
|
9
|
+
~
|
|
10
|
+
~ Copyright (c) 2018. Readium Foundation. All rights reserved.
|
|
11
|
+
~ Use of this source code is governed by a BSD-style license which is detailed in the
|
|
12
|
+
~ LICENSE file present in the project repository where this source code is maintained.
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<org.readium.r2.navigator.epub.fxl.R2FXLLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
16
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
17
|
+
android:id="@+id/r2FXLLayout"
|
|
18
|
+
android:layout_width="match_parent"
|
|
19
|
+
android:layout_height="match_parent">
|
|
20
|
+
|
|
21
|
+
<ScrollView
|
|
22
|
+
android:layout_width="match_parent"
|
|
23
|
+
android:layout_height="match_parent"
|
|
24
|
+
android:fillViewport="true"
|
|
25
|
+
android:scrollbars="none">
|
|
26
|
+
|
|
27
|
+
<RelativeLayout
|
|
28
|
+
android:layout_width="match_parent"
|
|
29
|
+
android:layout_height="wrap_content"
|
|
30
|
+
android:layout_gravity="center">
|
|
31
|
+
|
|
32
|
+
<LinearLayout
|
|
33
|
+
android:layout_width="wrap_content"
|
|
34
|
+
android:layout_height="wrap_content"
|
|
35
|
+
android:layout_centerInParent="true"
|
|
36
|
+
android:gravity="center_horizontal"
|
|
37
|
+
android:orientation="horizontal"
|
|
38
|
+
tools:ignore="UselessParent">
|
|
39
|
+
|
|
40
|
+
<org.readium.r2.navigator.R2BasicWebView
|
|
41
|
+
android:id="@+id/webViewSingle"
|
|
42
|
+
android:layout_width="0dp"
|
|
43
|
+
android:layout_height="wrap_content"
|
|
44
|
+
android:layout_weight="1"
|
|
45
|
+
android:layerType="hardware" />
|
|
46
|
+
|
|
47
|
+
</LinearLayout>
|
|
48
|
+
|
|
49
|
+
</RelativeLayout>
|
|
50
|
+
</ScrollView>
|
|
51
|
+
|
|
52
|
+
</org.readium.r2.navigator.epub.fxl.R2FXLLayout>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
|
|
4
|
+
Not sure why it's not being imported from readium-navigator, but if its not here
|
|
5
|
+
the android build throws an error due to UserSettings.kt#updateViewCSS
|
|
6
|
+
|
|
7
|
+
~ Module: r2-navigator-kotlin
|
|
8
|
+
~ Developers: Aferdita Muriqi, Clément Baumann
|
|
9
|
+
~
|
|
10
|
+
~ Copyright (c) 2018. Readium Foundation. All rights reserved.
|
|
11
|
+
~ Use of this source code is governed by a BSD-style license which is detailed in the
|
|
12
|
+
~ LICENSE file present in the project repository where this source code is maintained.
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
16
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
17
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
18
|
+
android:layout_width="match_parent"
|
|
19
|
+
android:layout_height="match_parent"
|
|
20
|
+
android:orientation="vertical">
|
|
21
|
+
|
|
22
|
+
<org.readium.r2.navigator.R2WebView
|
|
23
|
+
android:id="@+id/webView"
|
|
24
|
+
android:layout_width="match_parent"
|
|
25
|
+
android:layout_height="match_parent"/>
|
|
26
|
+
|
|
27
|
+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeComponent, UIManager, } from 'react-native';
|
|
2
|
+
import { COMPONENT_NAME, LINKING_ERROR } from '../utils';
|
|
3
|
+
export const BaseReadiumView = UIManager.getViewManagerConfig(COMPONENT_NAME) != null
|
|
4
|
+
? requireNativeComponent(COMPONENT_NAME)
|
|
5
|
+
: () => {
|
|
6
|
+
throw new Error(LINKING_ERROR);
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BaseReadiumView: () => null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BaseReadiumView = () => null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { View, Platform, findNodeHandle, StyleSheet } from 'react-native';
|
|
3
|
+
import { Settings } from '../interfaces';
|
|
4
|
+
import { createFragment, getWidthOrHeightValue as dimension } from '../utils';
|
|
5
|
+
import { BaseReadiumView } from './BaseReadiumView';
|
|
6
|
+
export const ReadiumView = ({ onLocationChange: wrappedOnLocationChange, onTableOfContents: wrappedOnTableOfContents, settings: unmappedSettings, ...props }) => {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const [{ height, width }, setDimensions] = useState({
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
});
|
|
12
|
+
// set the view dimensions on layout
|
|
13
|
+
const onLayout = useCallback(({ nativeEvent: { layout: { width, height } } }) => {
|
|
14
|
+
setDimensions({
|
|
15
|
+
width: dimension(width),
|
|
16
|
+
height: dimension(height),
|
|
17
|
+
});
|
|
18
|
+
}, []);
|
|
19
|
+
// wrap the native onLocationChange and extract the raw event value
|
|
20
|
+
const onLocationChange = useCallback((event) => {
|
|
21
|
+
if (wrappedOnLocationChange) {
|
|
22
|
+
wrappedOnLocationChange(event.nativeEvent);
|
|
23
|
+
}
|
|
24
|
+
}, [wrappedOnLocationChange]);
|
|
25
|
+
const onTableOfContents = useCallback((event) => {
|
|
26
|
+
if (wrappedOnTableOfContents) {
|
|
27
|
+
const toc = event.nativeEvent.toc || null;
|
|
28
|
+
wrappedOnTableOfContents(toc);
|
|
29
|
+
}
|
|
30
|
+
}, [wrappedOnTableOfContents]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (Platform.OS === 'android') {
|
|
33
|
+
const viewId = findNodeHandle(ref.current);
|
|
34
|
+
createFragment(viewId);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
return (<View style={styles.container} onLayout={onLayout}>
|
|
38
|
+
<BaseReadiumView height={height} width={width} {...props} onLocationChange={onLocationChange} onTableOfContents={onTableOfContents} settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined} ref={ref}/>
|
|
39
|
+
</View>);
|
|
40
|
+
};
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: { width: '100%', height: '100%' },
|
|
43
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useImperativeHandle } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { useReaderRef, useSettingsObserver, useLocationObserver, } from '../../web/hooks';
|
|
4
|
+
export const ReadiumView = React.forwardRef(({ file, settings, location, onLocationChange, onTableOfContents, style = {}, height, width, }, ref) => {
|
|
5
|
+
const readerRef = useReaderRef({
|
|
6
|
+
file,
|
|
7
|
+
onLocationChange,
|
|
8
|
+
onTableOfContents,
|
|
9
|
+
});
|
|
10
|
+
const reader = readerRef.current;
|
|
11
|
+
useImperativeHandle(ref, () => ({
|
|
12
|
+
nextPage: () => {
|
|
13
|
+
readerRef.current?.nextPage();
|
|
14
|
+
},
|
|
15
|
+
prevPage: () => {
|
|
16
|
+
readerRef.current?.previousPage();
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
useSettingsObserver(reader, settings);
|
|
20
|
+
useLocationObserver(reader, location);
|
|
21
|
+
const mainStyle = {
|
|
22
|
+
...styles.maximize,
|
|
23
|
+
...style,
|
|
24
|
+
};
|
|
25
|
+
if (height)
|
|
26
|
+
mainStyle.height = height;
|
|
27
|
+
if (width)
|
|
28
|
+
mainStyle.width = width;
|
|
29
|
+
return (<View style={styles.container}>
|
|
30
|
+
{!reader && <div style={loaderStyle}>Loading reader...</div>}
|
|
31
|
+
<div id="D2Reader-Container" style={styles.d2Container}>
|
|
32
|
+
<main style={mainStyle} tabIndex={-1} id="iframe-wrapper">
|
|
33
|
+
<div id="reader-loading" className="loading" style={loaderStyle}></div>
|
|
34
|
+
<div id="reader-error" className="error"></div>
|
|
35
|
+
</main>
|
|
36
|
+
</div>
|
|
37
|
+
</View>);
|
|
38
|
+
});
|
|
39
|
+
const loaderStyle = {
|
|
40
|
+
width: '100%',
|
|
41
|
+
height: '100%',
|
|
42
|
+
textAlign: 'center',
|
|
43
|
+
position: 'relative',
|
|
44
|
+
top: 'calc(50% - 10px)',
|
|
45
|
+
};
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
container: {
|
|
48
|
+
width: '100%',
|
|
49
|
+
height: '100%',
|
|
50
|
+
},
|
|
51
|
+
d2Container: {
|
|
52
|
+
width: '100%',
|
|
53
|
+
height: '100%',
|
|
54
|
+
display: 'flex',
|
|
55
|
+
},
|
|
56
|
+
maximize: {
|
|
57
|
+
width: '100%',
|
|
58
|
+
height: '100%',
|
|
59
|
+
display: 'flex',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// NOTE: readium uses an index so the order is very important here
|
|
2
|
+
export var Appearance;
|
|
3
|
+
(function (Appearance) {
|
|
4
|
+
/**
|
|
5
|
+
* A traditional "light" mode
|
|
6
|
+
*/
|
|
7
|
+
Appearance["DEFAULT"] = "readium-default-on";
|
|
8
|
+
Appearance["SEPIA"] = "readium-sepia-on";
|
|
9
|
+
/**
|
|
10
|
+
* A traditional "dark" mode
|
|
11
|
+
*/
|
|
12
|
+
Appearance["NIGHT"] = "readium-night-on";
|
|
13
|
+
})(Appearance || (Appearance = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// NOTE: readium uses an index so the order is very important here
|
|
2
|
+
export var FontFamily;
|
|
3
|
+
(function (FontFamily) {
|
|
4
|
+
FontFamily["ORIGINAL"] = "Original";
|
|
5
|
+
FontFamily["HELVETICA_NEUE"] = "Helvetica Neue";
|
|
6
|
+
FontFamily["IOWAN_OLD_STYLE"] = "Iowan Old Style";
|
|
7
|
+
FontFamily["ATHELAS"] = "Athelas";
|
|
8
|
+
FontFamily["SERAVEK"] = "Seravek";
|
|
9
|
+
FontFamily["OPEN_DYSLEXIC"] = "OpenDyslexic";
|
|
10
|
+
FontFamily["ACCESSIBLE_DFA"] = "AccessibleDfA";
|
|
11
|
+
FontFamily["IA_WRITER_DUOSPACE"] = "IA Writer Duospace";
|
|
12
|
+
})(FontFamily || (FontFamily = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import type { Settings } from './Settings';
|
|
3
|
+
import type { Link } from './Link';
|
|
4
|
+
import type { Locator } from './Locator';
|
|
5
|
+
import type { File } from './File';
|
|
6
|
+
export type BaseReadiumViewProps = {
|
|
7
|
+
file: File;
|
|
8
|
+
location?: Locator | Link;
|
|
9
|
+
settings?: Partial<Settings>;
|
|
10
|
+
style?: ViewStyle;
|
|
11
|
+
onLocationChange?: (locator: Locator) => void;
|
|
12
|
+
onTableOfContents?: (toc: Link[] | null) => void;
|
|
13
|
+
ref?: any;
|
|
14
|
+
height?: number;
|
|
15
|
+
width?: number;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Appearance, FontFamily, TextAlignment, ColumnCount, } from '../enums';
|
|
2
|
+
import { RANGES, indexOfObjectValue, clamp, } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* A reader settings object with sensible defaults.
|
|
5
|
+
*/
|
|
6
|
+
export class Settings {
|
|
7
|
+
// TODO:
|
|
8
|
+
// - ligatures
|
|
9
|
+
// - paraIndent
|
|
10
|
+
appearance = Appearance.DEFAULT;
|
|
11
|
+
fontFamily = FontFamily.ORIGINAL;
|
|
12
|
+
textAlign = TextAlignment.JUSTIFY;
|
|
13
|
+
colCount = ColumnCount.AUTO;
|
|
14
|
+
scroll = false;
|
|
15
|
+
fontOverride = false;
|
|
16
|
+
verticalScroll = false;
|
|
17
|
+
bodyHyphens = false;
|
|
18
|
+
advancedSettings = true;
|
|
19
|
+
/**
|
|
20
|
+
* Range: 100.0 - 300.0
|
|
21
|
+
*/
|
|
22
|
+
fontSize = 100;
|
|
23
|
+
/**
|
|
24
|
+
* Range: 0.0 - 0.5
|
|
25
|
+
*/
|
|
26
|
+
wordSpacing = 0;
|
|
27
|
+
/**
|
|
28
|
+
* Range: 0.0 - 0.5
|
|
29
|
+
*/
|
|
30
|
+
letterSpacing = 0;
|
|
31
|
+
/**
|
|
32
|
+
* Range: 0.5 - 4.0
|
|
33
|
+
*/
|
|
34
|
+
pageMargins = 0;
|
|
35
|
+
/**
|
|
36
|
+
* Range: 1.0 - 2.0
|
|
37
|
+
*/
|
|
38
|
+
lineHeight = 1;
|
|
39
|
+
/**
|
|
40
|
+
* Range: 0.0 - 2.0
|
|
41
|
+
*/
|
|
42
|
+
paragraphMargins = 0;
|
|
43
|
+
static map(settings) {
|
|
44
|
+
const defaultValues = new Settings();
|
|
45
|
+
const mapped = {};
|
|
46
|
+
Object.keys(defaultValues)
|
|
47
|
+
.forEach((key) => {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];
|
|
50
|
+
});
|
|
51
|
+
mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
|
|
52
|
+
mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
|
|
53
|
+
mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
|
|
54
|
+
mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
|
|
55
|
+
Object.keys(RANGES).forEach((key) => {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
|
|
58
|
+
});
|
|
59
|
+
return mapped;
|
|
60
|
+
}
|
|
61
|
+
}
|