-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathMaterialHeaderButton.tsx
39 lines (37 loc) · 1.23 KB
/
MaterialHeaderButton.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 {
defaultRenderVisibleButton,
HeaderButton,
HeaderButtonsComponentType,
} from 'react-navigation-header-buttons';
import * as React from 'react';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
export const MaterialHeaderButton: HeaderButtonsComponentType = (props) => {
// the `props` here come from <Item ... />
// you may access them and pass something else to `HeaderButton` if you like
return (
<HeaderButton
// the usual way to render:
// IconComponent={MaterialIcons}
// iconSize={23}
// you can customize the colors, by default colors from React navigation theme will be used
// pressColor="blue"
{...props}
// alternative way to customize what is rendered:
renderButton={(itemProps) => {
// access anything that was defined on <Item ... />
const { color, iconName } = itemProps;
return iconName ? (
<MaterialIcons
// @ts-expect-error typings for MaterialIcons are stricter than ours
name={iconName}
color={color}
size={23}
/>
) : (
// will render text with default styles
defaultRenderVisibleButton(itemProps)
);
}}
/>
);
};