forked from vonovak/react-navigation-header-buttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsageLeft.tsx
39 lines (36 loc) · 1.21 KB
/
UsageLeft.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
import React from 'react';
import { MaterialIcons } from '@expo/vector-icons';
import { View } from 'react-native';
import { HeaderButtons, HeaderButton, Item } from 'react-navigation-header-buttons';
import { Button } from './PaddedButton';
const MaterialHeaderButton = (props) => (
<HeaderButton {...props} IconComponent={MaterialIcons} iconSize={23} color="blue" />
);
export function UsageLeft({ navigation, route }) {
React.useLayoutEffect(() => {
navigation.setOptions({
headerLeft: () => (
<HeaderButtons left HeaderButtonComponent={MaterialHeaderButton}>
<Item
title="Test"
iconName={route.params && route.params.showIcon ? 'arrow-back' : undefined}
onPress={() => alert('Test')}
/>
</HeaderButtons>
),
headerRight: () => (
<HeaderButtons HeaderButtonComponent={MaterialHeaderButton}>
<Item title="back" onPress={() => navigation.goBack()} />
</HeaderButtons>
),
});
}, [navigation, route]);
return (
<View>
<Button
onPress={() => navigation.setParams({ showIcon: !(route.params && route.params.showIcon) })}
title="Toggle Icon and Text"
/>
</View>
);
}