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
A small component for using context menu's on iOS.
4
+
5
+
<br><br>
7
6
8
7
## 🚧⚠️ Documentation WIP ⚠️🚧
9
8
@@ -34,8 +33,6 @@
34
33
|`1.4`| iOS 10 to iOS 15<br>Xcode 13+ |
35
34
|`1.3` and Below | iOS 10 to 14<br>Xcode 12+ |
36
35
37
-
📝 **Note**: Supports projects targeting iOS 10 but will use the action sheet fallback when running on iOS 12 and older.
38
-
39
36
<br><br>
40
37
41
38
## Table of Contents
@@ -117,8 +114,6 @@ Very special thanks to: [junzhengca](https://github.com/junzhengca), [brentvatne
117
114
118
115
<br><br>
119
116
120
-
<br><br>
121
-
122
117
## A. Introduction
123
118
124
119
A react native component to use [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) on iOS 13 and later.
@@ -159,7 +154,7 @@ A react native component to use [`UIMenu`](https://developer.apple.com/documenta
159
154
`ContextMenuView``ActionSheetIOS` fallback for simple example 1 to 9
160
155

161
156
162
-
`ContextMenuView``ActionSheetIOS` fallback for context menu view test 1 to 6
157
+
`ContextMenuView``ActionSheetIOS` fallback for context menu view test 1 to 6 (removed in `v3.x`+).
163
158

164
159
165
160
`ContextMenuButton` examples, **Left**: [Example 1](#ContextMenuButton-Example-01), and **Right**: [Example 2](#ContextMenuButton-Example-02)
@@ -174,7 +169,7 @@ A react native component to use [`UIMenu`](https://developer.apple.com/documenta
174
169
* Extensive support for SF Symbols configuration (e.g. `pointSize`, `weight`, `scale`, `hierarchicalColor`, `paletteColors`).
175
170
* Support for iOS 14 functionality (like the `UIButton` context menu, dynamically updating the menu while it's visible, etc).
176
171
* Support for setting (almost) all of the native [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) and [`UIAction`](https://developer.apple.com/documentation/uikit/uiaction) properties (e.g. `UIMenuElementState`, `MenuElementAtrributes`, `discoverabilityTitle`, etc.)
177
-
* Basic `ActionSheetIOS` menu fallback for iOS 12 and below.
172
+
* Basic `ActionSheetIOS` menu fallback for iOS 12 and below (removed in `v3.x`+).
178
173
* Support for creating custom context menu previews (with support for dynamic or fixed preview sizes, setting the [`UIPreviewParameters`](https://developer.apple.com/documentation/uikit/uipreviewparameters), specifying a [`UITargetedPreview`](https://developer.apple.com/documentation/uikit/uitargetedpreview), etc).
179
174
* Support for custom auxiliary previews (experimental).
180
175
* Support for deferred context menu items.
@@ -253,7 +248,7 @@ pod update
253
248
254
249
### Troubleshooting
255
250
256
-
If you encounter any errors/bugs while using this library, or want a particular feature implemented, please create an issue! (my inbox is a mess, please feel free to tag me). ✨
251
+
If you encounter any errors/bugs while using this library, or want a particular feature implemented, please create an issue (my inbox is a mess, please feel free to tag me). ✨
| 🔤 `shouldWaitForMenuToHide`<br/>`BeforeFiringOnPressMenuItem`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| If set to `true` (which it is by default), the `onPressMenuItem` event will be triggered after the context menu has been hidden (i.e. after `onMenuDidHide` event is triggered).<br><br>Set this to `false` if you want `onPressMenuItem` to trigger as soon as an item has been pressed in the context menu.<br><br>📝 **Note**: Layout updates while the context menu is transitioning from it's open to hidden state might cause layout flickering (e.g. [Issue #43](https://github.com/dominicstop/react-native-ios-context-menu/issues/43)). |
390
385
| 🔤 `isContextMenuEnabled`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Enables or disables the context menu. Useful if you want to temporarily disable the context menu. |
391
386
| 🔤 `lazyPreview`<br/><br/>⚛️ `boolean`<br><br>✳️ **Default**: `true`| If set to `true` (which it is by default), the custom context menu preview (i.e. the component returned from the `ContextMenuView.renderPreview` prop) and the auxiliary preview (i.e. the component returned from the `ContextMenuView.renderAuxillaryPreview` prop) are only mounted/rendered when the context menu is visible.<br><br>Set this to `false` if you want the preview content to be always mounted. |
392
-
| 🔤 `shouldEnable`<br>`AggressiveCleanup`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Deprecated. This prop no longer does anything (see `shouldCleanupOnComponentWillUnmount`<br>`ForMenuPreview`, and `shouldCleanup`<br/>`OnComponentWillUnmountForAuxPreview`<br/>). |
393
-
| 🔤 `useActionSheetFallback`<br><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Context menus are only supported on iOS 13+ (i.e context menus are not supported on iOS 12, and below).<br><br>On iOS 12 and below, a long press on a `ContextMenuView` will show a [`ActionSheetIOS`](https://reactnative.dev/docs/actionsheetios#docsNav) menu based on the current `menuConfig` prop.<br><br> If you want to disable this behavior, set this prop to false.<br><br>📝 **Note**: Default value is `false` on iOS 13+, and `true` on iOS 12 and below. |
394
387
| 🔤 `renderPreview`<br/><br/>⚛️ [`() => React.ReactElement`](PLACE_HOLDER_LINK)| This prop is a "render" prop, i.e it accepts a function that returns a react component.<br><br>The returned component will displayed in the context menu preview. |
| 🔤 `internalCleanupMode`<br/><br/>⚛️ `RNICleanupMode`<br/><br/>✳️ **Default**: `automatic` | Internally, a clean up routine is triggered whenever a component is unmounted.<br><br>However, if the clean up routine is triggered too early, this will lead to the context menu component disappearing (E.g. [issue #34](https://github.com/dominicstop/react-native-ios-context-menu/issues/34)).<br><br>If you are experiencing this issue, you can disable the clean up routine from triggering altogether by setting this prop to `disabled`.<br><br>Additionally, you can also try setting this prop to either to `viewController`, `didMoveToWindowNil`, or `reactComponentWillUnmount`.<br/><br/>`viewController` mode will trigger the clean up routine via the `UIViewController.viewWillDisappear` lifecycle method, and `didMoveToWindowNil` will trigger the cleanup routine during the `UIView.didMoveToWindow` lifecycle method, while the `reactComponentWillUnmount` mode on the other hand, will trigger the clean up routine via the `componentWillUnmount` react lifecycle event. |
399
-
| 🔤 `shouldCleanupOnComponent`<br>`WillUnmountForMenuPreview`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `false`| If set to `true`, the custom preview is immediately freed from memory once the context menu is closed.<br/><br/>📝 **Note**: For the immediately cleanup to take effect, the `lazyPreview` prop also needs to be enabled. |
400
-
| 🔤 `shouldCleanupOnComponent`<br/>`WillUnmountForAuxPreview`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `false`| If set to `true`, the aux. preview is immediately freed from memory once the context menu is closed.<br/><br/>📝 **Note**: For the immediately cleanup to take effect, the `lazyPreview` prop also needs to be enabled. |
401
391
402
392
<br><br>
403
393
@@ -445,7 +435,7 @@ For basic usage, please see [Example 1](#contextmenubutton-example-01) section.
445
435
446
436
* The only difference between them is that the `ContextMenuButton` component does not have a preview, and it can be immediately shown when its tapped instead of having to do a long press. See [Example 2](#422-contextmenubutton-simple-example-2) for more details.<br>
447
437
448
-
* Note that `ContextMenuButton` is only available on iOS 14 and above. On iOS 13, it will use a `ContextMenuButton`, and on iOS 12 and below, it will use the `ActionSheetFallback` module to present a `ActionSheetIOS` menu.<br>
438
+
* Note that `ContextMenuButton` is only available on iOS 14 and above. On iOS 13, it will use a `ContextMenuButton`,<br>
449
439
450
440
* If you want to add additional touch events, you can wrap this component inside a button component (e.g. `TouchableOpacity`). <br>
451
441
* When wrapping this component inside a button, please make sure to set the `useActionSheetFallback` prop to `false`.
@@ -488,27 +478,6 @@ For basic usage, please see [Example 1](#contextmenubutton-example-01) section.
488
478
489
479
<br>
490
480
491
-
#### `ActionSheetFallback` Module
492
-
493
-
A module to show a `ActionSheetIOS` menu based on a `MenuConfig` object.
494
-
495
-
This module attempts to approximate `UIMenu` behavior using `ActionSheetIOS`, so it's very limited (i.e. it does not support menu/action icons, etc.), but it does support things like submenu's, destructive actions/menu's, inline submenu's, and hidden actions.
496
-
497
-
<br>
498
-
499
-
* Import the module like this: `import { ActionSheetFallback } from "react-native-ios-context-menu";`<br><br>
500
-
501
-
* To present a `ActionSheetIOS` menu, call `const selectedAction = await ActionSheetFallback.show(menuConfig)`
| 🔤 `show` <br/><br/>⚛️ `(menuConfig: MenuConfig):`<br/>`Promise<MenuAction ¦ null>`| This function accepts a `MenuConfig` object and returns the selected `MenuAction` object or null if cancelled. |
A small component for using context menu's on iOS.
4
+
5
+
<br><br>
7
6
8
7
## 🚧⚠️ Documentation WIP ⚠️🚧
9
8
@@ -115,8 +114,6 @@ Very special thanks to: [junzhengca](https://github.com/junzhengca), [brentvatne
115
114
116
115
<br><br>
117
116
118
-
<br><br>
119
-
120
117
## A. Introduction
121
118
122
119
A react native component to use [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) on iOS 13 and later.
@@ -157,7 +154,7 @@ A react native component to use [`UIMenu`](https://developer.apple.com/documenta
157
154
`ContextMenuView``ActionSheetIOS` fallback for simple example 1 to 9
158
155

159
156
160
-
`ContextMenuView``ActionSheetIOS` fallback for context menu view test 1 to 6
157
+
`ContextMenuView``ActionSheetIOS` fallback for context menu view test 1 to 6 (removed in `v3.x`+).
161
158

162
159
163
160
`ContextMenuButton` examples, **Left**: [Example 1](#ContextMenuButton-Example-01), and **Right**: [Example 2](#ContextMenuButton-Example-02)
@@ -172,7 +169,7 @@ A react native component to use [`UIMenu`](https://developer.apple.com/documenta
172
169
* Extensive support for SF Symbols configuration (e.g. `pointSize`, `weight`, `scale`, `hierarchicalColor`, `paletteColors`).
173
170
* Support for iOS 14 functionality (like the `UIButton` context menu, dynamically updating the menu while it's visible, etc).
174
171
* Support for setting (almost) all of the native [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) and [`UIAction`](https://developer.apple.com/documentation/uikit/uiaction) properties (e.g. `UIMenuElementState`, `MenuElementAtrributes`, `discoverabilityTitle`, etc.)
175
-
* Basic `ActionSheetIOS` menu fallback for iOS 12 and below.
172
+
* Basic `ActionSheetIOS` menu fallback for iOS 12 and below (removed in `v3.x`+).
176
173
* Support for creating custom context menu previews (with support for dynamic or fixed preview sizes, setting the [`UIPreviewParameters`](https://developer.apple.com/documentation/uikit/uipreviewparameters), specifying a [`UITargetedPreview`](https://developer.apple.com/documentation/uikit/uitargetedpreview), etc).
177
174
* Support for custom auxiliary previews (experimental).
Copy file name to clipboardExpand all lines: docs/README-02-Docs.md
+1-27Lines changed: 1 addition & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,15 +19,10 @@
19
19
| 🔤 `shouldWaitForMenuToHide`<br/>`BeforeFiringOnPressMenuItem`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| If set to `true` (which it is by default), the `onPressMenuItem` event will be triggered after the context menu has been hidden (i.e. after `onMenuDidHide` event is triggered).<br><br>Set this to `false` if you want `onPressMenuItem` to trigger as soon as an item has been pressed in the context menu.<br><br>📝 **Note**: Layout updates while the context menu is transitioning from it's open to hidden state might cause layout flickering (e.g. [Issue #43](https://github.com/dominicstop/react-native-ios-context-menu/issues/43)). |
20
20
| 🔤 `isContextMenuEnabled`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Enables or disables the context menu. Useful if you want to temporarily disable the context menu. |
21
21
| 🔤 `lazyPreview`<br/><br/>⚛️ `boolean`<br><br>✳️ **Default**: `true`| If set to `true` (which it is by default), the custom context menu preview (i.e. the component returned from the `ContextMenuView.renderPreview` prop) and the auxiliary preview (i.e. the component returned from the `ContextMenuView.renderAuxillaryPreview` prop) are only mounted/rendered when the context menu is visible.<br><br>Set this to `false` if you want the preview content to be always mounted. |
22
-
| 🔤 `shouldEnable`<br>`AggressiveCleanup`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Deprecated. This prop no longer does anything (see `shouldCleanupOnComponentWillUnmount`<br>`ForMenuPreview`, and `shouldCleanup`<br/>`OnComponentWillUnmountForAuxPreview`<br/>). |
23
-
| 🔤 `useActionSheetFallback`<br><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `true`| Context menus are only supported on iOS 13+ (i.e context menus are not supported on iOS 12, and below).<br><br>On iOS 12 and below, a long press on a `ContextMenuView` will show a [`ActionSheetIOS`](https://reactnative.dev/docs/actionsheetios#docsNav) menu based on the current `menuConfig` prop.<br><br> If you want to disable this behavior, set this prop to false.<br><br>📝 **Note**: Default value is `false` on iOS 13+, and `true` on iOS 12 and below. |
24
22
| 🔤 `renderPreview`<br/><br/>⚛️ [`() => React.ReactElement`](PLACE_HOLDER_LINK)| This prop is a "render" prop, i.e it accepts a function that returns a react component.<br><br>The returned component will displayed in the context menu preview. |
| 🔤 `internalCleanupMode`<br/><br/>⚛️ `RNICleanupMode`<br/><br/>✳️ **Default**: `automatic` | Internally, a clean up routine is triggered whenever a component is unmounted.<br><br>However, if the clean up routine is triggered too early, this will lead to the context menu component disappearing (E.g. [issue #34](https://github.com/dominicstop/react-native-ios-context-menu/issues/34)).<br><br>If you are experiencing this issue, you can disable the clean up routine from triggering altogether by setting this prop to `disabled`.<br><br>Additionally, you can also try setting this prop to either to `viewController`, `didMoveToWindowNil`, or `reactComponentWillUnmount`.<br/><br/>`viewController` mode will trigger the clean up routine via the `UIViewController.viewWillDisappear` lifecycle method, and `didMoveToWindowNil` will trigger the cleanup routine during the `UIView.didMoveToWindow` lifecycle method, while the `reactComponentWillUnmount` mode on the other hand, will trigger the clean up routine via the `componentWillUnmount` react lifecycle event. |
29
-
| 🔤 `shouldCleanupOnComponent`<br>`WillUnmountForMenuPreview`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `false`| If set to `true`, the custom preview is immediately freed from memory once the context menu is closed.<br/><br/>📝 **Note**: For the immediately cleanup to take effect, the `lazyPreview` prop also needs to be enabled. |
30
-
| 🔤 `shouldCleanupOnComponent`<br/>`WillUnmountForAuxPreview`<br/><br/>⚛️ `boolean`<br/><br/>✳️ **Default**: `false`| If set to `true`, the aux. preview is immediately freed from memory once the context menu is closed.<br/><br/>📝 **Note**: For the immediately cleanup to take effect, the `lazyPreview` prop also needs to be enabled. |
31
26
32
27
<br><br>
33
28
@@ -75,7 +70,7 @@ For basic usage, please see [Example 1](#contextmenubutton-example-01) section.
75
70
76
71
* The only difference between them is that the `ContextMenuButton` component does not have a preview, and it can be immediately shown when its tapped instead of having to do a long press. See [Example 2](#422-contextmenubutton-simple-example-2) for more details.<br>
77
72
78
-
* Note that `ContextMenuButton` is only available on iOS 14 and above. On iOS 13, it will use a `ContextMenuButton`, and on iOS 12 and below, it will use the `ActionSheetFallback` module to present a `ActionSheetIOS` menu.<br>
73
+
* Note that `ContextMenuButton` is only available on iOS 14 and above. On iOS 13, it will use a `ContextMenuButton`,<br>
79
74
80
75
* If you want to add additional touch events, you can wrap this component inside a button component (e.g. `TouchableOpacity`). <br>
81
76
* When wrapping this component inside a button, please make sure to set the `useActionSheetFallback` prop to `false`.
@@ -118,27 +113,6 @@ For basic usage, please see [Example 1](#contextmenubutton-example-01) section.
118
113
119
114
<br>
120
115
121
-
#### `ActionSheetFallback` Module
122
-
123
-
A module to show a `ActionSheetIOS` menu based on a `MenuConfig` object.
124
-
125
-
This module attempts to approximate `UIMenu` behavior using `ActionSheetIOS`, so it's very limited (i.e. it does not support menu/action icons, etc.), but it does support things like submenu's, destructive actions/menu's, inline submenu's, and hidden actions.
126
-
127
-
<br>
128
-
129
-
* Import the module like this: `import { ActionSheetFallback } from "react-native-ios-context-menu";`<br><br>
130
-
131
-
* To present a `ActionSheetIOS` menu, call `const selectedAction = await ActionSheetFallback.show(menuConfig)`
| 🔤 `show` <br/><br/>⚛️ `(menuConfig: MenuConfig):`<br/>`Promise<MenuAction ¦ null>`| This function accepts a `MenuConfig` object and returns the selected `MenuAction` object or null if cancelled. |
0 commit comments