-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathUsageLeft.tsx
43 lines (41 loc) · 1.34 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
40
41
42
43
import * as React from 'react';
import { HeaderButtons, Item } from 'react-navigation-header-buttons';
import type { ScreenProps } from '../NavTypes';
import { MaterialHeaderButton } from '../components/MaterialHeaderButton';
import { Button } from '../components/PaddedButton';
import { ScreenBody } from '../components/ScreenBody';
export function UsageLeft({ navigation, route }: ScreenProps<'UsageLeft'>) {
React.useLayoutEffect(() => {
navigation.setOptions({
headerLeft: () => (
<HeaderButtons left HeaderButtonComponent={MaterialHeaderButton}>
<Item
title="Test"
iconName={
route.params && route.params.showIcon ? 'arrow-back' : undefined
}
style={{ backgroundColor: 'pink', marginRight: 10 }}
onPress={() => alert('Test')}
/>
</HeaderButtons>
),
headerRight: () => (
<HeaderButtons HeaderButtonComponent={MaterialHeaderButton}>
<Item title="back" onPress={() => navigation.goBack()} />
</HeaderButtons>
),
});
}, [navigation, route]);
return (
<ScreenBody>
<Button
onPress={() =>
navigation.setParams({
showIcon: !(route.params && route.params.showIcon),
})
}
title="Toggle Icon and Text"
/>
</ScreenBody>
);
}