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/ui/Sheet.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Modal, Pressable, StyleSheet,
|
|
2
|
+
import { Modal, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Text } from './Text';
|
|
3
4
|
import type { ViewStyle } from 'react-native';
|
|
4
5
|
import type { ChromeColors } from '../themes';
|
|
5
6
|
import { Glass } from './Glass';
|
|
7
|
+
import { useLabels } from '../strings';
|
|
6
8
|
import { Icon } from './Icons';
|
|
7
9
|
|
|
8
10
|
interface Props {
|
|
@@ -21,13 +23,14 @@ interface Props {
|
|
|
21
23
|
|
|
22
24
|
/** Rounded frosted-glass sheet: the book stays faintly visible behind it. */
|
|
23
25
|
export function Sheet({ visible, title, subtitle, colors, height = '70%', closeIcon = 'x', onClose, children, overlay }: Props) {
|
|
26
|
+
const L = useLabels();
|
|
24
27
|
const button =
|
|
25
28
|
closeIcon === 'check' ? (
|
|
26
|
-
<Pressable onPress={onClose} hitSlop={10} style={[styles.circle, { backgroundColor: colors.dark ? '#ffffff' : '#000000' }]} accessibilityRole="button" accessibilityLabel=
|
|
27
|
-
<Icon name="check" color={colors.dark ? '#000000' : '#ffffff'} size={24} strokeWidth={2.2} />
|
|
29
|
+
<Pressable onPress={onClose} hitSlop={10} style={[styles.circle, { backgroundColor: colors.strong || (colors.dark ? '#ffffff' : '#000000') }]} accessibilityRole="button" accessibilityLabel={L.done}>
|
|
30
|
+
<Icon name="check" color={colors.onStrong || (colors.dark ? '#000000' : '#ffffff')} size={24} strokeWidth={2.2} />
|
|
28
31
|
</Pressable>
|
|
29
32
|
) : (
|
|
30
|
-
<Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel=
|
|
33
|
+
<Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel={L.close}>
|
|
31
34
|
<Glass dark={colors.dark} background={colors.glass} border={colors.glassBorder} style={styles.circle}>
|
|
32
35
|
<Icon name="close" color={colors.text} size={22} />
|
|
33
36
|
</Glass>
|
|
@@ -42,7 +45,7 @@ export function Sheet({ visible, title, subtitle, colors, height = '70%', closeI
|
|
|
42
45
|
{closeIcon === 'x' && button}
|
|
43
46
|
<View style={styles.titleBox} pointerEvents="none">
|
|
44
47
|
{!!title && (
|
|
45
|
-
<Text style={[styles.title, { color: colors.text }]} numberOfLines={1}>
|
|
48
|
+
<Text style={[styles.title, { color: colors.text }]} numberOfLines={1} maxFontSizeMultiplier={1.3} accessibilityRole="header">
|
|
46
49
|
{title}
|
|
47
50
|
</Text>
|
|
48
51
|
)}
|
package/src/ui/Text.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { createContext, forwardRef, useContext } from 'react';
|
|
2
|
+
import { StyleSheet, Text as RNText, TextInput as RNTextInput } from 'react-native';
|
|
3
|
+
import type { TextInputProps, TextProps } from 'react-native';
|
|
4
|
+
import type { UiFonts } from '../types';
|
|
5
|
+
|
|
6
|
+
export const UiFontsContext = createContext<UiFonts | null>(null);
|
|
7
|
+
|
|
8
|
+
/** Text of the reader's interface. Uses the host's `uiFonts` when given; a style with its own fontFamily keeps it. */
|
|
9
|
+
export function Text(props: TextProps) {
|
|
10
|
+
const fonts = useContext(UiFontsContext);
|
|
11
|
+
if (!fonts) return <RNText {...props} />;
|
|
12
|
+
const flat = StyleSheet.flatten(props.style) || {};
|
|
13
|
+
if (flat.fontFamily) return <RNText {...props} />;
|
|
14
|
+
const weight = flat.fontWeight === 'bold' ? 700 : Number(flat.fontWeight) || 400;
|
|
15
|
+
// a font file per weight: the weight is in the family, so the style's weight must not be applied again
|
|
16
|
+
const family = (weight >= 600 && fonts.bold) || (weight >= 500 && fonts.medium) || null;
|
|
17
|
+
const style = family ? { fontFamily: family, fontWeight: 'normal' as const } : { fontFamily: fonts.regular };
|
|
18
|
+
return <RNText {...props} style={[props.style, style]} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Text field of the reader's interface, in the host's regular `uiFonts` font when given. */
|
|
22
|
+
export const TextInput = forwardRef<RNTextInput, TextInputProps>(function TextInput(props, ref) {
|
|
23
|
+
const fonts = useContext(UiFontsContext);
|
|
24
|
+
const flat = StyleSheet.flatten(props.style) || {};
|
|
25
|
+
if (!fonts || flat.fontFamily) return <RNTextInput ref={ref} {...props} />;
|
|
26
|
+
return <RNTextInput ref={ref} {...props} style={[props.style, { fontFamily: fonts.regular }]} />;
|
|
27
|
+
});
|