Skip to content

Commit 7859dcc

Browse files
Karthik-B-06kodiakhq[bot]
authored andcommitted
chore(example-app): ✨ add component examples to Circular Progress screen
1 parent 23d0dfd commit 7859dcc

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed
Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,78 @@
11
import React from "react";
22
import {
33
Box,
4+
Button,
45
CircularProgress,
56
useTheme,
67
} from "@adaptui/react-native-tailwind";
78

9+
const useCircularProgressState = (initialValue: number | null = 0) => {
10+
const [value, setValue] = React.useState<number | null>(initialValue);
11+
12+
React.useEffect(() => {
13+
const clearId = setInterval(() => {
14+
setValue(prevValue => {
15+
if (prevValue == null) {
16+
return prevValue;
17+
}
18+
return prevValue + 5;
19+
});
20+
}, 500);
21+
22+
if (value === 100) {
23+
clearInterval(clearId);
24+
}
25+
26+
return () => {
27+
clearInterval(clearId);
28+
};
29+
}, [setValue, value]);
30+
31+
return [value, setValue] as const;
32+
};
33+
834
export const CircularProgressScreen = () => {
935
const tailwind = useTheme();
36+
const [value, setValue] = useCircularProgressState();
1037
return (
1138
<Box
1239
style={tailwind.style(
1340
"flex-1 justify-center items-center px-2 bg-white-900",
1441
)}
1542
>
16-
<CircularProgress size="sm" />
17-
<CircularProgress />
18-
<CircularProgress size="lg" />
19-
<CircularProgress size="xl" />
43+
<Box style={tailwind.style("my-5")}>
44+
<CircularProgress size="sm" />
45+
</Box>
46+
<Box style={tailwind.style("my-5")}>
47+
<CircularProgress themeColor="primary" />
48+
</Box>
49+
<Box style={tailwind.style("my-5")}>
50+
<CircularProgress
51+
style={tailwind.style("w-48 h-48")}
52+
themeColor="primary"
53+
progressTrackColor={tailwind.getColor("text-green-600")}
54+
/>
55+
</Box>
56+
<Box style={tailwind.style("my-5")}>
57+
<CircularProgress size="lg" />
58+
</Box>
59+
<Box style={tailwind.style("my-5")}>
60+
<CircularProgress value={value} themeColor="primary" size="xl" />
61+
</Box>
62+
<Box style={tailwind.style("my-5")}>
63+
<CircularProgress
64+
hint={`${value}%`}
65+
value={value}
66+
themeColor="primary"
67+
size="xl"
68+
/>
69+
</Box>
70+
<Box style={tailwind.style("flex-row justify-center w-full")}>
71+
<Button onPress={() => setValue(0)}>Reset</Button>
72+
<Button variant="ghost" onPress={() => setValue(null)}>
73+
Make Indeterminate
74+
</Button>
75+
</Box>
2076
</Box>
2177
);
2278
};

0 commit comments

Comments
 (0)