️ Impl. ContextMenuView.isContextMenuEnabled

This commit is contained in:
Dominic Go 2021-11-30 07:45:18 +08:00
parent 748997dd5e
commit 6b606da0fd
6 changed files with 13 additions and 4 deletions

View File

@ -54,7 +54,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"

View File

@ -31,9 +31,9 @@ RCT_EXPORT_VIEW_PROPERTY(onPressMenuItem , RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(menuConfig, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(enableContextMenu , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isMenuPrimaryAction, BOOL);
RCT_EXPORT_VIEW_PROPERTY(enableContextMenu , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isMenuPrimaryAction , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isContextMenuEnabled, BOOL);
// MARK: - View Manager Commands
// ------------------------------

View File

@ -110,6 +110,8 @@ class RNIContextMenuView: UIView {
@objc var shouldUseDiscoverabilityTitleAsFallbackValueForSubtitle = true;
@objc var isContextMenuEnabled = true;
// MARK: - Init
// ------------
@ -320,6 +322,8 @@ extension RNIContextMenuView: UIContextMenuInteractionDelegate {
configurationForMenuAtLocation location: CGPoint
) -> UIContextMenuConfiguration? {
guard self.isContextMenuEnabled else { return nil };
self.onMenuWillCreate?([:]);
return UIContextMenuConfiguration(

View File

@ -35,4 +35,6 @@ RCT_EXPORT_VIEW_PROPERTY(previewConfig, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(shouldUseDiscoverabilityTitleAsFallbackValueForSubtitle, BOOL);
RCT_EXPORT_VIEW_PROPERTY(isContextMenuEnabled, BOOL);
@end

View File

@ -23,6 +23,7 @@ export type ContextMenuViewBaseProps = Pick<RNIContextMenuViewProps,
| 'menuConfig'
| 'previewConfig'
| 'shouldUseDiscoverabilityTitleAsFallbackValueForSubtitle'
| 'isContextMenuEnabled'
// Lifecycle Events
| 'onMenuWillShow'
| 'onMenuWillHide'

View File

@ -35,6 +35,8 @@ export type RNIContextMenuViewProps = ViewProps & {
* */
shouldUseDiscoverabilityTitleAsFallbackValueForSubtitle?: boolean;
isContextMenuEnabled?: boolean;
// Events - Lifecycle
// ------------------