aksos-react-native-epub-reader 0.1.0 → 0.1.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/lib/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export { EpubReaderView } from './EpubReaderView';
2
2
  export type { EpubReaderViewProps } from './EpubReaderView';
3
3
  export { EpubReader } from './EpubReader';
4
- export type { EpubReaderProps, EpubReaderHandle } from './EpubReader';
5
- export { THEMES, FONTS, HIGHLIGHT_COLORS, DEFAULT_SETTINGS, getTheme, getFont, chromeColors } from './themes';
4
+ export type { EpubReaderProps, EpubReaderHandle, ReaderErrorInfo } from './EpubReader';
5
+ export { THEMES, FONTS, HIGHLIGHT_COLORS, DEFAULT_SETTINGS, getTheme, getFont, chromeColors, themeColors, isDark } from './themes';
6
+ export type { ChromeColors } from './themes';
7
+ export { DEFAULT_LABELS } from './strings';
8
+ export type { ReaderLabels } from './strings';
6
9
  export * from './types';
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.chromeColors = exports.getFont = exports.getTheme = exports.DEFAULT_SETTINGS = exports.HIGHLIGHT_COLORS = exports.FONTS = exports.THEMES = exports.EpubReader = exports.EpubReaderView = void 0;
17
+ exports.DEFAULT_LABELS = exports.isDark = exports.themeColors = exports.chromeColors = exports.getFont = exports.getTheme = exports.DEFAULT_SETTINGS = exports.HIGHLIGHT_COLORS = exports.FONTS = exports.THEMES = exports.EpubReader = exports.EpubReaderView = void 0;
18
18
  var EpubReaderView_1 = require("./EpubReaderView");
19
19
  Object.defineProperty(exports, "EpubReaderView", { enumerable: true, get: function () { return EpubReaderView_1.EpubReaderView; } });
20
20
  var EpubReader_1 = require("./EpubReader");
@@ -27,4 +27,8 @@ Object.defineProperty(exports, "DEFAULT_SETTINGS", { enumerable: true, get: func
27
27
  Object.defineProperty(exports, "getTheme", { enumerable: true, get: function () { return themes_1.getTheme; } });
28
28
  Object.defineProperty(exports, "getFont", { enumerable: true, get: function () { return themes_1.getFont; } });
29
29
  Object.defineProperty(exports, "chromeColors", { enumerable: true, get: function () { return themes_1.chromeColors; } });
30
+ Object.defineProperty(exports, "themeColors", { enumerable: true, get: function () { return themes_1.themeColors; } });
31
+ Object.defineProperty(exports, "isDark", { enumerable: true, get: function () { return themes_1.isDark; } });
32
+ var strings_1 = require("./strings");
33
+ Object.defineProperty(exports, "DEFAULT_LABELS", { enumerable: true, get: function () { return strings_1.DEFAULT_LABELS; } });
30
34
  __exportStar(require("./types"), exports);
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Every text the reader shows. Pass a partial object as the `labels` prop of EpubReaderView to translate
3
+ * (for example into Pashto, Dari or Arabic); anything you leave out stays English.
4
+ */
5
+ export interface ReaderLabels {
6
+ contents: string;
7
+ chapters: string;
8
+ font: string;
9
+ lineSpacing: string;
10
+ characterSpacing: string;
11
+ wordSpacing: string;
12
+ margins: string;
13
+ columns: string;
14
+ columnsAuto: string;
15
+ columnsOne: string;
16
+ columnsTwo: string;
17
+ slide: string;
18
+ curl: string;
19
+ fastFade: string;
20
+ scrollMode: string;
21
+ light: string;
22
+ dark: string;
23
+ matchDevice: string;
24
+ matchSurroundings: string;
25
+ appearance: string;
26
+ pageTurnStyle: string;
27
+ delete: string;
28
+ deleteBookmark: string;
29
+ deleteHighlight: string;
30
+ search: string;
31
+ searchBook: string;
32
+ searchInBook: string;
33
+ searching: string;
34
+ noResults: string;
35
+ themesSettings: string;
36
+ customizeTheme: string;
37
+ customize: string;
38
+ resetTheme: string;
39
+ boldText: string;
40
+ justifyText: string;
41
+ pageTurnSound: string;
42
+ accessibilityLayout: string;
43
+ smallerText: string;
44
+ largerText: string;
45
+ readerMenu: string;
46
+ closeBook: string;
47
+ share: string;
48
+ rotationLock: string;
49
+ rotationLockNeedsPackage: string;
50
+ lineGuide: string;
51
+ turnOffLineGuide: string;
52
+ backgroundDimming: string;
53
+ dimHigh: string;
54
+ dimMedium: string;
55
+ dimLow: string;
56
+ dimNone: string;
57
+ bookmarkPage: string;
58
+ highlight: string;
59
+ note: string;
60
+ addNote: string;
61
+ addANote: string;
62
+ underline: string;
63
+ removeHighlight: string;
64
+ dismiss: string;
65
+ done: string;
66
+ close: string;
67
+ cancel: string;
68
+ save: string;
69
+ ok: string;
70
+ noToc: string;
71
+ noBookmarks: string;
72
+ noHighlights: string;
73
+ bookmarks: string;
74
+ highlights: string;
75
+ loading: string;
76
+ couldNotOpen: string;
77
+ tryAgain: string;
78
+ openLink: string;
79
+ open: string;
80
+ lastPageInChapter: string;
81
+ /** "N pages left in chapter" */
82
+ pagesLeft: (n: number) => string;
83
+ /** "3 of 120" */
84
+ pageOfTotal: (page: number, total: number) => string;
85
+ /** "Page 3 of 120" */
86
+ pageOfTotalLong: (page: number, total: number) => string;
87
+ returnToPage: (page: number) => string;
88
+ /** how numbers are written (e.g. Arabic-Indic digits for an Arabic UI) */
89
+ formatNumber: (n: number) => string;
90
+ }
91
+ export declare const DEFAULT_LABELS: ReaderLabels;
92
+ export declare const LabelsProvider: import("react").Provider<ReaderLabels>;
93
+ export declare function useLabels(): ReaderLabels;
94
+ export declare function mergeLabels(partial?: Partial<ReaderLabels>): ReaderLabels;
package/lib/strings.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelsProvider = exports.DEFAULT_LABELS = void 0;
4
+ exports.useLabels = useLabels;
5
+ exports.mergeLabels = mergeLabels;
6
+ const react_1 = require("react");
7
+ exports.DEFAULT_LABELS = {
8
+ contents: 'Contents',
9
+ chapters: 'Chapters',
10
+ font: 'Font',
11
+ lineSpacing: 'LINE SPACING',
12
+ characterSpacing: 'CHARACTER SPACING',
13
+ wordSpacing: 'WORD SPACING',
14
+ margins: 'MARGINS',
15
+ columns: 'Columns',
16
+ columnsAuto: 'Auto Set',
17
+ columnsOne: 'One',
18
+ columnsTwo: 'Two',
19
+ slide: 'Slide',
20
+ curl: 'Curl',
21
+ fastFade: 'Fast Fade',
22
+ scrollMode: 'Scroll',
23
+ light: 'Light',
24
+ dark: 'Dark',
25
+ matchDevice: 'Match Device',
26
+ matchSurroundings: 'Match Surroundings',
27
+ appearance: 'Appearance',
28
+ pageTurnStyle: 'Page turn style',
29
+ delete: 'Delete',
30
+ deleteBookmark: 'Delete bookmark?',
31
+ deleteHighlight: 'Delete highlight?',
32
+ search: 'Search',
33
+ searchBook: 'Search Book',
34
+ searchInBook: 'Search in book',
35
+ searching: 'Searching…',
36
+ noResults: 'No results',
37
+ themesSettings: 'Themes & Settings',
38
+ customizeTheme: 'Customize Theme',
39
+ customize: 'Customize',
40
+ resetTheme: 'Reset Theme',
41
+ boldText: 'Bold Text',
42
+ justifyText: 'Justify Text',
43
+ pageTurnSound: 'Page Turn Sound',
44
+ accessibilityLayout: 'Accessibility & Layout Options',
45
+ smallerText: 'Smaller text',
46
+ largerText: 'Larger text',
47
+ readerMenu: 'Reader menu',
48
+ closeBook: 'Close book',
49
+ share: 'Share',
50
+ rotationLock: 'Rotation lock',
51
+ rotationLockNeedsPackage: 'Install expo-screen-orientation to enable the rotation lock.',
52
+ lineGuide: 'Line guide',
53
+ turnOffLineGuide: 'Turn Off Line Guide',
54
+ backgroundDimming: 'Background Dimming',
55
+ dimHigh: 'High',
56
+ dimMedium: 'Medium',
57
+ dimLow: 'Low',
58
+ dimNone: 'None',
59
+ bookmarkPage: 'Bookmark this page',
60
+ highlight: 'Highlight',
61
+ note: 'Note',
62
+ addNote: 'Add note',
63
+ addANote: 'Add a note',
64
+ underline: 'Underline',
65
+ removeHighlight: 'Remove highlight',
66
+ dismiss: 'Dismiss',
67
+ done: 'Done',
68
+ close: 'Close',
69
+ cancel: 'Cancel',
70
+ save: 'Save',
71
+ ok: 'OK',
72
+ noToc: 'No table of contents',
73
+ noBookmarks: 'No bookmarks yet. Tap the bookmark button while reading.',
74
+ noHighlights: 'No highlights or notes yet. Select text to add one.',
75
+ bookmarks: 'Bookmarks',
76
+ highlights: 'Highlights',
77
+ loading: 'Opening book…',
78
+ couldNotOpen: 'This book could not be opened',
79
+ tryAgain: 'Try again',
80
+ openLink: 'Open this link?',
81
+ open: 'Open',
82
+ lastPageInChapter: 'Last page in chapter',
83
+ pagesLeft: (n) => `${n} page${n === 1 ? '' : 's'} left in chapter`,
84
+ pageOfTotal: (p, t) => `${p} of ${t}`,
85
+ pageOfTotalLong: (p, t) => `Page ${p} of ${t}`,
86
+ returnToPage: (p) => `Return to page ${p}`,
87
+ formatNumber: (n) => String(n)
88
+ };
89
+ const LabelsContext = (0, react_1.createContext)(exports.DEFAULT_LABELS);
90
+ exports.LabelsProvider = LabelsContext.Provider;
91
+ function useLabels() {
92
+ return (0, react_1.useContext)(LabelsContext);
93
+ }
94
+ function mergeLabels(partial) {
95
+ return partial ? { ...exports.DEFAULT_LABELS, ...partial } : exports.DEFAULT_LABELS;
96
+ }
package/lib/themes.d.ts CHANGED
@@ -13,6 +13,8 @@ export declare function themeColors(settings: ReaderSettings, systemDark: boolea
13
13
  export declare function toEngineSettings(settings: ReaderSettings, systemDark: boolean, insets: {
14
14
  top: number;
15
15
  bottom: number;
16
+ left?: number;
17
+ right?: number;
16
18
  }): {
17
19
  bg: string;
18
20
  fg: string;
@@ -31,6 +33,8 @@ export declare function toEngineSettings(settings: ReaderSettings, systemDark: b
31
33
  insets: {
32
34
  top: number;
33
35
  bottom: number;
36
+ left: number;
37
+ right: number;
34
38
  };
35
39
  };
36
40
  export interface ChromeColors {
package/lib/themes.js CHANGED
@@ -118,7 +118,7 @@ function toEngineSettings(settings, systemDark, insets) {
118
118
  justify: settings.justify,
119
119
  mode: settings.pageTurn,
120
120
  direction: settings.direction,
121
- insets: { top: insets.top + 40, bottom: insets.bottom + 40 }
121
+ insets: { top: insets.top + 40, bottom: insets.bottom + 40, left: insets.left || 0, right: insets.right || 0 }
122
122
  };
123
123
  }
124
124
  function mix(hex, other, amount) {
package/lib/types.d.ts CHANGED
@@ -126,8 +126,24 @@ export interface ReaderSettings {
126
126
  /** 'auto' follows the book's page-progression-direction / language */
127
127
  direction: 'auto' | 'ltr' | 'rtl';
128
128
  }
129
+ /**
130
+ * Where the book comes from.
131
+ * - uri: file://, content:// (Android), https://, or an asset/bundle URI that fetch() can read. `headers` are sent with the request.
132
+ * - base64: the EPUB bytes as base64 (a data: prefix is accepted).
133
+ * `key` identifies the book: when it changes the reader opens the new source. Defaults to the uri, or to a fingerprint of the data.
134
+ */
129
135
  export type EpubSource = {
130
136
  uri: string;
137
+ headers?: Record<string, string>;
138
+ key?: string;
131
139
  } | {
132
140
  base64: string;
141
+ key?: string;
133
142
  };
143
+ /** Safe-area space around the page, in points. Left/right matter in landscape on notched phones. */
144
+ export interface SafeInsets {
145
+ top: number;
146
+ bottom: number;
147
+ left?: number;
148
+ right?: number;
149
+ }
@@ -37,27 +37,34 @@ exports.AppearanceSheet = AppearanceSheet;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const themes_1 = require("../themes");
40
+ const strings_1 = require("../strings");
40
41
  const Icons_1 = require("./Icons");
41
42
  const Sheet_1 = require("./Sheet");
42
43
  const Slider_1 = require("./Slider");
43
44
  const SIZE = { min: 12, max: 40, step: 2 };
44
45
  const TURNS = [
45
- { id: 'slide', label: 'Slide', icon: 'pageSlide' },
46
- { id: 'curl', label: 'Curl', icon: 'pageCurl' },
47
- { id: 'fade', label: 'Fast Fade', icon: 'pageFade' },
48
- { id: 'scroll', label: 'Scroll', icon: 'pageScroll' }
46
+ { id: 'slide', label: 'slide', icon: 'pageSlide' },
47
+ { id: 'curl', label: 'curl', icon: 'pageCurl' },
48
+ { id: 'fade', label: 'fastFade', icon: 'pageFade' },
49
+ { id: 'scroll', label: 'scrollMode', icon: 'pageScroll' }
49
50
  ];
50
51
  const APPEARANCES = [
51
- { id: 'light', label: 'Light', icon: 'sun', key: 'light' },
52
- { id: 'dark', label: 'Dark', icon: 'moon', key: 'dark' },
53
- { id: 'device', label: 'Match Device', icon: 'contrast', key: 'device' },
54
- { id: 'device', label: 'Match Surroundings', icon: 'sunLow', key: 'surroundings' }
52
+ { id: 'light', label: 'light', icon: 'sun', key: 'light' },
53
+ { id: 'dark', label: 'dark', icon: 'moon', key: 'dark' },
54
+ { id: 'device', label: 'matchDevice', icon: 'contrast', key: 'device' },
55
+ { id: 'device', label: 'matchSurroundings', icon: 'sunLow', key: 'surroundings' }
55
56
  ];
56
57
  /** Icon of the current appearance choice: the button always shows the state it is in. */
57
58
  const appearanceIcon = (a) => (a === 'light' ? 'sun' : a === 'dark' ? 'moon' : 'contrast');
58
59
  /** "Themes & Settings" sheet. */
59
60
  function AppearanceSheet({ visible, colors, settings: s, systemDark, onChange, onCustomize, onClose }) {
61
+ const L = (0, strings_1.useLabels)();
60
62
  const [menu, setMenu] = (0, react_1.useState)(null);
63
+ // a popup left open must not reappear the next time the sheet is shown
64
+ (0, react_1.useEffect)(() => {
65
+ if (!visible)
66
+ setMenu(null);
67
+ }, [visible]);
61
68
  const dark = (0, themes_1.isDark)(s, systemDark);
62
69
  const turn = TURNS.find((t) => t.id === s.pageTurn) || TURNS[0];
63
70
  const menuView = menu && (react_1.default.createElement(react_1.default.Fragment, null,
@@ -69,27 +76,27 @@ function AppearanceSheet({ visible, colors, settings: s, systemDark, onChange, o
69
76
  } },
70
77
  react_1.default.createElement(react_native_1.View, { style: styles.check }, s.pageTurn === t.id && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
71
78
  react_1.default.createElement(Icons_1.Icon, { name: t.icon, color: colors.text, size: 24 }),
72
- react_1.default.createElement(react_native_1.Text, { style: [styles.menuText, { color: colors.text }] }, t.label))))
79
+ react_1.default.createElement(react_native_1.Text, { style: [styles.menuText, { color: colors.text }] }, L[t.label]))))
73
80
  : APPEARANCES.map((a) => (react_1.default.createElement(react_native_1.Pressable, { key: a.key, style: styles.menuItem, onPress: () => {
74
81
  onChange({ appearance: a.id });
75
82
  setMenu(null);
76
83
  } },
77
84
  react_1.default.createElement(react_native_1.View, { style: styles.check }, s.appearance === a.id && a.key !== 'surroundings' && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
78
85
  react_1.default.createElement(Icons_1.Icon, { name: a.icon, color: colors.text, size: 24 }),
79
- react_1.default.createElement(react_native_1.Text, { style: [styles.menuText, { color: colors.text }] }, a.label)))))));
80
- return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: onClose, title: "Themes & Settings", height: "auto", overlay: menuView || undefined },
86
+ react_1.default.createElement(react_native_1.Text, { style: [styles.menuText, { color: colors.text }] }, L[a.label])))))));
87
+ return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: onClose, title: L.themesSettings, height: "auto", overlay: menuView || undefined },
81
88
  react_1.default.createElement(react_native_1.View, { style: styles.body },
82
89
  react_1.default.createElement(react_native_1.View, { style: styles.row },
83
90
  react_1.default.createElement(react_native_1.View, { style: [styles.pill, { flex: 1, backgroundColor: colors.card }] },
84
- react_1.default.createElement(react_native_1.Pressable, { style: styles.half, onPress: () => onChange({ fontSize: Math.max(SIZE.min, s.fontSize - SIZE.step) }), accessibilityLabel: "Smaller text" },
91
+ react_1.default.createElement(react_native_1.Pressable, { style: styles.half, onPress: () => onChange({ fontSize: Math.max(SIZE.min, s.fontSize - SIZE.step) }), accessibilityRole: "button", accessibilityLabel: L.smallerText },
85
92
  react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 15, fontWeight: '500' } }, "A")),
86
93
  react_1.default.createElement(react_native_1.View, { style: [styles.divider, { backgroundColor: colors.separator }] }),
87
- react_1.default.createElement(react_native_1.Pressable, { style: styles.half, onPress: () => onChange({ fontSize: Math.min(SIZE.max, s.fontSize + SIZE.step) }), accessibilityLabel: "Larger text" },
94
+ react_1.default.createElement(react_native_1.Pressable, { style: styles.half, onPress: () => onChange({ fontSize: Math.min(SIZE.max, s.fontSize + SIZE.step) }), accessibilityRole: "button", accessibilityLabel: L.largerText },
88
95
  react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 26, fontWeight: '500' } }, "A"))),
89
96
  react_1.default.createElement(react_native_1.View, { style: [styles.pill, { width: 150, backgroundColor: colors.card }] },
90
- react_1.default.createElement(react_native_1.Pressable, { style: [styles.half, menu === 'turn' && { backgroundColor: colors.separator }], onPress: () => setMenu(menu === 'turn' ? null : 'turn'), accessibilityLabel: `Page turn style: ${turn.label}` },
97
+ react_1.default.createElement(react_native_1.Pressable, { style: [styles.half, menu === 'turn' && { backgroundColor: colors.separator }], onPress: () => setMenu(menu === 'turn' ? null : 'turn'), accessibilityRole: "button", accessibilityLabel: `${L.pageTurnStyle}: ${L[turn.label]}` },
91
98
  react_1.default.createElement(Icons_1.Icon, { name: turn.icon, color: colors.text, size: 26 })),
92
- react_1.default.createElement(react_native_1.Pressable, { style: [styles.half, menu === 'appearance' && { backgroundColor: colors.separator }], onPress: () => setMenu(menu === 'appearance' ? null : 'appearance'), accessibilityLabel: "Appearance" },
99
+ react_1.default.createElement(react_native_1.Pressable, { style: [styles.half, menu === 'appearance' && { backgroundColor: colors.separator }], onPress: () => setMenu(menu === 'appearance' ? null : 'appearance'), accessibilityRole: "button", accessibilityLabel: L.appearance },
93
100
  react_1.default.createElement(Icons_1.Icon, { name: appearanceIcon(s.appearance), color: colors.text, size: 26 })))),
94
101
  react_1.default.createElement(react_native_1.View, { style: styles.brightness },
95
102
  react_1.default.createElement(Icons_1.Icon, { name: "sunLow", color: colors.subtext, size: 20 }),
@@ -105,7 +112,7 @@ function AppearanceSheet({ visible, colors, settings: s, systemDark, onChange, o
105
112
  })),
106
113
  react_1.default.createElement(react_native_1.Pressable, { onPress: onCustomize, style: [styles.customize, { backgroundColor: colors.card }], accessibilityRole: "button" },
107
114
  react_1.default.createElement(Icons_1.Icon, { name: "sliders", color: colors.text, size: 22 }),
108
- react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 18, fontWeight: '600', marginStart: 10 } }, "Customize")))));
115
+ react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 18, fontWeight: '600', marginStart: 10 } }, L.customize)))));
109
116
  }
110
117
  const styles = react_native_1.StyleSheet.create({
111
118
  body: { paddingHorizontal: 16, paddingBottom: 28 },
@@ -37,43 +37,45 @@ exports.ContentsSheet = ContentsSheet;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const themes_1 = require("../themes");
40
+ const strings_1 = require("../strings");
40
41
  const Sheet_1 = require("./Sheet");
41
42
  const TABS = [
42
- { id: 'contents', label: 'Chapters' },
43
- { id: 'bookmarks', label: 'Bookmarks' },
44
- { id: 'notes', label: 'Highlights' }
43
+ { id: 'contents', label: 'chapters' },
44
+ { id: 'bookmarks', label: 'bookmarks' },
45
+ { id: 'notes', label: 'highlights' }
45
46
  ];
46
47
  /** Contents sheet: Chapters | Bookmarks | Highlights, each row with its page number. */
47
48
  function ContentsSheet(p) {
48
49
  const { colors } = p;
50
+ const L = (0, strings_1.useLabels)();
49
51
  const [tab, setTab] = (0, react_1.useState)(p.initialTab || 'contents');
50
- const confirmDelete = (what, fn) => react_native_1.Alert.alert(`Delete ${what}?`, undefined, [
51
- { text: 'Cancel', style: 'cancel' },
52
- { text: 'Delete', style: 'destructive', onPress: fn }
52
+ const confirmDelete = (title, fn) => react_native_1.Alert.alert(title, undefined, [
53
+ { text: L.cancel, style: 'cancel' },
54
+ { text: L.delete, style: 'destructive', onPress: fn }
53
55
  ]);
54
56
  const empty = (text) => react_1.default.createElement(react_native_1.Text, { style: [styles.empty, { color: colors.subtext }] }, text);
55
57
  const rowBorder = { borderColor: colors.separator };
56
58
  return (react_1.default.createElement(Sheet_1.Sheet, { visible: p.visible, colors: colors, onClose: p.onClose, closeIcon: "check", title: p.title, subtitle: p.subtitle, height: "90%" },
57
59
  react_1.default.createElement(react_native_1.View, { style: [styles.segment, { backgroundColor: colors.card }] }, TABS.map((t) => (react_1.default.createElement(react_native_1.Pressable, { key: t.id, onPress: () => setTab(t.id), style: [styles.segItem, tab === t.id && { backgroundColor: colors.dark ? 'rgba(255,255,255,0.22)' : '#ffffff' }], accessibilityRole: "tab", accessibilityState: { selected: tab === t.id } },
58
- react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontWeight: tab === t.id ? '600' : '400', fontSize: 16 } }, t.label))))),
59
- tab === 'contents' && (react_1.default.createElement(react_native_1.FlatList, { data: p.toc, keyExtractor: (_, i) => String(i), ListEmptyComponent: empty('No table of contents'), renderItem: ({ item }) => {
60
+ react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontWeight: tab === t.id ? '600' : '400', fontSize: 16 }, maxFontSizeMultiplier: 1.3 }, L[t.label]))))),
61
+ tab === 'contents' && (react_1.default.createElement(react_native_1.FlatList, { data: p.toc, keyExtractor: (_, i) => String(i), ListEmptyComponent: empty(L.noToc), renderItem: ({ item }) => {
60
62
  const active = item.spine === p.currentSpine && !item.fragment;
61
- return (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoToc(item), style: [styles.row, rowBorder, { paddingStart: 20 + item.level * 18 }] },
63
+ return (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoToc(item), accessibilityRole: "button", style: [styles.row, rowBorder, { paddingStart: 20 + item.level * 18 }] },
62
64
  react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: active ? colors.accent : colors.text, flex: 1 }], numberOfLines: 2 }, item.label),
63
- react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, p.pageOf(item.spine, 0))));
65
+ react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, L.formatNumber(p.pageOf(item.spine, 0)))));
64
66
  } })),
65
- tab === 'bookmarks' && (react_1.default.createElement(react_native_1.FlatList, { data: p.bookmarks.slice().sort((a, b) => a.progress - b.progress), keyExtractor: (b) => b.id, ListEmptyComponent: empty('No bookmarks yet. Tap the bookmark button while reading.'), renderItem: ({ item }) => (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoBookmark(item), onLongPress: () => confirmDelete('bookmark', () => p.onDeleteBookmark(item.id)), style: [styles.row, rowBorder] },
67
+ tab === 'bookmarks' && (react_1.default.createElement(react_native_1.FlatList, { data: p.bookmarks.slice().sort((a, b) => a.progress - b.progress), keyExtractor: (b) => b.id, ListEmptyComponent: empty(L.noBookmarks), renderItem: ({ item }) => (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoBookmark(item), onLongPress: () => confirmDelete(L.deleteBookmark, () => p.onDeleteBookmark(item.id)), style: [styles.row, rowBorder] },
66
68
  react_1.default.createElement(react_native_1.View, { style: { flex: 1 } },
67
69
  react_1.default.createElement(react_native_1.Text, { style: [styles.meta, { color: colors.accent }] }, item.chapter),
68
70
  react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: colors.text }], numberOfLines: 2 }, item.excerpt)),
69
- react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, p.pageOf(item.spine, item.offset)))) })),
70
- tab === 'notes' && (react_1.default.createElement(react_native_1.FlatList, { data: p.highlights.slice().sort((a, b) => a.spine - b.spine || a.start - b.start), keyExtractor: (h) => h.id, ListEmptyComponent: empty('No highlights or notes yet. Select text to add one.'), renderItem: ({ item }) => (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoHighlight(item), onLongPress: () => confirmDelete('highlight', () => p.onDeleteHighlight(item.id)), style: [styles.row, rowBorder] },
71
+ react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, L.formatNumber(p.pageOf(item.spine, item.offset))))) })),
72
+ tab === 'notes' && (react_1.default.createElement(react_native_1.FlatList, { data: p.highlights.slice().sort((a, b) => a.spine - b.spine || a.start - b.start), keyExtractor: (h) => h.id, ListEmptyComponent: empty(L.noHighlights), renderItem: ({ item }) => (react_1.default.createElement(react_native_1.Pressable, { onPress: () => p.onGoHighlight(item), onLongPress: () => confirmDelete(L.deleteHighlight, () => p.onDeleteHighlight(item.id)), style: [styles.row, rowBorder] },
71
73
  react_1.default.createElement(react_native_1.View, { style: [styles.bar, { backgroundColor: themes_1.HIGHLIGHT_COLORS[item.color] }] }),
72
74
  react_1.default.createElement(react_native_1.View, { style: { flex: 1 } },
73
75
  !!item.note && react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: colors.text, fontWeight: '600' }] }, item.note),
74
76
  react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: item.note ? colors.subtext : colors.text }], numberOfLines: 3 }, item.text),
75
77
  !!item.chapter && react_1.default.createElement(react_native_1.Text, { style: [styles.meta, { color: colors.subtext }] }, item.chapter)),
76
- react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, p.pageOf(item.spine, item.start)))) }))));
78
+ react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, L.formatNumber(p.pageOf(item.spine, item.start))))) }))));
77
79
  }
78
80
  const styles = react_native_1.StyleSheet.create({
79
81
  segment: { flexDirection: 'row', marginHorizontal: 16, marginTop: 34, marginBottom: 6, borderRadius: 18, padding: 3 },
@@ -37,10 +37,10 @@ exports.CustomizeSheet = CustomizeSheet;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const themes_1 = require("../themes");
40
+ const strings_1 = require("../strings");
40
41
  const Icons_1 = require("./Icons");
41
42
  const Sheet_1 = require("./Sheet");
42
43
  const Slider_1 = require("./Slider");
43
- const COLUMN_LABEL = { auto: 'Auto Set', '1': 'One', '2': 'Two' };
44
44
  const GREEN = { true: '#34c759' };
45
45
  function Toggle(props) {
46
46
  return (react_1.default.createElement(react_native_1.View, { style: styles.toggleBox },
@@ -48,6 +48,8 @@ function Toggle(props) {
48
48
  }
49
49
  /** "Customize Theme" sheet: font, bold, spacing, margins, columns, justify, sound. */
50
50
  function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange, onReset, onClose }) {
51
+ const L = (0, strings_1.useLabels)();
52
+ const COLUMN_LABEL = { auto: L.columnsAuto, '1': L.columnsOne, '2': L.columnsTwo };
51
53
  const [fonts, setFonts] = (0, react_1.useState)(false);
52
54
  const [columnsMenu, setColumnsMenu] = (0, react_1.useState)(false);
53
55
  const off = !s.customize;
@@ -74,7 +76,7 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
74
76
  setColumnsMenu(false);
75
77
  onClose();
76
78
  };
77
- return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: close, closeIcon: "check", title: "Customize Theme", height: "92%" },
79
+ return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: close, closeIcon: "check", title: L.customizeTheme, height: "92%" },
78
80
  react_1.default.createElement(react_native_1.View, { style: [styles.preview, { backgroundColor: page.bg }] },
79
81
  react_1.default.createElement(react_native_1.Text, { style: [styles.aa, { color: page.fg, fontFamily: previewFont }] }, "Aa"),
80
82
  react_1.default.createElement(react_native_1.Text, { numberOfLines: 4, style: {
@@ -84,7 +86,7 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
84
86
  } }, sample)),
85
87
  react_1.default.createElement(react_native_1.ScrollView, { contentContainerStyle: styles.pad },
86
88
  react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
87
- row('textSize', 'Font', react_1.default.createElement(react_native_1.View, { style: styles.value2 },
89
+ row('textSize', L.font, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
88
90
  react_1.default.createElement(react_native_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, font.name),
89
91
  react_1.default.createElement(Icons_1.Icon, { name: fonts ? 'chevronUp' : 'chevronRight', color: colors.subtext, size: 18 })), () => setFonts((v) => !v), false),
90
92
  fonts &&
@@ -94,16 +96,16 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
94
96
  }, style: [styles.line, border] },
95
97
  react_1.default.createElement(react_native_1.View, { style: styles.check }, s.fontId === f.id && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
96
98
  react_1.default.createElement(react_native_1.Text, { style: [styles.label, { color: colors.text }] }, f.name)))),
97
- row('bold', 'Bold Text', react_1.default.createElement(Toggle, { value: s.bold, onValueChange: (v) => onChange({ bold: v }), trackColor: GREEN }))),
98
- react_1.default.createElement(react_native_1.Text, { style: [styles.heading, { color: colors.text }] }, "Accessibility & Layout Options"),
99
+ row('bold', L.boldText, react_1.default.createElement(Toggle, { value: s.bold, onValueChange: (v) => onChange({ bold: v }), trackColor: GREEN }))),
100
+ react_1.default.createElement(react_native_1.Text, { style: [styles.heading, { color: colors.text }] }, L.accessibilityLayout),
99
101
  react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
100
- row('sliders', 'Customize', react_1.default.createElement(Toggle, { value: s.customize, onValueChange: (v) => onChange({ customize: v }), trackColor: GREEN }), undefined, false),
101
- sliderRow('LINE SPACING', 'lineSpacing', s.lineHeight, 1.1, 2.2, 0.05, s.lineHeight.toFixed(2), 'lineHeight'),
102
- sliderRow('CHARACTER SPACING', 'charSpacing', s.letterSpacing, -50, 100, 5, `${s.letterSpacing}%`, 'letterSpacing'),
103
- sliderRow('WORD SPACING', 'wordSpacing', s.wordSpacing, -50, 100, 5, `${s.wordSpacing}%`, 'wordSpacing'),
104
- sliderRow('MARGINS', 'margins', s.margins, -50, 100, 5, `${s.margins}%`, 'margins')),
102
+ row('sliders', L.customize, react_1.default.createElement(Toggle, { value: s.customize, onValueChange: (v) => onChange({ customize: v }), trackColor: GREEN }), undefined, false),
103
+ sliderRow(L.lineSpacing, 'lineSpacing', s.lineHeight, 1.1, 2.2, 0.05, s.lineHeight.toFixed(2), 'lineHeight'),
104
+ sliderRow(L.characterSpacing, 'charSpacing', s.letterSpacing, -50, 100, 5, `${s.letterSpacing}%`, 'letterSpacing'),
105
+ sliderRow(L.wordSpacing, 'wordSpacing', s.wordSpacing, -50, 100, 5, `${s.wordSpacing}%`, 'wordSpacing'),
106
+ sliderRow(L.margins, 'margins', s.margins, -50, 100, 5, `${s.margins}%`, 'margins')),
105
107
  react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card, marginTop: 16 }] },
106
- row('columns', 'Columns', react_1.default.createElement(react_native_1.View, { style: styles.value2 },
108
+ row('columns', L.columns, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
107
109
  react_1.default.createElement(react_native_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, COLUMN_LABEL[String(s.columns)]),
108
110
  react_1.default.createElement(Icons_1.Icon, { name: columnsMenu ? 'chevronUp' : 'chevronDown', color: colors.subtext, size: 18 })), () => setColumnsMenu((v) => !v), false),
109
111
  columnsMenu &&
@@ -113,10 +115,10 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
113
115
  } },
114
116
  react_1.default.createElement(react_native_1.View, { style: styles.check }, s.columns === c && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
115
117
  react_1.default.createElement(react_native_1.Text, { style: [styles.label, { color: colors.text }] }, COLUMN_LABEL[String(c)])))),
116
- row('justify', 'Justify Text', react_1.default.createElement(Toggle, { value: s.justify, onValueChange: (v) => onChange({ justify: v }), trackColor: GREEN })),
117
- row(s.pageSound ? 'sound' : 'soundOff', 'Page Turn Sound', react_1.default.createElement(Toggle, { value: s.pageSound, onValueChange: (v) => onChange({ pageSound: v }), trackColor: GREEN }))),
118
- react_1.default.createElement(react_native_1.Pressable, { onPress: onReset, style: [styles.reset, { backgroundColor: colors.card }] },
119
- react_1.default.createElement(react_native_1.Text, { style: { color: '#ff3b30', fontSize: 18, fontWeight: '600' } }, "Reset Theme")))));
118
+ row('justify', L.justifyText, react_1.default.createElement(Toggle, { value: s.justify, onValueChange: (v) => onChange({ justify: v }), trackColor: GREEN })),
119
+ row(s.pageSound ? 'sound' : 'soundOff', L.pageTurnSound, react_1.default.createElement(Toggle, { value: s.pageSound, onValueChange: (v) => onChange({ pageSound: v }), trackColor: GREEN }))),
120
+ react_1.default.createElement(react_native_1.Pressable, { onPress: onReset, style: [styles.reset, { backgroundColor: colors.card }], accessibilityRole: "button" },
121
+ react_1.default.createElement(react_native_1.Text, { style: { color: '#ff3b30', fontSize: 18, fontWeight: '600' } }, L.resetTheme)))));
120
122
  }
121
123
  const styles = react_native_1.StyleSheet.create({
122
124
  preview: { paddingHorizontal: 22, paddingTop: 12, paddingBottom: 18, marginBottom: 10 },
@@ -7,31 +7,33 @@ exports.HighlightMenu = HighlightMenu;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_native_1 = require("react-native");
9
9
  const themes_1 = require("../themes");
10
+ const strings_1 = require("../strings");
10
11
  const Glass_1 = require("./Glass");
11
12
  const Icons_1 = require("./Icons");
12
- const W = 316;
13
+ const MAX_W = 316;
13
14
  const H = 50;
14
15
  /** Floating glass palette shown over a highlight, like Apple Books. */
15
16
  function HighlightMenu({ highlight, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }) {
17
+ const L = (0, strings_1.useLabels)();
18
+ const W = Math.min(MAX_W, screen.width - 16); // narrow windows (split screen, foldable cover screens)
16
19
  const left = Math.max(8, Math.min(screen.width - W - 8, rect.x + rect.width / 2 - W / 2));
17
20
  const above = rect.y - H - 10;
18
21
  const top = above > 60 ? above : rect.y + rect.height + 10;
19
22
  return (react_1.default.createElement(react_1.default.Fragment, null,
20
- react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: onDismiss, accessibilityLabel: "Dismiss" }),
21
- react_1.default.createElement(Glass_1.Glass, { dark: colors.dark, background: colors.sheetGlass, border: colors.glassBorder, intensity: 55, style: [styles.menu, { left, top }] },
22
- Object.keys(themes_1.HIGHLIGHT_COLORS).map((c) => (react_1.default.createElement(react_native_1.Pressable, { key: c, onPress: () => onColor(c), hitSlop: 4, accessibilityLabel: `${c} highlight` },
23
+ react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: onDismiss, accessibilityLabel: L.dismiss }),
24
+ react_1.default.createElement(Glass_1.Glass, { dark: colors.dark, background: colors.sheetGlass, border: colors.glassBorder, intensity: 55, style: [styles.menu, { left, top, width: W }] },
25
+ Object.keys(themes_1.HIGHLIGHT_COLORS).map((c) => (react_1.default.createElement(react_native_1.Pressable, { key: c, onPress: () => onColor(c), hitSlop: 8, accessibilityRole: "button", accessibilityLabel: `${c} ${L.highlight}`, accessibilityState: { selected: highlight.color === c } },
23
26
  react_1.default.createElement(react_native_1.View, { style: [styles.dot, { backgroundColor: themes_1.HIGHLIGHT_COLORS[c], borderWidth: highlight.color === c ? 2 : 0, borderColor: colors.text }] })))),
24
- react_1.default.createElement(react_native_1.Pressable, { onPress: onToggleUnderline, hitSlop: 6, accessibilityLabel: "Underline" },
27
+ react_1.default.createElement(react_native_1.Pressable, { onPress: onToggleUnderline, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.underline, accessibilityState: { selected: highlight.style === 'underline' } },
25
28
  react_1.default.createElement(Icons_1.Icon, { name: "underline", color: colors.text, size: 22, active: highlight.style === 'underline', strokeWidth: highlight.style === 'underline' ? 2.4 : 1.8 })),
26
- react_1.default.createElement(react_native_1.Pressable, { onPress: onNote, hitSlop: 6, accessibilityLabel: "Note" },
29
+ react_1.default.createElement(react_native_1.Pressable, { onPress: onNote, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.note },
27
30
  react_1.default.createElement(Icons_1.Icon, { name: "pencil", color: colors.text, size: 22 })),
28
- react_1.default.createElement(react_native_1.Pressable, { onPress: onDelete, hitSlop: 6, accessibilityLabel: "Remove highlight" },
31
+ react_1.default.createElement(react_native_1.Pressable, { onPress: onDelete, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.removeHighlight },
29
32
  react_1.default.createElement(Icons_1.Icon, { name: "trash", color: "#ff3b30", size: 22 })))));
30
33
  }
31
34
  const styles = react_native_1.StyleSheet.create({
32
35
  menu: {
33
36
  position: 'absolute',
34
- width: W,
35
37
  height: H,
36
38
  borderRadius: 25,
37
39
  flexDirection: 'row',
@@ -39,5 +41,5 @@ const styles = react_native_1.StyleSheet.create({
39
41
  justifyContent: 'space-around',
40
42
  paddingHorizontal: 12
41
43
  },
42
- dot: { width: 26, height: 26, borderRadius: 13 }
44
+ dot: { width: 28, height: 28, borderRadius: 14 }
43
45
  });
@@ -36,21 +36,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.NoteEditor = NoteEditor;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
+ const strings_1 = require("../strings");
39
40
  function NoteEditor({ visible, quote, initial, colors, onSave, onCancel }) {
41
+ const L = (0, strings_1.useLabels)();
40
42
  const [text, setText] = (0, react_1.useState)(initial);
41
43
  (0, react_1.useEffect)(() => setText(initial), [initial, visible]);
42
- return (react_1.default.createElement(react_native_1.Modal, { visible: visible, animationType: "slide", transparent: true, onRequestClose: onCancel },
43
- react_1.default.createElement(react_native_1.KeyboardAvoidingView, { behavior: react_native_1.Platform.OS === 'ios' ? 'padding' : undefined, style: styles.wrap },
44
+ return (react_1.default.createElement(react_native_1.Modal, { visible: visible, animationType: "slide", transparent: true, onRequestClose: onCancel, statusBarTranslucent: true },
45
+ react_1.default.createElement(react_native_1.KeyboardAvoidingView, { behavior: react_native_1.Platform.OS === 'ios' ? 'padding' : 'height', style: styles.wrap },
44
46
  react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: onCancel }),
45
47
  react_1.default.createElement(react_native_1.View, { style: [styles.card, { backgroundColor: colors.sheet }] },
46
48
  react_1.default.createElement(react_native_1.View, { style: styles.head },
47
- react_1.default.createElement(react_native_1.Pressable, { onPress: onCancel, hitSlop: 10 },
48
- react_1.default.createElement(react_native_1.Text, { style: { color: colors.accent, fontSize: 17 } }, "Cancel")),
49
- react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 17, fontWeight: '600' } }, "Note"),
50
- react_1.default.createElement(react_native_1.Pressable, { onPress: () => onSave(text.trim()), hitSlop: 10 },
51
- react_1.default.createElement(react_native_1.Text, { style: { color: colors.accent, fontSize: 17, fontWeight: '600' } }, "Save"))),
49
+ react_1.default.createElement(react_native_1.Pressable, { onPress: onCancel, hitSlop: 12, accessibilityRole: "button" },
50
+ react_1.default.createElement(react_native_1.Text, { style: { color: colors.accent, fontSize: 17 }, maxFontSizeMultiplier: 1.4 }, L.cancel)),
51
+ react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 17, fontWeight: '600' }, maxFontSizeMultiplier: 1.4 }, L.note),
52
+ react_1.default.createElement(react_native_1.Pressable, { onPress: () => onSave(text.trim()), hitSlop: 12, accessibilityRole: "button" },
53
+ react_1.default.createElement(react_native_1.Text, { style: { color: colors.accent, fontSize: 17, fontWeight: '600' }, maxFontSizeMultiplier: 1.4 }, L.save))),
52
54
  react_1.default.createElement(react_native_1.Text, { numberOfLines: 3, style: [styles.quote, { color: colors.subtext, borderColor: colors.accent }] }, quote),
53
- react_1.default.createElement(react_native_1.TextInput, { autoFocus: true, multiline: true, value: text, onChangeText: setText, placeholder: "Add a note", placeholderTextColor: colors.subtext, style: [styles.input, { color: colors.text, backgroundColor: colors.card }] })))));
55
+ react_1.default.createElement(react_native_1.TextInput, { autoFocus: true, multiline: true, value: text, onChangeText: setText, placeholder: L.addANote, placeholderTextColor: colors.subtext, style: [styles.input, { color: colors.text, backgroundColor: colors.card }] })))));
54
56
  }
55
57
  const styles = react_native_1.StyleSheet.create({
56
58
  wrap: { flex: 1, justifyContent: 'flex-end', backgroundColor: 'rgba(0,0,0,0.35)' },