react-native-elearn-ui 0.1.12 → 0.1.14
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/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/HomeScreen.js +665 -650
- package/lib/module/screens/HomeScreen.js.map +1 -1
- package/lib/module/screens/index.js +0 -8
- package/lib/module/screens/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/HomeScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/index.d.ts +0 -8
- package/lib/typescript/src/screens/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +0 -8
- package/src/screens/HomeScreen.tsx +461 -522
- package/src/screens/index.ts +0 -8
- package/lib/module/screens/PearlChaptersScreen.js +0 -359
- package/lib/module/screens/PearlChaptersScreen.js.map +0 -1
- package/lib/module/screens/PearlReaderScreen.js +0 -313
- package/lib/module/screens/PearlReaderScreen.js.map +0 -1
- package/lib/module/screens/PearlsScreen.js +0 -153
- package/lib/module/screens/PearlsScreen.js.map +0 -1
- package/lib/module/screens/QbankScreen.js +0 -370
- package/lib/module/screens/QbankScreen.js.map +0 -1
- package/lib/module/screens/QuestionScreen.js +0 -437
- package/lib/module/screens/QuestionScreen.js.map +0 -1
- package/lib/module/screens/QuizStartScreen.js +0 -283
- package/lib/module/screens/QuizStartScreen.js.map +0 -1
- package/lib/module/screens/ResultScreen.js +0 -646
- package/lib/module/screens/ResultScreen.js.map +0 -1
- package/lib/module/screens/TopicListScreen.js +0 -420
- package/lib/module/screens/TopicListScreen.js.map +0 -1
- package/lib/module/screens/pearlsMockData.js +0 -77
- package/lib/module/screens/pearlsMockData.js.map +0 -1
- package/lib/typescript/src/screens/PearlChaptersScreen.d.ts +0 -13
- package/lib/typescript/src/screens/PearlChaptersScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/PearlReaderScreen.d.ts +0 -14
- package/lib/typescript/src/screens/PearlReaderScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/PearlsScreen.d.ts +0 -11
- package/lib/typescript/src/screens/PearlsScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/QbankScreen.d.ts +0 -10
- package/lib/typescript/src/screens/QbankScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/QuestionScreen.d.ts +0 -14
- package/lib/typescript/src/screens/QuestionScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/QuizStartScreen.d.ts +0 -14
- package/lib/typescript/src/screens/QuizStartScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/ResultScreen.d.ts +0 -13
- package/lib/typescript/src/screens/ResultScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/TopicListScreen.d.ts +0 -12
- package/lib/typescript/src/screens/TopicListScreen.d.ts.map +0 -1
- package/lib/typescript/src/screens/pearlsMockData.d.ts +0 -3
- package/lib/typescript/src/screens/pearlsMockData.d.ts.map +0 -1
- package/src/screens/PearlChaptersScreen.tsx +0 -330
- package/src/screens/PearlReaderScreen.tsx +0 -306
- package/src/screens/PearlsScreen.tsx +0 -147
- package/src/screens/QbankScreen.tsx +0 -327
- package/src/screens/QuestionScreen.tsx +0 -423
- package/src/screens/QuizStartScreen.tsx +0 -260
- package/src/screens/ResultScreen.tsx +0 -618
- package/src/screens/TopicListScreen.tsx +0 -388
- package/src/screens/pearlsMockData.ts +0 -70
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Course, Topic } from '../types/index.js';
|
|
3
|
-
interface TopicListScreenProps {
|
|
4
|
-
course?: Course;
|
|
5
|
-
courseId?: string;
|
|
6
|
-
onBack: () => void;
|
|
7
|
-
hideHeader?: boolean;
|
|
8
|
-
onSelectTopic?: (course: Course, topic: Topic) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const TopicListScreen: React.FC<TopicListScreenProps>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=TopicListScreen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TopicListScreen.d.ts","sourceRoot":"","sources":["../../../../src/screens/TopicListScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,mBAAU,CAAC;AAK9C,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAsN1D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pearlsMockData.d.ts","sourceRoot":"","sources":["../../../../src/screens/pearlsMockData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAU,CAAC;AAE3C,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAmE1C,CAAC"}
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
ScrollView,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
TouchableOpacity,
|
|
7
|
-
StatusBar,
|
|
8
|
-
Modal,
|
|
9
|
-
Dimensions,
|
|
10
|
-
} from 'react-native';
|
|
11
|
-
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
12
|
-
import { useTheme } from '../context/ThemeContext';
|
|
13
|
-
import { Typography, Card, Icon } from '../components';
|
|
14
|
-
import { MOCK_PEARLS_TOPICS } from './pearlsMockData';
|
|
15
|
-
import type { PearlTopic, PearlChapter } from '../types';
|
|
16
|
-
|
|
17
|
-
const { height: SCREEN_HEIGHT } = Dimensions.get('window');
|
|
18
|
-
|
|
19
|
-
interface PearlChaptersScreenProps {
|
|
20
|
-
topic?: PearlTopic;
|
|
21
|
-
topicId?: string;
|
|
22
|
-
onBack: () => void;
|
|
23
|
-
hideHeader?: boolean;
|
|
24
|
-
onSelectChapter?: (topic: PearlTopic, chapter: PearlChapter) => void;
|
|
25
|
-
title?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const PearlChaptersScreen: React.FC<PearlChaptersScreenProps> = ({
|
|
29
|
-
topic,
|
|
30
|
-
topicId,
|
|
31
|
-
onBack,
|
|
32
|
-
hideHeader = false,
|
|
33
|
-
onSelectChapter,
|
|
34
|
-
title = 'Pearls',
|
|
35
|
-
}) => {
|
|
36
|
-
const theme = useTheme();
|
|
37
|
-
const [bottomSheetVisible, setBottomSheetVisible] = useState(false);
|
|
38
|
-
|
|
39
|
-
const activeTopic = topic || MOCK_PEARLS_TOPICS.find((t) => t.id === topicId);
|
|
40
|
-
|
|
41
|
-
if (!activeTopic) {
|
|
42
|
-
return (
|
|
43
|
-
<SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
|
|
44
|
-
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 }}>
|
|
45
|
-
<Typography variant="h2" bold style={{ marginBottom: 12 }}>Topic not found</Typography>
|
|
46
|
-
<TouchableOpacity
|
|
47
|
-
onPress={onBack}
|
|
48
|
-
style={{
|
|
49
|
-
paddingHorizontal: 20,
|
|
50
|
-
paddingVertical: 10,
|
|
51
|
-
borderRadius: 8,
|
|
52
|
-
backgroundColor: theme.primary,
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
<Typography variant="body" bold color="#FFFFFF">Go Back</Typography>
|
|
56
|
-
</TouchableOpacity>
|
|
57
|
-
</View>
|
|
58
|
-
</SafeAreaView>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const sections = Object.keys(activeTopic.sections || {});
|
|
63
|
-
|
|
64
|
-
// --- Render bottom sheet overlay for topics filter ---
|
|
65
|
-
const renderBottomSheet = () => {
|
|
66
|
-
const list = [
|
|
67
|
-
{ name: 'Vertebral Curves', count: 25 },
|
|
68
|
-
{ name: 'Introduction', count: 15 },
|
|
69
|
-
{ name: 'Definition and scope', count: 15 },
|
|
70
|
-
{ name: 'Branches of anatomy', count: 5 },
|
|
71
|
-
{ name: 'Anatomical terminology', count: 23 },
|
|
72
|
-
{ name: 'Anatomical positions', count: 25 },
|
|
73
|
-
{ name: 'CSF', count: 15 },
|
|
74
|
-
{ name: 'Levels of structural organization', count: 15 },
|
|
75
|
-
{ name: 'Systems of the human body overview', count: 5 },
|
|
76
|
-
{ name: 'Tissue types', count: 23 },
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<Modal
|
|
81
|
-
visible={bottomSheetVisible}
|
|
82
|
-
transparent
|
|
83
|
-
animationType="slide"
|
|
84
|
-
onRequestClose={() => setBottomSheetVisible(false)}
|
|
85
|
-
>
|
|
86
|
-
<View style={styles.sheetOverlay}>
|
|
87
|
-
{/* Backdrop click closer */}
|
|
88
|
-
<TouchableOpacity
|
|
89
|
-
activeOpacity={1}
|
|
90
|
-
style={styles.sheetBackdrop}
|
|
91
|
-
onPress={() => setBottomSheetVisible(false)}
|
|
92
|
-
/>
|
|
93
|
-
|
|
94
|
-
<View style={styles.sheetContent}>
|
|
95
|
-
{/* Grabber indicator bar */}
|
|
96
|
-
<View style={styles.sheetGrabber} />
|
|
97
|
-
|
|
98
|
-
<View style={styles.sheetHeader}>
|
|
99
|
-
<Typography variant="h2" bold color={theme.textPrimary}>
|
|
100
|
-
{activeTopic.title}
|
|
101
|
-
</Typography>
|
|
102
|
-
</View>
|
|
103
|
-
|
|
104
|
-
<ScrollView contentContainerStyle={styles.sheetScroll}>
|
|
105
|
-
{list.map((item, idx) => (
|
|
106
|
-
<TouchableOpacity
|
|
107
|
-
key={idx}
|
|
108
|
-
style={styles.sheetItemRow}
|
|
109
|
-
onPress={() => {
|
|
110
|
-
setBottomSheetVisible(false);
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
<Typography variant="body" color={theme.textPrimary}>
|
|
114
|
-
{item.name}
|
|
115
|
-
</Typography>
|
|
116
|
-
<Typography variant="caption" color={theme.textSecondary}>
|
|
117
|
-
{item.count} Modules
|
|
118
|
-
</Typography>
|
|
119
|
-
</TouchableOpacity>
|
|
120
|
-
))}
|
|
121
|
-
</ScrollView>
|
|
122
|
-
</View>
|
|
123
|
-
</View>
|
|
124
|
-
</Modal>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
|
|
130
|
-
<StatusBar barStyle="dark-content" />
|
|
131
|
-
|
|
132
|
-
{/* Header */}
|
|
133
|
-
{!hideHeader && (
|
|
134
|
-
<View style={styles.header}>
|
|
135
|
-
<TouchableOpacity onPress={onBack} style={styles.backButton}>
|
|
136
|
-
<Icon name="arrow-left" size={20} color={theme.textPrimary} />
|
|
137
|
-
</TouchableOpacity>
|
|
138
|
-
|
|
139
|
-
<Typography variant="h2" bold style={styles.headerTitle}>
|
|
140
|
-
{title}
|
|
141
|
-
</Typography>
|
|
142
|
-
|
|
143
|
-
<TouchableOpacity onPress={() => setBottomSheetVisible(true)} style={styles.headerRightBtn}>
|
|
144
|
-
<Icon name="list" size={20} color={theme.textPrimary} />
|
|
145
|
-
</TouchableOpacity>
|
|
146
|
-
</View>
|
|
147
|
-
)}
|
|
148
|
-
|
|
149
|
-
{/* Chapters list view */}
|
|
150
|
-
<ScrollView contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false}>
|
|
151
|
-
{sections.map((sectionName) => {
|
|
152
|
-
const list = activeTopic.sections?.[sectionName] || [];
|
|
153
|
-
return (
|
|
154
|
-
<View key={sectionName} style={styles.sectionBlock}>
|
|
155
|
-
<Typography variant="h2" bold color={theme.textPrimary} style={styles.sectionHeading}>
|
|
156
|
-
{sectionName}
|
|
157
|
-
</Typography>
|
|
158
|
-
|
|
159
|
-
<View style={styles.chaptersList}>
|
|
160
|
-
{list.map((chapter) => (
|
|
161
|
-
<TouchableOpacity
|
|
162
|
-
key={chapter.id}
|
|
163
|
-
activeOpacity={0.8}
|
|
164
|
-
onPress={() => onSelectChapter?.(activeTopic, chapter)}
|
|
165
|
-
disabled={chapter.isLocked}
|
|
166
|
-
>
|
|
167
|
-
<Card bordered style={styles.chapterCard}>
|
|
168
|
-
<View style={styles.chapterRow}>
|
|
169
|
-
{/* Left sequential index */}
|
|
170
|
-
<Typography variant="body" bold color={theme.textSecondary} style={styles.chapterNumber}>
|
|
171
|
-
{chapter.number}
|
|
172
|
-
</Typography>
|
|
173
|
-
|
|
174
|
-
{/* Middle Text */}
|
|
175
|
-
<Typography variant="body" color={theme.textPrimary} style={styles.chapterTitle}>
|
|
176
|
-
{chapter.title}
|
|
177
|
-
</Typography>
|
|
178
|
-
|
|
179
|
-
{/* Right locks/free badges */}
|
|
180
|
-
<View style={styles.chapterBadgeCol}>
|
|
181
|
-
{chapter.isFree ? (
|
|
182
|
-
<View style={[styles.freeBadge, { borderColor: theme.primary }]}>
|
|
183
|
-
<Typography variant="caption" bold color={theme.primary} style={styles.freeText}>
|
|
184
|
-
FREE
|
|
185
|
-
</Typography>
|
|
186
|
-
</View>
|
|
187
|
-
) : chapter.isLocked ? (
|
|
188
|
-
<View style={styles.lockCircle}>
|
|
189
|
-
<Icon name="lock" size={12} color={theme.textSecondary} />
|
|
190
|
-
</View>
|
|
191
|
-
) : null}
|
|
192
|
-
</View>
|
|
193
|
-
</View>
|
|
194
|
-
</Card>
|
|
195
|
-
</TouchableOpacity>
|
|
196
|
-
))}
|
|
197
|
-
</View>
|
|
198
|
-
</View>
|
|
199
|
-
);
|
|
200
|
-
})}
|
|
201
|
-
</ScrollView>
|
|
202
|
-
|
|
203
|
-
{/* Bottom Filter Sheet */}
|
|
204
|
-
{renderBottomSheet()}
|
|
205
|
-
</SafeAreaView>
|
|
206
|
-
);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const styles = StyleSheet.create({
|
|
210
|
-
safeArea: {
|
|
211
|
-
flex: 1,
|
|
212
|
-
},
|
|
213
|
-
header: {
|
|
214
|
-
flexDirection: 'row',
|
|
215
|
-
justifyContent: 'space-between',
|
|
216
|
-
alignItems: 'center',
|
|
217
|
-
paddingHorizontal: 16,
|
|
218
|
-
paddingVertical: 12,
|
|
219
|
-
},
|
|
220
|
-
backButton: {
|
|
221
|
-
padding: 6,
|
|
222
|
-
},
|
|
223
|
-
headerTitle: {
|
|
224
|
-
fontSize: 18,
|
|
225
|
-
fontWeight: '700',
|
|
226
|
-
},
|
|
227
|
-
headerRightBtn: {
|
|
228
|
-
padding: 6,
|
|
229
|
-
},
|
|
230
|
-
scrollContent: {
|
|
231
|
-
paddingHorizontal: 16,
|
|
232
|
-
paddingTop: 8,
|
|
233
|
-
paddingBottom: 24,
|
|
234
|
-
},
|
|
235
|
-
sectionBlock: {
|
|
236
|
-
marginBottom: 20,
|
|
237
|
-
},
|
|
238
|
-
sectionHeading: {
|
|
239
|
-
fontSize: 16,
|
|
240
|
-
marginBottom: 12,
|
|
241
|
-
},
|
|
242
|
-
chaptersList: {
|
|
243
|
-
marginTop: 2,
|
|
244
|
-
},
|
|
245
|
-
chapterCard: {
|
|
246
|
-
padding: 12,
|
|
247
|
-
marginBottom: 10,
|
|
248
|
-
borderRadius: 12,
|
|
249
|
-
},
|
|
250
|
-
chapterRow: {
|
|
251
|
-
flexDirection: 'row',
|
|
252
|
-
alignItems: 'center',
|
|
253
|
-
},
|
|
254
|
-
chapterNumber: {
|
|
255
|
-
fontSize: 14,
|
|
256
|
-
width: 24,
|
|
257
|
-
textAlign: 'center',
|
|
258
|
-
marginRight: 8,
|
|
259
|
-
},
|
|
260
|
-
chapterTitle: {
|
|
261
|
-
flex: 1,
|
|
262
|
-
fontSize: 14,
|
|
263
|
-
lineHeight: 18,
|
|
264
|
-
},
|
|
265
|
-
chapterBadgeCol: {
|
|
266
|
-
justifyContent: 'center',
|
|
267
|
-
alignItems: 'flex-end',
|
|
268
|
-
marginLeft: 8,
|
|
269
|
-
},
|
|
270
|
-
freeBadge: {
|
|
271
|
-
borderWidth: 1.5,
|
|
272
|
-
borderRadius: 6,
|
|
273
|
-
paddingHorizontal: 8,
|
|
274
|
-
paddingVertical: 3,
|
|
275
|
-
},
|
|
276
|
-
freeText: {
|
|
277
|
-
fontSize: 9,
|
|
278
|
-
},
|
|
279
|
-
lockCircle: {
|
|
280
|
-
width: 20,
|
|
281
|
-
height: 20,
|
|
282
|
-
borderRadius: 10,
|
|
283
|
-
backgroundColor: '#F1F5F9',
|
|
284
|
-
justifyContent: 'center',
|
|
285
|
-
alignItems: 'center',
|
|
286
|
-
},
|
|
287
|
-
// Bottom Sheet styling
|
|
288
|
-
sheetOverlay: {
|
|
289
|
-
flex: 1,
|
|
290
|
-
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
291
|
-
justifyContent: 'flex-end',
|
|
292
|
-
},
|
|
293
|
-
sheetBackdrop: {
|
|
294
|
-
...StyleSheet.absoluteFillObject,
|
|
295
|
-
},
|
|
296
|
-
sheetContent: {
|
|
297
|
-
backgroundColor: '#FFFFFF',
|
|
298
|
-
borderTopLeftRadius: 20,
|
|
299
|
-
borderTopRightRadius: 20,
|
|
300
|
-
maxHeight: SCREEN_HEIGHT * 0.7,
|
|
301
|
-
paddingBottom: 20,
|
|
302
|
-
},
|
|
303
|
-
sheetGrabber: {
|
|
304
|
-
width: 40,
|
|
305
|
-
height: 4,
|
|
306
|
-
backgroundColor: '#E2E8F0',
|
|
307
|
-
borderRadius: 2,
|
|
308
|
-
alignSelf: 'center',
|
|
309
|
-
marginTop: 8,
|
|
310
|
-
marginBottom: 16,
|
|
311
|
-
},
|
|
312
|
-
sheetHeader: {
|
|
313
|
-
paddingHorizontal: 20,
|
|
314
|
-
paddingBottom: 12,
|
|
315
|
-
borderBottomWidth: 1,
|
|
316
|
-
borderBottomColor: '#F1F5F9',
|
|
317
|
-
},
|
|
318
|
-
sheetScroll: {
|
|
319
|
-
paddingHorizontal: 20,
|
|
320
|
-
paddingVertical: 8,
|
|
321
|
-
},
|
|
322
|
-
sheetItemRow: {
|
|
323
|
-
flexDirection: 'row',
|
|
324
|
-
justifyContent: 'space-between',
|
|
325
|
-
alignItems: 'center',
|
|
326
|
-
paddingVertical: 14,
|
|
327
|
-
borderBottomWidth: 1,
|
|
328
|
-
borderBottomColor: '#F8FAFC',
|
|
329
|
-
},
|
|
330
|
-
});
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
ScrollView,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
TouchableOpacity,
|
|
7
|
-
StatusBar,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
10
|
-
import { useTheme } from '../context/ThemeContext';
|
|
11
|
-
import { Typography, Icon } from '../components';
|
|
12
|
-
import { MOCK_PEARLS_TOPICS } from './pearlsMockData';
|
|
13
|
-
import type { PearlTopic, PearlChapter } from '../types';
|
|
14
|
-
|
|
15
|
-
interface PearlReaderScreenProps {
|
|
16
|
-
topic?: PearlTopic;
|
|
17
|
-
topicId?: string;
|
|
18
|
-
chapter?: PearlChapter;
|
|
19
|
-
chapterId?: string;
|
|
20
|
-
onBack: () => void;
|
|
21
|
-
hideHeader?: boolean;
|
|
22
|
-
title?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const PearlReaderScreen: React.FC<PearlReaderScreenProps> = ({
|
|
26
|
-
topic,
|
|
27
|
-
topicId,
|
|
28
|
-
chapter,
|
|
29
|
-
chapterId,
|
|
30
|
-
onBack,
|
|
31
|
-
hideHeader = false,
|
|
32
|
-
title = 'Pearls',
|
|
33
|
-
}) => {
|
|
34
|
-
const theme = useTheme();
|
|
35
|
-
|
|
36
|
-
const activeTopic = topic || MOCK_PEARLS_TOPICS.find((t) => t.id === topicId);
|
|
37
|
-
|
|
38
|
-
// Flatten chapters for reader mode navigation
|
|
39
|
-
const flattenedChapters: PearlChapter[] = [];
|
|
40
|
-
if (activeTopic && activeTopic.sections) {
|
|
41
|
-
Object.keys(activeTopic.sections).forEach((sectionName) => {
|
|
42
|
-
const sectionChapters = activeTopic.sections?.[sectionName] || [];
|
|
43
|
-
flattenedChapters.push(...sectionChapters);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const initialIndex = chapterId
|
|
48
|
-
? flattenedChapters.findIndex((c) => c.id === chapterId)
|
|
49
|
-
: chapter
|
|
50
|
-
? flattenedChapters.findIndex((c) => c.id === chapter.id)
|
|
51
|
-
: 0;
|
|
52
|
-
|
|
53
|
-
const [activeChapterIndex, setActiveChapterIndex] = useState<number>(initialIndex >= 0 ? initialIndex : 0);
|
|
54
|
-
const [isCompleted, setIsCompleted] = useState(false);
|
|
55
|
-
|
|
56
|
-
const activeChapter = flattenedChapters[activeChapterIndex];
|
|
57
|
-
|
|
58
|
-
if (!activeChapter) {
|
|
59
|
-
return (
|
|
60
|
-
<SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
|
|
61
|
-
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 }}>
|
|
62
|
-
<Typography variant="h2" bold style={{ marginBottom: 12 }}>Chapter not found</Typography>
|
|
63
|
-
<TouchableOpacity
|
|
64
|
-
onPress={onBack}
|
|
65
|
-
style={{
|
|
66
|
-
paddingHorizontal: 20,
|
|
67
|
-
paddingVertical: 10,
|
|
68
|
-
borderRadius: 8,
|
|
69
|
-
backgroundColor: theme.primary,
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<Typography variant="body" bold color="#FFFFFF">Go Back</Typography>
|
|
73
|
-
</TouchableOpacity>
|
|
74
|
-
</View>
|
|
75
|
-
</SafeAreaView>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const handlePrevChapter = () => {
|
|
80
|
-
if (activeChapterIndex > 0) {
|
|
81
|
-
setActiveChapterIndex(activeChapterIndex - 1);
|
|
82
|
-
setIsCompleted(false);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const handleNextChapter = () => {
|
|
87
|
-
if (activeChapterIndex < flattenedChapters.length - 1) {
|
|
88
|
-
setActiveChapterIndex(activeChapterIndex + 1);
|
|
89
|
-
setIsCompleted(false);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
|
|
95
|
-
<StatusBar barStyle="dark-content" />
|
|
96
|
-
|
|
97
|
-
{/* Header */}
|
|
98
|
-
{!hideHeader && (
|
|
99
|
-
<View style={styles.header}>
|
|
100
|
-
<TouchableOpacity onPress={onBack} style={styles.backButton}>
|
|
101
|
-
<Icon name="arrow-left" size={20} color={theme.textPrimary} />
|
|
102
|
-
</TouchableOpacity>
|
|
103
|
-
|
|
104
|
-
<Typography variant="h2" bold style={styles.headerTitle}>
|
|
105
|
-
{title}
|
|
106
|
-
</Typography>
|
|
107
|
-
|
|
108
|
-
<View style={styles.headerRightPlaceholder} />
|
|
109
|
-
</View>
|
|
110
|
-
)}
|
|
111
|
-
|
|
112
|
-
{/* Reader Container */}
|
|
113
|
-
<View style={styles.readerContainer}>
|
|
114
|
-
{/* Subheader progress banner */}
|
|
115
|
-
<View style={styles.readerSubHeader}>
|
|
116
|
-
<Typography variant="body" bold color={theme.textPrimary} style={styles.readerSubTitle}>
|
|
117
|
-
{activeChapter.title.split('.')[0] || activeChapter.title}
|
|
118
|
-
</Typography>
|
|
119
|
-
<Typography variant="body" bold color={theme.textSecondary}>
|
|
120
|
-
{activeChapterIndex + 1}/{flattenedChapters.length}
|
|
121
|
-
</Typography>
|
|
122
|
-
</View>
|
|
123
|
-
|
|
124
|
-
<ScrollView contentContainerStyle={styles.readerScroll} showsVerticalScrollIndicator={false}>
|
|
125
|
-
{activeChapter.bullets.map((bullet, idx) => {
|
|
126
|
-
const parts = bullet.split(':');
|
|
127
|
-
const boldPart = parts[0];
|
|
128
|
-
const rest = parts.slice(1).join(':');
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<View key={idx} style={styles.bulletRow}>
|
|
132
|
-
<Typography variant="body" color={theme.textPrimary} style={styles.bulletPointDot}>
|
|
133
|
-
•
|
|
134
|
-
</Typography>
|
|
135
|
-
<Typography variant="body" color={theme.textPrimary} style={styles.bulletText}>
|
|
136
|
-
{rest ? (
|
|
137
|
-
<>
|
|
138
|
-
<Typography variant="body" bold>{boldPart}:</Typography>
|
|
139
|
-
{rest}
|
|
140
|
-
</>
|
|
141
|
-
) : (
|
|
142
|
-
bullet
|
|
143
|
-
)}
|
|
144
|
-
</Typography>
|
|
145
|
-
</View>
|
|
146
|
-
);
|
|
147
|
-
})}
|
|
148
|
-
</ScrollView>
|
|
149
|
-
|
|
150
|
-
{/* Checkbox status bar */}
|
|
151
|
-
<View style={styles.checkboxBar}>
|
|
152
|
-
<TouchableOpacity
|
|
153
|
-
activeOpacity={0.8}
|
|
154
|
-
onPress={() => setIsCompleted(!isCompleted)}
|
|
155
|
-
style={styles.checkboxRow}
|
|
156
|
-
>
|
|
157
|
-
<View style={[
|
|
158
|
-
styles.checkboxBox,
|
|
159
|
-
{ borderColor: theme.border },
|
|
160
|
-
isCompleted && { backgroundColor: theme.primary, borderColor: theme.primary }
|
|
161
|
-
]}>
|
|
162
|
-
{isCompleted && <View style={styles.checkboxInner} />}
|
|
163
|
-
</View>
|
|
164
|
-
<Typography variant="body" bold color={theme.textPrimary}>
|
|
165
|
-
Mark as Complete
|
|
166
|
-
</Typography>
|
|
167
|
-
</TouchableOpacity>
|
|
168
|
-
</View>
|
|
169
|
-
|
|
170
|
-
{/* Navigation bottom buttons */}
|
|
171
|
-
<View style={styles.footerRow}>
|
|
172
|
-
<TouchableOpacity
|
|
173
|
-
onPress={handlePrevChapter}
|
|
174
|
-
disabled={activeChapterIndex === 0}
|
|
175
|
-
style={[styles.footerBtn, activeChapterIndex === 0 && { opacity: 0.4 }]}
|
|
176
|
-
>
|
|
177
|
-
<Typography variant="body" bold color={theme.textPrimary}>
|
|
178
|
-
Prev
|
|
179
|
-
</Typography>
|
|
180
|
-
</TouchableOpacity>
|
|
181
|
-
|
|
182
|
-
<TouchableOpacity
|
|
183
|
-
onPress={handleNextChapter}
|
|
184
|
-
disabled={activeChapterIndex === flattenedChapters.length - 1}
|
|
185
|
-
style={[
|
|
186
|
-
styles.nextActionBtn,
|
|
187
|
-
{ backgroundColor: theme.primary },
|
|
188
|
-
activeChapterIndex === flattenedChapters.length - 1 && { opacity: 0.4 }
|
|
189
|
-
]}
|
|
190
|
-
>
|
|
191
|
-
<Typography variant="body" bold color="#FFFFFF">
|
|
192
|
-
Next
|
|
193
|
-
</Typography>
|
|
194
|
-
</TouchableOpacity>
|
|
195
|
-
</View>
|
|
196
|
-
</View>
|
|
197
|
-
</SafeAreaView>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const styles = StyleSheet.create({
|
|
202
|
-
safeArea: {
|
|
203
|
-
flex: 1,
|
|
204
|
-
},
|
|
205
|
-
header: {
|
|
206
|
-
flexDirection: 'row',
|
|
207
|
-
justifyContent: 'space-between',
|
|
208
|
-
alignItems: 'center',
|
|
209
|
-
paddingHorizontal: 16,
|
|
210
|
-
paddingVertical: 12,
|
|
211
|
-
},
|
|
212
|
-
backButton: {
|
|
213
|
-
padding: 6,
|
|
214
|
-
},
|
|
215
|
-
headerTitle: {
|
|
216
|
-
fontSize: 18,
|
|
217
|
-
fontWeight: '700',
|
|
218
|
-
},
|
|
219
|
-
headerRightPlaceholder: {
|
|
220
|
-
width: 32,
|
|
221
|
-
},
|
|
222
|
-
readerContainer: {
|
|
223
|
-
flex: 1,
|
|
224
|
-
},
|
|
225
|
-
readerSubHeader: {
|
|
226
|
-
flexDirection: 'row',
|
|
227
|
-
justifyContent: 'space-between',
|
|
228
|
-
alignItems: 'center',
|
|
229
|
-
paddingHorizontal: 16,
|
|
230
|
-
paddingVertical: 12,
|
|
231
|
-
borderBottomWidth: 1,
|
|
232
|
-
borderBottomColor: '#E2E8F0',
|
|
233
|
-
},
|
|
234
|
-
readerSubTitle: {
|
|
235
|
-
flex: 1,
|
|
236
|
-
fontSize: 14,
|
|
237
|
-
marginRight: 16,
|
|
238
|
-
},
|
|
239
|
-
readerScroll: {
|
|
240
|
-
paddingHorizontal: 16,
|
|
241
|
-
paddingVertical: 16,
|
|
242
|
-
},
|
|
243
|
-
bulletRow: {
|
|
244
|
-
flexDirection: 'row',
|
|
245
|
-
alignItems: 'flex-start',
|
|
246
|
-
marginBottom: 16,
|
|
247
|
-
},
|
|
248
|
-
bulletPointDot: {
|
|
249
|
-
fontSize: 18,
|
|
250
|
-
marginRight: 10,
|
|
251
|
-
lineHeight: 20,
|
|
252
|
-
},
|
|
253
|
-
bulletText: {
|
|
254
|
-
flex: 1,
|
|
255
|
-
fontSize: 14,
|
|
256
|
-
lineHeight: 22,
|
|
257
|
-
},
|
|
258
|
-
checkboxBar: {
|
|
259
|
-
paddingHorizontal: 16,
|
|
260
|
-
paddingVertical: 14,
|
|
261
|
-
borderTopWidth: 1,
|
|
262
|
-
borderTopColor: '#E2E8F0',
|
|
263
|
-
backgroundColor: '#F8FAFC',
|
|
264
|
-
},
|
|
265
|
-
checkboxRow: {
|
|
266
|
-
flexDirection: 'row',
|
|
267
|
-
alignItems: 'center',
|
|
268
|
-
},
|
|
269
|
-
checkboxBox: {
|
|
270
|
-
width: 20,
|
|
271
|
-
height: 20,
|
|
272
|
-
borderWidth: 2,
|
|
273
|
-
borderRadius: 4,
|
|
274
|
-
justifyContent: 'center',
|
|
275
|
-
alignItems: 'center',
|
|
276
|
-
marginRight: 10,
|
|
277
|
-
},
|
|
278
|
-
checkboxInner: {
|
|
279
|
-
width: 10,
|
|
280
|
-
height: 10,
|
|
281
|
-
borderRadius: 2,
|
|
282
|
-
backgroundColor: '#FFFFFF',
|
|
283
|
-
},
|
|
284
|
-
footerRow: {
|
|
285
|
-
flexDirection: 'row',
|
|
286
|
-
alignItems: 'center',
|
|
287
|
-
paddingHorizontal: 16,
|
|
288
|
-
paddingVertical: 12,
|
|
289
|
-
backgroundColor: '#FFFFFF',
|
|
290
|
-
borderTopWidth: 1,
|
|
291
|
-
borderTopColor: '#E2E8F0',
|
|
292
|
-
justifyContent: 'space-between',
|
|
293
|
-
},
|
|
294
|
-
footerBtn: {
|
|
295
|
-
paddingVertical: 8,
|
|
296
|
-
paddingHorizontal: 12,
|
|
297
|
-
},
|
|
298
|
-
nextActionBtn: {
|
|
299
|
-
paddingHorizontal: 24,
|
|
300
|
-
paddingVertical: 10,
|
|
301
|
-
borderRadius: 8,
|
|
302
|
-
minWidth: 80,
|
|
303
|
-
justifyContent: 'center',
|
|
304
|
-
alignItems: 'center',
|
|
305
|
-
},
|
|
306
|
-
});
|