import { Pressable, View } from 'react-native'; import { useColors } from '../../hook'; import { useI18nContext } from '../../i18n'; import { usePaletteContext } from '../../theme'; import { IconButton } from '../../ui/Button'; import { Icon } from '../../ui/Image'; import { Ripple } from '../../ui/Ripple'; import { SingleLineText, TimerText } from '../../ui/Text'; import { gVoiceBarHeight } from '../const'; import type { VoiceBarProps } from './types'; import { useVoiceBar } from './VoiceBar.hooks'; /** * Component for recording and playing speech. */ export function VoiceBar(props: VoiceBarProps) { const { height } = props; const { tr } = useI18nContext(); const { colors } = usePaletteContext(); const { getColor } = useColors({ trash: { light: colors.neutral[5], dark: colors.neutral[6], }, trash_bg: { light: colors.neutral[9], dark: colors.neutral[7], }, }); const { state, onClickedClearButton, onClickedRecordButton, onClickedSendButton, contentTimerRef, playRipple, onContentTimeChanged, currentTime, } = useVoiceBar(props); const getTextTip = () => { switch (state) { case 'idle': return tr('voice_bar_tip_click_record'); case 'recording': return tr('voice_bar_tip_recording'); case 'playing': return tr('voice_bar_tip_playing'); case 'stopping': return tr('voice_bar_tip_click_play'); } }; return ( {state === 'playing' || state === 'stopping' ? ( ) : null} {'s'} {state === 'playing' || state === 'stopping' ? ( ) : null} {getTextTip()} 50 ? 'flex' : 'none', }} > {tr('voice_bar_remain', 60 - currentTime)} ); }