mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {View} from 'react-native'
3import {Text} from '../../util/text/Text'
4// @ts-ignore no type definition -prf
5import ProgressCircle from 'react-native-progress/Circle'
6// @ts-ignore no type definition -prf
7import ProgressPie from 'react-native-progress/Pie'
8import {s} from 'lib/styles'
9import {usePalette} from 'lib/hooks/usePalette'
10import {MAX_GRAPHEME_LENGTH} from 'lib/constants'
11
12const DANGER_LENGTH = MAX_GRAPHEME_LENGTH
13
14export function CharProgress({count}: {count: number}) {
15 const pal = usePalette('default')
16 const textColor = count > DANGER_LENGTH ? '#e60000' : pal.colors.text
17 const circleColor = count > DANGER_LENGTH ? '#e60000' : pal.colors.link
18 return (
19 <>
20 <Text style={[s.mr10, s.tabularNum, {color: textColor}]}>
21 {MAX_GRAPHEME_LENGTH - count}
22 </Text>
23 <View>
24 {count > DANGER_LENGTH ? (
25 <ProgressPie
26 size={30}
27 borderWidth={4}
28 borderColor={circleColor}
29 color={circleColor}
30 progress={Math.min(
31 (count - MAX_GRAPHEME_LENGTH) / MAX_GRAPHEME_LENGTH,
32 1,
33 )}
34 />
35 ) : (
36 <ProgressCircle
37 size={30}
38 borderWidth={1}
39 borderColor={pal.colors.border}
40 color={circleColor}
41 progress={count / MAX_GRAPHEME_LENGTH}
42 />
43 )}
44 </View>
45 </>
46 )
47}