MCPcopy Index your code
hub / github.com/callstack/react-native-paper / PaperExample

Function PaperExample

example/src/index.native.tsx:37–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35const Drawer = createDrawerNavigator<{ Home: undefined }>();
36
37export default function PaperExample() {
38 useKeepAwake();
39
40 const [fontsLoaded] = useFonts({
41 Abel: require('../assets/fonts/Abel-Regular.ttf'),
42 });
43
44 const [isReady, setIsReady] = React.useState(false);
45 const [initialState, setInitialState] = React.useState<
46 InitialState | undefined
47 >();
48
49 const [shouldUseDeviceColors, setShouldUseDeviceColors] =
50 React.useState(true);
51 const [isDarkMode, setIsDarkMode] = React.useState(false);
52 const [themeVersion, setThemeVersion] = React.useState<2 | 3>(3);
53 const [rtl, setRtl] = React.useState<boolean>(
54 I18nManager.getConstants().isRTL
55 );
56 const [collapsed, setCollapsed] = React.useState(false);
57 const [customFontLoaded, setCustomFont] = React.useState(false);
58 const [rippleEffectEnabled, setRippleEffectEnabled] = React.useState(true);
59
60 const { theme: mdTheme } = useMaterial3Theme();
61 const theme = React.useMemo(() => {
62 if (themeVersion === 2) {
63 return isDarkMode ? MD2DarkTheme : MD2LightTheme;
64 }
65
66 if (!deviceColorsSupported || !shouldUseDeviceColors) {
67 return isDarkMode ? MD3DarkTheme : MD3LightTheme;
68 }
69
70 return isDarkMode
71 ? { ...MD3DarkTheme, colors: mdTheme.dark }
72 : { ...MD3LightTheme, colors: mdTheme.light };
73 }, [isDarkMode, mdTheme, shouldUseDeviceColors, themeVersion]);
74
75 React.useEffect(() => {
76 const restoreState = async () => {
77 try {
78 const savedStateString = await AsyncStorage.getItem(PERSISTENCE_KEY);
79 const state = JSON.parse(savedStateString || '');
80
81 setInitialState(state);
82 } catch (e) {
83 // ignore error
84 } finally {
85 setIsReady(true);
86 }
87 };
88
89 if (!isReady) {
90 restoreState();
91 }
92 }, [isReady]);
93
94 React.useEffect(() => {

Callers

nothing calls this directly

Calls 5

restoreStateFunction · 0.70
restorePrefsFunction · 0.70
savePrefsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…