forked from vonovak/react-navigation-header-buttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsageWithOverflow.tsx
49 lines (45 loc) · 1.39 KB
/
UsageWithOverflow.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
import React from 'react';
import { MaterialIcons } from '@expo/vector-icons';
import { View, Text } from 'react-native';
import {
HeaderButtons,
HeaderButton,
Item,
HiddenItem,
OverflowMenu,
defaultOnOverflowMenuPress,
} from 'react-navigation-header-buttons';
const MaterialHeaderButton = (props) => (
<HeaderButton {...props} IconComponent={MaterialIcons} iconSize={23} color="blue" />
);
const RightHeader = () => (
<HeaderButtons HeaderButtonComponent={MaterialHeaderButton}>
<Item title="person" iconName="person" onPress={() => alert('person')} />
<Item title="edit" onPress={() => alert('edit')} />
<OverflowMenu
OverflowIcon={<MaterialIcons name="more-vert" size={23} color="blue" />}
pressColor="blue"
onPress={(params) => {
defaultOnOverflowMenuPress({
...params,
cancelButtonLabel: 'cancel - custom iOS label!',
});
}}
>
<HiddenItem title="hidden" onPress={() => alert('hidden shortcut')} />
</OverflowMenu>
</HeaderButtons>
);
export function UsageWithOverflow({ navigation }) {
React.useLayoutEffect(() => {
navigation.setOptions({
headerRight: RightHeader,
// title: 'sfhdskjfh kjsahfkjsahf skjfh askjfhaskjhf sakfhask ',
});
}, [navigation]);
return (
<View style={{ flex: 1 }}>
<Text>default overflow menu handler with custom cancel label</Text>
</View>
);
}