From b01aa58e3bbb64710b2883cfa1b99d66f7a75cd4 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Mar 2025 10:17:56 -0400 Subject: [PATCH] DEL: ios-context package RNMenu covers 95% of use case --- components/TooltipMenu.tsx | 72 +----------------------- components/addresses/AddressItem.tsx | 1 + ios/BlueWallet.xcodeproj/project.pbxproj | 4 +- ios/Podfile.lock | 6 -- package-lock.json | 20 ------- package.json | 1 - tests/setup.js | 4 -- 7 files changed, 5 insertions(+), 103 deletions(-) diff --git a/components/TooltipMenu.tsx b/components/TooltipMenu.tsx index addaad844..4d0a6519d 100644 --- a/components/TooltipMenu.tsx +++ b/components/TooltipMenu.tsx @@ -1,7 +1,6 @@ import React, { useCallback, useMemo } from 'react'; -import { Platform, Pressable, TouchableOpacity } from 'react-native'; +import { Platform, TouchableOpacity } from 'react-native'; import { MenuView, MenuAction, NativeActionEvent } from '@react-native-menu/menu'; -import { ContextMenuView, RenderItem, OnPressMenuItemEventObject, IconConfig, MenuElementConfig } from 'react-native-ios-context-menu'; import { ToolTipMenuProps, Action } from './types'; import { useSettings } from '../hooks/context/useSettings'; @@ -9,11 +8,8 @@ const ToolTipMenu = (props: ToolTipMenuProps) => { const { title = '', isMenuPrimaryAction = false, - renderPreview, disabled = false, onPress, - onMenuWillShow, - onMenuWillHide, buttonStyle, onPressMenuItem, children, @@ -23,18 +19,6 @@ const ToolTipMenu = (props: ToolTipMenuProps) => { const { language } = useSettings(); - // Map Menu Items for iOS Context Menu - const mapMenuItemForContextMenuView = useCallback((action: Action) => { - if (!action.id) return null; - return { - actionKey: action.id.toString(), - actionTitle: action.text, - icon: action.icon?.iconValue ? ({ iconType: 'SYSTEM', iconValue: action.icon.iconValue } as IconConfig) : undefined, - state: action.menuState ?? undefined, - attributes: action.disabled ? ['disabled'] : [], - }; - }, []); - // Map Menu Items for RN Menu (supports subactions and displayInline) const mapMenuItemForMenuView = useCallback((action: Action): MenuAction | null => { if (!action.id) return null; @@ -88,11 +72,6 @@ const ToolTipMenu = (props: ToolTipMenuProps) => { return menuItem; }, []); - const contextMenuItems = useMemo(() => { - const flattenedActions = props.actions.flat().filter(action => action.id); - return flattenedActions.map(mapMenuItemForContextMenuView).filter(item => item !== null) as MenuElementConfig[]; - }, [props.actions, mapMenuItemForContextMenuView]); - const menuViewItemsIOS = useMemo(() => { return props.actions .map(actionGroup => { @@ -119,13 +98,6 @@ const ToolTipMenu = (props: ToolTipMenuProps) => { return mergedActions.map(mapMenuItemForMenuView).filter(item => item !== null) as MenuAction[]; }, [props.actions, mapMenuItemForMenuView]); - const handlePressMenuItemForContextMenuView = useCallback( - (event: OnPressMenuItemEventObject) => { - onPressMenuItem(event.nativeEvent.actionKey); - }, - [onPressMenuItem], - ); - const handlePressMenuItemForMenuView = useCallback( ({ nativeEvent }: NativeActionEvent) => { onPressMenuItem(nativeEvent.event); @@ -133,46 +105,6 @@ const ToolTipMenu = (props: ToolTipMenuProps) => { [onPressMenuItem], ); - const renderContextMenuView = () => { - return ( - - {onPress ? ( - - {children} - - ) : ( - children - )} - - ); - }; - const renderMenuView = () => { return ( { ); }; - return props.actions.length > 0 ? (Platform.OS === 'ios' && renderPreview ? renderContextMenuView() : renderMenuView()) : null; + return props.actions.length > 0 ? renderMenuView() : null; }; export default ToolTipMenu; diff --git a/components/addresses/AddressItem.tsx b/components/addresses/AddressItem.tsx index de377f5ee..78254d040 100644 --- a/components/addresses/AddressItem.tsx +++ b/components/addresses/AddressItem.tsx @@ -149,6 +149,7 @@ const AddressItem = ({ item, balanceUnit, walletID, allowSignVerifyMessage }: Ad title={item.address} actions={menuActions} onPressMenuItem={onToolTipPress} + // Revisit once RNMenu has renderPreview prop renderPreview={renderPreview} onPress={navigateToReceive} isButton diff --git a/ios/BlueWallet.xcodeproj/project.pbxproj b/ios/BlueWallet.xcodeproj/project.pbxproj index 4cdd85588..f529c8ec1 100644 --- a/ios/BlueWallet.xcodeproj/project.pbxproj +++ b/ios/BlueWallet.xcodeproj/project.pbxproj @@ -164,7 +164,7 @@ B4D0B2682C1DED67006B6B1B /* ReceiveMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */; }; B4EE583C226703320003363C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B40D4E35225841ED00428FCC /* Assets.xcassets */; }; B4EFF73B2C3F6C5E0095D655 /* MockData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4EFF73A2C3F6C5E0095D655 /* MockData.swift */; }; - C978A716948AB7DEC5B6F677 /* (null) in Frameworks */ = {isa = PBXBuildFile; }; + C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -428,7 +428,7 @@ files = ( 782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */, 764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */, - C978A716948AB7DEC5B6F677 /* (null) in Frameworks */, + C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */, 17CDA0718F42DB2CE856C872 /* libPods-BlueWallet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 00efe5a69..353999a26 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1318,8 +1318,6 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - react-native-ios-context-menu (1.15.3): - - React-Core - react-native-menu (1.2.1): - React - react-native-randombytes (3.6.1): @@ -1939,7 +1937,6 @@ DEPENDENCIES: - react-native-bw-file-access (from `../blue_modules/react-native-bw-file-access`) - react-native-document-picker (from `../node_modules/react-native-document-picker`) - react-native-image-picker (from `../node_modules/react-native-image-picker`) - - react-native-ios-context-menu (from `../node_modules/react-native-ios-context-menu`) - "react-native-menu (from `../node_modules/@react-native-menu/menu`)" - react-native-randombytes (from `../node_modules/react-native-randombytes`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) @@ -2094,8 +2091,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-document-picker" react-native-image-picker: :path: "../node_modules/react-native-image-picker" - react-native-ios-context-menu: - :path: "../node_modules/react-native-ios-context-menu" react-native-menu: :path: "../node_modules/@react-native-menu/menu" react-native-randombytes: @@ -2259,7 +2254,6 @@ SPEC CHECKSUMS: react-native-bw-file-access: fe925b77dbf48500df0b294c6851f8c84607a203 react-native-document-picker: 530879d9e89b490f0954bcc4ab697c5b5e35d659 react-native-image-picker: 130fad649d07e4eec8faaed361d3bba570e1e5ff - react-native-ios-context-menu: 986da6dcba70094bcc2a8049f68410fe7d25aff1 react-native-menu: 2cfe0a3b3c610ed331f00d9f0df300db14ba8692 react-native-randombytes: 3c8f3e89d12487fd03a2f966c288d495415fc116 react-native-safe-area-context: 3e33e7c43c8b74dba436a5a32651cb8d7064c740 diff --git a/package-lock.json b/package-lock.json index bf3316759..6a0b46b5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,7 +78,6 @@ "react-native-handoff": "github:BlueWallet/react-native-handoff#v0.0.4", "react-native-haptic-feedback": "2.3.3", "react-native-image-picker": "7.2.3", - "react-native-ios-context-menu": "github:BlueWallet/react-native-ios-context-menu#e5c1217cd220bfab6e6d9a7c65838545082e3f8e", "react-native-keychain": "9.1.0", "react-native-linear-gradient": "2.8.3", "react-native-localize": "3.4.1", @@ -2459,12 +2458,6 @@ "bugsnag-source-maps": "bin/cli" } }, - "node_modules/@dominicstop/ts-event-emitter": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@dominicstop/ts-event-emitter/-/ts-event-emitter-1.1.0.tgz", - "integrity": "sha512-CcxmJIvUb1vsFheuGGVSQf4KdPZC44XolpUT34+vlal+LyQoBUOn31pjFET5M9ctOxEpt8xa0M3/2M7uUiAoJw==", - "license": "MIT" - }, "node_modules/@egjs/hammerjs": { "version": "2.0.17", "resolved": "https://registry.npmjs.org/@egjs/hammerjs/-/hammerjs-2.0.17.tgz", @@ -22266,19 +22259,6 @@ "react-native": "*" } }, - "node_modules/react-native-ios-context-menu": { - "version": "1.15.3", - "resolved": "git+ssh://git@github.com/BlueWallet/react-native-ios-context-menu.git#e5c1217cd220bfab6e6d9a7c65838545082e3f8e", - "integrity": "sha512-cQnRYOcP3zGQpCEm7w8oSAKDibX3Ncu8G4xof3mXCbXkqwM00Vdbref8ZJcK9omBY5vwEvyNjFLQ+C/NW47iyQ==", - "license": "MIT", - "dependencies": { - "@dominicstop/ts-event-emitter": "^1.1.0" - }, - "peerDependencies": { - "react": "*", - "react-native": "*" - } - }, "node_modules/react-native-keychain": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/react-native-keychain/-/react-native-keychain-9.1.0.tgz", diff --git a/package.json b/package.json index 1729dbf8e..9e5389668 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,6 @@ "react-native-handoff": "github:BlueWallet/react-native-handoff#v0.0.4", "react-native-haptic-feedback": "2.3.3", "react-native-image-picker": "7.2.3", - "react-native-ios-context-menu": "github:BlueWallet/react-native-ios-context-menu#e5c1217cd220bfab6e6d9a7c65838545082e3f8e", "react-native-keychain": "9.1.0", "react-native-linear-gradient": "2.8.3", "react-native-localize": "3.4.1", diff --git a/tests/setup.js b/tests/setup.js index 16ba6217e..b41ce83a6 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -229,10 +229,6 @@ jest.mock('realm', () => { }; }); -jest.mock('react-native-ios-context-menu', () => { - return {}; -}); - jest.mock('rn-qr-generator', () => ({ detect: jest.fn(uri => { if (uri === 'invalid-image') {