aksos-react-native-epub-reader 0.1.0 → 0.2.1
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/CHANGELOG.md +60 -0
- package/README.md +178 -20
- package/lib/EpubReader.d.ts +66 -15
- package/lib/EpubReader.js +168 -30
- package/lib/EpubReaderView.d.ts +37 -5
- package/lib/EpubReaderView.js +194 -93
- package/lib/cfiOrder.d.ts +2 -0
- package/lib/cfiOrder.js +34 -0
- package/lib/engine/html.js +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.js +5 -1
- package/lib/strings.d.ts +94 -0
- package/lib/strings.js +96 -0
- package/lib/themes.d.ts +28 -6
- package/lib/themes.js +80 -20
- package/lib/types.d.ts +82 -1
- package/lib/ui/AppearanceSheet.d.ts +4 -2
- package/lib/ui/AppearanceSheet.js +40 -26
- package/lib/ui/ContentsSheet.d.ts +2 -0
- package/lib/ui/ContentsSheet.js +32 -22
- package/lib/ui/CustomizeSheet.d.ts +4 -2
- package/lib/ui/CustomizeSheet.js +31 -27
- package/lib/ui/HighlightMenu.d.ts +4 -2
- package/lib/ui/HighlightMenu.js +13 -11
- package/lib/ui/NoteEditor.js +12 -9
- package/lib/ui/SearchSheet.js +19 -6
- package/lib/ui/Sheet.js +7 -4
- package/lib/ui/Text.d.ts +9 -0
- package/lib/ui/Text.js +62 -0
- package/package.json +81 -76
- package/src/EpubReader.tsx +239 -43
- package/src/EpubReaderView.tsx +287 -99
- package/src/cfiOrder.ts +28 -0
- package/src/engine/epubcfi.js +527 -0
- package/src/engine/html.ts +1 -1
- package/src/engine/reader.js +1273 -157
- package/src/index.ts +5 -2
- package/src/strings.ts +187 -0
- package/src/themes.ts +97 -21
- package/src/types.ts +88 -2
- package/src/ui/AppearanceSheet.tsx +47 -29
- package/src/ui/ContentsSheet.tsx +34 -22
- package/src/ui/CustomizeSheet.tsx +27 -21
- package/src/ui/HighlightMenu.tsx +17 -13
- package/src/ui/NoteEditor.tsx +12 -9
- package/src/ui/SearchSheet.tsx +22 -5
- package/src/ui/Sheet.tsx +8 -5
- package/src/ui/Text.tsx +27 -0
package/src/EpubReaderView.tsx
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { Alert, Animated, Linking, Platform, Pressable, Share, StatusBar, StyleSheet,
|
|
3
|
-
import {
|
|
2
|
+
import { AccessibilityInfo, ActivityIndicator, Alert, Animated, Linking, Platform, Pressable, Share, StatusBar, StyleSheet, useColorScheme, useWindowDimensions, View } from 'react-native';
|
|
3
|
+
import { Text, UiFontsContext } from './ui/Text';
|
|
4
|
+
import { EpubReader, sourceKeyOf } from './EpubReader';
|
|
4
5
|
import type { EpubReaderHandle } from './EpubReader';
|
|
5
|
-
import { chromeColors, DEFAULT_SETTINGS, isDark, themeColors } from './themes';
|
|
6
|
+
import { chromeColors, DEFAULT_SETTINGS, fontChoices, isDark, themeColors } from './themes';
|
|
7
|
+
import type { ChromeOverrides } from './themes';
|
|
6
8
|
import type {
|
|
7
9
|
Bookmark,
|
|
10
|
+
BookColors,
|
|
8
11
|
BookLocation,
|
|
9
12
|
BookMetadata,
|
|
13
|
+
CustomFont,
|
|
10
14
|
EpubSource,
|
|
11
15
|
Highlight,
|
|
12
|
-
HighlightColor,
|
|
13
16
|
PageTurn,
|
|
14
17
|
ReaderSettings,
|
|
18
|
+
ReaderTheme,
|
|
15
19
|
RelocateEvent,
|
|
20
|
+
SafeInsets,
|
|
16
21
|
SearchResult,
|
|
17
22
|
SelectionEvent,
|
|
18
|
-
TocItem
|
|
23
|
+
TocItem,
|
|
24
|
+
UiFonts
|
|
19
25
|
} from './types';
|
|
20
26
|
import { AppearanceSheet } from './ui/AppearanceSheet';
|
|
21
27
|
import { ContentsSheet } from './ui/ContentsSheet';
|
|
22
28
|
import { CustomizeSheet } from './ui/CustomizeSheet';
|
|
23
29
|
import { playPageTurn } from './sound';
|
|
30
|
+
import { LabelsProvider, mergeLabels, useLabels } from './strings';
|
|
31
|
+
import type { ReaderLabels } from './strings';
|
|
24
32
|
import { Glass } from './ui/Glass';
|
|
25
33
|
import { HighlightMenu } from './ui/HighlightMenu';
|
|
26
34
|
import { Icon } from './ui/Icons';
|
|
@@ -33,8 +41,10 @@ export interface EpubReaderViewProps {
|
|
|
33
41
|
source: EpubSource;
|
|
34
42
|
/** shown in the Contents sheet until the book's own title is read */
|
|
35
43
|
title?: string;
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
/** Space for the status bar / home indicator (and notch in landscape). Use useSafeAreaInsets() from react-native-safe-area-context. */
|
|
45
|
+
safeInsets?: SafeInsets;
|
|
46
|
+
/** where to open: an offset or an epub.js CFI ({ cfi: 'epubcfi(...)' }) */
|
|
47
|
+
initialLocation?: BookLocation | { cfi: string };
|
|
38
48
|
initialSettings?: Partial<ReaderSettings>;
|
|
39
49
|
initialHighlights?: Highlight[];
|
|
40
50
|
initialBookmarks?: Bookmark[];
|
|
@@ -46,6 +56,29 @@ export interface EpubReaderViewProps {
|
|
|
46
56
|
onMetadata?: (m: BookMetadata) => void;
|
|
47
57
|
onCover?: (dataUri: string) => void;
|
|
48
58
|
onError?: (message: string) => void;
|
|
59
|
+
/** Texts of the interface; leave out what you do not translate (see ReaderLabels). */
|
|
60
|
+
labels?: Partial<ReaderLabels>;
|
|
61
|
+
/** Largest EPUB in bytes that will be opened (default 150 MB, 0 = no limit). */
|
|
62
|
+
maxFileSize?: number;
|
|
63
|
+
/** Highlight colours by name, shown in the highlight menu (default: the built-in five). See EpubReader. */
|
|
64
|
+
highlightColors?: Record<string, string>;
|
|
65
|
+
highlightOpacity?: number;
|
|
66
|
+
/** App fonts; the ones with an `id` are added to the font list. See EpubReader. */
|
|
67
|
+
fonts?: CustomFont[];
|
|
68
|
+
bookColors?: BookColors;
|
|
69
|
+
maxZoom?: number;
|
|
70
|
+
/** characters per epub.js location (default 150, 0 = off). See EpubReader. */
|
|
71
|
+
locationChars?: number;
|
|
72
|
+
repairZeroWidth?: boolean;
|
|
73
|
+
onLocations?: (info: { count: number }) => void;
|
|
74
|
+
/** Page themes instead of the built-in six (Themes sheet and page colours). */
|
|
75
|
+
themes?: ReaderTheme[];
|
|
76
|
+
/** Colours of buttons, sheets and menus, for light and dark pages. Missing ones keep the default. */
|
|
77
|
+
chrome?: ChromeOverrides;
|
|
78
|
+
/** Fonts of the interface (not the book), e.g. the app's own font. */
|
|
79
|
+
uiFonts?: UiFonts;
|
|
80
|
+
/** Light or dark for the 'device' appearance. Default: the phone's setting. Pass the app's own when it has one. */
|
|
81
|
+
colorScheme?: 'light' | 'dark';
|
|
49
82
|
}
|
|
50
83
|
|
|
51
84
|
const RESET_THEME: Partial<ReaderSettings> = {
|
|
@@ -69,26 +102,53 @@ try {
|
|
|
69
102
|
ScreenOrientation = null;
|
|
70
103
|
}
|
|
71
104
|
|
|
72
|
-
const
|
|
73
|
-
{ id: 'high', label: '
|
|
74
|
-
{ id: 'medium', label: '
|
|
75
|
-
{ id: 'low', label: '
|
|
76
|
-
{ id: 'none', label: '
|
|
105
|
+
const DIM_IDS: { id: DimLevel; label: 'dimHigh' | 'dimMedium' | 'dimLow' | 'dimNone' }[] = [
|
|
106
|
+
{ id: 'high', label: 'dimHigh' },
|
|
107
|
+
{ id: 'medium', label: 'dimMedium' },
|
|
108
|
+
{ id: 'low', label: 'dimLow' },
|
|
109
|
+
{ id: 'none', label: 'dimNone' }
|
|
77
110
|
];
|
|
78
111
|
|
|
79
112
|
const SAMPLE = 'The reader turned the page slowly, listening to the wind move across the empty hills.';
|
|
80
113
|
const uid = () => Date.now().toString(36) + Math.random().toString(36).slice(2, 7);
|
|
81
114
|
|
|
82
|
-
|
|
83
|
-
|
|
115
|
+
// Used when the host passes no safeInsets. A guess from the screen size; the exact values come from react-native-safe-area-context.
|
|
116
|
+
function defaultInsets(width: number, height: number): SafeInsets {
|
|
117
|
+
if (Platform.OS !== 'ios') return { top: StatusBar.currentHeight || 24, bottom: 0 };
|
|
118
|
+
const long = Math.max(width, height);
|
|
119
|
+
const landscape = width > height;
|
|
120
|
+
const notch = long >= 812; // iPhone X and later (iPads are larger but have no notch: they are caught by the short side)
|
|
121
|
+
const phone = Math.min(width, height) < 600;
|
|
122
|
+
if (!phone) return { top: 24, bottom: 20 };
|
|
123
|
+
if (!notch) return { top: 20, bottom: 0 };
|
|
124
|
+
const top = long >= 852 ? 59 : 47;
|
|
125
|
+
return landscape ? { top: 0, bottom: 21, left: top, right: top } : { top, bottom: 34 };
|
|
84
126
|
}
|
|
85
127
|
|
|
86
128
|
type SheetName = null | 'contents' | 'search' | 'appearance' | 'customize';
|
|
87
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Full reader screen. A different `source` (or Try again after an error) starts a fresh screen, so highlights,
|
|
132
|
+
* bookmarks and position of one book can never leak into another.
|
|
133
|
+
*/
|
|
88
134
|
export function EpubReaderView(props: EpubReaderViewProps) {
|
|
89
|
-
const
|
|
135
|
+
const [attempt, setAttempt] = useState(0);
|
|
136
|
+
const labels = useMemo(() => mergeLabels(props.labels), [props.labels]);
|
|
137
|
+
return (
|
|
138
|
+
<LabelsProvider value={labels}>
|
|
139
|
+
<UiFontsContext.Provider value={props.uiFonts || null}>
|
|
140
|
+
<ReaderScreen key={`${sourceKeyOf(props.source)}#${attempt}`} {...props} onRetry={() => setAttempt((a) => a + 1)} />
|
|
141
|
+
</UiFontsContext.Provider>
|
|
142
|
+
</LabelsProvider>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function ReaderScreen(props: EpubReaderViewProps & { onRetry: () => void }) {
|
|
147
|
+
const L = useLabels();
|
|
90
148
|
const screen = useWindowDimensions();
|
|
91
|
-
const
|
|
149
|
+
const safe = props.safeInsets || defaultInsets(screen.width, screen.height);
|
|
150
|
+
const phoneScheme = useColorScheme();
|
|
151
|
+
const systemDark = (props.colorScheme || phoneScheme) === 'dark';
|
|
92
152
|
const reader = useRef<EpubReaderHandle>(null);
|
|
93
153
|
|
|
94
154
|
const [settings, setSettings] = useState<ReaderSettings>({ ...DEFAULT_SETTINGS, ...props.initialSettings });
|
|
@@ -116,13 +176,38 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
116
176
|
const [results, setResults] = useState<SearchResult[]>([]);
|
|
117
177
|
const [searching, setSearching] = useState(false);
|
|
118
178
|
const [error, setError] = useState<string | null>(null);
|
|
179
|
+
// the book could not be opened (or the reader engine stopped): a full screen with a way out
|
|
180
|
+
const [fatal, setFatal] = useState<string | null>(null);
|
|
181
|
+
const [loaded, setLoaded] = useState(false);
|
|
182
|
+
const [reduceMotion, setReduceMotion] = useState(false);
|
|
119
183
|
const searchId = useRef(0);
|
|
184
|
+
const latestProps = useRef(props);
|
|
185
|
+
latestProps.current = props;
|
|
186
|
+
const settingsRef = useRef(settings);
|
|
187
|
+
const highlightsRef = useRef(highlights);
|
|
188
|
+
const bookmarksRef = useRef(bookmarks);
|
|
189
|
+
const lockedByUs = useRef(false);
|
|
120
190
|
const seen = useRef<Record<number, { len: number; pc: number }>>({});
|
|
121
191
|
const layoutKey = useRef('');
|
|
122
192
|
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
let on = true;
|
|
195
|
+
AccessibilityInfo.isReduceMotionEnabled?.().then((v) => on && setReduceMotion(!!v)).catch(() => undefined);
|
|
196
|
+
const sub = AccessibilityInfo.addEventListener?.('reduceMotionChanged', (v: boolean) => setReduceMotion(!!v));
|
|
197
|
+
return () => {
|
|
198
|
+
on = false;
|
|
199
|
+
sub?.remove?.();
|
|
200
|
+
};
|
|
201
|
+
}, []);
|
|
202
|
+
// people who asked for less motion get the fade instead of the curl or slide
|
|
203
|
+
const readerSettings = useMemo(
|
|
204
|
+
() => (reduceMotion && (settings.pageTurn === 'curl' || settings.pageTurn === 'slide') ? { ...settings, pageTurn: 'fade' as PageTurn } : settings),
|
|
205
|
+
[settings, reduceMotion]
|
|
206
|
+
);
|
|
207
|
+
|
|
123
208
|
const dark = isDark(settings, systemDark);
|
|
124
|
-
const page = themeColors(settings, systemDark);
|
|
125
|
-
const colors = useMemo(() => chromeColors(page, dark), [page, dark]);
|
|
209
|
+
const page = themeColors(settings, systemDark, props.themes);
|
|
210
|
+
const colors = useMemo(() => chromeColors(page, dark, props.chrome), [page, dark, props.chrome]);
|
|
126
211
|
|
|
127
212
|
// ----- chrome visibility animation
|
|
128
213
|
const fade = useRef(new Animated.Value(1)).current;
|
|
@@ -139,33 +224,26 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
139
224
|
}, [chrome]);
|
|
140
225
|
|
|
141
226
|
// ----- persistence helpers
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
162
|
-
[props.onBookmarksChange]
|
|
163
|
-
);
|
|
164
|
-
const changeSettings = (patch: Partial<ReaderSettings>) => {
|
|
165
|
-
const next = { ...settings, ...patch };
|
|
227
|
+
// The next list is computed from a ref and the host is told outside of any state updater, so a callback
|
|
228
|
+
// never runs during render (StrictMode runs updaters twice) and quick successive edits never lose each other.
|
|
229
|
+
const updateHighlights = useCallback((fn: (prev: Highlight[]) => Highlight[]) => {
|
|
230
|
+
const next = fn(highlightsRef.current);
|
|
231
|
+
highlightsRef.current = next;
|
|
232
|
+
setHighlights(next);
|
|
233
|
+
latestProps.current.onHighlightsChange?.(next);
|
|
234
|
+
}, []);
|
|
235
|
+
const updateBookmarks = useCallback((fn: (prev: Bookmark[]) => Bookmark[]) => {
|
|
236
|
+
const next = fn(bookmarksRef.current);
|
|
237
|
+
bookmarksRef.current = next;
|
|
238
|
+
setBookmarks(next);
|
|
239
|
+
latestProps.current.onBookmarksChange?.(next);
|
|
240
|
+
}, []);
|
|
241
|
+
const changeSettings = useCallback((patch: Partial<ReaderSettings>) => {
|
|
242
|
+
const next = { ...settingsRef.current, ...patch };
|
|
243
|
+
settingsRef.current = next;
|
|
166
244
|
setSettings(next);
|
|
167
|
-
|
|
168
|
-
};
|
|
245
|
+
latestProps.current.onSettingsChange?.(next);
|
|
246
|
+
}, []);
|
|
169
247
|
|
|
170
248
|
// ----- book page numbers (estimated from characters per page)
|
|
171
249
|
const onRelocate = (e: RelocateEvent) => {
|
|
@@ -184,6 +262,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
184
262
|
const next = pc > 0 && len > 0 ? len / pc : 1200;
|
|
185
263
|
setCpp((old) => (Math.abs(old - next) / next > 0.01 ? next : old));
|
|
186
264
|
setLoc(e);
|
|
265
|
+
setLoaded(true);
|
|
187
266
|
setActive(null);
|
|
188
267
|
props.onLocationChange?.(e);
|
|
189
268
|
};
|
|
@@ -203,10 +282,10 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
203
282
|
// header / footer drawn on the page: chapter title + page number, or "N pages left" + "x of y" while the controls are shown
|
|
204
283
|
useEffect(() => {
|
|
205
284
|
if (!loc) return;
|
|
206
|
-
const header = chrome ? (pagesLeft === 0 ?
|
|
207
|
-
const footer = chrome ?
|
|
285
|
+
const header = chrome ? (pagesLeft === 0 ? L.lastPageInChapter : L.pagesLeft(pagesLeft)) : loc.chapter;
|
|
286
|
+
const footer = chrome ? L.pageOfTotal(curPage, totalPages) : L.formatNumber(curPage);
|
|
208
287
|
reader.current?.setLabels(header, footer);
|
|
209
|
-
}, [chrome, loc, curPage, totalPages, pagesLeft]);
|
|
288
|
+
}, [chrome, loc, curPage, totalPages, pagesLeft, L]);
|
|
210
289
|
|
|
211
290
|
// ----- bookmarks
|
|
212
291
|
const bookmarkHere = useMemo(
|
|
@@ -221,7 +300,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
221
300
|
} else {
|
|
222
301
|
updateBookmarks((prev) => [
|
|
223
302
|
...prev,
|
|
224
|
-
{ id: uid(), spine: loc.spine, offset: loc.offset, chapter: loc.chapter, excerpt: loc.excerpt, progress: loc.progress, createdAt: Date.now() }
|
|
303
|
+
{ id: uid(), spine: loc.spine, offset: loc.offset, cfi: loc.startCfi, chapter: loc.chapter, excerpt: loc.excerpt, progress: loc.progress, createdAt: Date.now() }
|
|
225
304
|
]);
|
|
226
305
|
}
|
|
227
306
|
};
|
|
@@ -235,7 +314,8 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
235
314
|
start: sel.start,
|
|
236
315
|
end: sel.end,
|
|
237
316
|
text: sel.text.replace(/\s+/g, ' ').trim(),
|
|
238
|
-
color: 'yellow',
|
|
317
|
+
color: props.highlightColors ? Object.keys(props.highlightColors)[0] || 'yellow' : 'yellow',
|
|
318
|
+
cfi: sel.cfi,
|
|
239
319
|
chapter: loc?.chapter,
|
|
240
320
|
createdAt: Date.now()
|
|
241
321
|
};
|
|
@@ -280,18 +360,20 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
280
360
|
};
|
|
281
361
|
const toggleRotationLock = async () => {
|
|
282
362
|
if (!ScreenOrientation) {
|
|
283
|
-
Alert.alert(
|
|
363
|
+
Alert.alert(L.rotationLock, L.rotationLockNeedsPackage);
|
|
284
364
|
return;
|
|
285
365
|
}
|
|
286
366
|
try {
|
|
287
367
|
if (rotLocked) {
|
|
288
368
|
await ScreenOrientation.unlockAsync();
|
|
369
|
+
lockedByUs.current = false;
|
|
289
370
|
setRotLocked(false);
|
|
290
371
|
} else {
|
|
291
372
|
const o = await ScreenOrientation.getOrientationAsync();
|
|
292
373
|
const O = ScreenOrientation.Orientation;
|
|
293
374
|
const L = ScreenOrientation.OrientationLock;
|
|
294
375
|
await ScreenOrientation.lockAsync(o === O.LANDSCAPE_LEFT ? L.LANDSCAPE_LEFT : o === O.LANDSCAPE_RIGHT ? L.LANDSCAPE_RIGHT : L.PORTRAIT_UP);
|
|
376
|
+
lockedByUs.current = true;
|
|
295
377
|
setRotLocked(true);
|
|
296
378
|
}
|
|
297
379
|
} catch {
|
|
@@ -300,7 +382,8 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
300
382
|
};
|
|
301
383
|
useEffect(
|
|
302
384
|
() => () => {
|
|
303
|
-
|
|
385
|
+
// only release a lock this reader set: the host app may have its own orientation policy
|
|
386
|
+
if (ScreenOrientation && lockedByUs.current) ScreenOrientation.unlockAsync().catch(() => undefined);
|
|
304
387
|
},
|
|
305
388
|
[]
|
|
306
389
|
);
|
|
@@ -311,6 +394,13 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
311
394
|
setChrome(false);
|
|
312
395
|
} else setLineMenu(true);
|
|
313
396
|
};
|
|
397
|
+
const openLink = (href: string) => {
|
|
398
|
+
if (!/^(https?|mailto):/i.test(href)) return;
|
|
399
|
+
Alert.alert(L.openLink, href, [
|
|
400
|
+
{ text: L.cancel, style: 'cancel' },
|
|
401
|
+
{ text: L.open, onPress: () => Linking.openURL(href).catch(() => undefined) }
|
|
402
|
+
]);
|
|
403
|
+
};
|
|
314
404
|
const share = () => {
|
|
315
405
|
const text = [loc?.excerpt, meta?.title && `— ${meta.title}`].filter(Boolean).join(' ');
|
|
316
406
|
Share.share({ message: text || meta?.title || '' }).catch(() => undefined);
|
|
@@ -318,17 +408,29 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
318
408
|
|
|
319
409
|
const progressFill = Math.max(0, Math.min(1, loc?.progress ?? 0));
|
|
320
410
|
const tx = colors.text;
|
|
411
|
+
// text on the progress fill: the host's onStrong, else the default for that fill
|
|
412
|
+
const onFill = colors.onStrong || (colors.strong ? '#ffffff' : dark ? tx : '#ffffff');
|
|
321
413
|
|
|
322
414
|
return (
|
|
323
415
|
<View style={[styles.root, { backgroundColor: page.bg }]}>
|
|
324
416
|
<EpubReader
|
|
325
417
|
ref={reader}
|
|
326
418
|
source={props.source}
|
|
327
|
-
settings={
|
|
419
|
+
settings={readerSettings}
|
|
328
420
|
systemDark={systemDark}
|
|
329
421
|
safeInsets={safe}
|
|
330
422
|
initialLocation={props.initialLocation}
|
|
331
423
|
highlights={highlights}
|
|
424
|
+
maxFileSize={props.maxFileSize}
|
|
425
|
+
highlightColors={props.highlightColors}
|
|
426
|
+
highlightOpacity={props.highlightOpacity}
|
|
427
|
+
fonts={props.fonts}
|
|
428
|
+
bookColors={props.bookColors}
|
|
429
|
+
themes={props.themes}
|
|
430
|
+
maxZoom={props.maxZoom}
|
|
431
|
+
locationChars={props.locationChars}
|
|
432
|
+
repairZeroWidth={props.repairZeroWidth}
|
|
433
|
+
onLocations={props.onLocations}
|
|
332
434
|
onReady={({ metadata, rtl: isRtl }) => {
|
|
333
435
|
setMeta(metadata);
|
|
334
436
|
setRtl(isRtl);
|
|
@@ -354,18 +456,43 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
354
456
|
setActive(null);
|
|
355
457
|
}
|
|
356
458
|
}}
|
|
357
|
-
onLink={
|
|
459
|
+
onLink={openLink}
|
|
460
|
+
onLinkJump={(from) => setReturnTo({ spine: from.spine, offset: from.offset, page: pageOf(from.spine, from.offset) })}
|
|
461
|
+
onDirectionChange={setRtl}
|
|
358
462
|
onSearchResults={(id, found, done) => {
|
|
359
463
|
if (id !== searchId.current) return;
|
|
360
464
|
setResults((prev) => prev.concat(found));
|
|
361
465
|
if (done) setSearching(false);
|
|
362
466
|
}}
|
|
363
|
-
onError={(m) => {
|
|
364
|
-
|
|
467
|
+
onError={(m, info) => {
|
|
468
|
+
if (info.fatal || !loaded) setFatal(m);
|
|
469
|
+
else setError(m);
|
|
365
470
|
props.onError?.(m);
|
|
366
471
|
}}
|
|
367
472
|
/>
|
|
368
473
|
|
|
474
|
+
{/* screen readers cannot tap the page: this reveals the controls and turns pages */}
|
|
475
|
+
{!chrome && (
|
|
476
|
+
<View
|
|
477
|
+
pointerEvents="none"
|
|
478
|
+
accessible
|
|
479
|
+
accessibilityRole="button"
|
|
480
|
+
accessibilityLabel={L.readerMenu}
|
|
481
|
+
accessibilityActions={[
|
|
482
|
+
{ name: 'activate', label: L.readerMenu },
|
|
483
|
+
{ name: 'increment', label: 'Next page' },
|
|
484
|
+
{ name: 'decrement', label: 'Previous page' }
|
|
485
|
+
]}
|
|
486
|
+
onAccessibilityAction={(e) => {
|
|
487
|
+
const a = e.nativeEvent.actionName;
|
|
488
|
+
if (a === 'increment') reader.current?.next();
|
|
489
|
+
else if (a === 'decrement') reader.current?.prev();
|
|
490
|
+
else setChrome(true);
|
|
491
|
+
}}
|
|
492
|
+
style={[styles.a11yHandle, { bottom: safe.bottom, left: safe.left || 0 }]}
|
|
493
|
+
/>
|
|
494
|
+
)}
|
|
495
|
+
|
|
369
496
|
{/* page brightness */}
|
|
370
497
|
<View pointerEvents="none" style={[StyleSheet.absoluteFill, { backgroundColor: '#000000', opacity: (1 - settings.brightness) * 0.75 }]} />
|
|
371
498
|
|
|
@@ -390,8 +517,8 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
390
517
|
)}
|
|
391
518
|
|
|
392
519
|
{/* close */}
|
|
393
|
-
<Animated.View pointerEvents={chrome ? 'auto' : 'none'} style={[styles.closeWrap, { top: safe.top + 2, opacity: fade }]}>
|
|
394
|
-
<Pressable onPress={props.onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel=
|
|
520
|
+
<Animated.View pointerEvents={chrome ? 'auto' : 'none'} {...hiddenA11y(!chrome)} style={[styles.closeWrap, { top: safe.top + 2, right: 16 + (safe.right || 0), opacity: fade }]}>
|
|
521
|
+
<Pressable onPress={props.onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel={L.closeBook}>
|
|
395
522
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.circle}>
|
|
396
523
|
<Icon name="close" color={tx} size={22} />
|
|
397
524
|
</Glass>
|
|
@@ -400,7 +527,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
400
527
|
|
|
401
528
|
{/* back to where we came from, like the "193" pill in Books */}
|
|
402
529
|
{returnTo && (
|
|
403
|
-
<Animated.View pointerEvents={chrome ? 'auto' : 'none'} style={[styles.returnWrap, { top: safe.top + 2, opacity: fade }]}>
|
|
530
|
+
<Animated.View pointerEvents={chrome ? 'auto' : 'none'} {...hiddenA11y(!chrome)} style={[styles.returnWrap, { top: safe.top + 2, left: 16 + (safe.left || 0), opacity: fade }]}>
|
|
404
531
|
<Pressable
|
|
405
532
|
onPress={() => {
|
|
406
533
|
reader.current?.goTo({ spine: returnTo.spine, offset: returnTo.offset });
|
|
@@ -408,11 +535,11 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
408
535
|
}}
|
|
409
536
|
hitSlop={8}
|
|
410
537
|
accessibilityRole="button"
|
|
411
|
-
accessibilityLabel={
|
|
538
|
+
accessibilityLabel={L.returnToPage(returnTo.page)}
|
|
412
539
|
>
|
|
413
540
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.returnPill}>
|
|
414
541
|
<Icon name="undo" color={tx} size={22} />
|
|
415
|
-
<Text style={{ color: tx, fontSize: 20, marginStart: 8 }}>{returnTo.page}</Text>
|
|
542
|
+
<Text style={{ color: tx, fontSize: 20, marginStart: 8 }} maxFontSizeMultiplier={1.3}>{L.formatNumber(returnTo.page)}</Text>
|
|
416
543
|
</Glass>
|
|
417
544
|
</Pressable>
|
|
418
545
|
</Animated.View>
|
|
@@ -421,9 +548,10 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
421
548
|
{/* menu button (collapsed) */}
|
|
422
549
|
<Animated.View
|
|
423
550
|
pointerEvents={chrome && !menuOpen ? 'auto' : 'none'}
|
|
424
|
-
|
|
551
|
+
{...hiddenA11y(!(chrome && !menuOpen))}
|
|
552
|
+
style={[styles.menuBtnWrap, { bottom: safe.bottom + 14, right: 16 + (safe.right || 0), opacity: Animated.multiply(fade, Animated.subtract(1, menuFade)) }]}
|
|
425
553
|
>
|
|
426
|
-
<Pressable onPress={() => setMenuOpen(true)} accessibilityRole="button" accessibilityLabel=
|
|
554
|
+
<Pressable onPress={() => setMenuOpen(true)} accessibilityRole="button" accessibilityLabel={L.readerMenu}>
|
|
427
555
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.menuBtn}>
|
|
428
556
|
<Icon name="list" color={tx} size={24} />
|
|
429
557
|
</Glass>
|
|
@@ -431,29 +559,29 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
431
559
|
</Animated.View>
|
|
432
560
|
|
|
433
561
|
{/* floating controls (expanded menu) */}
|
|
434
|
-
<Animated.View pointerEvents={chrome && menuOpen ? 'box-none' : 'none'} style={[styles.controls, { bottom: safe.bottom + 44, opacity: menuFade }]}>
|
|
562
|
+
<Animated.View pointerEvents={chrome && menuOpen ? 'box-none' : 'none'} {...hiddenA11y(!(chrome && menuOpen))} style={[styles.controls, { bottom: safe.bottom + 44, right: 16 + (safe.right || 0), opacity: menuFade }]}>
|
|
435
563
|
<Pressable
|
|
436
564
|
onPress={() => {
|
|
437
565
|
setMenuOpen(false);
|
|
438
566
|
setSheet('contents');
|
|
439
567
|
}}
|
|
440
568
|
accessibilityRole="button"
|
|
441
|
-
accessibilityLabel=
|
|
569
|
+
accessibilityLabel={L.contents}
|
|
442
570
|
style={styles.pillWrap}
|
|
443
571
|
>
|
|
444
572
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.pill}>
|
|
445
573
|
<View style={styles.pillRow} onLayout={(e) => setPillW(e.nativeEvent.layout.width)}>
|
|
446
|
-
<Text style={[styles.pillText, { color: tx }]}>
|
|
574
|
+
<Text style={[styles.pillText, { color: tx }]} maxFontSizeMultiplier={1.3}>{L.contents} • {L.formatNumber(percent)}%</Text>
|
|
447
575
|
<Icon name="list" color={tx} size={24} />
|
|
448
576
|
</View>
|
|
449
577
|
{/* progress fill with inverted text on top of it */}
|
|
450
578
|
<View
|
|
451
579
|
pointerEvents="none"
|
|
452
|
-
style={[styles.fill, { width: progressFill * pillW, backgroundColor: dark ? 'rgba(255,255,255,0.35)' : '#1c1408', [rtl ? 'right' : 'left']: 0 }]}
|
|
580
|
+
style={[styles.fill, { width: progressFill * pillW, backgroundColor: colors.strong || (dark ? 'rgba(255,255,255,0.35)' : '#1c1408'), [rtl ? 'right' : 'left']: 0 }]}
|
|
453
581
|
>
|
|
454
582
|
<View style={[styles.pillRow, { position: 'absolute', top: 0, width: pillW, [rtl ? 'right' : 'left']: 0 }]}>
|
|
455
|
-
<Text style={[styles.pillText, { color:
|
|
456
|
-
<Icon name="list" color={
|
|
583
|
+
<Text style={[styles.pillText, { color: onFill }]} maxFontSizeMultiplier={1.3}>{L.contents} • {L.formatNumber(percent)}%</Text>
|
|
584
|
+
<Icon name="list" color={onFill} size={24} />
|
|
457
585
|
</View>
|
|
458
586
|
</View>
|
|
459
587
|
</Glass>
|
|
@@ -465,12 +593,12 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
465
593
|
setSheet('search');
|
|
466
594
|
}}
|
|
467
595
|
accessibilityRole="button"
|
|
468
|
-
accessibilityLabel=
|
|
596
|
+
accessibilityLabel={L.searchBook}
|
|
469
597
|
style={styles.pillWrap}
|
|
470
598
|
>
|
|
471
599
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.pill}>
|
|
472
600
|
<View style={styles.pillRow}>
|
|
473
|
-
<Text style={[styles.pillText, { color: tx }]}>
|
|
601
|
+
<Text style={[styles.pillText, { color: tx }]} maxFontSizeMultiplier={1.3}>{L.searchBook}</Text>
|
|
474
602
|
<Icon name="search" color={tx} size={24} />
|
|
475
603
|
</View>
|
|
476
604
|
</Glass>
|
|
@@ -482,34 +610,34 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
482
610
|
setSheet('appearance');
|
|
483
611
|
}}
|
|
484
612
|
accessibilityRole="button"
|
|
485
|
-
accessibilityLabel=
|
|
613
|
+
accessibilityLabel={L.themesSettings}
|
|
486
614
|
style={styles.pillWrap}
|
|
487
615
|
>
|
|
488
616
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.pill}>
|
|
489
617
|
<View style={styles.pillRow}>
|
|
490
|
-
<Text style={[styles.pillText, { color: tx }]}>
|
|
618
|
+
<Text style={[styles.pillText, { color: tx }]} maxFontSizeMultiplier={1.3}>{L.themesSettings}</Text>
|
|
491
619
|
<Icon name="textSize" color={tx} size={26} />
|
|
492
620
|
</View>
|
|
493
621
|
</Glass>
|
|
494
622
|
</Pressable>
|
|
495
623
|
|
|
496
624
|
<View style={styles.roundRow}>
|
|
497
|
-
<Pressable onPress={share} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel=
|
|
625
|
+
<Pressable onPress={share} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel={L.share}>
|
|
498
626
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.round}>
|
|
499
627
|
<Icon name="share" color={tx} size={24} />
|
|
500
628
|
</Glass>
|
|
501
629
|
</Pressable>
|
|
502
|
-
<Pressable onPress={toggleRotationLock} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel=
|
|
630
|
+
<Pressable onPress={toggleRotationLock} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel={L.rotationLock} accessibilityState={{ selected: rotLocked }}>
|
|
503
631
|
<Glass dark={dark} background={rotLocked ? (dark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.18)') : colors.glass} border={colors.glassBorder} style={styles.round}>
|
|
504
632
|
<Icon name="rotationLock" color={tx} size={26} active={rotLocked} />
|
|
505
633
|
</Glass>
|
|
506
634
|
</Pressable>
|
|
507
|
-
<Pressable onPress={onLineGuideButton} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel=
|
|
635
|
+
<Pressable onPress={onLineGuideButton} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel={L.lineGuide} accessibilityState={{ selected: lineGuide }}>
|
|
508
636
|
<Glass dark={dark} background={lineGuide ? (dark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.18)') : colors.glass} border={colors.glassBorder} style={styles.round}>
|
|
509
637
|
<Icon name="lineGuide" color={tx} size={26} active={lineGuide} />
|
|
510
638
|
</Glass>
|
|
511
639
|
</Pressable>
|
|
512
|
-
<Pressable onPress={toggleBookmark} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel=
|
|
640
|
+
<Pressable onPress={toggleBookmark} style={styles.roundWrap} accessibilityRole="button" accessibilityLabel={L.bookmarkPage} accessibilityState={{ selected: bookmarkHere.length > 0 }}>
|
|
513
641
|
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.round}>
|
|
514
642
|
<Icon name="bookmark" color={tx} size={24} active={bookmarkHere.length > 0} />
|
|
515
643
|
</Glass>
|
|
@@ -518,7 +646,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
518
646
|
</Animated.View>
|
|
519
647
|
|
|
520
648
|
{selection && !active && !noteFor && (() => {
|
|
521
|
-
const w = 214;
|
|
649
|
+
const w = Math.min(Math.max(214, screen.width * 0.5), screen.width - 16);
|
|
522
650
|
const r = selection.rect;
|
|
523
651
|
const left = Math.max(8, Math.min(screen.width - w - 8, r.x + r.width / 2 - w / 2));
|
|
524
652
|
// the system callout (Copy / Look Up) sits above the selection, so ours goes below it
|
|
@@ -530,20 +658,20 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
530
658
|
style={styles.selBtn}
|
|
531
659
|
onPress={() => createHighlight(selection, false)}
|
|
532
660
|
accessibilityRole="button"
|
|
533
|
-
accessibilityLabel=
|
|
661
|
+
accessibilityLabel={L.highlight}
|
|
534
662
|
>
|
|
535
663
|
<Icon name="highlighter" color={tx} size={22} />
|
|
536
|
-
<Text style={[styles.selText, { color: tx }]}>
|
|
664
|
+
<Text style={[styles.selText, { color: tx }]} numberOfLines={1} maxFontSizeMultiplier={1.2}>{L.highlight}</Text>
|
|
537
665
|
</Pressable>
|
|
538
666
|
<View style={[styles.selSep, { backgroundColor: colors.separator }]} />
|
|
539
667
|
<Pressable
|
|
540
668
|
style={styles.selBtn}
|
|
541
669
|
onPress={() => createHighlight(selection, true)}
|
|
542
670
|
accessibilityRole="button"
|
|
543
|
-
accessibilityLabel=
|
|
671
|
+
accessibilityLabel={L.addNote}
|
|
544
672
|
>
|
|
545
673
|
<Icon name="pencil" color={tx} size={22} />
|
|
546
|
-
<Text style={[styles.selText, { color: tx }]}>
|
|
674
|
+
<Text style={[styles.selText, { color: tx }]} numberOfLines={1} maxFontSizeMultiplier={1.2}>{L.note}</Text>
|
|
547
675
|
</Pressable>
|
|
548
676
|
</Glass>
|
|
549
677
|
);
|
|
@@ -555,7 +683,8 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
555
683
|
rect={active.rect}
|
|
556
684
|
screen={screen}
|
|
557
685
|
colors={colors}
|
|
558
|
-
|
|
686
|
+
palette={props.highlightColors}
|
|
687
|
+
onColor={(c) => patchHighlight(activeHighlight.id, { color: c })}
|
|
559
688
|
onToggleUnderline={() => patchHighlight(activeHighlight.id, { style: activeHighlight.style === 'underline' ? 'highlight' : 'underline' })}
|
|
560
689
|
onNote={() => {
|
|
561
690
|
setNoteFor(activeHighlight.id);
|
|
@@ -566,43 +695,89 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
566
695
|
/>
|
|
567
696
|
)}
|
|
568
697
|
|
|
569
|
-
{
|
|
570
|
-
|
|
698
|
+
{/* opening the book: shown until the first page is there */}
|
|
699
|
+
{!loaded && !fatal && (
|
|
700
|
+
<View style={[StyleSheet.absoluteFill, styles.splash, { backgroundColor: page.bg }]} pointerEvents="box-none">
|
|
701
|
+
<ActivityIndicator color={page.fg} />
|
|
702
|
+
<Text style={{ color: page.fg, opacity: 0.6, marginTop: 12, fontSize: 15 }} maxFontSizeMultiplier={1.3}>
|
|
703
|
+
{L.loading}
|
|
704
|
+
</Text>
|
|
705
|
+
<Pressable
|
|
706
|
+
onPress={props.onClose}
|
|
707
|
+
hitSlop={10}
|
|
708
|
+
accessibilityRole="button"
|
|
709
|
+
accessibilityLabel={L.closeBook}
|
|
710
|
+
style={[styles.splashClose, { top: safe.top + 2, right: 16 + (safe.right || 0) }]}
|
|
711
|
+
>
|
|
712
|
+
<Glass dark={dark} background={colors.glass} border={colors.glassBorder} style={styles.circle}>
|
|
713
|
+
<Icon name="close" color={tx} size={22} />
|
|
714
|
+
</Glass>
|
|
715
|
+
</Pressable>
|
|
716
|
+
</View>
|
|
717
|
+
)}
|
|
718
|
+
|
|
719
|
+
{/* the book cannot be shown: always a way back */}
|
|
720
|
+
{!!fatal && (
|
|
721
|
+
<View style={[StyleSheet.absoluteFill, styles.splash, { backgroundColor: page.bg }]} accessibilityViewIsModal>
|
|
722
|
+
<Text style={{ color: page.fg, fontSize: 18, fontWeight: '600', textAlign: 'center' }} accessibilityRole="header">
|
|
723
|
+
{L.couldNotOpen}
|
|
724
|
+
</Text>
|
|
725
|
+
<Text style={{ color: page.fg, opacity: 0.7, fontSize: 15, textAlign: 'center', marginTop: 10 }} accessibilityRole="alert">
|
|
726
|
+
{fatal}
|
|
727
|
+
</Text>
|
|
728
|
+
<View style={styles.fatalButtons}>
|
|
729
|
+
<Pressable onPress={props.onRetry} style={[styles.fatalBtn, { backgroundColor: colors.accent }]} accessibilityRole="button">
|
|
730
|
+
<Text style={{ color: '#ffffff', fontSize: 16, fontWeight: '600' }}>{L.tryAgain}</Text>
|
|
731
|
+
</Pressable>
|
|
732
|
+
{!!props.onClose && (
|
|
733
|
+
<Pressable onPress={props.onClose} style={[styles.fatalBtn, { backgroundColor: colors.card }]} accessibilityRole="button">
|
|
734
|
+
<Text style={{ color: tx, fontSize: 16, fontWeight: '600' }}>{L.close}</Text>
|
|
735
|
+
</Pressable>
|
|
736
|
+
)}
|
|
737
|
+
</View>
|
|
738
|
+
</View>
|
|
739
|
+
)}
|
|
740
|
+
|
|
741
|
+
{error && !fatal && (
|
|
742
|
+
<View style={[styles.error, { backgroundColor: colors.sheet }]} accessibilityRole="alert">
|
|
571
743
|
<Text style={{ color: colors.text, fontSize: 15, textAlign: 'center' }}>{error}</Text>
|
|
572
|
-
<Pressable onPress={() => setError(null)} style={{ marginTop: 12 }}>
|
|
573
|
-
<Text style={{ color: colors.accent, fontSize: 16 }}>
|
|
744
|
+
<Pressable onPress={() => setError(null)} style={{ marginTop: 12, padding: 8 }} accessibilityRole="button">
|
|
745
|
+
<Text style={{ color: colors.accent, fontSize: 16 }}>{L.ok}</Text>
|
|
574
746
|
</Pressable>
|
|
575
747
|
</View>
|
|
576
748
|
)}
|
|
577
749
|
|
|
578
750
|
{lineMenu && (
|
|
579
751
|
<>
|
|
580
|
-
<Pressable style={StyleSheet.absoluteFill} onPress={() => setLineMenu(false)} accessibilityLabel=
|
|
752
|
+
<Pressable style={StyleSheet.absoluteFill} onPress={() => setLineMenu(false)} accessibilityLabel={L.dismiss} />
|
|
581
753
|
<View style={[styles.lineMenu, { bottom: safe.bottom + 20, backgroundColor: colors.dark ? '#4a4742' : '#ffffff', borderColor: colors.glassBorder }]}>
|
|
582
|
-
<Text style={[styles.lineMenuHead, { color: colors.subtext }]}>
|
|
583
|
-
{
|
|
754
|
+
<Text style={[styles.lineMenuHead, { color: colors.subtext }]}>{L.backgroundDimming}</Text>
|
|
755
|
+
{DIM_IDS.map((d) => (
|
|
584
756
|
<Pressable
|
|
585
757
|
key={d.id}
|
|
586
758
|
style={styles.lineItem}
|
|
759
|
+
accessibilityRole="button"
|
|
760
|
+
accessibilityState={{ selected: dimLevel === d.id }}
|
|
587
761
|
onPress={() => {
|
|
588
762
|
setDimLevel(d.id);
|
|
589
763
|
setLineMenu(false);
|
|
590
764
|
}}
|
|
591
765
|
>
|
|
592
766
|
<View style={styles.lineCheck}>{dimLevel === d.id && <Icon name="check" color={tx} size={20} />}</View>
|
|
593
|
-
<Text style={{ color: tx, fontSize: 19 }}>{d.label}</Text>
|
|
767
|
+
<Text style={{ color: tx, fontSize: 19 }}>{L[d.label]}</Text>
|
|
594
768
|
</Pressable>
|
|
595
769
|
))}
|
|
596
770
|
<View style={[styles.lineSep, { backgroundColor: colors.separator }]} />
|
|
597
771
|
<Pressable
|
|
598
772
|
style={styles.lineItem}
|
|
773
|
+
accessibilityRole="button"
|
|
599
774
|
onPress={() => {
|
|
600
775
|
setLineGuide(false);
|
|
601
776
|
setLineMenu(false);
|
|
602
777
|
}}
|
|
603
778
|
>
|
|
604
779
|
<View style={styles.lineCheck} />
|
|
605
|
-
<Text style={{ color: tx, fontSize: 19 }}>
|
|
780
|
+
<Text style={{ color: tx, fontSize: 19 }}>{L.turnOffLineGuide}</Text>
|
|
606
781
|
</Pressable>
|
|
607
782
|
</View>
|
|
608
783
|
</>
|
|
@@ -612,12 +787,13 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
612
787
|
visible={sheet === 'contents'}
|
|
613
788
|
colors={colors}
|
|
614
789
|
title={meta?.title || props.title || ''}
|
|
615
|
-
subtitle={
|
|
790
|
+
subtitle={L.pageOfTotalLong(curPage, totalPages)}
|
|
616
791
|
toc={toc}
|
|
617
792
|
currentSpine={loc?.spine ?? 0}
|
|
618
793
|
pageOf={pageOf}
|
|
619
794
|
bookmarks={bookmarks}
|
|
620
795
|
highlights={highlights}
|
|
796
|
+
palette={props.highlightColors}
|
|
621
797
|
onClose={closeSheet}
|
|
622
798
|
onGoToc={(item) => {
|
|
623
799
|
closeSheet();
|
|
@@ -625,11 +801,11 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
625
801
|
}}
|
|
626
802
|
onGoBookmark={(b) => {
|
|
627
803
|
closeSheet();
|
|
628
|
-
jump({ spine: b.spine, offset: b.offset });
|
|
804
|
+
jump(b.cfi ? { cfi: b.cfi, spine: b.spine, offset: b.offset } : { spine: b.spine, offset: b.offset });
|
|
629
805
|
}}
|
|
630
806
|
onGoHighlight={(h) => {
|
|
631
807
|
closeSheet();
|
|
632
|
-
jump({ spine: h.spine, offset: h.start });
|
|
808
|
+
jump(h.cfi ? { cfi: h.cfi, spine: h.spine, offset: h.start } : { spine: h.spine, offset: h.start });
|
|
633
809
|
}}
|
|
634
810
|
onDeleteBookmark={(id) => updateBookmarks((prev) => prev.filter((b) => b.id !== id))}
|
|
635
811
|
onDeleteHighlight={(id) => updateHighlights((prev) => prev.filter((h) => h.id !== id))}
|
|
@@ -653,6 +829,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
653
829
|
colors={colors}
|
|
654
830
|
settings={settings}
|
|
655
831
|
systemDark={systemDark}
|
|
832
|
+
themes={props.themes}
|
|
656
833
|
onChange={changeSettings}
|
|
657
834
|
onCustomize={() => switchSheet('customize')}
|
|
658
835
|
onClose={closeSheet}
|
|
@@ -663,6 +840,7 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
663
840
|
page={page}
|
|
664
841
|
settings={settings}
|
|
665
842
|
sample={loc?.excerpt || SAMPLE}
|
|
843
|
+
fontList={fontChoices(props.fonts)}
|
|
666
844
|
onChange={changeSettings}
|
|
667
845
|
onReset={() => changeSettings(RESET_THEME)}
|
|
668
846
|
onClose={() => switchSheet('appearance')}
|
|
@@ -684,9 +862,9 @@ export function EpubReaderView(props: EpubReaderViewProps) {
|
|
|
684
862
|
|
|
685
863
|
const styles = StyleSheet.create({
|
|
686
864
|
root: { flex: 1 },
|
|
687
|
-
closeWrap: { position: 'absolute'
|
|
865
|
+
closeWrap: { position: 'absolute' },
|
|
688
866
|
circle: { width: 42, height: 42, borderRadius: 21, alignItems: 'center', justifyContent: 'center' },
|
|
689
|
-
controls: { position: 'absolute',
|
|
867
|
+
controls: { position: 'absolute', width: '68%', minWidth: 260, maxWidth: 420 },
|
|
690
868
|
selBar: { position: 'absolute', height: 48, borderRadius: 24, flexDirection: 'row', alignItems: 'center' },
|
|
691
869
|
selBtn: { flex: 1, height: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6 },
|
|
692
870
|
selText: { fontSize: 15, fontWeight: '600' },
|
|
@@ -699,9 +877,9 @@ const styles = StyleSheet.create({
|
|
|
699
877
|
lineItem: { flexDirection: 'row', alignItems: 'center', paddingVertical: 12, paddingHorizontal: 18 },
|
|
700
878
|
lineCheck: { width: 34 },
|
|
701
879
|
lineSep: { height: StyleSheet.hairlineWidth, marginVertical: 6, marginHorizontal: 18 },
|
|
702
|
-
menuBtnWrap: { position: 'absolute'
|
|
880
|
+
menuBtnWrap: { position: 'absolute' },
|
|
703
881
|
menuBtn: { width: 54, height: 54, borderRadius: 27, alignItems: 'center', justifyContent: 'center' },
|
|
704
|
-
returnWrap: { position: 'absolute'
|
|
882
|
+
returnWrap: { position: 'absolute' },
|
|
705
883
|
returnPill: { height: 46, borderRadius: 23, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16 },
|
|
706
884
|
pillRow: { height: 50, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 22 },
|
|
707
885
|
pillWrap: { marginBottom: 8 },
|
|
@@ -717,5 +895,15 @@ const styles = StyleSheet.create({
|
|
|
717
895
|
width: 0, height: 0, borderLeftWidth: 8, borderRightWidth: 8, borderBottomWidth: 7,
|
|
718
896
|
borderLeftColor: '#ff3b30', borderRightColor: '#ff3b30', borderBottomColor: 'transparent'
|
|
719
897
|
},
|
|
720
|
-
error: { position: 'absolute', left: 24, right: 24, top: '40%', padding: 20, borderRadius: 14, alignItems: 'center', elevation: 10 }
|
|
898
|
+
error: { position: 'absolute', left: 24, right: 24, top: '40%', padding: 20, borderRadius: 14, alignItems: 'center', elevation: 10 },
|
|
899
|
+
splash: { alignItems: 'center', justifyContent: 'center', paddingHorizontal: 32 },
|
|
900
|
+
splashClose: { position: 'absolute' },
|
|
901
|
+
fatalButtons: { flexDirection: 'row', gap: 12, marginTop: 24 },
|
|
902
|
+
fatalBtn: { minWidth: 110, height: 46, borderRadius: 23, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 20 },
|
|
903
|
+
a11yHandle: { position: 'absolute', width: 48, height: 48, backgroundColor: 'transparent' }
|
|
721
904
|
});
|
|
905
|
+
|
|
906
|
+
// controls that are faded out must not stay reachable for VoiceOver / TalkBack
|
|
907
|
+
function hiddenA11y(hidden: boolean) {
|
|
908
|
+
return { accessibilityElementsHidden: hidden, importantForAccessibility: (hidden ? 'no-hide-descendants' : 'auto') as 'no-hide-descendants' | 'auto' };
|
|
909
|
+
}
|