APP-1645: Improve video upload progress indicator (#11248)

This commit is contained in:
Spence Pope
2026-08-12 17:14:06 -04:00
committed by GitHub
parent 3d736c76b7
commit f5f980e58e
4 changed files with 155 additions and 36 deletions
+16 -28
View File
@@ -25,7 +25,6 @@ import {Circle as ProgressCircle} from 'react-native-progress'
import Animated, {
type AnimatedRef,
type AnimatedStyle,
Easing,
FadeIn,
FadeOut,
interpolateColor,
@@ -37,7 +36,6 @@ import Animated, {
useAnimatedStyle,
useDerivedValue,
useSharedValue,
withRepeat,
withTiming,
ZoomIn,
ZoomOut,
@@ -127,6 +125,7 @@ import {atoms as a, native, useBreakpoints, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as EmojiPicker from '#/components/EmojiPicker'
import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheckIcon} from '#/components/icons/CircleCheck'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfoIcon} from '#/components/icons/CircleInfo'
import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmileIcon} from '#/components/icons/Emoji'
import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
@@ -180,6 +179,7 @@ import {
processVideo,
type VideoState,
} from './state/video'
import {videoProgressWithinPhase} from './state/videoProgress'
import {type TextInputRef} from './text-input/TextInput.types'
import {getVideoMetadata} from './videos/metadata'
import {clearThumbnailCache} from './videos/VideoTranscodeBackdrop'
@@ -1996,7 +1996,10 @@ function ComposerEmbeds({
(video.status === 'compressing' ? (
<VideoTranscodeProgress
asset={video.asset}
progress={video.progress}
progress={videoProgressWithinPhase(
'compressing',
video.progress,
)}
clear={clearVideo}
/>
) : video.video ? (
@@ -2672,28 +2675,7 @@ function VideoUploadToolbar({state}: {state: VideoState}) {
const t = useTheme()
const {t: l} = useLingui()
const progress = state.progress
const shouldRotate =
state.status === 'processing' && (progress === 0 || progress === 1)
let wheelProgress = shouldRotate ? 0.33 : progress
const rotate = useDerivedValue(() => {
if (shouldRotate) {
return withRepeat(
withTiming(360, {
duration: 2500,
easing: Easing.out(Easing.cubic),
}),
-1,
)
}
return 0
})
const animatedStyle = useAnimatedStyle(() => {
return {
transform: [{rotateZ: `${rotate.get()}deg`}],
}
})
let wheelProgress = progress
let text = ''
@@ -2723,7 +2705,7 @@ function VideoUploadToolbar({state}: {state: VideoState}) {
break
case 'error':
text = l`Error`
wheelProgress = 100
wheelProgress = 1
break
case 'done':
if (isGif) {
@@ -2736,7 +2718,13 @@ function VideoUploadToolbar({state}: {state: VideoState}) {
return (
<ToolbarWrapper style={[a.flex_row, a.align_center, {paddingVertical: 5}]}>
<Animated.View style={[animatedStyle]}>
{state.status === 'done' ? (
<Animated.View
entering={ZoomIn.duration(300)}
style={[a.align_center, a.justify_center, {height: 30, width: 30}]}>
<CircleCheckIcon size="lg" fill={t.palette.primary_500} />
</Animated.View>
) : (
<ProgressCircle
size={30}
borderWidth={1}
@@ -2748,7 +2736,7 @@ function VideoUploadToolbar({state}: {state: VideoState}) {
}
progress={wheelProgress}
/>
</Animated.View>
)}
<Text style={[a.font_semi_bold, a.ml_sm]}>{text}</Text>
</ToolbarWrapper>
)