An ATproto social media client -- with an independent Appview.
at main 64 lines 1.5 kB view raw
1import {type StyleProp, type ViewStyle} from 'react-native' 2import {View} from 'react-native' 3import {msg, plural} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {atoms as a, useTheme} from '#/alf' 7import {Text} from '#/components/Typography' 8 9/** 10 * Absolutely positioned time indicator showing how many seconds are remaining 11 * Time is in seconds 12 */ 13export function TimeIndicator({ 14 time, 15 style, 16}: { 17 time: number 18 style?: StyleProp<ViewStyle> 19}) { 20 const t = useTheme() 21 const {_} = useLingui() 22 23 if (isNaN(time)) { 24 return null 25 } 26 27 const minutes = Math.floor(time / 60) 28 const seconds = String(time % 60).padStart(2, '0') 29 30 return ( 31 <View 32 pointerEvents="none" 33 accessibilityLabel={_( 34 msg`Time remaining: ${plural(Number(time) || 0, { 35 one: '# second', 36 other: '# seconds', 37 })}`, 38 )} 39 accessibilityHint="" 40 style={[ 41 { 42 backgroundColor: 'rgba(0, 0, 0, 0.5)', 43 borderRadius: 6, 44 paddingHorizontal: 6, 45 paddingVertical: 3, 46 left: 6, 47 bottom: 6, 48 minHeight: 21, 49 }, 50 a.absolute, 51 a.justify_center, 52 style, 53 ]}> 54 <Text 55 style={[ 56 {color: t.palette.white, fontSize: 12, fontVariant: ['tabular-nums']}, 57 a.font_bold, 58 {lineHeight: 1.25}, 59 ]}> 60 {`${minutes}:${seconds}`} 61 </Text> 62 </View> 63 ) 64}