Open History to see the last commit
1import { LinearProgressIndicator } from "@expo/ui/jetpack-compose";
2import { fillMaxWidth } from "@expo/ui/jetpack-compose/modifiers";
3import { View } from "react-native";
4import { useReducedMotion } from "react-native-reanimated";
5import { NativeThemeHost } from "./NativeThemeHost.android";
6import { useControlTheme } from "./useControlTheme";
7import { clampProgress, type ProgressProps } from "./Progress.types";
8
9export function Progress(props: ProgressProps) {
10 const value = clampProgress(props.value);
11 const reducedMotion = useReducedMotion();
12 const { colors } = useControlTheme();
13 return (
14 <View
15 className={props.className}
16 accessible
17 accessibilityRole="progressbar"
18 accessibilityLabel={props.label}
19 accessibilityValue={
20 value === undefined ? undefined : { min: 0, max: 100, now: Math.round(value * 100) }
21 }
22 accessibilityState={{ busy: value === undefined }}
23 >
24 {reducedMotion && value === undefined ? (
25 <View className="h-1 rounded-full bg-primary/30" />
26 ) : (
27 <View importantForAccessibility="no-hide-descendants">
28 <NativeThemeHost matchContents={{ vertical: true }} style={{ width: "100%" }}>
29 <LinearProgressIndicator
30 progress={value}
31 color={colors["--color-primary"]}
32 trackColor={colors["--color-subtle"]}
33 modifiers={[fillMaxWidth()]}
34 />
35 </NativeThemeHost>
36 </View>
37 )}
38 </View>
39 );
40}