You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* extract overflow handlers and e2e.js
* add some docs
* revamp example
* further improvements to docs and types
* fix some flow types
* remove useless stateFromProps
* remove confusing disabled prop
| left: boolean | whether the `HeaderButtons` are on the left from header title | false by default |
46
-
| HeaderButtonComponent: React.ComponentType<\*> | component that renders the buttons | Typically, you'll want to provide a component that wraps `HeaderButton` provided by this package, as seen in the [quick example](#quick-example). However, you're free to use your own component (see `HeaderButton` for reference). |
47
-
| OverflowIcon?: React.Element<\*> | React element for the overflow icon | you need to provide this only if you need an overflow icon |
48
-
| overflowButtonWrapperStyle?: ViewStyleProp | optional styles for overflow button | there are some default styles set, as seen in `OverflowButton.js`|
49
-
| onOverflowMenuPress?: ({ hiddenButtons: Array<React.Element<\*>>, overflowButtonRef: ?View }) => any | function that is called when overflow menu is pressed. | This will override the default handler. Use this prop if you want to customize your overflow button behavior - I will likely not merge PRs that add props for the overflow menu since I prefer these customizations to happen in userland. |
| left: boolean | whether the `HeaderButtons` are on the left from header title | false by default |
47
+
| HeaderButtonComponent: React.ComponentType<any> | component that renders the buttons | Typically, you'll want to provide a component that wraps `HeaderButton` provided by this package, as seen in the [quick example](#quick-example). However, you're free to use your own component (see `HeaderButton` for reference). |
48
+
| OverflowIcon?: React.Element<any> | React element for the overflow icon | you need to provide this only if you need an overflow icon |
49
+
| overflowButtonWrapperStyle?: ViewStyleProp | optional styles for overflow button | there are some default styles set, as seen in `OverflowButton.js`|
50
+
| onOverflowMenuPress?: ({ hiddenButtons: Array<React.Element<any>>, overflowButtonRef: View }) => any | function that is called when overflow menu is pressed. | This will override the default handler. Note the default handler offers (limited) customization. See more below. |
51
+
| overflowButtonTestID?: string | testID to locate the overflow button in e2e tests | the default is available under `import { OVERFLOW_BUTTON_TEST_ID } from 'react-navigation-header-buttons/e2e'`|
| onPress: ?() => any | function to call on press | if this is a falsy value, the button won't react to touches (will be disabled) |
56
-
| title: string | title for the button, required ||
57
-
| show: "always" or "never" | string specifying if the icon should be shown or hidden in overflow menu | "always" by default |
58
-
| ButtonElement?: React.Node | optional React element to show as button. Use this for completely custom buttons. | if neither `IconComponent` nor this is defined, will render text with the `title`|
59
-
| iconName?: string | icon name, used together with the `IconComponent` prop ||
60
-
| buttonStyle?: ViewStyleProp | style to apply to the button | applies to both icon and text |
61
-
| buttonWrapperStyle?: ViewStyleProp | style to apply to the touchable element that wraps the button ||
62
-
| testID?: string | ID to locate the view in e2e tests | testID of the overflow button is exported under `OVERFLOW_BUTTON_TEST_ID`|
| onPress: ?() => any | function to call on press | if this is a falsy value, the button won't react to touches (will be disabled) |
58
+
| title: string | title for the button, required ||
59
+
| show: "always" or "never" | string specifying if the icon should be shown or hidden in overflow menu | the strings are accessible under `Item.SHOW_ALWAYS` and `Item.SHOW_NEVER`. "always" by default |
60
+
| ButtonElement?: React.Node | optional React element to show as button. Use this for completely custom buttons. | if neither `IconComponent` nor `ButtonElement` is defined, will render text with the `title`|
61
+
| iconName?: string | icon name, used together with the `IconComponent` prop ||
62
+
| buttonStyle?: ViewStyleProp | style to apply to the button | applies to both icon and text |
63
+
| buttonWrapperStyle?: ViewStyleProp | style to apply to the touchable element that wraps the button ||
64
+
| testID?: string | ID to locate the view in e2e tests ||
65
+
66
+
Note - as an alternative to `<Item title="edit" show={Item.SHOW_NEVER} onPress={...} />` you can also use `<HiddenItem title="edit" onPress={...} />`
63
67
64
68
`HeaderButton` accepts:
65
69
@@ -73,6 +77,10 @@ You may also pass other props that will be passed to the underlying `react-nativ
73
77
74
78
Please note that `HeaderButton` also requires other props to function correctly. Some of these props are passed from `<Item .. />` (such as `iconName`) and also `<HeaderButtons ... />`. When wrapping `HeaderButton` it is thus important to not forget to pass down all props the wrapping component receives (this is easy using the spread operator), as documented in the [quick example](#quick-example).
75
79
80
+
#### Customize the cancel button label of overflow menu on iOS
81
+
82
+
The default handler for overflow menu is exported as `defaultOnOverflowMenuPress`. On iOS, it uses `ActionSheetIOS` and on Android, it uses `UIManager.showPopupMenu`. One of the usual things you may want to do is override the cancel button label on iOS - see [example](example/screens/UsageWithOverflow.tsx).
83
+
76
84
#### How to integrate in your project
77
85
78
86
This sections covers how you should use the library in your project. Please note that there are numerous [example screens](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/navbar-buttons-demo/screens).
0 commit comments