Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

LoadingScreen.tsx

31 lines1.3 KB

1import { ActivityIndicator, StatusBar, View } from "react-native";
2import { useSafeAreaInsets } from "react-native-safe-area-context";
3import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
4​
5import { AppText as Text } from "./AppText";
6import { BrandMark } from "./BrandMark";
7​
8export function LoadingScreen(props: {
9 readonly message: string;
10 readonly messagePlacement?: "above-spinner" | "below-spinner";
11}) {
12 const { themeAppearance: colorScheme } = useAppearancePreferences();
13 const insets = useSafeAreaInsets();
14 const messagePlacement = props.messagePlacement ?? "below-spinner";
15​
16 return (
17 <View className="flex-1 bg-screen" style={{ paddingTop: insets.top }}>
18 <StatusBar barStyle={colorScheme === "dark" ? "light-content" : "dark-content"} />
19 <View className="flex-1 items-center justify-center gap-5 px-6">
20 <BrandMark compact />
21 {messagePlacement === "above-spinner" ? (
22 <Text className="font-t3-bold text-lg text-foreground">{props.message}</Text>
23 ) : null}
24 <ActivityIndicator size="large" />
25 {messagePlacement === "below-spinner" ? (
26 <Text className="font-t3-bold text-lg text-foreground">{props.message}</Text>
27 ) : null}
28 </View>
29 </View>
30 );