change charprogress appearance

This commit is contained in:
Samuel Newman
2026-05-21 14:31:28 +03:00
parent 16699d98a5
commit 4529d13558
@@ -4,18 +4,15 @@ import {
View, View,
type ViewStyle, type ViewStyle,
} from 'react-native' } from 'react-native'
// @ts-ignore no type definition -prf
import ProgressCircle from 'react-native-progress/Circle'
// @ts-ignore no type definition -prf
import ProgressPie from 'react-native-progress/Pie'
import {MAX_GRAPHEME_LENGTH} from '#/lib/constants' import {MAX_GRAPHEME_LENGTH} from '#/lib/constants'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {ProgressCircle} from '#/components/Progress'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
export function CharProgress({ export function CharProgress({
count, count,
max, max = MAX_GRAPHEME_LENGTH,
style, style,
textStyle, textStyle,
size, size,
@@ -26,40 +23,42 @@ export function CharProgress({
textStyle?: StyleProp<TextStyle> textStyle?: StyleProp<TextStyle>
size?: number size?: number
}) { }) {
const maxLength = max || MAX_GRAPHEME_LENGTH
const t = useTheme() const t = useTheme()
const textColor = count > maxLength ? '#e60000' : t.atoms.text.color const textColor = count > max ? '#e60000' : t.atoms.text.color
const circleColor = count > maxLength ? '#e60000' : t.palette.primary_500 const circleColor = count > max ? '#e60000' : t.palette.primary_500
return ( return (
<View <View style={[style]}>
style={[a.flex_row, a.align_center, a.justify_between, a.gap_sm, style]}> {max - count < 100 && (
<Text <View
style={[ style={[
{color: textColor, fontVariant: ['tabular-nums']}, a.absolute,
a.flex_grow, a.inset_0,
a.text_right, a.justify_center,
textStyle, a.align_center,
]} a.px_xs,
maxFontSizeMultiplier={1}> ]}>
{maxLength - count} <Text
</Text> style={[
{count > maxLength ? ( {color: textColor, fontVariant: ['tabular-nums']},
<ProgressPie a.text_center,
size={size ?? 30} a.text_xs,
borderWidth={4} {maxWidth: '100%'},
borderColor={circleColor} textStyle,
color={circleColor} ]}
progress={Math.min((count - maxLength) / maxLength, 1)} maxFontSizeMultiplier={1}
/> adjustsFontSizeToFit
) : ( numberOfLines={1}>
<ProgressCircle {max - count}
size={size ?? 30} </Text>
borderWidth={1} </View>
borderColor={t.atoms.border_contrast_low.borderColor}
color={circleColor}
progress={count / maxLength}
/>
)} )}
<ProgressCircle
size={size ?? 32}
borderWidth={3}
borderColor={t.palette.contrast_50}
color={circleColor}
progress={Math.min(count / max, 1)}
/>
</View> </View>
) )
} }