-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathHomeScreen.tsx
81 lines (77 loc) · 2.43 KB
/
HomeScreen.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
72
73
74
75
76
77
78
79
80
81
import * as React from 'react';
import { Text, ScrollView } from 'react-native';
import { ThemeContext } from '../ThemeProvider';
import type { ScreenProps } from '../NavTypes';
import { Button } from '../components/PaddedButton';
import { HeaderButtons, Item } from 'react-navigation-header-buttons';
import { MaterialHeaderButton } from '../components/MaterialHeaderButton';
export function HomeScreen({ navigation }: ScreenProps<'HomeScreen'>) {
React.useLayoutEffect(() => {
navigation.setOptions({
title: 'Header Buttons demo',
headerRight: () => (
<HeaderButtons HeaderButtonComponent={MaterialHeaderButton}>
<Item
title="settings"
iconName="settings"
onPress={() => alert('settings')}
/>
<Item
title="search"
iconName="search"
onPress={() => alert('search')}
/>
</HeaderButtons>
),
});
}, [navigation]);
const _navigateTo = (destinationScreen: any) => {
navigation.navigate(destinationScreen);
};
const { toggleTheme } = React.useContext(ThemeContext);
return (
<ScrollView contentContainerStyle={{ rowGap: 10 }}>
<Text style={{ margin: 15 }}>Explore possible usages with:</Text>
<Button
onPress={() => _navigateTo('UsageWithIcons')}
title="Vector icons"
/>
<Button
onPress={() => _navigateTo('UsageWithOverflow')}
title="Default overflow menu"
/>
<Button
onPress={() => _navigateTo('UsageWithCustomOverflow')}
title="Custom overflow menu action"
/>
<Button
onPress={() => _navigateTo('UsageNativeMenu')}
title="Native menu overflow"
/>
<Button
onPress={() => _navigateTo('UsageWithOverflowComplex')}
title="Overflow menu - all handlers"
/>
<Button
onPress={() => _navigateTo('UsageDifferentFontFamilies')}
title="Different font families in one menu"
/>
<Button
onPress={() => _navigateTo('UsageDisabled')}
title="Disabled state"
/>
<Button
onPress={() => _navigateTo('UsageLeft')}
title="On the left side of header"
/>
<Button
onPress={() => _navigateTo('UsageCustom')}
title="Custom elements"
/>
<Button
onPress={toggleTheme}
title="Toggle Theme (ripple, text and icon color changes)"
/>
</ScrollView>
);
}