forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {View} from 'react-native'
2// @ts-expect-error no type definition
3import ProgressPie from 'react-native-progress/Pie'
4import {type ImagePickerAsset} from 'expo-image-picker'
5
6import {clamp} from '#/lib/numbers'
7import {atoms as a, useTheme} from '#/alf'
8import {IS_WEB} from '#/env'
9import {ExternalEmbedRemoveBtn} from '../ExternalEmbedRemoveBtn'
10import {VideoTranscodeBackdrop} from './VideoTranscodeBackdrop'
11
12export function VideoTranscodeProgress({
13 asset,
14 progress,
15 clear,
16}: {
17 asset: ImagePickerAsset
18 progress: number
19 clear: () => void
20}) {
21 const t = useTheme()
22
23 if (IS_WEB) return null
24
25 let aspectRatio = asset.width / asset.height
26
27 if (isNaN(aspectRatio)) {
28 aspectRatio = 16 / 9
29 }
30
31 aspectRatio = clamp(aspectRatio, 1 / 1, 3 / 1)
32
33 return (
34 <View
35 style={[
36 a.w_full,
37 t.atoms.bg_contrast_50,
38 a.rounded_md,
39 a.overflow_hidden,
40 {aspectRatio},
41 ]}>
42 <VideoTranscodeBackdrop uri={asset.uri} />
43 <View
44 style={[
45 a.flex_1,
46 a.align_center,
47 a.justify_center,
48 a.gap_lg,
49 a.absolute,
50 a.inset_0,
51 ]}>
52 <ProgressPie
53 size={48}
54 borderWidth={3}
55 borderColor={t.atoms.text.color}
56 color={t.atoms.text.color}
57 progress={progress}
58 />
59 </View>
60 <ExternalEmbedRemoveBtn onRemove={clear} />
61 </View>
62 )
63}