Skip to content

Commit

Permalink
feat: compact target mark view
Browse files Browse the repository at this point in the history
  • Loading branch information
leaftail1880 committed Oct 21, 2024
1 parent 23f3b21 commit 2a3a111
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SettingsStore {
markStyle: 'background' | 'border' = 'background'
showMarkWeightTip = true
collapseLongAssignmentText = false
targetMarkCompact = false

/**
* Map containing per student overrides
Expand Down
5 changes: 5 additions & 0 deletions src/screens/settings/marks/Marks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export default observer(function Notifications(
title='"Вес: " перед весом оценки'
setting="showMarkWeightTip"
/>
<SwitchSetting
title="Компактное отображение"
description="Компактное отображение целевой оценки"
setting="targetMarkCompact"
/>
</List.Section>
{student && (
<List.Section title="Для ученика">
Expand Down
78 changes: 48 additions & 30 deletions src/screens/totals/term/MarksInline.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from 'mobx-react-lite'
import React, { useMemo } from 'react'
import { ScrollView, StyleProp, View, ViewStyle } from 'react-native'
import { Text } from 'react-native-paper'
import { Chip, Text } from 'react-native-paper'
import Loading from '~components/Loading'
import Mark from '~components/Mark'
import { styles } from '~constants'
Expand Down Expand Up @@ -155,35 +155,53 @@ export default observer(function SubjectMarksInline(
style={{ padding: Spacings.s2, alignSelf: 'center' }}
/>
</View>
<View
style={{
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
padding: Spacings.s2,
}}
>
{toGetTarget && (
<View style={[styles.stretch, { gap: Spacings.s1 }]}>
<Text>До </Text>
<Mark
mark={student?.targetMark}
duty={false}
style={{ padding: Spacings.s1 }}
/>
<Text>нужно {toGetTarget}x</Text>

<Mark
duty={false}
style={{ padding: Spacings.s1, paddingHorizontal: Spacings.s2 }}
textStyle={{ fontSize: 10 }}
subTextStyle={{ fontSize: 8 }}
weight={student?.defaultMarkWeight}
mark={student?.defaultMark}
/>
</View>
)}
</View>
{toGetTarget && (
<View
style={{
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
padding: Spacings.s2,
gap: Spacings.s2,
}}
>
{Settings.targetMarkCompact && (
<Chip mode="flat" compact>
<Text>
<Text>Нужно </Text>
<Text
style={{ fontWeight: 'bold', color: Theme.colors.primary }}
>
{toGetTarget}x
</Text>
</Text>
</Chip>
)}
{!Settings.targetMarkCompact && (
<View style={[styles.stretch, { gap: Spacings.s1 }]}>
<Text>До</Text>
<Mark
mark={student?.targetMark}
duty={false}
style={{ padding: Spacings.s1 }}
/>
<Text>нужно </Text>
<Text style={{ fontWeight: 'bold', color: Theme.colors.primary }}>
{toGetTarget}x
</Text>

<Mark
duty={false}
style={{ padding: Spacings.s1, paddingHorizontal: Spacings.s2 }}
textStyle={{ fontSize: 10 }}
subTextStyle={{ fontSize: 8 }}
weight={student?.defaultMarkWeight}
mark={student?.defaultMark}
/>
</View>
)}
</View>
)}
</>
)
})
Expand Down

0 comments on commit 2a3a111

Please sign in to comment.