-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.tsx
71 lines (65 loc) · 2.25 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import { I18nManager } from 'react-native';
import { KitchenSink } from './components/KitchenSink';
import { CollapsibleHeaderLayout } from '@brightlayer-ui/react-native-components';
import { UserMenuExample } from './components/UserMenuExample';
import { useThemeContext } from './contexts/ThemeContext';
import RNRestart from 'react-native-restart';
import { StackNavigationProp } from '@react-navigation/stack';
import { RootStackParamList } from './router';
export const toggleRTL = (): void => {
if (I18nManager.isRTL) {
I18nManager.allowRTL(false);
I18nManager.forceRTL(false);
} else {
I18nManager.forceRTL(true);
}
RNRestart.Restart();
};
type AppProps = {
navigation: StackNavigationProp<RootStackParamList, 'App'>;
};
export const App: React.FC<AppProps> = ({ navigation }) => {
const { theme: themeType, setTheme } = useThemeContext();
return (
<CollapsibleHeaderLayout
HeaderProps={{
variant: 'dynamic',
title: 'Valley Forge',
subtitle: 'The Last Stand',
icon: { name: 'menu' },
info: 'hello',
expandable: true,
backgroundImage: require('./assets/images/farm.jpg'),
onIconPress: (): void => {
navigation.openDrawer();
},
searchableConfig: { placeholder: 'Search', autoFocus: true },
actionItems: [
{
icon: { name: 'more' },
onPress: () => {},
component: (
<UserMenuExample
onToggleRTL={toggleRTL}
onToggleTheme={(): void => setTheme(themeType === 'light' ? 'dark' : 'light')}
/>
),
},
],
}}
ScrollViewProps={{
nestedScrollEnabled: true,
keyboardShouldPersistTaps: 'handled',
}}
>
<KitchenSink />
</CollapsibleHeaderLayout>
);
};