aksos-react-native-epub-reader 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +351 -2
- package/lib/EpubReader.d.ts +76 -0
- package/lib/EpubReader.js +284 -0
- package/lib/EpubReaderView.d.ts +31 -0
- package/lib/EpubReaderView.js +599 -0
- package/lib/assets/page-turn-1.wav +0 -0
- package/lib/assets/page-turn-2.wav +0 -0
- package/lib/assets/page-turn-3.wav +0 -0
- package/lib/assets/page-turn-4.wav +0 -0
- package/lib/engine/html.d.ts +1 -0
- package/lib/engine/html.js +5 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +34 -0
- package/lib/sound.d.ts +1 -0
- package/lib/sound.js +71 -0
- package/lib/strings.d.ts +94 -0
- package/lib/strings.js +96 -0
- package/lib/themes.d.ts +60 -0
- package/lib/themes.js +166 -0
- package/lib/types.d.ts +149 -0
- package/lib/types.js +2 -0
- package/lib/ui/AppearanceSheet.d.ts +15 -0
- package/lib/ui/AppearanceSheet.js +134 -0
- package/lib/ui/ContentsSheet.d.ts +27 -0
- package/lib/ui/ContentsSheet.js +89 -0
- package/lib/ui/CustomizeSheet.d.ts +16 -0
- package/lib/ui/CustomizeSheet.js +141 -0
- package/lib/ui/Glass.d.ts +15 -0
- package/lib/ui/Glass.js +27 -0
- package/lib/ui/HighlightMenu.d.ts +25 -0
- package/lib/ui/HighlightMenu.js +45 -0
- package/lib/ui/Icons.d.ts +17 -0
- package/lib/ui/Icons.js +193 -0
- package/lib/ui/LineGuide.d.ts +21 -0
- package/lib/ui/LineGuide.js +92 -0
- package/lib/ui/NoteEditor.d.ts +12 -0
- package/lib/ui/NoteEditor.js +63 -0
- package/lib/ui/Scrubber.d.ts +15 -0
- package/lib/ui/Scrubber.js +86 -0
- package/lib/ui/SearchSheet.d.ts +14 -0
- package/lib/ui/SearchSheet.js +79 -0
- package/lib/ui/Sheet.d.ts +19 -0
- package/lib/ui/Sheet.js +40 -0
- package/lib/ui/Slider.d.ts +14 -0
- package/lib/ui/Slider.js +53 -0
- package/package.json +76 -6
- package/src/EpubReader.tsx +356 -0
- package/src/EpubReaderView.tsx +865 -0
- package/src/assets/page-turn-1.wav +0 -0
- package/src/assets/page-turn-2.wav +0 -0
- package/src/assets/page-turn-3.wav +0 -0
- package/src/assets/page-turn-4.wav +0 -0
- package/src/engine/html.ts +2 -0
- package/src/engine/reader.js +2047 -0
- package/src/index.ts +9 -0
- package/src/sound.ts +66 -0
- package/src/strings.ts +187 -0
- package/src/themes.ts +188 -0
- package/src/types.ts +154 -0
- package/src/ui/AppearanceSheet.tsx +176 -0
- package/src/ui/ContentsSheet.tsx +146 -0
- package/src/ui/CustomizeSheet.tsx +191 -0
- package/src/ui/Glass.tsx +37 -0
- package/src/ui/HighlightMenu.tsx +66 -0
- package/src/ui/Icons.tsx +246 -0
- package/src/ui/LineGuide.tsx +87 -0
- package/src/ui/NoteEditor.tsx +57 -0
- package/src/ui/Scrubber.tsx +78 -0
- package/src/ui/SearchSheet.tsx +95 -0
- package/src/ui/Sheet.tsx +71 -0
- package/src/ui/Slider.tsx +30 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AppearanceSheet = AppearanceSheet;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const themes_1 = require("../themes");
|
|
40
|
+
const strings_1 = require("../strings");
|
|
41
|
+
const Icons_1 = require("./Icons");
|
|
42
|
+
const Sheet_1 = require("./Sheet");
|
|
43
|
+
const Slider_1 = require("./Slider");
|
|
44
|
+
const SIZE = { min: 12, max: 40, step: 2 };
|
|
45
|
+
const TURNS = [
|
|
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' }
|
|
50
|
+
];
|
|
51
|
+
const APPEARANCES = [
|
|
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' }
|
|
56
|
+
];
|
|
57
|
+
/** Icon of the current appearance choice: the button always shows the state it is in. */
|
|
58
|
+
const appearanceIcon = (a) => (a === 'light' ? 'sun' : a === 'dark' ? 'moon' : 'contrast');
|
|
59
|
+
/** "Themes & Settings" sheet. */
|
|
60
|
+
function AppearanceSheet({ visible, colors, settings: s, systemDark, onChange, onCustomize, onClose }) {
|
|
61
|
+
const L = (0, strings_1.useLabels)();
|
|
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]);
|
|
68
|
+
const dark = (0, themes_1.isDark)(s, systemDark);
|
|
69
|
+
const turn = TURNS.find((t) => t.id === s.pageTurn) || TURNS[0];
|
|
70
|
+
const menuView = menu && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
71
|
+
react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: () => setMenu(null) }),
|
|
72
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.menu, { backgroundColor: colors.dark ? '#4a4742' : '#ffffff', borderColor: colors.glassBorder }] }, menu === 'turn'
|
|
73
|
+
? TURNS.map((t) => (react_1.default.createElement(react_native_1.Pressable, { key: t.id, style: styles.menuItem, onPress: () => {
|
|
74
|
+
onChange({ pageTurn: t.id });
|
|
75
|
+
setMenu(null);
|
|
76
|
+
} },
|
|
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 })),
|
|
78
|
+
react_1.default.createElement(Icons_1.Icon, { name: t.icon, color: colors.text, size: 24 }),
|
|
79
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.menuText, { color: colors.text }] }, L[t.label]))))
|
|
80
|
+
: APPEARANCES.map((a) => (react_1.default.createElement(react_native_1.Pressable, { key: a.key, style: styles.menuItem, onPress: () => {
|
|
81
|
+
onChange({ appearance: a.id });
|
|
82
|
+
setMenu(null);
|
|
83
|
+
} },
|
|
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 })),
|
|
85
|
+
react_1.default.createElement(Icons_1.Icon, { name: a.icon, color: colors.text, size: 24 }),
|
|
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 },
|
|
88
|
+
react_1.default.createElement(react_native_1.View, { style: styles.body },
|
|
89
|
+
react_1.default.createElement(react_native_1.View, { style: styles.row },
|
|
90
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.pill, { flex: 1, backgroundColor: colors.card }] },
|
|
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 },
|
|
92
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 15, fontWeight: '500' } }, "A")),
|
|
93
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.divider, { backgroundColor: colors.separator }] }),
|
|
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 },
|
|
95
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 26, fontWeight: '500' } }, "A"))),
|
|
96
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.pill, { width: 150, backgroundColor: colors.card }] },
|
|
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]}` },
|
|
98
|
+
react_1.default.createElement(Icons_1.Icon, { name: turn.icon, color: colors.text, size: 26 })),
|
|
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 },
|
|
100
|
+
react_1.default.createElement(Icons_1.Icon, { name: appearanceIcon(s.appearance), color: colors.text, size: 26 })))),
|
|
101
|
+
react_1.default.createElement(react_native_1.View, { style: styles.brightness },
|
|
102
|
+
react_1.default.createElement(Icons_1.Icon, { name: "sunLow", color: colors.subtext, size: 20 }),
|
|
103
|
+
react_1.default.createElement(react_native_1.View, { style: { flex: 1, marginHorizontal: 10 } },
|
|
104
|
+
react_1.default.createElement(Slider_1.Slider, { value: s.brightness, min: 0.3, max: 1, step: 0.01, onChange: (v) => onChange({ brightness: v }), color: colors.text, track: colors.separator, thumbColor: "#ffffff" })),
|
|
105
|
+
react_1.default.createElement(Icons_1.Icon, { name: "sun", color: colors.subtext, size: 26 })),
|
|
106
|
+
react_1.default.createElement(react_native_1.View, { style: styles.grid }, themes_1.THEMES.map((t) => {
|
|
107
|
+
const c = dark ? t.dark : t.light;
|
|
108
|
+
const on = t.id === s.themeId;
|
|
109
|
+
return (react_1.default.createElement(react_native_1.Pressable, { key: t.id, onPress: () => onChange({ themeId: t.id }), style: [styles.tile, { backgroundColor: c.bg, borderColor: on ? colors.text : colors.separator, borderWidth: on ? 3 : react_native_1.StyleSheet.hairlineWidth }], accessibilityRole: "radio", accessibilityState: { selected: on } },
|
|
110
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: c.fg, fontSize: 30, fontFamily: themes_1.serifFont, fontWeight: t.bold ? '800' : '400' } }, "Aa"),
|
|
111
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: c.fg, fontSize: 15, fontFamily: themes_1.serifFont, fontWeight: t.bold ? '700' : '400' } }, t.name)));
|
|
112
|
+
})),
|
|
113
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: onCustomize, style: [styles.customize, { backgroundColor: colors.card }], accessibilityRole: "button" },
|
|
114
|
+
react_1.default.createElement(Icons_1.Icon, { name: "sliders", color: colors.text, size: 22 }),
|
|
115
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: colors.text, fontSize: 18, fontWeight: '600', marginStart: 10 } }, L.customize)))));
|
|
116
|
+
}
|
|
117
|
+
const styles = react_native_1.StyleSheet.create({
|
|
118
|
+
body: { paddingHorizontal: 16, paddingBottom: 28 },
|
|
119
|
+
row: { flexDirection: 'row', gap: 10 },
|
|
120
|
+
pill: { height: 58, borderRadius: 29, flexDirection: 'row', alignItems: 'center', overflow: 'hidden' },
|
|
121
|
+
half: { flex: 1, height: '100%', alignItems: 'center', justifyContent: 'center' },
|
|
122
|
+
divider: { width: react_native_1.StyleSheet.hairlineWidth, height: 24 },
|
|
123
|
+
brightness: { flexDirection: 'row', alignItems: 'center', marginTop: 14, marginBottom: 8, paddingHorizontal: 4 },
|
|
124
|
+
grid: { flexDirection: 'row', flexWrap: 'wrap', gap: 10, marginTop: 6 },
|
|
125
|
+
tile: { width: '31.6%', height: 92, borderRadius: 22, alignItems: 'center', justifyContent: 'center' },
|
|
126
|
+
customize: { marginTop: 12, height: 58, borderRadius: 29, flexDirection: 'row', alignItems: 'center', justifyContent: 'center' },
|
|
127
|
+
menu: {
|
|
128
|
+
position: 'absolute', top: 80, right: 16, width: 250, borderRadius: 24, paddingVertical: 8, borderWidth: react_native_1.StyleSheet.hairlineWidth,
|
|
129
|
+
shadowColor: '#000', shadowOpacity: 0.3, shadowRadius: 16, shadowOffset: { width: 0, height: 6 }, elevation: 12
|
|
130
|
+
},
|
|
131
|
+
menuItem: { flexDirection: 'row', alignItems: 'center', paddingVertical: 12, paddingHorizontal: 14 },
|
|
132
|
+
check: { width: 26, alignItems: 'center' },
|
|
133
|
+
menuText: { fontSize: 18, marginStart: 14, flexShrink: 1 }
|
|
134
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChromeColors } from '../themes';
|
|
3
|
+
import type { Bookmark, Highlight, TocItem } from '../types';
|
|
4
|
+
export type ContentsTab = 'contents' | 'bookmarks' | 'notes';
|
|
5
|
+
interface Props {
|
|
6
|
+
visible: boolean;
|
|
7
|
+
colors: ChromeColors;
|
|
8
|
+
title: string;
|
|
9
|
+
/** e.g. "Page 100 of 219" */
|
|
10
|
+
subtitle: string;
|
|
11
|
+
toc: TocItem[];
|
|
12
|
+
currentSpine: number;
|
|
13
|
+
/** estimated page number in the whole book for a spine item + character offset */
|
|
14
|
+
pageOf: (spine: number, offset: number) => number;
|
|
15
|
+
bookmarks: Bookmark[];
|
|
16
|
+
highlights: Highlight[];
|
|
17
|
+
initialTab?: ContentsTab;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onGoToc: (item: TocItem) => void;
|
|
20
|
+
onGoBookmark: (b: Bookmark) => void;
|
|
21
|
+
onGoHighlight: (h: Highlight) => void;
|
|
22
|
+
onDeleteBookmark: (id: string) => void;
|
|
23
|
+
onDeleteHighlight: (id: string) => void;
|
|
24
|
+
}
|
|
25
|
+
/** Contents sheet: Chapters | Bookmarks | Highlights, each row with its page number. */
|
|
26
|
+
export declare function ContentsSheet(p: Props): React.JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ContentsSheet = ContentsSheet;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const themes_1 = require("../themes");
|
|
40
|
+
const strings_1 = require("../strings");
|
|
41
|
+
const Sheet_1 = require("./Sheet");
|
|
42
|
+
const TABS = [
|
|
43
|
+
{ id: 'contents', label: 'chapters' },
|
|
44
|
+
{ id: 'bookmarks', label: 'bookmarks' },
|
|
45
|
+
{ id: 'notes', label: 'highlights' }
|
|
46
|
+
];
|
|
47
|
+
/** Contents sheet: Chapters | Bookmarks | Highlights, each row with its page number. */
|
|
48
|
+
function ContentsSheet(p) {
|
|
49
|
+
const { colors } = p;
|
|
50
|
+
const L = (0, strings_1.useLabels)();
|
|
51
|
+
const [tab, setTab] = (0, react_1.useState)(p.initialTab || 'contents');
|
|
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 }
|
|
55
|
+
]);
|
|
56
|
+
const empty = (text) => react_1.default.createElement(react_native_1.Text, { style: [styles.empty, { color: colors.subtext }] }, text);
|
|
57
|
+
const rowBorder = { borderColor: colors.separator };
|
|
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%" },
|
|
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 } },
|
|
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 }) => {
|
|
62
|
+
const active = item.spine === p.currentSpine && !item.fragment;
|
|
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 }] },
|
|
64
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: active ? colors.accent : colors.text, flex: 1 }], numberOfLines: 2 }, item.label),
|
|
65
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, L.formatNumber(p.pageOf(item.spine, 0)))));
|
|
66
|
+
} })),
|
|
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] },
|
|
68
|
+
react_1.default.createElement(react_native_1.View, { style: { flex: 1 } },
|
|
69
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.meta, { color: colors.accent }] }, item.chapter),
|
|
70
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: colors.text }], numberOfLines: 2 }, item.excerpt)),
|
|
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] },
|
|
73
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.bar, { backgroundColor: themes_1.HIGHLIGHT_COLORS[item.color] }] }),
|
|
74
|
+
react_1.default.createElement(react_native_1.View, { style: { flex: 1 } },
|
|
75
|
+
!!item.note && react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: colors.text, fontWeight: '600' }] }, item.note),
|
|
76
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.rowText, { color: item.note ? colors.subtext : colors.text }], numberOfLines: 3 }, item.text),
|
|
77
|
+
!!item.chapter && react_1.default.createElement(react_native_1.Text, { style: [styles.meta, { color: colors.subtext }] }, item.chapter)),
|
|
78
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.page, { color: colors.subtext }] }, L.formatNumber(p.pageOf(item.spine, item.start))))) }))));
|
|
79
|
+
}
|
|
80
|
+
const styles = react_native_1.StyleSheet.create({
|
|
81
|
+
segment: { flexDirection: 'row', marginHorizontal: 16, marginTop: 34, marginBottom: 6, borderRadius: 18, padding: 3 },
|
|
82
|
+
segItem: { flex: 1, alignItems: 'center', paddingVertical: 8, borderRadius: 15 },
|
|
83
|
+
row: { flexDirection: 'row', alignItems: 'center', paddingVertical: 17, paddingHorizontal: 20, marginHorizontal: 0, borderBottomWidth: react_native_1.StyleSheet.hairlineWidth },
|
|
84
|
+
rowText: { fontSize: 18, lineHeight: 24 },
|
|
85
|
+
page: { fontSize: 18, marginStart: 12, minWidth: 34, textAlign: 'right' },
|
|
86
|
+
meta: { fontSize: 13, marginBottom: 2, fontWeight: '600' },
|
|
87
|
+
bar: { width: 3, alignSelf: 'stretch', borderRadius: 2, marginEnd: 12 },
|
|
88
|
+
empty: { textAlign: 'center', padding: 32, fontSize: 16 }
|
|
89
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChromeColors } from '../themes';
|
|
3
|
+
import type { ReaderSettings, ThemeColors } from '../types';
|
|
4
|
+
interface Props {
|
|
5
|
+
visible: boolean;
|
|
6
|
+
colors: ChromeColors;
|
|
7
|
+
page: ThemeColors;
|
|
8
|
+
settings: ReaderSettings;
|
|
9
|
+
sample: string;
|
|
10
|
+
onChange: (patch: Partial<ReaderSettings>) => void;
|
|
11
|
+
onReset: () => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
/** "Customize Theme" sheet: font, bold, spacing, margins, columns, justify, sound. */
|
|
15
|
+
export declare function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange, onReset, onClose }: Props): React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CustomizeSheet = CustomizeSheet;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const themes_1 = require("../themes");
|
|
40
|
+
const strings_1 = require("../strings");
|
|
41
|
+
const Icons_1 = require("./Icons");
|
|
42
|
+
const Sheet_1 = require("./Sheet");
|
|
43
|
+
const Slider_1 = require("./Slider");
|
|
44
|
+
const GREEN = { true: '#34c759' };
|
|
45
|
+
function Toggle(props) {
|
|
46
|
+
return (react_1.default.createElement(react_native_1.View, { style: styles.toggleBox },
|
|
47
|
+
react_1.default.createElement(react_native_1.Switch, { ...props })));
|
|
48
|
+
}
|
|
49
|
+
/** "Customize Theme" sheet: font, bold, spacing, margins, columns, justify, sound. */
|
|
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 };
|
|
53
|
+
const [fonts, setFonts] = (0, react_1.useState)(false);
|
|
54
|
+
const [columnsMenu, setColumnsMenu] = (0, react_1.useState)(false);
|
|
55
|
+
const off = !s.customize;
|
|
56
|
+
const font = (0, themes_1.getFont)(s.fontId);
|
|
57
|
+
const previewFont = s.fontId === 'system' ? undefined : themes_1.serifFont;
|
|
58
|
+
const border = { borderTopWidth: react_native_1.StyleSheet.hairlineWidth, borderColor: colors.separator };
|
|
59
|
+
const sliderRow = (label, icon, value, min, max, step, show, key) => (react_1.default.createElement(react_native_1.View, { style: [styles.sliderBlock, border, off && styles.dim], pointerEvents: off ? 'none' : 'auto' },
|
|
60
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.caption, { color: colors.subtext }] }, label),
|
|
61
|
+
react_1.default.createElement(react_native_1.View, { style: styles.sliderRow },
|
|
62
|
+
react_1.default.createElement(Icons_1.Icon, { name: icon, color: colors.text, size: 24 }),
|
|
63
|
+
react_1.default.createElement(react_native_1.View, { style: { flex: 1, marginHorizontal: 12 } },
|
|
64
|
+
react_1.default.createElement(Slider_1.Slider, { value: value, min: min, max: max, step: step, onChange: (v) => onChange({ [key]: v }), color: colors.text, track: colors.separator, thumbColor: "#ffffff" })),
|
|
65
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.value, { color: colors.subtext }] }, show))));
|
|
66
|
+
const row = (icon, label, right, onPress, top = true, iconActive = false) => {
|
|
67
|
+
const content = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
68
|
+
react_1.default.createElement(react_native_1.View, { style: styles.rowIcon },
|
|
69
|
+
react_1.default.createElement(Icons_1.Icon, { name: icon, color: colors.text, size: 22, active: iconActive })),
|
|
70
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.label, { color: colors.text }] }, label),
|
|
71
|
+
right));
|
|
72
|
+
return onPress ? (react_1.default.createElement(react_native_1.Pressable, { style: [styles.line, top && border], onPress: onPress }, content)) : (react_1.default.createElement(react_native_1.View, { style: [styles.line, top && border] }, content));
|
|
73
|
+
};
|
|
74
|
+
const close = () => {
|
|
75
|
+
setFonts(false);
|
|
76
|
+
setColumnsMenu(false);
|
|
77
|
+
onClose();
|
|
78
|
+
};
|
|
79
|
+
return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: close, closeIcon: "check", title: L.customizeTheme, height: "92%" },
|
|
80
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.preview, { backgroundColor: page.bg }] },
|
|
81
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.aa, { color: page.fg, fontFamily: previewFont }] }, "Aa"),
|
|
82
|
+
react_1.default.createElement(react_native_1.Text, { numberOfLines: 4, style: {
|
|
83
|
+
color: page.fg, fontFamily: previewFont, fontSize: Math.min(s.fontSize, 22),
|
|
84
|
+
lineHeight: Math.min(s.fontSize, 22) * (s.customize ? s.lineHeight : 1.5),
|
|
85
|
+
fontWeight: s.bold ? '700' : '400', textAlign: s.justify ? 'justify' : 'auto'
|
|
86
|
+
} }, sample)),
|
|
87
|
+
react_1.default.createElement(react_native_1.ScrollView, { contentContainerStyle: styles.pad },
|
|
88
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
|
|
89
|
+
row('textSize', L.font, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
|
|
90
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, font.name),
|
|
91
|
+
react_1.default.createElement(Icons_1.Icon, { name: fonts ? 'chevronUp' : 'chevronRight', color: colors.subtext, size: 18 })), () => setFonts((v) => !v), false),
|
|
92
|
+
fonts &&
|
|
93
|
+
themes_1.FONTS.map((f) => (react_1.default.createElement(react_native_1.Pressable, { key: f.id, onPress: () => {
|
|
94
|
+
onChange({ fontId: f.id });
|
|
95
|
+
setFonts(false);
|
|
96
|
+
}, style: [styles.line, border] },
|
|
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 })),
|
|
98
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.label, { color: colors.text }] }, f.name)))),
|
|
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),
|
|
101
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
|
|
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')),
|
|
107
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card, marginTop: 16 }] },
|
|
108
|
+
row('columns', L.columns, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
|
|
109
|
+
react_1.default.createElement(react_native_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, COLUMN_LABEL[String(s.columns)]),
|
|
110
|
+
react_1.default.createElement(Icons_1.Icon, { name: columnsMenu ? 'chevronUp' : 'chevronDown', color: colors.subtext, size: 18 })), () => setColumnsMenu((v) => !v), false),
|
|
111
|
+
columnsMenu &&
|
|
112
|
+
['auto', 1, 2].map((c) => (react_1.default.createElement(react_native_1.Pressable, { key: String(c), style: [styles.line, border], onPress: () => {
|
|
113
|
+
onChange({ columns: c });
|
|
114
|
+
setColumnsMenu(false);
|
|
115
|
+
} },
|
|
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 })),
|
|
117
|
+
react_1.default.createElement(react_native_1.Text, { style: [styles.label, { color: colors.text }] }, COLUMN_LABEL[String(c)])))),
|
|
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)))));
|
|
122
|
+
}
|
|
123
|
+
const styles = react_native_1.StyleSheet.create({
|
|
124
|
+
preview: { paddingHorizontal: 22, paddingTop: 12, paddingBottom: 18, marginBottom: 10 },
|
|
125
|
+
aa: { fontSize: 34, textAlign: 'right', marginBottom: 6 },
|
|
126
|
+
pad: { paddingHorizontal: 16, paddingBottom: 40 },
|
|
127
|
+
group: { borderRadius: 24, overflow: 'hidden' },
|
|
128
|
+
line: { flexDirection: 'row', alignItems: 'center', minHeight: 56, paddingHorizontal: 18 },
|
|
129
|
+
rowIcon: { width: 34, height: 28, alignItems: 'flex-start', justifyContent: 'center' },
|
|
130
|
+
toggleBox: { height: 31, minWidth: 51, alignItems: 'center', justifyContent: 'center' },
|
|
131
|
+
label: { flex: 1, fontSize: 18, lineHeight: 24 },
|
|
132
|
+
check: { width: 34, height: 24, justifyContent: 'center' },
|
|
133
|
+
value2: { flexDirection: 'row', alignItems: 'center', gap: 4 },
|
|
134
|
+
heading: { fontSize: 22, fontWeight: '700', marginTop: 26, marginBottom: 10, marginStart: 4 },
|
|
135
|
+
sliderBlock: { paddingHorizontal: 18, paddingTop: 10, paddingBottom: 6 },
|
|
136
|
+
dim: { opacity: 0.45 },
|
|
137
|
+
caption: { fontSize: 14, marginBottom: 2 },
|
|
138
|
+
sliderRow: { flexDirection: 'row', alignItems: 'center' },
|
|
139
|
+
value: { width: 50, textAlign: 'right', fontSize: 17, lineHeight: 22 },
|
|
140
|
+
reset: { marginTop: 18, height: 58, borderRadius: 29, alignItems: 'center', justifyContent: 'center' }
|
|
141
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
interface Props {
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
|
+
/** translucent tint drawn over the blur (use ChromeColors.glass or .sheetGlass) */
|
|
6
|
+
background: string;
|
|
7
|
+
border?: string;
|
|
8
|
+
dark: boolean;
|
|
9
|
+
/** blur strength 0..100 */
|
|
10
|
+
intensity?: number;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** Frosted glass surface: blurs the book behind it so reading is not interrupted. */
|
|
14
|
+
export declare function Glass({ style, background, border, dark, intensity, children }: Props): React.JSX.Element;
|
|
15
|
+
export {};
|
package/lib/ui/Glass.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Glass = Glass;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
// expo-blur is optional: with it the controls are frosted glass, without it they are plain translucent.
|
|
10
|
+
let BlurView = null;
|
|
11
|
+
try {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
BlurView = require('expo-blur').BlurView;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
BlurView = null;
|
|
17
|
+
}
|
|
18
|
+
/** Frosted glass surface: blurs the book behind it so reading is not interrupted. */
|
|
19
|
+
function Glass({ style, background, border, dark, intensity = 38, children }) {
|
|
20
|
+
const base = { overflow: 'hidden', borderWidth: border ? react_native_1.StyleSheet.hairlineWidth : 0, borderColor: border };
|
|
21
|
+
if (BlurView) {
|
|
22
|
+
return (react_1.default.createElement(BlurView, { intensity: intensity, tint: dark ? 'dark' : 'light', style: [base, style] },
|
|
23
|
+
react_1.default.createElement(react_native_1.View, { style: [react_native_1.StyleSheet.absoluteFill, { backgroundColor: background }], pointerEvents: "none" }),
|
|
24
|
+
children));
|
|
25
|
+
}
|
|
26
|
+
return react_1.default.createElement(react_native_1.View, { style: [base, { backgroundColor: background }, style] }, children);
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChromeColors } from '../themes';
|
|
3
|
+
import type { Highlight, HighlightColor } from '../types';
|
|
4
|
+
interface Props {
|
|
5
|
+
highlight: Highlight;
|
|
6
|
+
rect: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
screen: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
colors: ChromeColors;
|
|
17
|
+
onColor: (c: HighlightColor) => void;
|
|
18
|
+
onToggleUnderline: () => void;
|
|
19
|
+
onNote: () => void;
|
|
20
|
+
onDelete: () => void;
|
|
21
|
+
onDismiss: () => void;
|
|
22
|
+
}
|
|
23
|
+
/** Floating glass palette shown over a highlight, like Apple Books. */
|
|
24
|
+
export declare function HighlightMenu({ highlight, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }: Props): React.JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HighlightMenu = HighlightMenu;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const themes_1 = require("../themes");
|
|
10
|
+
const strings_1 = require("../strings");
|
|
11
|
+
const Glass_1 = require("./Glass");
|
|
12
|
+
const Icons_1 = require("./Icons");
|
|
13
|
+
const MAX_W = 316;
|
|
14
|
+
const H = 50;
|
|
15
|
+
/** Floating glass palette shown over a highlight, like Apple Books. */
|
|
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)
|
|
19
|
+
const left = Math.max(8, Math.min(screen.width - W - 8, rect.x + rect.width / 2 - W / 2));
|
|
20
|
+
const above = rect.y - H - 10;
|
|
21
|
+
const top = above > 60 ? above : rect.y + rect.height + 10;
|
|
22
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
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 } },
|
|
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 }] })))),
|
|
27
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: onToggleUnderline, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.underline, accessibilityState: { selected: highlight.style === 'underline' } },
|
|
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 })),
|
|
29
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: onNote, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.note },
|
|
30
|
+
react_1.default.createElement(Icons_1.Icon, { name: "pencil", color: colors.text, size: 22 })),
|
|
31
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: onDelete, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.removeHighlight },
|
|
32
|
+
react_1.default.createElement(Icons_1.Icon, { name: "trash", color: "#ff3b30", size: 22 })))));
|
|
33
|
+
}
|
|
34
|
+
const styles = react_native_1.StyleSheet.create({
|
|
35
|
+
menu: {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
height: H,
|
|
38
|
+
borderRadius: 25,
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'space-around',
|
|
42
|
+
paddingHorizontal: 12
|
|
43
|
+
},
|
|
44
|
+
dot: { width: 28, height: 28, borderRadius: 14 }
|
|
45
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Vector icon set (24 x 24 grid, rounded strokes). Every icon takes the colour it is drawn in, so it follows the
|
|
4
|
+
* theme (light / dark / any page colour). Some icons carry state: `active` fills or closes them
|
|
5
|
+
* (bookmark, rotation lock, line guide).
|
|
6
|
+
*/
|
|
7
|
+
export type IconName = 'close' | 'check' | 'chevronRight' | 'chevronUp' | 'chevronDown' | 'list' | 'search' | 'textSize' | 'share' | 'bookmark' | 'rotationLock' | 'lineGuide' | 'undo' | 'sun' | 'sunLow' | 'moon' | 'contrast' | 'pageSlide' | 'pageCurl' | 'pageFade' | 'pageScroll' | 'sliders' | 'lineSpacing' | 'charSpacing' | 'wordSpacing' | 'margins' | 'columns' | 'bold' | 'justify' | 'trash' | 'pencil' | 'underline' | 'highlighter' | 'sound' | 'soundOff';
|
|
8
|
+
interface Props {
|
|
9
|
+
name: IconName;
|
|
10
|
+
color: string;
|
|
11
|
+
size?: number;
|
|
12
|
+
/** filled / closed state for bookmark, rotation lock, line guide */
|
|
13
|
+
active?: boolean;
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function Icon({ name, color, size, active, strokeWidth }: Props): React.JSX.Element;
|
|
17
|
+
export {};
|