Skip to content

Commit

Permalink
feat(lessonPicker): show selected lesson number
Browse files Browse the repository at this point in the history
feat(lessonPicker): use all if nothing selected
  • Loading branch information
IgorKhramtsov committed Sep 22, 2024
1 parent b891345 commit a65050d
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions app/(app)/lessonPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ export default function Index() {
router.replace({
pathname: '/lessons',
params: {
assignmentIds: selectedAssignments,
assignmentIds:
selectedAssignments.length > 0
? selectedAssignments
: assignments.map(e => e.id),
interleave: interleave.toString(),
},
})
}, [selectedAssignments, interleave])
}, [selectedAssignments, assignments, interleave])

const subjectsByLevel = useMemo(() => {
const result = new Map<number, Map<SubjectType, Subject[]>>()
Expand Down Expand Up @@ -100,6 +103,11 @@ export default function Index() {
return result
}, [subjects])

const buttonCopy = useMemo(
() => (selectedIds.length === 0 ? 'Batch, Please!' : 'Start lessons'),
[selectedIds],
)

if (isLoading) {
return <FullPageLoading />
}
Expand Down Expand Up @@ -175,12 +183,19 @@ export default function Index() {
</Pressable>
<View style={{ height: 12 }} />

<Pressable
style={styles.startButtonView}
disabled={selectedIds.length === 0}
onPress={startLessons}>
<View>
<Text style={styles.startButtonText}>Start Lessons</Text>
<Pressable style={styles.startButtonView} onPress={startLessons}>
<View style={appStyles.row}>
<Text style={styles.startButtonText}>{buttonCopy}</Text>
{selectedIds.length > 0 && (
<>
<View style={{ width: 4 }} />
<View style={styles.startbuttonLenTextContainer}>
<Text style={styles.startbuttonLenText}>
{selectedIds.length}
</Text>
</View>
</>
)}
</View>
</Pressable>
</BlurView>
Expand Down Expand Up @@ -214,6 +229,16 @@ const stylesheet = createStyleSheet({
...typography.callout,
color: Colors.white,
},
startbuttonLenTextContainer: {
backgroundColor: Colors.white,
borderRadius: 18,
paddingHorizontal: 7,
paddingVertical: 3,
},
startbuttonLenText: {
...typography.callout,
color: Colors.pink,
},
viewText: {
...typography.titleC,
paddingHorizontal: 4,
Expand Down

0 comments on commit a65050d

Please sign in to comment.