Open History to see the last commit
1import { NativeThemeHost } from "./NativeThemeHost.android";
2import { LoadingIndicator } from "@expo/ui/jetpack-compose";
3import { size as composeSize } from "@expo/ui/jetpack-compose/modifiers";
4import { StyleSheet, View, type ActivityIndicatorProps } from "react-native";
5import { useResolveClassNames, withUniwind } from "uniwind";
6
7function AndroidActivityIndicator({
8 animating = true,
9 color,
10 colorClassName: _colorClassName,
11 className: _className,
12 hidesWhenStopped: _hidesWhenStopped,
13 size = "small",
14 style,
15 ...viewProps
16}: ActivityIndicatorProps) {
17 const { color: primaryColor } = useResolveClassNames("text-primary");
18 const diameter = typeof size === "number" ? size : size === "large" ? 48 : 20;
19
20 return (
21 <View
22 accessible={animating}
23 accessibilityRole="progressbar"
24 accessibilityState={{ busy: animating }}
25 {...viewProps}
26 style={[styles.container, style]}
27 >
28 <View
29 pointerEvents="none"
30 importantForAccessibility="no-hide-descendants"
31 style={{ width: diameter, height: diameter }}
32 >
33 {animating ? (
34 <NativeThemeHost ignoreSafeAreaKeyboardInsets style={{ flex: 1 }}>
35 <LoadingIndicator
36 color={color ?? primaryColor}
37 modifiers={[composeSize(diameter, diameter)]}
38 />
39 </NativeThemeHost>
40 ) : null}
41 </View>
42 </View>
43 );
44}
45
46export const AppActivityIndicator = withUniwind(AndroidActivityIndicator);
47
48const styles = StyleSheet.create({
49 container: { alignItems: "center", justifyContent: "center" },
50});