diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-12-05 13:59:13 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-12-05 13:59:13 -0600 |
commit | 73c84f6f64d70473da6f77675a00c7e222d4dfee (patch) | |
tree | 3e2a9c0e7973862b250693c9bc0e32a390e31d67 /src | |
parent | 39bab0bb08c0fbe1a3deeeb5178e97ac15242bcd (diff) | |
download | voidsky-73c84f6f64d70473da6f77675a00c7e222d4dfee.tar.zst |
Better sized and more informative character counter
Diffstat (limited to 'src')
-rw-r--r-- | src/view/com/composer/ComposePost.tsx | 29 | ||||
-rw-r--r-- | src/view/com/util/ProgressCircle.native.tsx | 3 | ||||
-rw-r--r-- | src/view/com/util/ProgressCircle.tsx | 20 |
3 files changed, 24 insertions, 28 deletions
diff --git a/src/view/com/composer/ComposePost.tsx b/src/view/com/composer/ComposePost.tsx index 10d9f4b1c..d53d04abf 100644 --- a/src/view/com/composer/ComposePost.tsx +++ b/src/view/com/composer/ComposePost.tsx @@ -15,7 +15,10 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {UserAutocompleteViewModel} from '../../../state/models/user-autocomplete-view' import {Autocomplete} from './Autocomplete' import * as Toast from '../util/Toast' -import ProgressCircle from '../util/ProgressCircle' +// @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 {TextLink} from '../util/Link' import {UserAvatar} from '../util/UserAvatar' import {useStores} from '../../../state' @@ -252,10 +255,26 @@ export const ComposePost = observer(function ComposePost({ {MAX_TEXT_LENGTH - text.length} </Text> <View> - <ProgressCircle - color={progressColor} - progress={text.length / MAX_TEXT_LENGTH} - /> + {text.length > DANGER_TEXT_LENGTH ? ( + <ProgressPie + size={30} + borderWidth={4} + borderColor={progressColor} + color={progressColor} + progress={Math.min( + (text.length - MAX_TEXT_LENGTH) / MAX_TEXT_LENGTH, + 1, + )} + /> + ) : ( + <ProgressCircle + size={30} + borderWidth={1} + borderColor={colors.gray2} + color={progressColor} + progress={text.length / MAX_TEXT_LENGTH} + /> + )} </View> </View> <Autocomplete diff --git a/src/view/com/util/ProgressCircle.native.tsx b/src/view/com/util/ProgressCircle.native.tsx deleted file mode 100644 index a09232b4b..000000000 --- a/src/view/com/util/ProgressCircle.native.tsx +++ /dev/null @@ -1,3 +0,0 @@ -// @ts-ignore no type definition -prf -import ProgressCircle from 'react-native-progress/Circle' -export default ProgressCircle diff --git a/src/view/com/util/ProgressCircle.tsx b/src/view/com/util/ProgressCircle.tsx deleted file mode 100644 index 0e425a6e6..000000000 --- a/src/view/com/util/ProgressCircle.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {View} from 'react-native' -import {CircularProgressbar, buildStyles} from 'react-circular-progressbar' - -const ProgressCircle = ({ - color, - progress, -}: { - color?: string - progress: number -}) => { - return ( - <View style={{width: 20, height: 20}}> - <CircularProgressbar - value={progress * 100} - styles={buildStyles({pathColor: color || '#00f'})} - /> - </View> - ) -} -export default ProgressCircle |