-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathUsageWithIcons.tsx
44 lines (39 loc) · 1.56 KB
/
UsageWithIcons.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
import React from 'react';
import { Ionicons } from '@expo/vector-icons';
import { Text } from 'react-native';
import {
HeaderButtons,
HeaderButton,
Item,
HiddenItem,
OverflowMenu,
} from 'react-navigation-header-buttons';
const IoniconsHeaderButton = (props) => (
// the `props` here come from <Item ... />
// you may access them and pass something else to `HeaderButton` if you like
<HeaderButton {...props} IconComponent={Ionicons} iconSize={23} color="blue" />
);
const ReusableSelectItem = ({ onPress }) => <Item title="Edit" onPress={onPress} />;
const ReusableHiddenItem = ({ onPress }) => <HiddenItem title="hidden2" onPress={onPress} />;
export function UsageWithIcons({ navigation }) {
React.useLayoutEffect(() => {
navigation.setOptions({
// in your app, extract the arrow function into a separate component
// to avoid creating a new one every time
headerRight: () => (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<Item title="search" iconName="ios-search" onPress={() => alert('search')} />
<ReusableSelectItem onPress={() => alert('Edit')} />
<OverflowMenu
style={{ marginHorizontal: 10 }}
OverflowIcon={<Ionicons name="ios-more" size={23} color="blue" />}
>
<HiddenItem title="hidden1" onPress={() => alert('hidden1')} />
<ReusableHiddenItem onPress={() => alert('hidden2')} />
</OverflowMenu>
</HeaderButtons>
),
});
}, [navigation]);
return <Text style={{ flex: 1, margin: 20 }}>demo!</Text>;
}