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.
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { KeyboardAvoidingView, Modal, Platform, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
3
3
  import type { ChromeColors } from '../themes';
4
+ import { useLabels } from '../strings';
4
5
 
5
6
  interface Props {
6
7
  visible: boolean;
@@ -12,20 +13,21 @@ interface Props {
12
13
  }
13
14
 
14
15
  export function NoteEditor({ visible, quote, initial, colors, onSave, onCancel }: Props) {
16
+ const L = useLabels();
15
17
  const [text, setText] = useState(initial);
16
18
  useEffect(() => setText(initial), [initial, visible]);
17
19
  return (
18
- <Modal visible={visible} animationType="slide" transparent onRequestClose={onCancel}>
19
- <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={styles.wrap}>
20
+ <Modal visible={visible} animationType="slide" transparent onRequestClose={onCancel} statusBarTranslucent>
21
+ <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.wrap}>
20
22
  <Pressable style={StyleSheet.absoluteFill} onPress={onCancel} />
21
23
  <View style={[styles.card, { backgroundColor: colors.sheet }]}>
22
24
  <View style={styles.head}>
23
- <Pressable onPress={onCancel} hitSlop={10}>
24
- <Text style={{ color: colors.accent, fontSize: 17 }}>Cancel</Text>
25
+ <Pressable onPress={onCancel} hitSlop={12} accessibilityRole="button">
26
+ <Text style={{ color: colors.accent, fontSize: 17 }} maxFontSizeMultiplier={1.4}>{L.cancel}</Text>
25
27
  </Pressable>
26
- <Text style={{ color: colors.text, fontSize: 17, fontWeight: '600' }}>Note</Text>
27
- <Pressable onPress={() => onSave(text.trim())} hitSlop={10}>
28
- <Text style={{ color: colors.accent, fontSize: 17, fontWeight: '600' }}>Save</Text>
28
+ <Text style={{ color: colors.text, fontSize: 17, fontWeight: '600' }} maxFontSizeMultiplier={1.4}>{L.note}</Text>
29
+ <Pressable onPress={() => onSave(text.trim())} hitSlop={12} accessibilityRole="button">
30
+ <Text style={{ color: colors.accent, fontSize: 17, fontWeight: '600' }} maxFontSizeMultiplier={1.4}>{L.save}</Text>
29
31
  </Pressable>
30
32
  </View>
31
33
  <Text numberOfLines={3} style={[styles.quote, { color: colors.subtext, borderColor: colors.accent }]}>
@@ -36,7 +38,7 @@ export function NoteEditor({ visible, quote, initial, colors, onSave, onCancel }
36
38
  multiline
37
39
  value={text}
38
40
  onChangeText={setText}
39
- placeholder="Add a note"
41
+ placeholder={L.addANote}
40
42
  placeholderTextColor={colors.subtext}
41
43
  style={[styles.input, { color: colors.text, backgroundColor: colors.card }]}
42
44
  />
@@ -1,7 +1,8 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { FlatList, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
2
+ import { FlatList, Keyboard, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
3
3
  import type { ChromeColors } from '../themes';
4
4
  import type { SearchResult } from '../types';
5
+ import { useLabels } from '../strings';
5
6
  import { Icon } from './Icons';
6
7
  import { Sheet } from './Sheet';
7
8
 
@@ -16,7 +17,19 @@ interface Props {
16
17
  }
17
18
 
18
19
  export function SearchSheet({ visible, colors, results, searching, onClose, onSearch, onPick }: Props) {
20
+ const L = useLabels();
19
21
  const [q, setQ] = useState('');
22
+ const [kb, setKb] = useState(0);
23
+
24
+ // the sheet sits at the bottom, so the keyboard would cover the lower results
25
+ useEffect(() => {
26
+ const show = Keyboard.addListener('keyboardDidShow', (e) => setKb(e.endCoordinates?.height || 0));
27
+ const hide = Keyboard.addListener('keyboardDidHide', () => setKb(0));
28
+ return () => {
29
+ show.remove();
30
+ hide.remove();
31
+ };
32
+ }, []);
20
33
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
21
34
 
22
35
  useEffect(() => {
@@ -27,13 +40,14 @@ export function SearchSheet({ visible, colors, results, searching, onClose, onSe
27
40
  }, [q]);
28
41
 
29
42
  return (
30
- <Sheet visible={visible} colors={colors} onClose={onClose} height="85%" title="Search">
43
+ <Sheet visible={visible} colors={colors} onClose={onClose} height="85%" title={L.search}>
31
44
  <View style={[styles.field, { backgroundColor: colors.card }]}>
32
45
  <Icon name="search" color={colors.subtext} size={20} />
33
46
  <TextInput
34
47
  value={q}
35
48
  onChangeText={setQ}
36
- placeholder="Search in book"
49
+ placeholder={L.searchInBook}
50
+ accessibilityLabel={L.searchInBook}
37
51
  placeholderTextColor={colors.subtext}
38
52
  style={[styles.input, { color: colors.text }]}
39
53
  autoCorrect={false}
@@ -45,16 +59,18 @@ export function SearchSheet({ visible, colors, results, searching, onClose, onSe
45
59
  <FlatList
46
60
  data={results}
47
61
  keyboardShouldPersistTaps="handled"
62
+ keyboardDismissMode="on-drag"
63
+ contentContainerStyle={{ paddingBottom: kb }}
48
64
  keyExtractor={(_, i) => String(i)}
49
65
  ListHeaderComponent={
50
66
  q.trim().length >= 2 ? (
51
67
  <Text style={[styles.count, { color: colors.subtext }]}>
52
- {searching ? 'Searching...' : `${results.length}${results.length >= 500 ? '+' : ''} results`}
68
+ {searching ? L.searching : results.length === 0 ? L.noResults : `${L.formatNumber(results.length)}${results.length >= 500 ? '+' : ''}`}
53
69
  </Text>
54
70
  ) : null
55
71
  }
56
72
  renderItem={({ item }) => (
57
- <Pressable onPress={() => onPick(item)} style={[styles.row, { borderColor: colors.separator }]}>
73
+ <Pressable onPress={() => onPick(item)} style={[styles.row, { borderColor: colors.separator }]} accessibilityRole="button">
58
74
  <Text style={[styles.chapter, { color: colors.accent }]} numberOfLines={1}>
59
75
  {item.chapter}
60
76
  </Text>
package/src/ui/Sheet.tsx CHANGED
@@ -3,6 +3,7 @@ import { Modal, Pressable, StyleSheet, Text, View } from 'react-native';
3
3
  import type { ViewStyle } from 'react-native';
4
4
  import type { ChromeColors } from '../themes';
5
5
  import { Glass } from './Glass';
6
+ import { useLabels } from '../strings';
6
7
  import { Icon } from './Icons';
7
8
 
8
9
  interface Props {
@@ -21,13 +22,14 @@ interface Props {
21
22
 
22
23
  /** Rounded frosted-glass sheet: the book stays faintly visible behind it. */
23
24
  export function Sheet({ visible, title, subtitle, colors, height = '70%', closeIcon = 'x', onClose, children, overlay }: Props) {
25
+ const L = useLabels();
24
26
  const button =
25
27
  closeIcon === 'check' ? (
26
- <Pressable onPress={onClose} hitSlop={10} style={[styles.circle, { backgroundColor: colors.dark ? '#ffffff' : '#000000' }]} accessibilityRole="button" accessibilityLabel="Done">
28
+ <Pressable onPress={onClose} hitSlop={10} style={[styles.circle, { backgroundColor: colors.dark ? '#ffffff' : '#000000' }]} accessibilityRole="button" accessibilityLabel={L.done}>
27
29
  <Icon name="check" color={colors.dark ? '#000000' : '#ffffff'} size={24} strokeWidth={2.2} />
28
30
  </Pressable>
29
31
  ) : (
30
- <Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel="Close">
32
+ <Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel={L.close}>
31
33
  <Glass dark={colors.dark} background={colors.glass} border={colors.glassBorder} style={styles.circle}>
32
34
  <Icon name="close" color={colors.text} size={22} />
33
35
  </Glass>
@@ -42,7 +44,7 @@ export function Sheet({ visible, title, subtitle, colors, height = '70%', closeI
42
44
  {closeIcon === 'x' && button}
43
45
  <View style={styles.titleBox} pointerEvents="none">
44
46
  {!!title && (
45
- <Text style={[styles.title, { color: colors.text }]} numberOfLines={1}>
47
+ <Text style={[styles.title, { color: colors.text }]} numberOfLines={1} maxFontSizeMultiplier={1.3} accessibilityRole="header">
46
48
  {title}
47
49
  </Text>
48
50
  )}