From 66f249c29338671a95ac994773cab13a17496148 Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 27 Feb 2025 10:07:28 -0700 Subject: [PATCH 1/8] change modals to magic-modal library --- __mocks__/react-native-magic-modal.js | 16 + __tests__/About.snapshot.tsx | 3 +- __tests__/AddressBook.snapshot.tsx | 3 +- __tests__/Header.snapshot.tsx | 2 - .../History.ValueTransferDetail.unit.tsx | 48 +- __tests__/History.snapshot.tsx | 2 - __tests__/Info.es.unit.tsx | 3 +- __tests__/Info.snapshot.tsx | 3 +- __tests__/Info.us.unit.tsx | 3 +- __tests__/Insight.snapshot.tsx | 4 +- __tests__/LoadedApp.snapshot.tsx | 1 + __tests__/Memo.snapshot.tsx | 3 +- __tests__/MessagesAddress.snapshot.tsx | 2 - __tests__/Pools.snapshot.tsx | 4 +- __tests__/PrivKey.snapshot.tsx | 3 - __tests__/Rescan.snapshot.tsx | 3 +- __tests__/Send.snapshot.tsx | 2 - __tests__/Settings.snapshot.tsx | 2 - __tests__/SyncReport.snapshot.tsx | 3 +- .../__snapshots__/LoadedApp.snapshot.tsx.snap | 1 + app/AppState/AppContextLoaded.ts | 8 +- app/AppState/AppStateLoaded.ts | 20 - app/LoadedApp/LoadedApp.tsx | 764 ++++++------------ app/LoadedApp/components/Menu.tsx | 7 +- app/context/contextAppLoaded.tsx | 4 +- components/About/About.tsx | 7 +- components/AddressBook/AddressBook.tsx | 25 +- components/Components/AddressItem.tsx | 6 +- components/Components/SingleAddress.tsx | 2 +- components/Components/TextInputAddress.tsx | 19 +- components/Header/Header.tsx | 28 +- components/History/History.tsx | 86 +- .../components/ValueTransferDetail.tsx | 149 ++-- .../History/components/ValueTransferLine.tsx | 26 +- components/Info/Info.tsx | 7 +- components/Insight/Insight.tsx | 8 +- components/Memo/Memo.tsx | 9 +- components/Messages/Messages.tsx | 4 - components/Messages/MessagesAddress.tsx | 6 - components/Messages/MessagesAll.tsx | 9 +- components/Messages/MessagesModal.tsx | 10 +- .../Messages/components/ContactLine.tsx | 12 +- .../Messages/components/ContactList.tsx | 66 +- .../Messages/components/MessageLine.tsx | 15 +- .../Messages/components/MessageList.tsx | 80 +- components/Pools/Pools.tsx | 7 +- components/PrivKey/PrivKey.tsx | 7 +- components/Receive/Receive.tsx | 4 - components/Rescan/Rescan.tsx | 9 +- components/Seed/Seed.tsx | 20 +- components/Send/Send.tsx | 140 ++-- components/Send/components/Confirm.tsx | 10 +- components/Send/components/ScannerAddress.tsx | 11 +- components/Settings/Settings.tsx | 8 +- components/SyncReport/SyncReport.tsx | 7 +- components/Ufvk/ImportUfvk.tsx | 19 +- components/Ufvk/ShowUfvk.tsx | 20 +- components/Ufvk/components/ScannerUfvk.tsx | 9 +- package.json | 1 + patches/react-native-qrcode-svg+6.3.14.patch | 11 - 60 files changed, 672 insertions(+), 1099 deletions(-) create mode 100644 __mocks__/react-native-magic-modal.js delete mode 100644 patches/react-native-qrcode-svg+6.3.14.patch diff --git a/__mocks__/react-native-magic-modal.js b/__mocks__/react-native-magic-modal.js new file mode 100644 index 000000000..84b384eb1 --- /dev/null +++ b/__mocks__/react-native-magic-modal.js @@ -0,0 +1,16 @@ +import { View } from 'react-native'; +import React from 'react'; + +export const useMagicModal = jest.fn(() => ({ + hide: jest.fn(), +})); + +export const magicModal = { + show: jest.fn(), + hide: jest.fn(), + hideAll: jest.fn(), + enableFullWindowOverlay: jest.fn(), + disableFullWindowOverlay: jest.fn(), +}; + +export const MagicModalPortal = () => ; diff --git a/__tests__/About.snapshot.tsx b/__tests__/About.snapshot.tsx index a0209eeb3..570d579ed 100644 --- a/__tests__/About.snapshot.tsx +++ b/__tests__/About.snapshot.tsx @@ -66,10 +66,9 @@ describe('Component About - test', () => { state.translate = mockTranslate; state.info = mockInfo; state.totalBalance = mockTotalBalance; - const onClose = jest.fn(); const about = render( - + , ); expect(about.toJSON()).toMatchSnapshot(); diff --git a/__tests__/AddressBook.snapshot.tsx b/__tests__/AddressBook.snapshot.tsx index b8ae0eb81..2837cf47d 100644 --- a/__tests__/AddressBook.snapshot.tsx +++ b/__tests__/AddressBook.snapshot.tsx @@ -61,11 +61,10 @@ describe('Component Address Book - test', () => { const state = defaultAppContextLoaded; state.addressBook = mockAddressBook; state.translate = mockTranslate; - const onClose = jest.fn(); const onSet = jest.fn(); const ab: any = render( - + , ); expect(ab.toJSON()).toMatchSnapshot(); diff --git a/__tests__/Header.snapshot.tsx b/__tests__/Header.snapshot.tsx index 552278907..9a330c474 100644 --- a/__tests__/Header.snapshot.tsx +++ b/__tests__/Header.snapshot.tsx @@ -89,10 +89,8 @@ describe('Component Header - test', () => { poolsMoreInfoOnClick={onFunction} syncingStatusMoreInfoOnClick={onFunction} toggleMenuDrawer={onFunction} - setComputingModalVisible={onFunction} setBackgroundError={onFunction} setPrivacyOption={onFunction} - setUfvkViewModalVisible={onFunction} addLastSnackbar={onFunction} setShieldingAmount={onFunction} /> diff --git a/__tests__/History.ValueTransferDetail.unit.tsx b/__tests__/History.ValueTransferDetail.unit.tsx index ee3b9e5af..ea3aefb6a 100644 --- a/__tests__/History.ValueTransferDetail.unit.tsx +++ b/__tests__/History.ValueTransferDetail.unit.tsx @@ -105,22 +105,17 @@ describe('Component History ValueTransferDetail - test', () => { state.info = mockInfo; state.totalBalance = mockTotalBalance; state.valueTransfers = mockValueTransfers; - const onClose = jest.fn(); const onSetOption = jest.fn(); - const onMove = jest.fn(); test('History ValueTransferDetail - sent ValueTransfer with 2 addresses', () => { render( , ).toJSON(); @@ -137,13 +132,10 @@ describe('Component History ValueTransferDetail - test', () => { , ); @@ -157,14 +149,11 @@ describe('Component History ValueTransferDetail - test', () => { render( , ); @@ -178,13 +167,10 @@ describe('Component History ValueTransferDetail - test', () => { , ); @@ -200,13 +186,10 @@ describe('Component History ValueTransferDetail - test', () => { , ); @@ -219,14 +202,11 @@ describe('Component History ValueTransferDetail - test', () => { render( , ); diff --git a/__tests__/History.snapshot.tsx b/__tests__/History.snapshot.tsx index beb26c09e..8a99f472a 100644 --- a/__tests__/History.snapshot.tsx +++ b/__tests__/History.snapshot.tsx @@ -136,7 +136,6 @@ describe('Component History - test', () => { toggleMenuDrawer={onFunction} poolsMoreInfoOnClick={onFunction} syncingStatusMoreInfoOnClick={onFunction} - setComputingModalVisible={onFunction} setPrivacyOption={onFunction} setShieldingAmount={onFunction} setScrollToTop={onFunction} @@ -164,7 +163,6 @@ describe('Component History - test', () => { toggleMenuDrawer={onFunction} poolsMoreInfoOnClick={onFunction} syncingStatusMoreInfoOnClick={onFunction} - setComputingModalVisible={onFunction} setPrivacyOption={onFunction} setShieldingAmount={onFunction} setScrollToTop={onFunction} diff --git a/__tests__/Info.es.unit.tsx b/__tests__/Info.es.unit.tsx index d8c61f986..262b52c24 100644 --- a/__tests__/Info.es.unit.tsx +++ b/__tests__/Info.es.unit.tsx @@ -66,10 +66,9 @@ describe('Component Info - test', () => { state.info = mockInfo; state.zecPrice = mockZecPrice; state.currency = CurrencyEnum.USDCurrency; - const onClose = jest.fn(); render( - + , ); screen.getByText('$ 33,33'); diff --git a/__tests__/Info.snapshot.tsx b/__tests__/Info.snapshot.tsx index bfd17bc5b..da5167820 100644 --- a/__tests__/Info.snapshot.tsx +++ b/__tests__/Info.snapshot.tsx @@ -68,10 +68,9 @@ describe('Component Info - test', () => { state.zecPrice = mockZecPrice; state.translate = mockTranslate; state.totalBalance = mockTotalBalance; - const onClose = jest.fn(); const info: any = render( - + , ); expect(info.toJSON()).toMatchSnapshot(); diff --git a/__tests__/Info.us.unit.tsx b/__tests__/Info.us.unit.tsx index bcd21cd9e..f86a84ff4 100644 --- a/__tests__/Info.us.unit.tsx +++ b/__tests__/Info.us.unit.tsx @@ -66,10 +66,9 @@ describe('Component Info - test', () => { state.info = mockInfo; state.zecPrice = mockZecPrice; state.currency = CurrencyEnum.USDCurrency; - const onClose = jest.fn(); render( - + , ); screen.getByText('$ 33.33'); diff --git a/__tests__/Insight.snapshot.tsx b/__tests__/Insight.snapshot.tsx index 6e21ef9b6..4449e0604 100644 --- a/__tests__/Insight.snapshot.tsx +++ b/__tests__/Insight.snapshot.tsx @@ -62,10 +62,10 @@ describe('Component Insight - test', () => { state.translate = mockTranslate; state.info = mockInfo; state.totalBalance = mockTotalBalance; - const onClose = jest.fn(); + const onSet = jest.fn(); const insight = render( - + , ); expect(insight.toJSON()).toMatchSnapshot(); diff --git a/__tests__/LoadedApp.snapshot.tsx b/__tests__/LoadedApp.snapshot.tsx index fc370be8a..3fec2bce6 100644 --- a/__tests__/LoadedApp.snapshot.tsx +++ b/__tests__/LoadedApp.snapshot.tsx @@ -134,6 +134,7 @@ jest.mock('react-native-gesture-handler', () => { return { RNGestureHandlerModule: RN, + GestureHandlerRootView: ({ children }: {children: React.ReactNode}) => children, }; }); jest.mock('react-native-keychain', () => ({ diff --git a/__tests__/Memo.snapshot.tsx b/__tests__/Memo.snapshot.tsx index 07debc685..2ad7b8a77 100644 --- a/__tests__/Memo.snapshot.tsx +++ b/__tests__/Memo.snapshot.tsx @@ -58,11 +58,10 @@ describe('Component Memo - test', () => { test('Memo - snapshot', () => { const state = defaultAppContextLoaded; state.translate = mockTranslate; - const onClose = jest.fn(); const onSetMemo = jest.fn(); const memo = render( - + , ); expect(memo.toJSON()).toMatchSnapshot(); diff --git a/__tests__/MessagesAddress.snapshot.tsx b/__tests__/MessagesAddress.snapshot.tsx index d77a3f813..b7d1aa7df 100644 --- a/__tests__/MessagesAddress.snapshot.tsx +++ b/__tests__/MessagesAddress.snapshot.tsx @@ -126,8 +126,6 @@ describe('Component Messages Address - test', () => { setScrollToBottom={onFunction} scrollToBottom={false} address={mockAddresses[0].uOrchardAddress} - closeModal={onFunction} - openModal={onFunction} sendTransaction={onFunction} setServerOption={onFunction} /> diff --git a/__tests__/Pools.snapshot.tsx b/__tests__/Pools.snapshot.tsx index d13cc6e9c..ed6d9170f 100644 --- a/__tests__/Pools.snapshot.tsx +++ b/__tests__/Pools.snapshot.tsx @@ -65,11 +65,11 @@ describe('Component Pools - test', () => { state.translate = mockTranslate; state.info = mockInfo; state.totalBalance = mockTotalBalance; - const onClose = jest.fn(); + const onSet = jest.fn(); test('Pools - snapshot', () => { const pools = render( - + , ); expect(pools.toJSON()).toMatchSnapshot(); diff --git a/__tests__/PrivKey.snapshot.tsx b/__tests__/PrivKey.snapshot.tsx index 6c80240c5..c8db20ab9 100644 --- a/__tests__/PrivKey.snapshot.tsx +++ b/__tests__/PrivKey.snapshot.tsx @@ -65,7 +65,6 @@ describe('Component PrivKey - test', () => { state.translate = mockTranslate; state.info = mockInfo; state.totalBalance = mockTotalBalance; - const onClose = jest.fn(); test('PrivKey Private - snapshot', () => { const privKey = render( @@ -73,7 +72,6 @@ describe('Component PrivKey - test', () => { address={'UA-12345678901234567890'} keyType={0} privKey={'priv-key-12345678901234567890'} - closeModal={onClose} /> , ); @@ -86,7 +84,6 @@ describe('Component PrivKey - test', () => { address={'UA-12345678901234567890'} keyType={1} privKey={'view-key-12345678901234567890'} - closeModal={onClose} /> , ); diff --git a/__tests__/Rescan.snapshot.tsx b/__tests__/Rescan.snapshot.tsx index d4d78dd03..80688d239 100644 --- a/__tests__/Rescan.snapshot.tsx +++ b/__tests__/Rescan.snapshot.tsx @@ -63,12 +63,11 @@ describe('Component Rescan - test', () => { state.info = mockInfo; state.totalBalance = mockTotalBalance; state.wallet = mockWallet; - const onClose = jest.fn(); const onRescan = jest.fn(); test('Rescan - snapshot', () => { const rescan = render( - + , ); expect(rescan.toJSON()).toMatchSnapshot(); diff --git a/__tests__/Send.snapshot.tsx b/__tests__/Send.snapshot.tsx index 2101e1d8a..7074edbba 100644 --- a/__tests__/Send.snapshot.tsx +++ b/__tests__/Send.snapshot.tsx @@ -99,7 +99,6 @@ describe('Component Send - test', () => { sendTransaction={onFunction} clearToAddr={onFunction} toggleMenuDrawer={onFunction} - setComputingModalVisible={onFunction} poolsMoreInfoOnClick={onFunction} syncingStatusMoreInfoOnClick={onFunction} setPrivacyOption={onFunction} @@ -126,7 +125,6 @@ describe('Component Send - test', () => { sendTransaction={onFunction} clearToAddr={onFunction} toggleMenuDrawer={onFunction} - setComputingModalVisible={onFunction} poolsMoreInfoOnClick={onFunction} syncingStatusMoreInfoOnClick={onFunction} setPrivacyOption={onFunction} diff --git a/__tests__/Settings.snapshot.tsx b/__tests__/Settings.snapshot.tsx index ac041f159..009e2af27 100644 --- a/__tests__/Settings.snapshot.tsx +++ b/__tests__/Settings.snapshot.tsx @@ -100,13 +100,11 @@ describe('Component Settings - test', () => { state.recoveryWalletInfoOnDevice = true; state.donation = false; state.walletSettings = mockWalletSettings; - const onClose = jest.fn(); const onSetOption = jest.fn(); test('Settings - snapshot', () => { const settings = render( { state.wallet = mockWallet; state.syncingStatus = mockSyncingStatus; state.netInfo = mockNetInfo; - const onClose = jest.fn(); test('SyncReport - snapshot', () => { const sync = render( - + , ); expect(sync.toJSON()).toMatchSnapshot(); diff --git a/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap b/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap index 7103ee3c1..772894d58 100644 --- a/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap +++ b/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap @@ -53,6 +53,7 @@ exports[`Component LoadedApp - test LoadedApp - snapshot 1`] = ` size="large" /> + void, open: () => void) => void; + launchAddressBook: (add: string) => void; addressBookCurrentAddress: string; - addressBookOpenPriorModal: () => void; // is calculated in the header & needed in the send screen shieldingAmount: number; @@ -125,5 +124,10 @@ export default interface AppContextLoaded { rescanMenu: boolean; recoveryWalletInfoOnDevice: boolean; + // modals + setComputingModalShow: () => void; + closeAllModals: () => void; + setUfvkViewModalShow: () => void; + // eslint-disable-next-line semi } diff --git a/app/AppState/AppStateLoaded.ts b/app/AppState/AppStateLoaded.ts index 71efd95cb..7cee5dbb0 100644 --- a/app/AppState/AppStateLoaded.ts +++ b/app/AppState/AppStateLoaded.ts @@ -6,26 +6,6 @@ import { SelectServerEnum } from './enums/SelectServerEnum'; export default interface AppStateLoaded { appStateStatus: AppStateStatus; - // modals - aboutModalVisible: boolean; - computingModalVisible: boolean; - settingsModalVisible: boolean; - infoModalVisible: boolean; - rescanModalVisible: boolean; - seedViewModalVisible: boolean; - seedChangeModalVisible: boolean; - seedBackupModalVisible: boolean; - seedServerModalVisible: boolean; - ufvkViewModalVisible: boolean; - ufvkChangeModalVisible: boolean; - ufvkBackupModalVisible: boolean; - ufvkServerModalVisible: boolean; - syncReportModalVisible: boolean; - poolsModalVisible: boolean; - insightModalVisible: boolean; - addressBookModalVisible: boolean; - messagesModalVisible: boolean; - // change server helper newServer: ServerType; newSelectServer: SelectServerEnum | null; diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index 55212a06a..4535d7da0 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -1,7 +1,6 @@ /* eslint-disable react-native/no-inline-styles */ -import React, { Component, Suspense, useState, useMemo, useEffect } from 'react'; +import React, { Component, useState, useMemo, useEffect } from 'react'; import { - Modal, View, Alert, I18nManager, @@ -13,6 +12,7 @@ import { ActivityIndicator, Dimensions, } from 'react-native'; +import { MagicModalPortal, magicModal } from 'react-native-magic-modal'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { BottomTabBarButtonProps, createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; @@ -92,6 +92,7 @@ import Settings from '../../components/Settings'; import Menu from './components/Menu'; import { MessagesModal } from '../../components/Messages'; import { PlatformPressable } from '@react-navigation/elements'; +import { GestureHandlerRootView } from 'react-native-gesture-handler'; const About = React.lazy(() => import('../../components/About')); const Seed = React.lazy(() => import('../../components/Seed')); @@ -485,12 +486,14 @@ export class LoadedAppClass extends Component {}, shieldingAmount: 0, showSwipeableIcons: true, doRefresh: this.doRefresh, setZecPrice: this.setZecPrice, zenniesDonationAddress: props.zenniesDonationAddress, + setComputingModalShow: () => {}, + closeAllModals: () => {}, + setUfvkViewModalShow: () => {}, // context settings server: props.server, @@ -507,24 +510,6 @@ export class LoadedAppClass extends Component { - this.setState({ - aboutModalVisible: false, - computingModalVisible: false, - settingsModalVisible: false, - infoModalVisible: false, - rescanModalVisible: false, - seedViewModalVisible: false, - seedChangeModalVisible: false, - seedBackupModalVisible: false, - seedServerModalVisible: false, - ufvkViewModalVisible: false, - ufvkChangeModalVisible: false, - ufvkBackupModalVisible: false, - ufvkServerModalVisible: false, - syncReportModalVisible: false, - poolsModalVisible: false, - insightModalVisible: false, - addressBookModalVisible: false, - addressBookCurrentAddress: '', - addressBookOpenPriorModal: () => {}, - messagesModalVisible: false, - }); + magicModal.hideAll(); }; fetchBackgroundSyncing = async () => { @@ -824,8 +788,25 @@ export class LoadedAppClass extends Component { - this.setState({ ufvkViewModalVisible: value }); + setSeedViewModalShow = async () => { + magicModal.show(() => {}} + onClickCancel={() => {}} + action={SeedActionEnum.view} + setPrivacyOption={this.setPrivacyOption} + keepAwake={this.keepAwake} + /> + ); + }; + + setUfvkViewModalShow = async () => { + magicModal.show(() => {}} + onClickCancel={() => {}} + action={UfvkActionEnum.view} + setPrivacyOption={this.setPrivacyOption} + /> + ); }; setShieldingAmount = (value: number) => { @@ -867,7 +848,7 @@ export class LoadedAppClass extends Component 0) { // I need to check this out in the seed screen. - this.setState({ seedViewModalVisible: true }); + this.setSeedViewModalShow(); } } } else { @@ -1062,8 +1043,8 @@ export class LoadedAppClass extends Component { - this.setState({ computingModalVisible: visible }); + setComputingModalShow = () => { + magicModal.show(() => ); }; setInfo = (info: InfoType) => { @@ -1154,37 +1135,75 @@ export class LoadedAppClass extends Component { // Depending on the menu item, open the appropriate modal + await this.closeDrawer(); if (item === MenuItemEnum.About) { - this.setState({ aboutModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.Rescan) { - this.setState({ rescanModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.Settings) { - this.setState({ settingsModalVisible: true }); + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Info) { - this.setState({ infoModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.SyncReport) { - this.setState({ syncReportModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.FundPools) { - this.setState({ poolsModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.Insight) { - this.setState({ insightModalVisible: true }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.WalletSeedUfvk) { if (this.state.readOnly) { - this.setState({ ufvkViewModalVisible: true }); + this.setUfvkViewModalShow(); } else { - this.setState({ seedViewModalVisible: true }); + this.setSeedViewModalShow(); } } else if (item === MenuItemEnum.ChangeWallet) { if (this.state.readOnly) { - this.setState({ ufvkChangeModalVisible: true }); + return magicModal.show(() => await this.onClickOKChangeWallet({ startingApp: false })} + onClickCancel={() => {}} + action={UfvkActionEnum.change} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } else { - this.setState({ seedChangeModalVisible: true }); + return magicModal.show(() => await this.onClickOKChangeWallet({ startingApp: false })} + onClickCancel={() => {}} + action={SeedActionEnum.change} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } } else if (item === MenuItemEnum.RestoreWalletBackup) { if (this.state.readOnly) { - this.setState({ ufvkBackupModalVisible: true }); + return magicModal.show(() => await this.onClickOKRestoreBackup()} + onClickCancel={() => {}} + action={UfvkActionEnum.backup} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } else { - this.setState({ seedBackupModalVisible: true }); + return magicModal.show(() => await this.onClickOKRestoreBackup()} + onClickCancel={() => {}} + action={SeedActionEnum.backup} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } } else if (item === MenuItemEnum.LoadWalletFromSeed) { const { translate } = this.state; @@ -1220,10 +1239,9 @@ export class LoadedAppClass extends Component {}, }); + return magicModal.show(() => ).promise; } else if (item === MenuItemEnum.VoteForNym) { let update = false; if ( @@ -1266,9 +1284,17 @@ export class LoadedAppClass extends Component ).promise; } - this.closeDrawer(); }; setWalletOption = async (walletOption: string, value: string): Promise => { @@ -1344,13 +1370,31 @@ export class LoadedAppClass extends Component await this.onClickOKServerWallet()} + onClickCancel={async () => { + // restart all the tasks again, nothing happen. + this.rpc.setInRefresh(false); + await this.rpc.clearTimers(); + await this.rpc.configure(); + }} + action={UfvkActionEnum.server} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } else { - this.setState({ - seedServerModalVisible: true, - }); + await magicModal.show(() => await this.onClickOKServerWallet()} + onClickCancel={async () => { + // restart all the tasks again, nothing happen. + this.rpc.setInRefresh(false); + await this.rpc.clearTimers(); + await this.rpc.configure(); + }} + action={SeedActionEnum.server} + setPrivacyOption={this.setPrivacyOption} + /> + ).promise; } //console.log(`Error Reading Wallet ${value} - ${error}`); if (toast) { @@ -1536,7 +1580,6 @@ export class LoadedAppClass extends Component { - this.setState({ syncReportModalVisible: true }); + return magicModal.show(() => ).promise; }; poolsMoreInfoOnClick = async () => { - this.setState({ poolsModalVisible: true }); + return magicModal.show(() => ).promise; }; setBackgroundError = (title: string, error: string) => { @@ -1668,18 +1705,13 @@ export class LoadedAppClass extends Component void, openModal: () => void) => { - closeModal(); - setTimeout( - () => { - this.setState({ - addressBookModalVisible: true, - addressBookCurrentAddress: address, - addressBookOpenPriorModal: openModal, - }); - }, - Platform.OS === GlobalConst.platformOSios ? 100 : 1, - ); + // close modal make sense because this is called + // in a component which can live in differents screens + launchAddressBook = (address: string) => { + this.setState({ + addressBookCurrentAddress: address, + }); + return magicModal.show(() => ).promise; }; setScrollToTop = (value: boolean) => { @@ -1694,8 +1726,11 @@ export class LoadedAppClass extends Component { - this.drawerRef.closeDrawer(); + closeDrawer = async () => { + await this.drawerRef.closeDrawer(); + // wait a little to close the drawer menu properly + // we have to replace the drawer, check this out after. + //await new Promise(resolve => setTimeout(resolve, 150)); }; openDrawer = () => { @@ -1704,24 +1739,6 @@ export class LoadedAppClass extends Component - (this.drawerRef = ref)} - renderNavigationView={() => menu} - drawerType={'slide'} - drawerWidth={Dimensions.get('window').width * 0.7}> - this.setState({ aboutModalVisible: false })}> - }> - this.setState({ aboutModalVisible: false })} /> - - - - this.setState({ infoModalVisible: false })}> - }> - this.setState({ infoModalVisible: false })} /> - - - - this.setState({ syncReportModalVisible: false })}> - }> - this.setState({ syncReportModalVisible: false })} /> - - - - this.setState({ poolsModalVisible: false })}> - }> - this.setState({ poolsModalVisible: false })} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ insightModalVisible: false })}> - }> - this.setState({ insightModalVisible: false })} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ rescanModalVisible: false })}> - }> - this.setState({ rescanModalVisible: false })} doRescan={this.doRescan} /> - - - - this.setState({ settingsModalVisible: false })}> - this.setState({ settingsModalVisible: false })} - setWalletOption={this.setWalletOption} - setServerOption={this.setServerOption} - setCurrencyOption={this.setCurrencyOption} - setLanguageOption={this.setLanguageOption} - setSendAllOption={this.setSendAllOption} - setDonationOption={this.setDonationOption} - setPrivacyOption={this.setPrivacyOption} - setModeOption={this.setModeOption} - setSecurityOption={this.setSecurityOption} - setSelectServerOption={this.setSelectServerOption} - setRescanMenuOption={this.setRescanMenuOption} - setRecoveryWalletInfoOnDeviceOption={this.setRecoveryWalletInfoOnDeviceOption} - /> - - - this.setState({ seedViewModalVisible: false })}> - }> - this.setState({ seedViewModalVisible: false })} - onClickCancel={() => this.setState({ seedViewModalVisible: false })} - action={SeedActionEnum.view} - setPrivacyOption={this.setPrivacyOption} - keepAwake={this.keepAwake} - /> - - - - this.setState({ seedChangeModalVisible: false })}> - }> - await this.onClickOKChangeWallet({ startingApp: false })} - onClickCancel={() => this.setState({ seedChangeModalVisible: false })} - action={SeedActionEnum.change} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ seedBackupModalVisible: false })}> - }> - await this.onClickOKRestoreBackup()} - onClickCancel={() => this.setState({ seedBackupModalVisible: false })} - action={SeedActionEnum.backup} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ seedServerModalVisible: false })}> - }> - await this.onClickOKServerWallet()} - onClickCancel={async () => { - // restart all the tasks again, nothing happen. - this.rpc.setInRefresh(false); - await this.rpc.clearTimers(); - await this.rpc.configure(); - this.setState({ seedServerModalVisible: false }); - }} - action={SeedActionEnum.server} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ ufvkViewModalVisible: false })}> - }> - this.setState({ ufvkViewModalVisible: false })} - onClickCancel={() => this.setState({ ufvkViewModalVisible: false })} - action={UfvkActionEnum.view} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ ufvkChangeModalVisible: false })}> - }> - await this.onClickOKChangeWallet({ startingApp: false })} - onClickCancel={() => this.setState({ ufvkChangeModalVisible: false })} - action={UfvkActionEnum.change} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ ufvkBackupModalVisible: false })}> - }> - await this.onClickOKRestoreBackup()} - onClickCancel={() => this.setState({ ufvkBackupModalVisible: false })} - action={UfvkActionEnum.backup} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ ufvkServerModalVisible: false })}> - }> - await this.onClickOKServerWallet()} - onClickCancel={async () => { - // restart all the tasks again, nothing happen. - this.rpc.setInRefresh(false); - await this.rpc.clearTimers(); - await this.rpc.configure(); - this.setState({ ufvkServerModalVisible: false }); - }} - action={UfvkActionEnum.server} - setPrivacyOption={this.setPrivacyOption} - /> - - - - this.setState({ computingModalVisible: false })}> - }> - - - - - - this.setState({ - addressBookModalVisible: false, - addressBookCurrentAddress: '', - addressBookOpenPriorModal: () => {}, - }) - }> - }> - - this.setState({ - addressBookModalVisible: false, - addressBookCurrentAddress: '', - addressBookOpenPriorModal: () => {}, - }) - } - setAddressBook={this.setAddressBook} - /> - - - - this.setState({ messagesModalVisible: false })}> - }> - this.setState({ messagesModalVisible: false })} - /> - - - - - - {mode === ModeEnum.advanced || - (valueTransfersTotal !== null && valueTransfersTotal > 0) || - (!readOnly && !!totalBalance && totalBalance.spendableOrchard + totalBalance.spendablePrivate > 0) ? ( - ({ - tabBarIcon: ({ focused }) => fnTabBarIcon(route, focused), - tabBarIconStyle: { - alignSelf: 'center', - marginBottom: 2, - }, - tabBarLabelPosition: 'below-icon', - tabBarLabelStyle: { - alignSelf: 'center', - fontSize: 14, - }, - tabBarItemStyle: { - height: 60, - }, - tabBarActiveTintColor: colors.background, - tabBarActiveBackgroundColor: colors.primaryDisabled, - tabBarInactiveTintColor: colors.money, - tabBarInactiveBackgroundColor: colors.sideMenuBackground, - tabBarStyle: { - borderTopWidth: 1, - height: 60, - }, - headerShown: false, - tabBarButton: renderTabPressable(colors), - })}> - - {() => ( - - )} - - {!readOnly && - selectServer !== SelectServerEnum.offline && - (mode === ModeEnum.advanced || - (!!totalBalance && totalBalance.spendableOrchard + totalBalance.spendablePrivate > 0) || - (!!totalBalance && - totalBalance.orchardBal + totalBalance.privateBal > 0 && - totalBalance.spendableOrchard + totalBalance.spendablePrivate === 0 && - somePending)) && ( - - {() => ( - - )} - - )} - - {() => ( - + + (this.drawerRef = ref)} + renderNavigationView={() => menu} + drawerType={'slide'} + drawerWidth={Dimensions.get('window').width * 0.7}> + + + + {mode === ModeEnum.advanced || + (valueTransfersTotal !== null && valueTransfersTotal > 0) || + (!readOnly && !!totalBalance && totalBalance.spendableOrchard + totalBalance.spendablePrivate > 0) ? ( + ({ + tabBarIcon: ({ focused }) => fnTabBarIcon(route, focused), + tabBarIconStyle: { + alignSelf: 'center', + marginBottom: 2, + }, + tabBarLabelPosition: 'below-icon', + tabBarLabelStyle: { + alignSelf: 'center', + fontSize: 14, + }, + tabBarItemStyle: { + height: 60, + }, + tabBarActiveTintColor: colors.background, + tabBarActiveBackgroundColor: colors.primaryDisabled, + tabBarInactiveTintColor: colors.money, + tabBarInactiveBackgroundColor: colors.sideMenuBackground, + tabBarStyle: { + borderTopWidth: 1, + height: 60, + }, + headerShown: false, + tabBarButton: renderTabPressable(colors), + })}> + + {() => ( + + )} + + {!readOnly && + selectServer !== SelectServerEnum.offline && + (mode === ModeEnum.advanced || + (!!totalBalance && totalBalance.spendableOrchard + totalBalance.spendablePrivate > 0) || + (!!totalBalance && + totalBalance.orchardBal + totalBalance.privateBal > 0 && + totalBalance.spendableOrchard + totalBalance.spendablePrivate === 0 && + somePending)) && ( + + {() => ( + + )} + + )} + + {() => ( + + )} + + + ) : ( + <> + {valueTransfersTotal === null || addresses === null || totalBalance === null ? ( + + ) : ( + + + {() => ( + + )} + + )} - - - ) : ( - <> - {valueTransfersTotal === null || addresses === null || totalBalance === null ? ( - - ) : ( - - - {() => ( - - )} - - - )} - - )} - + + )} + + + ); } diff --git a/app/LoadedApp/components/Menu.tsx b/app/LoadedApp/components/Menu.tsx index e68ca4a5b..a07a322fd 100644 --- a/app/LoadedApp/components/Menu.tsx +++ b/app/LoadedApp/components/Menu.tsx @@ -14,10 +14,11 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import { MenuItemEnum, ModeEnum, SelectServerEnum } from '../../AppState'; +import { HideReturn } from 'react-native-magic-modal'; type MenuProps = { - onItemSelected: (item: MenuItemEnum) => Promise; - closeDrawer: () => void; + onItemSelected: (item: MenuItemEnum) => Promise | undefined>; + closeDrawer: () => Promise; }; const Menu: React.FunctionComponent = ({ onItemSelected, closeDrawer }) => { @@ -64,7 +65,7 @@ const Menu: React.FunctionComponent = ({ onItemSelected, closeDrawer //console.log('BIOMETRIC --------> ', resultBio); if (resultBio === false) { // snack with Error & closing the menu. - closeDrawer(); + await closeDrawer(); addLastSnackbar({ message: translate('biometrics-error') as string }); } else { onItemSelected(value); diff --git a/app/context/contextAppLoaded.tsx b/app/context/contextAppLoaded.tsx index 6d8631b0d..30ef6ca17 100644 --- a/app/context/contextAppLoaded.tsx +++ b/app/context/contextAppLoaded.tsx @@ -67,7 +67,6 @@ export const defaultAppContextLoaded: AppContextLoaded = { addressBook: [] as AddressBookFileClass[], launchAddressBook: () => {}, addressBookCurrentAddress: '', - addressBookOpenPriorModal: () => {}, security: {} as SecurityType, selectServer: SelectServerEnum.auto, rescanMenu: false, @@ -77,6 +76,9 @@ export const defaultAppContextLoaded: AppContextLoaded = { doRefresh: () => {}, setZecPrice: () => {}, zenniesDonationAddress: '', + setComputingModalShow: () => {}, + closeAllModals: () => {}, + setUfvkViewModalShow: () => {}, }; export const ContextAppLoaded = React.createContext(defaultAppContextLoaded); diff --git a/components/About/About.tsx b/components/About/About.tsx index f19b40fe1..c201f3fe0 100644 --- a/components/About/About.tsx +++ b/components/About/About.tsx @@ -14,15 +14,16 @@ import moment from 'moment'; import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; +import { useMagicModal } from 'react-native-magic-modal'; type AboutProps = { - closeModal: () => void; }; -const About: React.FunctionComponent = ({ closeModal }) => { +const About: React.FunctionComponent = () => { const context = useContext(ContextAppLoaded); const { info, translate, language } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); + const { hide } = useMagicModal(); const arrayTxtObject = translate('about.copyright'); let arrayTxt: string[] = []; @@ -46,7 +47,7 @@ const About: React.FunctionComponent = ({ closeModal }) => { noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> void; setAddressBook: (ab: AddressBookFileClass[]) => void; }; -const AddressBook: React.FunctionComponent = ({ closeModal, setAddressBook }) => { +const AddressBook: React.FunctionComponent = ({ setAddressBook }) => { const context = useContext(ContextAppLoaded); const { translate, language, addressBook, addressBookCurrentAddress, - addressBookOpenPriorModal, zenniesDonationAddress, } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [numAb, setNumAb] = useState(50); @@ -105,13 +104,7 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se setCurrentItem(null); setAction(null); if (addressBookCurrentAddress) { - closeModal(); - setTimeout( - () => { - addressBookOpenPriorModal(); - }, - Platform.OS === GlobalConst.platformOSios ? 100 : 1, - ); + hide(); } }; @@ -170,7 +163,7 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> = ({ closeModal, se item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={closeModal} + closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} /> @@ -250,7 +243,7 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={closeModal} + closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} /> @@ -268,7 +261,7 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={closeModal} + closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} addressProtected={true} diff --git a/components/Components/AddressItem.tsx b/components/Components/AddressItem.tsx index 7fbabd1fd..519928dd9 100644 --- a/components/Components/AddressItem.tsx +++ b/components/Components/AddressItem.tsx @@ -26,7 +26,6 @@ import 'moment/locale/ru'; type AddressItemProps = { address: string; closeModal: () => void; - openModal: () => void; oneLine?: boolean; onlyContact?: boolean; withIcon?: boolean; @@ -41,7 +40,6 @@ const AddressItem: React.FunctionComponent = ({ withIcon, withSendIcon, closeModal, - openModal, addressProtected, }) => { const context = useContext(ContextAppLoaded); @@ -157,7 +155,7 @@ const AddressItem: React.FunctionComponent = ({ )} {withIcon && !contact && oneLine && ( - launchAddressBook(address, closeModal, openModal)}> + launchAddressBook(address)}> = ({ )} {withIcon && !contact && !oneLine && ( - launchAddressBook(address, closeModal, openModal)}> + launchAddressBook(address)}> )} diff --git a/components/Components/SingleAddress.tsx b/components/Components/SingleAddress.tsx index 101bb4f8d..a59aba0a9 100644 --- a/components/Components/SingleAddress.tsx +++ b/components/Components/SingleAddress.tsx @@ -198,7 +198,7 @@ const SingleAddress: React.FunctionComponent = ({ address, i justifyContent: 'center', marginBottom: 30, }}> - {}} openModal={() => {}} /> + {}} /> diff --git a/components/Components/TextInputAddress.tsx b/components/Components/TextInputAddress.tsx index 5fcac6809..c9fdc2a2a 100644 --- a/components/Components/TextInputAddress.tsx +++ b/components/Components/TextInputAddress.tsx @@ -1,6 +1,6 @@ /* eslint-disable react-native/no-inline-styles */ import React, { useContext, useEffect, useState } from 'react'; -import { View, TouchableOpacity, TextInput, Modal } from 'react-native'; +import { View, TouchableOpacity, TextInput } from 'react-native'; import { useTheme } from '@react-navigation/native'; import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; import { faCheck, faQrcode, faXmark } from '@fortawesome/free-solid-svg-icons'; @@ -15,6 +15,7 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import Utils from '../../app/utils'; +import { magicModal } from 'react-native-magic-modal'; type TextInputAddressProps = { address: string; @@ -35,7 +36,6 @@ const TextInputAddress: React.FunctionComponent = ({ const { colors } = useTheme() as ThemeType; moment.locale(language); - const [qrcodeModalVisble, setQrcodeModalVisible] = useState(false); const [validAddress, setValidAddress] = useState(0); // 1 - OK, 0 - Empty, -1 - KO useEffect(() => { @@ -60,17 +60,14 @@ const TextInputAddress: React.FunctionComponent = ({ } }, [address, server.chainName, setError, setUOrchardAddress, translate]); + const setQrcodeModalShow = async () => { + await magicModal.show(() => ).promise; + }; + //console.log('render input text address'); return ( - setQrcodeModalVisible(false)}> - setQrcodeModalVisible(false)} /> - {translate('send.toaddress') as string} @@ -129,8 +126,8 @@ const TextInputAddress: React.FunctionComponent = ({ disabled={disabled} accessible={true} accessibilityLabel={translate('send.scan-acc') as string} - onPress={() => { - setQrcodeModalVisible(true); + onPress={async () => { + setQrcodeModalShow(); }}> diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index ef51760ff..26339ad58 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -28,6 +28,7 @@ import { GlobalConst, CommandEnum, SelectServerEnum, + RouteEnums, } from '../../app/AppState'; import { ContextAppLoaded } from '../../app/context'; import { ThemeType } from '../../app/types'; @@ -71,7 +72,6 @@ type HeaderProps = { addLastSnackbar?: (snackbar: SnackbarType) => void; // shielding setShieldingAmount?: (value: number) => void; - setComputingModalVisible?: (visible: boolean) => void; setScrollToTop?: (value: boolean) => void; setScrollToBottom?: (value: boolean) => void; // seed screen - shared between AppLoading & AppLoadad - different contexts @@ -81,8 +81,6 @@ type HeaderProps = { privacy?: boolean; // store the error if the App is in background setBackgroundError?: (title: string, error: string) => void; - // read-only wallet - setUfvkViewModalVisible?: (v: boolean) => void; // first funds received legend for the Seed screen receivedLegend?: boolean; }; @@ -100,11 +98,9 @@ const Header: React.FunctionComponent = ({ netInfo: netInfoProp, mode: modeProp, privacy: privacyProp, - setComputingModalVisible, setBackgroundError, noPrivacy, setPrivacyOption, - setUfvkViewModalVisible, addLastSnackbar, receivedLegend, setShieldingAmount, @@ -130,6 +126,9 @@ const Header: React.FunctionComponent = ({ navigation, selectServer, setZecPrice, + setComputingModalShow, + closeAllModals, + setUfvkViewModalShow, } = context; let translate: (key: string) => TranslateType, netInfo: NetInfoType, mode: ModeEnum, privacy: boolean; @@ -287,7 +286,7 @@ const Header: React.FunctionComponent = ({ }, []); const shieldFunds = async () => { - if (!setComputingModalVisible || !setBackgroundError || !addLastSnackbar) { + if (!setBackgroundError || !addLastSnackbar) { return; } if (!netInfo.isConnected || selectServer === SelectServerEnum.offline) { @@ -298,7 +297,7 @@ const Header: React.FunctionComponent = ({ // now zingolib only can shield `transparent`. let pools: PoolToShieldEnum = PoolToShieldEnum.transparentPoolToShield; - setComputingModalVisible(true); + setComputingModalShow(); // We need to activate this flag because if the App is syncing // while shielding, then it going to finish the current batch // and after that it run the shield process. @@ -355,7 +354,10 @@ const Header: React.FunctionComponent = ({ await RPC.rpcSetInterruptSyncAfterBatch(GlobalConst.false); // change to the history screen, just in case. if (navigation) { - navigation.navigate(translate('loadedapp.history-menu') as string); + navigation.navigate(RouteEnums.LoadedApp, { + screen: translate('loadedapp.history-menu') as string, + initial: false, + }); } // scroll to top in history, just in case. if (setScrollToTop) { @@ -365,7 +367,7 @@ const Header: React.FunctionComponent = ({ if (setScrollToBottom) { setScrollToBottom(true); } - setComputingModalVisible(false); + closeAllModals(); } }; @@ -442,9 +444,7 @@ const Header: React.FunctionComponent = ({ addLastSnackbar({ message: translate('biometrics-error') as string }); } } else { - if (setUfvkViewModalVisible) { - setUfvkViewModalVisible(true); - } + setUfvkViewModalShow(); } }; @@ -793,7 +793,6 @@ const Header: React.FunctionComponent = ({ {showShieldButton && !calculateDisableButtonToShield() && - setComputingModalVisible && valueTransfersTotal !== null && ( @@ -835,8 +834,7 @@ const Header: React.FunctionComponent = ({ )} {readOnly && ( <> - {setUfvkViewModalVisible && - !(mode === ModeEnum.basic && valueTransfersTotal !== null && valueTransfersTotal <= 0) && + {!(mode === ModeEnum.basic && valueTransfersTotal !== null && valueTransfersTotal <= 0) && !(mode === ModeEnum.basic && totalBalance && totalBalance.total <= 0) ? ( ufvkShowModal()}> diff --git a/components/History/History.tsx b/components/History/History.tsx index f3b3f074a..05a32c123 100644 --- a/components/History/History.tsx +++ b/components/History/History.tsx @@ -3,7 +3,6 @@ import React, { useContext, useState, useEffect, useCallback, useMemo, useRef } import { View, ScrollView, - Modal, RefreshControl, NativeScrollEvent, NativeSyntheticEvent, @@ -37,6 +36,7 @@ import { ContextAppLoaded } from '../../app/context'; import Header from '../Header'; import { MessagesAddress } from '../Messages'; import Utils from '../../app/utils'; +import { magicModal } from 'react-native-magic-modal'; type HistoryProps = { // side menu @@ -50,13 +50,10 @@ type HistoryProps = { // addLastSnackbar from context // shielding / sending setShieldingAmount: (value: number) => void; - setComputingModalVisible: (visible: boolean) => void; setScrollToTop: (value: boolean) => void; scrollToTop: boolean; setScrollToBottom: (value: boolean) => void; scrollToBottom: boolean; - // read-only wallet - setUfvkViewModalVisible?: (v: boolean) => void; // for messages sendTransaction: (s: SendPageStateClass) => Promise; setServerOption: ( @@ -71,9 +68,7 @@ const History: React.FunctionComponent = ({ toggleMenuDrawer, poolsMoreInfoOnClick, syncingStatusMoreInfoOnClick, - setComputingModalVisible, setPrivacyOption, - setUfvkViewModalVisible, setShieldingAmount, setScrollToTop, scrollToTop, @@ -96,10 +91,6 @@ const History: React.FunctionComponent = ({ const { colors } = useTheme() as ThemeType; moment.locale(language); - const [isValueTransferDetailModalShowing, setValueTransferDetailModalShowing] = useState(false); - const [isMessagesAddressModalShowing, setMessagesAddressModalShowing] = useState(false); - const [valueTransferDetail, setValueTransferDetail] = useState({} as ValueTransferType); - const [valueTransferDetailIndex, setValueTransferDetailIndex] = useState(-1); const [numVt, setNumVt] = useState(50); const [loadMoreButton, setLoadMoreButton] = useState(false); const [valueTransfersSliced, setValueTransfersSliced] = useState([]); @@ -144,15 +135,6 @@ const History: React.FunctionComponent = ({ setNumVt(numVt + 50); }, [numVt]); - const moveValueTransferDetail = (index: number, type: number) => { - // -1 -> Previous ValueTransfer - // 1 -> Next ValueTransfer - if ((index > 0 && type === -1) || (index < valueTransfersSliced.length - 1 && type === 1)) { - setValueTransferDetail(valueTransfersSliced[index + type]); - setValueTransferDetailIndex(index + type); - } - }; - const handleScrollToTop = () => { if (scrollViewRef.current) { scrollViewRef.current.scrollTo({ y: 0, animated: true }); @@ -165,6 +147,29 @@ const History: React.FunctionComponent = ({ setIsAtTop(isTop); }; + const setValueTransferDetailModalShow = async (index: number, vt: ValueTransferType) => { + await magicModal.show(() => + ).promise; + }; + + const setMessagesAddressModalShow = async (vt: ValueTransferType) => { + await magicModal.show(() => + ).promise; + }; + //console.log('render History - 4'); return ( @@ -177,41 +182,6 @@ const History: React.FunctionComponent = ({ width: '100%', height: '100%', }}> - setValueTransferDetailModalShowing(false)}> - setValueTransferDetailModalShowing(false)} - openModal={() => setValueTransferDetailModalShowing(true)} - setPrivacyOption={setPrivacyOption} - moveValueTransferDetail={moveValueTransferDetail} - /> - - - {isMessagesAddressModalShowing && ( - setMessagesAddressModalShowing(false)}> - setMessagesAddressModalShowing(false)} - openModal={() => setMessagesAddressModalShowing(true)} - sendTransaction={sendTransaction} - setServerOption={setServerOption} - /> - - )}
= ({ setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar /* context */} setShieldingAmount={setShieldingAmount} - setComputingModalVisible={setComputingModalVisible} setScrollToTop={setScrollToTop} setScrollToBottom={setScrollToBottom} setBackgroundError={setBackgroundError /* context */} - setUfvkViewModalVisible={setUfvkViewModalVisible} /> = ({ index={index} vt={vt} month={month} - setValueTransferDetail={(ttt: ValueTransferType) => setValueTransferDetail(ttt)} - setValueTransferDetailIndex={(iii: number) => setValueTransferDetailIndex(iii)} - setValueTransferDetailModalShowing={(bbb: boolean) => setValueTransferDetailModalShowing(bbb)} + setValueTransferDetailModalShow={setValueTransferDetailModalShow} nextLineWithSameTxid={ index >= valueTransfersSliced.length - 1 ? false : valueTransfersSliced[index + 1].txid === vt.txid } - setMessagesAddressModalShowing={(bbb: boolean) => setMessagesAddressModalShowing(bbb)} + setMessagesAddressModalShow={setMessagesAddressModalShow} addressProtected={vt.address === zenniesDonationAddress} /> ); diff --git a/components/History/components/ValueTransferDetail.tsx b/components/History/components/ValueTransferDetail.tsx index 45c0d3ef7..341553629 100644 --- a/components/History/components/ValueTransferDetail.tsx +++ b/components/History/components/ValueTransferDetail.tsx @@ -34,29 +34,24 @@ import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; // this is for http. (red) import { faTriangleExclamation, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'; import { RPCValueTransfersStatusEnum } from '../../../app/rpc/enums/RPCValueTransfersStatusEnum'; +import { useMagicModal } from 'react-native-magic-modal'; // this is for https. (primary) //import { faLock } from '@fortawesome/free-solid-svg-icons'; type ValueTransferDetailProps = { index: number; - length: number; - totalLength: number; vt: ValueTransferType; - closeModal: () => void; - openModal: () => void; + valueTransfersSliced: ValueTransferType[]; + totalLength: number; setPrivacyOption: (value: boolean) => Promise; - moveValueTransferDetail: (index: number, type: number) => void; }; const ValueTransferDetail: React.FunctionComponent = ({ index, - length, - totalLength, vt, - closeModal, + valueTransfersSliced, + totalLength, setPrivacyOption, - openModal, - moveValueTransferDetail, }) => { const context = useContext(ContextAppLoaded); const { @@ -72,32 +67,35 @@ const ValueTransferDetail: React.FunctionComponent = ( zenniesDonationAddress, } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); + const [valueTransfer, setValueTransfer] = useState(vt); + const [valueTransferIndex, setValueTransferIndex] = useState(index); const [spendColor, setSpendColor] = useState(colors.primaryDisabled); const [expandTxid, setExpandTxid] = useState(false); const [showNavigator, setShowNavigator] = useState(true); const [addressProtected, setAddressProtected] = useState(true); const isTheFirstMount = useRef(true); - const { memo, memoUA } = Utils.splitMemo(vt.memos); + const { memo, memoUA } = Utils.splitMemo(valueTransfer.memos); useEffect(() => { const spendCo = - vt.confirmations === 0 + valueTransfer.confirmations === 0 ? colors.primaryDisabled - : vt.kind === ValueTransferKindEnum.Received || vt.kind === ValueTransferKindEnum.Shield + : valueTransfer.kind === ValueTransferKindEnum.Received || valueTransfer.kind === ValueTransferKindEnum.Shield ? colors.primary : colors.text; setSpendColor(spendCo); - }, [colors.primary, colors.primaryDisabled, colors.text, vt.confirmations, vt.kind]); + }, [colors.primary, colors.primaryDisabled, colors.text, valueTransfer.confirmations, valueTransfer.kind]); useEffect(() => { (async () => { - setAddressProtected(await isAddressProtected(vt.address ? vt.address : '')); + setAddressProtected(await isAddressProtected(valueTransfer.address ? valueTransfer.address : '')); })(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [vt.address]); + }, [valueTransfer.address]); const handleTxIDClick = (txid?: string) => { if (!txid) { @@ -147,7 +145,17 @@ const ValueTransferDetail: React.FunctionComponent = ( return zenniesDonationAddress === add; }; - //console.log('vt', index, totalLength, isTheFirstMount); + const moveValueTransferDetail = (indexParm: number, typeParm: number) => { + // -1 -> Previous ValueTransfer + // 1 -> Next ValueTransfer + if ((indexParm > 0 && typeParm === -1) || (indexParm < valueTransfersSliced.length - 1 && typeParm === 1)) { + const newIndex = indexParm + typeParm; + setValueTransfer(valueTransfersSliced[newIndex]); + setValueTransferIndex(newIndex); + } + }; + + //console.log('vt', index, totalLength, isTheFirstMount, vt); return ( @@ -166,7 +174,7 @@ const ValueTransferDetail: React.FunctionComponent = ( noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={closeModal} + closeScreen={hide} /> {showNavigator && ( = ( marginTop: 5, }}> moveValueTransferDetail(index, -1)} + onPress={() => moveValueTransferDetail(valueTransferIndex, -1)} style={{ marginRight: 25 }} - disabled={index === 0}> + disabled={valueTransferIndex === 0}> - {(index + 1).toString()} + {(valueTransferIndex + 1).toString()} moveValueTransferDetail(index, 1)} + onPress={() => moveValueTransferDetail(valueTransferIndex, 1)} style={{ marginLeft: 25 }} - disabled={index === length - 1}> + disabled={valueTransferIndex === valueTransfersSliced.length - 1}> @@ -221,48 +229,48 @@ const ValueTransferDetail: React.FunctionComponent = ( borderColor: colors.border, }}> - {vt.kind === ValueTransferKindEnum.Sent && vt.confirmations === 0 + {valueTransfer.kind === ValueTransferKindEnum.Sent && valueTransfer.confirmations === 0 ? (translate('history.sending') as string) - : vt.kind === ValueTransferKindEnum.Sent && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.Sent && valueTransfer.confirmations > 0 ? (translate('history.sent') as string) - : vt.kind === ValueTransferKindEnum.Received && vt.confirmations === 0 + : valueTransfer.kind === ValueTransferKindEnum.Received && valueTransfer.confirmations === 0 ? (translate('history.receiving') as string) - : vt.kind === ValueTransferKindEnum.Received && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.Received && valueTransfer.confirmations > 0 ? (translate('history.received') as string) - : vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations === 0 + : valueTransfer.kind === ValueTransferKindEnum.MemoToSelf && valueTransfer.confirmations === 0 ? (translate('history.sendingtoself') as string) - : vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.MemoToSelf && valueTransfer.confirmations > 0 ? (translate('history.memotoself') as string) - : vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations === 0 + : valueTransfer.kind === ValueTransferKindEnum.SendToSelf && valueTransfer.confirmations === 0 ? (translate('history.sendingtoself') as string) - : vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.SendToSelf && valueTransfer.confirmations > 0 ? (translate('history.sendtoself') as string) - : vt.kind === ValueTransferKindEnum.Shield && vt.confirmations === 0 + : valueTransfer.kind === ValueTransferKindEnum.Shield && valueTransfer.confirmations === 0 ? (translate('history.shielding') as string) - : vt.kind === ValueTransferKindEnum.Shield && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.Shield && valueTransfer.confirmations > 0 ? (translate('history.shield') as string) - : vt.kind === ValueTransferKindEnum.Rejection && vt.confirmations === 0 + : valueTransfer.kind === ValueTransferKindEnum.Rejection && valueTransfer.confirmations === 0 ? (translate('history.sending') as string) - : vt.kind === ValueTransferKindEnum.Rejection && vt.confirmations > 0 + : valueTransfer.kind === ValueTransferKindEnum.Rejection && valueTransfer.confirmations > 0 ? (translate('history.rejection') as string) : ''} - {!!vt.zecPrice && vt.zecPrice > 0 && ( - + {!!valueTransfer.zecPrice && valueTransfer.zecPrice > 0 && ( + )} - {vt.confirmations === 0 && ( + {valueTransfer.confirmations === 0 && ( - {(vt.status === RPCValueTransfersStatusEnum.transmitted || - vt.status === RPCValueTransfersStatusEnum.calculated) && ( + {(valueTransfer.status === RPCValueTransfersStatusEnum.transmitted || + valueTransfer.status === RPCValueTransfersStatusEnum.calculated) && ( = ( - {(translate(`history.${vt.status}`) as string) + ' - ' + (translate('history.not-confirmed') as string)} + {(translate(`history.${valueTransfer.status}`) as string) + ' - ' + (translate('history.not-confirmed') as string)} )} @@ -300,11 +308,11 @@ const ValueTransferDetail: React.FunctionComponent = ( {translate('history.time') as string} - {vt.time ? moment((vt.time || 0) * 1000).format('YYYY MMM D h:mm a') : '--'} + {valueTransfer.time ? moment((valueTransfer.time || 0) * 1000).format('YYYY MMM D h:mm a') : '--'} {translate('history.confirmations') as string} - {vt.confirmations.toString()} + {valueTransfer.confirmations.toString()} @@ -312,8 +320,8 @@ const ValueTransferDetail: React.FunctionComponent = ( {translate('history.txid') as string} { - if (vt.txid) { - Clipboard.setString(vt.txid); + if (valueTransfer.txid) { + Clipboard.setString(valueTransfer.txid); addLastSnackbar({ message: translate('history.txcopied') as string, duration: SnackbarDurationEnum.short, @@ -321,13 +329,13 @@ const ValueTransferDetail: React.FunctionComponent = ( setExpandTxid(true); } }}> - {!vt.txid && {'Unknown'}} - {!expandTxid && !!vt.txid && {Utils.trimToSmall(vt.txid, 10)}} - {expandTxid && !!vt.txid && ( + {!valueTransfer.txid && {'Unknown'}} + {!expandTxid && !!valueTransfer.txid && {Utils.trimToSmall(valueTransfer.txid, 10)}} + {expandTxid && !!valueTransfer.txid && ( <> - {vt.txid} + {valueTransfer.txid} {server.chainName !== ChainNameEnum.regtestChainName && ( - handleTxIDClick(vt.txid)}> + handleTxIDClick(valueTransfer.txid)}> {translate('history.viewexplorer') as string} @@ -338,42 +346,41 @@ const ValueTransferDetail: React.FunctionComponent = ( - {!!vt.fee && vt.fee > 0 && ( + {!!valueTransfer.fee && valueTransfer.fee > 0 && ( {translate('history.txfee') as string} - + )} - {!!vt.address && ( + {!!valueTransfer.address && ( {translate('history.address') as string} )} - {!!vt.poolType && ( + {!!valueTransfer.poolType && ( {translate('history.pool') as string} - {vt.poolType} + {valueTransfer.poolType} )} {translate('history.amount') as string} - - {!!vt.zecPrice && vt.zecPrice > 0 && ( - + + {!!valueTransfer.zecPrice && valueTransfer.zecPrice > 0 && ( + )} @@ -418,7 +425,7 @@ const ValueTransferDetail: React.FunctionComponent = ( {!thisWalletAddress(memoUA) && ( {translate('addressbook.likely') as string} )} - {}} openModal={() => {}} /> + {}} /> )} {!contactFound(memoUA) && thisWalletAddress(memoUA) && ( diff --git a/components/History/components/ValueTransferLine.tsx b/components/History/components/ValueTransferLine.tsx index a361e9738..5a0a3e166 100644 --- a/components/History/components/ValueTransferLine.tsx +++ b/components/History/components/ValueTransferLine.tsx @@ -41,22 +41,18 @@ type ValueTransferLineProps = { index: number; month: string; vt: ValueTransferType; - setValueTransferDetail: (t: ValueTransferType) => void; - setValueTransferDetailIndex: (i: number) => void; - setValueTransferDetailModalShowing: (b: boolean) => void; + setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => void; nextLineWithSameTxid: boolean; - setMessagesAddressModalShowing: (b: boolean) => void; + setMessagesAddressModalShow: (vt: ValueTransferType) => Promise; addressProtected?: boolean; }; const ValueTransferLine: React.FunctionComponent = ({ index, vt, month, - setValueTransferDetail, - setValueTransferDetailIndex, - setValueTransferDetailModalShowing, + setValueTransferDetailModalShow, nextLineWithSameTxid, - //setMessagesAddressModalShowing, + //setMessagesAddressModalShow, addressProtected, }) => { const context = useContext(ContextAppLoaded); @@ -127,7 +123,7 @@ const ValueTransferLine: React.FunctionComponent = ({ //console.log(value); setValueTransferDetail(vt); setValueTransferDetailIndex(index); - setMessagesAddressModalShowing(true); + setMessagesAddressModalShow(true); swipeable.reset(); } maxWidthHit.current = true; @@ -159,7 +155,7 @@ const ValueTransferLine: React.FunctionComponent = ({ onPress={() => { setValueTransferDetail(vt); setValueTransferDetailIndex(index); - setMessagesAddressModalShowing(true); + setMessagesAddressModalShow(true); swipeable.reset(); }}> @@ -199,9 +195,7 @@ const ValueTransferLine: React.FunctionComponent = ({ { - setValueTransferDetail(vt); - setValueTransferDetailIndex(index); - setValueTransferDetailModalShowing(true); + setValueTransferDetailModalShow(index, vt); swipeable.reset(); }}> @@ -271,9 +265,7 @@ const ValueTransferLine: React.FunctionComponent = ({ { - setValueTransferDetail(vt); - setValueTransferDetailIndex(index); - setValueTransferDetailModalShowing(true); + setValueTransferDetailModalShow(index, vt); swipeableRef?.current?.reset(); }}> = ({ {!!vt.address && vt.confirmations > 0 && ( - {}} openModal={() => {}} /> + {}} /> )} void; }; -const Info: React.FunctionComponent = ({ closeModal }) => { +const Info: React.FunctionComponent = () => { const context = useContext(ContextAppLoaded); const { info, translate, currency, zecPrice, privacy, language, setZecPrice } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); return ( @@ -44,7 +45,7 @@ const Info: React.FunctionComponent = ({ closeModal }) => { noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> { }; type InsightProps = { - closeModal: () => void; setPrivacyOption: (value: boolean) => Promise; }; -const Insight: React.FunctionComponent = ({ closeModal, setPrivacyOption }) => { +const Insight: React.FunctionComponent = ({ setPrivacyOption }) => { const context = useContext(ContextAppLoaded); const { info, translate, privacy, addLastSnackbar, language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [pieAmounts, setPieAmounts] = useState([]); @@ -175,7 +176,6 @@ const Insight: React.FunctionComponent = ({ closeModal, setPrivacy onlyContact={true} withIcon={true} closeModal={() => {}} - openModal={() => {}} /> )} {!expandAddress[index] && !!item.address && ( @@ -253,7 +253,7 @@ const Insight: React.FunctionComponent = ({ closeModal, setPrivacy noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={closeModal} + closeScreen={hide} /> diff --git a/components/Memo/Memo.tsx b/components/Memo/Memo.tsx index 720669e0d..57272e733 100644 --- a/components/Memo/Memo.tsx +++ b/components/Memo/Memo.tsx @@ -25,17 +25,18 @@ import { faXmark } from '@fortawesome/free-solid-svg-icons'; import { ButtonTypeEnum, GlobalConst } from '../../app/AppState'; import FadeText from '../Components/FadeText'; import Utils from '../../app/utils'; +import { useMagicModal } from 'react-native-magic-modal'; type MemoProps = { - closeModal: () => void; message: string; includeUAMessage: boolean; setMessage: (m: string) => void; }; -const Memo: React.FunctionComponent = ({ closeModal, message, includeUAMessage, setMessage }) => { +const Memo: React.FunctionComponent = ({ message, includeUAMessage, setMessage }) => { const context = useContext(ContextAppLoaded); const { translate, language, uOrchardAddress } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [memo, setMemo] = useState(message); @@ -47,7 +48,7 @@ const Memo: React.FunctionComponent = ({ closeModal, message, include const doSaveAndClose = () => { setMessage(memo); - closeModal(); + hide(); }; return ( @@ -70,7 +71,7 @@ const Memo: React.FunctionComponent = ({ closeModal, message, include noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> void; scrollToBottom: boolean; - // read-only wallet - setUfvkViewModalVisible?: (v: boolean) => void; // for messages sendTransaction: (s: SendPageStateClass) => Promise; setServerOption: ( @@ -32,7 +30,6 @@ const Messages: React.FunctionComponent = ({ toggleMenuDrawer, syncingStatusMoreInfoOnClick, setPrivacyOption, - setUfvkViewModalVisible, setScrollToTop, scrollToTop, setScrollToBottom, @@ -45,7 +42,6 @@ const Messages: React.FunctionComponent = ({ toggleMenuDrawer={toggleMenuDrawer} syncingStatusMoreInfoOnClick={syncingStatusMoreInfoOnClick} setPrivacyOption={setPrivacyOption} - setUfvkViewModalVisible={setUfvkViewModalVisible} setScrollToTop={setScrollToTop} scrollToTop={scrollToTop} setScrollToBottom={setScrollToBottom} diff --git a/components/Messages/MessagesAddress.tsx b/components/Messages/MessagesAddress.tsx index dfb5511a3..7faed1493 100644 --- a/components/Messages/MessagesAddress.tsx +++ b/components/Messages/MessagesAddress.tsx @@ -17,8 +17,6 @@ type MessagesAddressProps = { setScrollToBottom: (value: boolean) => void; scrollToBottom: boolean; address: string; - closeModal: () => void; - openModal: () => void; sendTransaction: (s: SendPageStateClass) => Promise; setServerOption: ( value: ServerType, @@ -33,8 +31,6 @@ const MessagesAddress: React.FunctionComponent = ({ setScrollToBottom, scrollToBottom, address, - closeModal, - openModal, sendTransaction, setServerOption, }) => { @@ -58,8 +54,6 @@ const MessagesAddress: React.FunctionComponent = ({ setScrollToBottom={setScrollToBottom} scrollToBottom={scrollToBottom} address={address} - closeModal={closeModal} - openModal={openModal} sendTransaction={sendTransaction} setServerOption={setServerOption} /> diff --git a/components/Messages/MessagesAll.tsx b/components/Messages/MessagesAll.tsx index dae45d2b5..5cd3953cc 100644 --- a/components/Messages/MessagesAll.tsx +++ b/components/Messages/MessagesAll.tsx @@ -7,25 +7,23 @@ import { ContextAppLoaded } from '../../app/context'; import { useTheme } from '@react-navigation/native'; import { ThemeType } from '../../app/types'; import moment from 'moment'; +import { useMagicModal } from 'react-native-magic-modal'; type MessagesAllProps = { setPrivacyOption: (value: boolean) => Promise; setScrollToBottom: (value: boolean) => void; scrollToBottom: boolean; - closeModal: () => void; - openModal: () => void; }; const MessagesAll: React.FunctionComponent = ({ setPrivacyOption, setScrollToBottom, scrollToBottom, - closeModal, - openModal, }) => { const context = useContext(ContextAppLoaded); const { language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); return ( @@ -42,8 +40,7 @@ const MessagesAll: React.FunctionComponent = ({ setPrivacyOption={setPrivacyOption} setScrollToBottom={setScrollToBottom} scrollToBottom={scrollToBottom} - closeModal={closeModal} - openModal={openModal} + closeModal={hide} /> diff --git a/components/Messages/MessagesModal.tsx b/components/Messages/MessagesModal.tsx index 840e54a73..4d3dbafeb 100644 --- a/components/Messages/MessagesModal.tsx +++ b/components/Messages/MessagesModal.tsx @@ -3,6 +3,7 @@ import { SelectServerEnum, SendPageStateClass, ServerType } from '../../app/AppS import ContactList from './components/ContactList'; import moment from 'moment'; import { ContextAppLoaded } from '../../app/context'; +import { useMagicModal } from 'react-native-magic-modal'; type MessagesModalProps = { // side menu @@ -17,9 +18,6 @@ type MessagesModalProps = { scrollToTop: boolean; setScrollToBottom: (value: boolean) => void; scrollToBottom: boolean; - closeModal: () => void; - // read-only wallet - setUfvkViewModalVisible?: (v: boolean) => void; // for messages sendTransaction: (s: SendPageStateClass) => Promise; setServerOption: ( @@ -33,31 +31,29 @@ type MessagesModalProps = { const MessagesModal: React.FunctionComponent = ({ syncingStatusMoreInfoOnClick, setPrivacyOption, - setUfvkViewModalVisible, setScrollToTop, scrollToTop, setScrollToBottom, scrollToBottom, sendTransaction, setServerOption, - closeModal, }) => { const context = useContext(ContextAppLoaded); const { language } = context; + const { hide } = useMagicModal(); moment.locale(language); return ( ); diff --git a/components/Messages/components/ContactLine.tsx b/components/Messages/components/ContactLine.tsx index 3f06fd011..99916c8bf 100644 --- a/components/Messages/components/ContactLine.tsx +++ b/components/Messages/components/ContactLine.tsx @@ -39,7 +39,7 @@ type ContactLineProps = { month: string; c: ContactType; setContactDetail: (c: ContactType) => void; - setMessagesAddressModalShowing: (b: boolean) => void; + setMessagesAddressModalShow: () => void; addressProtected?: boolean; }; const ContactLine: React.FunctionComponent = ({ @@ -47,7 +47,7 @@ const ContactLine: React.FunctionComponent = ({ c, month, setContactDetail, - setMessagesAddressModalShowing, + setMessagesAddressModalShow, addressProtected, }) => { const context = useContext(ContextAppLoaded); @@ -120,7 +120,7 @@ const ContactLine: React.FunctionComponent = ({ if (!maxWidthHit.current) { //console.log(value); setContactDetail(c); - setMessagesAddressModalShowing(true); + setMessagesAddressModalShow(); swipeable.reset(); } maxWidthHit.current = true; @@ -151,7 +151,7 @@ const ContactLine: React.FunctionComponent = ({ style={{ zIndex: 999, padding: 20, alignSelf: 'flex-start' }} onPress={() => { setContactDetail(c); - setMessagesAddressModalShowing(true); + setMessagesAddressModalShow(); swipeable.reset(); }}> @@ -251,7 +251,7 @@ const ContactLine: React.FunctionComponent = ({ style={{ zIndex: 999 }} onPress={() => { setContactDetail(c); - setMessagesAddressModalShowing(true); + setMessagesAddressModalShow(); swipeableRef?.current?.reset(); }}> = ({ {c.label ? ( {c.label} ) : ( - {}} openModal={() => {}} /> + {}} /> )} {c.time ? moment((c.time || 0) * 1000).format('MMM D, h:mm a') : ''} diff --git a/components/Messages/components/ContactList.tsx b/components/Messages/components/ContactList.tsx index 96bdb8ca2..bda85c0bb 100644 --- a/components/Messages/components/ContactList.tsx +++ b/components/Messages/components/ContactList.tsx @@ -3,7 +3,6 @@ import React, { useContext, useState, useEffect, useRef } from 'react'; import { View, ScrollView, - Modal, RefreshControl, NativeScrollEvent, NativeSyntheticEvent, @@ -41,12 +40,12 @@ import { MessagesAddress, MessagesAll } from '../../Messages'; import Utils from '../../../app/utils'; import ContactLine from './ContactLine'; import RegText from '../../Components/RegText'; +import { magicModal } from 'react-native-magic-modal'; type ContactListProps = { toggleMenuDrawer?: () => void; syncingStatusMoreInfoOnClick: () => void; setPrivacyOption: (value: boolean) => Promise; - setUfvkViewModalVisible?: (v: boolean) => void; setScrollToTop: (value: boolean) => void; scrollToTop: boolean; setScrollToBottom: (value: boolean) => void; @@ -66,7 +65,6 @@ const ContactList: React.FunctionComponent = ({ toggleMenuDrawer, syncingStatusMoreInfoOnClick, setPrivacyOption, - setUfvkViewModalVisible, setScrollToTop, scrollToTop, setScrollToBottom, @@ -82,8 +80,6 @@ const ContactList: React.FunctionComponent = ({ const { colors } = useTheme() as ThemeType; moment.locale(language); - const [isMessagesAddressModalShowing, setMessagesAddressModalShowing] = useState(false); - const [isMessagesAllModalShowing, setMessagesAllModalShowing] = useState(false); const [contactDetail, setContactDetail] = useState({} as ContactType); const [contacts, setContacts] = useState([]); const [isAtTop, setIsAtTop] = useState(true); @@ -274,6 +270,27 @@ const ContactList: React.FunctionComponent = ({ setIsAtTop(isTop); }; + const setMessagesAddressModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + + const setMessagesAllModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + //console.log('render Contacts', filter, searchMode); //console.log('search text:', searchText, 'field:', searchTextField); @@ -289,45 +306,10 @@ const ContactList: React.FunctionComponent = ({ height: '100%', backgroundColor: colors.background, }}> - {isMessagesAddressModalShowing && ( - setMessagesAddressModalShowing(false)}> - setMessagesAddressModalShowing(false)} - openModal={() => setMessagesAddressModalShowing(true)} - sendTransaction={sendTransaction} - setServerOption={setServerOption} - /> - - )} - - {isMessagesAllModalShowing && ( - setMessagesAllModalShowing(false)}> - setMessagesAllModalShowing(false)} - openModal={() => setMessagesAllModalShowing(true)} - /> - - )}
= ({ { // call the screen - setMessagesAllModalShowing(true); + setMessagesAllModalShow(); }}> = ({ c={c} month={month} setContactDetail={(ttt: ContactType) => setContactDetail(ttt)} - setMessagesAddressModalShowing={(bbb: boolean) => setMessagesAddressModalShowing(bbb)} + setMessagesAddressModalShow={setMessagesAddressModalShow} addressProtected={c.address === zenniesDonationAddress} /> ); diff --git a/components/Messages/components/MessageLine.tsx b/components/Messages/components/MessageLine.tsx index f3870fadf..35284eb27 100644 --- a/components/Messages/components/MessageLine.tsx +++ b/components/Messages/components/MessageLine.tsx @@ -34,18 +34,14 @@ type MessageLineProps = { index: number; month: string; vt: ValueTransferType; - setValueTransferDetail: (t: ValueTransferType) => void; - setValueTransferDetailIndex: (i: number) => void; - setValueTransferDetailModalShowing: (b: boolean) => void; + setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => void; messageAddress?: string; }; const MessageLine: React.FunctionComponent = ({ index, vt, month, - setValueTransferDetail, - setValueTransferDetailIndex, - setValueTransferDetailModalShowing, + setValueTransferDetailModalShow, messageAddress, }) => { const context = useContext(ContextAppLoaded); @@ -106,9 +102,7 @@ const MessageLine: React.FunctionComponent = ({ { - setValueTransferDetail(vt); - setValueTransferDetailIndex(index); - setValueTransferDetailModalShowing(true); + setValueTransferDetailModalShow(index, vt); }}> = ({ }}> {!!vt.address && !messageAddress && ( - {}} openModal={() => {}} /> + {}} /> )} {(!!memo || !!memoUA) && ( @@ -178,7 +172,6 @@ const MessageLine: React.FunctionComponent = ({ address={memoUA} onlyContact={true} closeModal={() => {}} - openModal={() => {}} /> )} diff --git a/components/Messages/components/MessageList.tsx b/components/Messages/components/MessageList.tsx index c9dfbc096..bd98cc4a6 100644 --- a/components/Messages/components/MessageList.tsx +++ b/components/Messages/components/MessageList.tsx @@ -3,7 +3,6 @@ import React, { useContext, useState, useEffect, useCallback, useMemo, useRef } import { View, ScrollView, - Modal, RefreshControl, NativeScrollEvent, NativeSyntheticEvent, @@ -58,6 +57,7 @@ import { createAlert } from '../../../app/createAlert'; import selectingServer from '../../../app/selectingServer'; import { serverUris } from '../../../app/uris'; import Utils from '../../../app/utils'; +import { magicModal } from 'react-native-magic-modal'; type MessageListProps = { setPrivacyOption: (value: boolean) => Promise; @@ -65,7 +65,6 @@ type MessageListProps = { scrollToBottom: boolean; address?: string; closeModal?: () => void; - openModal?: () => void; sendTransaction?: (s: SendPageStateClass) => Promise; setServerOption?: ( value: ServerType, @@ -81,7 +80,6 @@ const MessageList: React.FunctionComponent = ({ scrollToBottom, address, closeModal, - openModal, sendTransaction, setServerOption, }) => { @@ -105,9 +103,6 @@ const MessageList: React.FunctionComponent = ({ const { colors } = useTheme() as ThemeType; moment.locale(language); - const [isValueTransferDetailModalShowing, setValueTransferDetailModalShowing] = useState(false); - const [valueTransferDetail, setValueTransferDetail] = useState({} as ValueTransferType); - const [valueTransferDetailIndex, setValueTransferDetailIndex] = useState(-1); const [numVt, setNumVt] = useState(50); const [loadMoreButton, setLoadMoreButton] = useState(false); const [messagesSliced, setMessagesSliced] = useState([]); @@ -119,7 +114,6 @@ const MessageList: React.FunctionComponent = ({ const [contentScrollViewHeight, setContentScrollViewHeight] = useState(0); const [scrollable, setScrollable] = useState(false); const [memoIcon, setMemoIcon] = useState(false); - const [memoModalVisible, setMemoModalVisible] = useState(false); const [validMemo, setValidMemo] = useState(0); // 1 - OK, 0 - Empty, -1 - KO const [disableSend, setDisableSend] = useState(false); const [anonymous, setAnonymous] = useState(false); @@ -310,15 +304,6 @@ const MessageList: React.FunctionComponent = ({ setNumVt(numVt + 50); }, [numVt]); - const moveValueTransferDetail = (index: number, type: number) => { - // -1 -> Previous ValueTransfer - // 1 -> Next ValueTransfer - if ((index > 0 && type === -1) || (index < messagesSliced.length - 1 && type === 1)) { - setValueTransferDetail(messagesSliced[index + type]); - setValueTransferDetailIndex(index + type); - } - }; - const handleScrollToBottom = () => { if (scrollViewRef.current) { scrollViewRef.current.scrollToEnd({ animated: true }); @@ -498,6 +483,26 @@ const MessageList: React.FunctionComponent = ({ totalBalance?.spendablePrivate, ]); + const setMemoModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + + const setValueTransferDetailModalShow = async (index: number, vt: ValueTransferType) => { + await magicModal.show(() => + ).promise; + }; + //if (address) { // console.log('render Messages', validMemo, 'memo local:', memo); //} @@ -523,39 +528,7 @@ const MessageList: React.FunctionComponent = ({ }%` : '100%', }}> - setValueTransferDetailModalShowing(false)}> - setValueTransferDetailModalShowing(false)} - openModal={() => setValueTransferDetailModalShowing(true)} - setPrivacyOption={setPrivacyOption} - moveValueTransferDetail={moveValueTransferDetail} - /> - - - setMemoModalVisible(false)}> - { - setMemoModalVisible(false); - }} - message={memo} - includeUAMessage={true} - setMessage={setMemo} - /> - - - {address && closeModal && openModal ? ( + {address ? ( <>
= ({ address={address} oneLine={true} withIcon={true} - closeModal={closeModal} - openModal={openModal} + closeModal={closeModalAndClean} /> @@ -770,9 +742,7 @@ const MessageList: React.FunctionComponent = ({ index={index} vt={vt} month={month} - setValueTransferDetail={(ttt: ValueTransferType) => setValueTransferDetail(ttt)} - setValueTransferDetailIndex={(iii: number) => setValueTransferDetailIndex(iii)} - setValueTransferDetailModalShowing={(bbb: boolean) => setValueTransferDetailModalShowing(bbb)} + setValueTransferDetailModalShow={setValueTransferDetailModalShow} messageAddress={address} /> ); @@ -895,7 +865,7 @@ const MessageList: React.FunctionComponent = ({ { Keyboard.dismiss(); - setMemoModalVisible(true); + setMemoModalShow(); }}> diff --git a/components/Pools/Pools.tsx b/components/Pools/Pools.tsx index 84d12b39e..0e17b166b 100644 --- a/components/Pools/Pools.tsx +++ b/components/Pools/Pools.tsx @@ -21,16 +21,17 @@ import 'moment/locale/ru'; import { CommandEnum } from '../../app/AppState'; import RPCModule from '../../app/RPCModule'; import { RPCWalletKindType } from '../../app/rpc/types/RPCWalletKindType'; +import { useMagicModal } from 'react-native-magic-modal'; type PoolsProps = { - closeModal: () => void; setPrivacyOption: (value: boolean) => Promise; }; -const Pools: React.FunctionComponent = ({ closeModal, setPrivacyOption }) => { +const Pools: React.FunctionComponent = ({ setPrivacyOption }) => { const context = useContext(ContextAppLoaded); const { totalBalance, info, translate, privacy, addLastSnackbar, somePending, language, shieldingAmount } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); const [orchardPool, setOrchardPool] = useState(false); const [saplingPool, setSaplingPool] = useState(false); const [transparentPool, setTransparentPool] = useState(false); @@ -69,7 +70,7 @@ const Pools: React.FunctionComponent = ({ closeModal, setPrivacyOpti noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={closeModal} + closeScreen={hide} /> void; address: string; keyType: number; privKey: string; }; -const PrivKey: React.FunctionComponent = ({ address, keyType, privKey, closeModal }) => { +const PrivKey: React.FunctionComponent = ({ address, keyType, privKey }) => { const context = useContext(ContextAppLoaded); const { translate, addLastSnackbar, language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [expandAddress, setExpandAddress] = useState(false); @@ -71,7 +72,7 @@ const PrivKey: React.FunctionComponent = ({ address, keyType, priv noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> void; syncingStatusMoreInfoOnClick: () => void; - setUfvkViewModalVisible?: (v: boolean) => void; alone: boolean; }; @@ -34,8 +33,6 @@ const Receive: React.FunctionComponent = ({ syncingStatusMoreInfoOnClick, // privacy // shielding - // read-only wallet - setUfvkViewModalVisible, // for receive alone, }) => { @@ -335,7 +332,6 @@ const Receive: React.FunctionComponent = ({ } toggleMenuDrawer={toggleMenuDrawer} syncingStatusMoreInfoOnClick={syncingStatusMoreInfoOnClick} - setUfvkViewModalVisible={setUfvkViewModalVisible} noBalance={true} noPrivacy={true} /> diff --git a/components/Rescan/Rescan.tsx b/components/Rescan/Rescan.tsx index bd991c52d..34de5e73b 100644 --- a/components/Rescan/Rescan.tsx +++ b/components/Rescan/Rescan.tsx @@ -15,16 +15,17 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import { ButtonTypeEnum, SelectServerEnum, SnackbarDurationEnum } from '../../app/AppState'; +import { useMagicModal } from 'react-native-magic-modal'; type RescanProps = { - closeModal: () => void; doRescan: () => void; }; -const Rescan: React.FunctionComponent = ({ closeModal, doRescan }) => { +const Rescan: React.FunctionComponent = ({ doRescan }) => { const context = useContext(ContextAppLoaded); const { wallet, translate, netInfo, addLastSnackbar, language, selectServer } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const doRescanAndClose = () => { @@ -33,7 +34,7 @@ const Rescan: React.FunctionComponent = ({ closeModal, doRescan }) return; } doRescan(); - closeModal(); + hide(); addLastSnackbar({ message: translate('loadedapp.syncing') as string, duration: SnackbarDurationEnum.longer, @@ -56,7 +57,7 @@ const Rescan: React.FunctionComponent = ({ closeModal, doRescan }) noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> = ({ } const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [seedPhrase, setSeedPhrase] = useState(''); @@ -164,15 +166,25 @@ const Seed: React.FunctionComponent = ({ { text: translate('confirm') as string, onPress: () => { - onClickOK(seedPhrase, Number(birthdayNumber)); + onClickOKHide(seedPhrase, Number(birthdayNumber)); }, }, - { text: translate('cancel') as string, onPress: () => onClickCancel(), style: 'cancel' }, + { text: translate('cancel') as string, onPress: () => onClickCancelHide(), style: 'cancel' }, ], { cancelable: false }, ); }; + const onClickCancelHide = () => { + onClickCancel(); + hide(); + }; + + const onClickOKHide = (seedPhraseParm: string, birthdayNumberParm: number) => { + onClickOK(seedPhraseParm, birthdayNumberParm); + hide(); + }; + //console.log('================================='); //console.log(wallet.seed, wallet.birthday); //console.log('render seed', privacy); @@ -199,7 +211,7 @@ const Seed: React.FunctionComponent = ({ mode={mode} privacy={privacy} receivedLegend={action === SeedActionEnum.view ? !basicFirstViewSeed : false} - closeScreen={onClickCancel} + closeScreen={onClickCancelHide} /> = ({ keepAwake(false); } if (times === 0) { - onClickOK(seedPhrase, Number(birthdayNumber)); + onClickOKHide(seedPhrase, Number(birthdayNumber)); } else if (times === 1) { onPressOK(); } diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index f431dd444..8cab81e25 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -1,6 +1,6 @@ /* eslint-disable react-native/no-inline-styles */ import React, { useState, useEffect, useContext, useCallback, useRef } from 'react'; -import { View, ScrollView, Modal, Keyboard, TextInput, TouchableOpacity, Platform, Text, Alert } from 'react-native'; +import { View, ScrollView, Keyboard, TextInput, TouchableOpacity, Platform, Text, Alert } from 'react-native'; import { faQrcode, faCheck, @@ -35,6 +35,7 @@ import { ServerUrisType, ServerType, SelectServerEnum, + RouteEnums, } from '../../app/AppState'; import { parseZcashURI, serverUris, ZcashURITargetClass } from '../../app/uris'; import RPCModule from '../../app/RPCModule'; @@ -59,6 +60,7 @@ import { RPCSpendablebalanceType } from '../../app/rpc/types/RPCSpendablebalance import { RPCSendallProposeType } from '../../app/rpc/types/RPCSendallProposeType'; import { sendEmail } from '../../app/sendEmail'; import selectingServer from '../../app/selectingServer'; +import { magicModal } from 'react-native-magic-modal'; type SendProps = { // side menu @@ -72,11 +74,8 @@ type SendProps = { // addLastSnackbar from context // shielding setShieldingAmount: (value: number) => void; - setComputingModalVisible: (visible: boolean) => void; setScrollToTop: (value: boolean) => void; setScrollToBottom: (value: boolean) => void; - // read-only wallet - setUfvkViewModalVisible?: (v: boolean) => void; // for send sendTransaction: (s: SendPageStateClass) => Promise; setServerOption: ( @@ -92,11 +91,9 @@ const Send: React.FunctionComponent = ({ sendTransaction, clearToAddr, toggleMenuDrawer, - setComputingModalVisible, syncingStatusMoreInfoOnClick, poolsMoreInfoOnClick, setPrivacyOption, - setUfvkViewModalVisible, setShieldingAmount, setScrollToTop, setScrollToBottom, @@ -127,12 +124,12 @@ const Send: React.FunctionComponent = ({ selectServer, setZecPrice, zenniesDonationAddress, + setComputingModalShow, + closeAllModals, } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); - const [qrcodeModalVisble, setQrcodeModalVisible] = useState(false); - const [confirmModalVisible, setConfirmModalVisible] = useState(false); const [memoEnabled, setMemoEnabled] = useState(false); const [validAddress, setValidAddress] = useState(0); // 1 - OK, 0 - Empty, -1 - KO const [validAmount, setValidAmount] = useState(0); // 1 - OK, 0 - Empty, -1 - Invalid number, -2 - Invalid Amount @@ -140,7 +137,6 @@ const Send: React.FunctionComponent = ({ const [sendButtonEnabled, setSendButtonEnabled] = useState(false); const [itemsPicker, setItemsPicker] = useState<{ label: string; value: string }[]>([]); const [memoIcon, setMemoIcon] = useState(false); - const [memoModalVisible, setMemoModalVisible] = useState(false); const [maxAmount, setMaxAmount] = useState(0); const [spendable, setSpendable] = useState(0); const [fee, setFee] = useState(0); @@ -704,15 +700,13 @@ const Send: React.FunctionComponent = ({ const confirmSend = async (sendPageStatePar: SendPageStateClass) => { if (!netInfo.isConnected || selectServer === SelectServerEnum.offline) { - setConfirmModalVisible(false); addLastSnackbar({ message: translate('loadedapp.connection-error') as string }); return; } // first interrupt syncing Just in case... await RPC.rpcSetInterruptSyncAfterBatch(GlobalConst.true); // First, close the confirm modal and show the "computing" modal - setConfirmModalVisible(false); - setComputingModalVisible(true); + setComputingModalShow(); // call the sendTransaction method in a timeout, allowing the modals to show properly setTimeout(async () => { @@ -724,9 +718,10 @@ const Send: React.FunctionComponent = ({ // Clear the fields clearState(); - if (navigation) { - navigation.navigate(translate('loadedapp.history-menu') as string); - } + navigation.navigate(RouteEnums.LoadedApp, { + screen: translate('loadedapp.history-menu') as string, + initial: false, + }); // scroll to top in history, just in case. setScrollToTop(true); @@ -740,7 +735,7 @@ const Send: React.FunctionComponent = ({ true, translate, ); - setComputingModalVisible(false); + closeAllModals(); // the app send successfully on the first attemp. // the sync process can continue @@ -782,9 +777,10 @@ const Send: React.FunctionComponent = ({ // Clear the fields clearState(); - if (navigation) { - navigation.navigate(translate('loadedapp.history-menu') as string); - } + navigation.navigate(RouteEnums.LoadedApp, { + screen: translate('loadedapp.history-menu') as string, + initial: false, + }); // scroll to top in history, just in case. setScrollToTop(true); @@ -798,7 +794,7 @@ const Send: React.FunctionComponent = ({ true, translate, ); - setComputingModalVisible(false); + closeAllModals(); // the app send successfully on the second attemp. // the sync process can continue @@ -830,7 +826,7 @@ const Send: React.FunctionComponent = ({ info.zingolib, ); }, 1000); - setComputingModalVisible(false); + closeAllModals(); }); }; @@ -856,6 +852,43 @@ const Send: React.FunctionComponent = ({ } }; + const setQrcodeModalShow = async () => { + await magicModal.show(() => { + updateToField(a, null, null, null, null); + }} + /> + ).promise; + }; + + const setMemoModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + + const setConfirmModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + //console.log( // 'Render, spendable', // spendable, @@ -880,62 +913,6 @@ const Send: React.FunctionComponent = ({ height: '100%', marginBottom: 200, }}> - setQrcodeModalVisible(false)}> - { - updateToField(a, null, null, null, null); - }} - closeModal={() => setQrcodeModalVisible(false)} - /> - - - setConfirmModalVisible(false)}> - { - setConfirmModalVisible(false); - }} - openModal={() => { - setConfirmModalVisible(true); - }} - confirmSend={confirmSend} - sendAllAmount={ - mode !== ModeEnum.basic && - Utils.parseStringLocaleToNumberFloat(amountText) === - Utils.parseStringLocaleToNumberFloat(maxAmount.toFixed(8)) - } - calculateFeeWithPropose={calculateFeeWithPropose} - sendPageState={buildSendState()} - /> - - - setMemoModalVisible(false)}> - { - setMemoModalVisible(false); - }} - message={memoText} - includeUAMessage={includeUAMemoBoolean} - setMessage={setMemoText} - /> - { @@ -951,11 +928,9 @@ const Send: React.FunctionComponent = ({ setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar /* context */} setShieldingAmount={setShieldingAmount} - setComputingModalVisible={setComputingModalVisible} setScrollToTop={setScrollToTop} setScrollToBottom={setScrollToBottom} setBackgroundError={setBackgroundError /* context */} - setUfvkViewModalVisible={setUfvkViewModalVisible} /> = ({ onlyContact={true} withIcon={true} closeModal={() => {}} - openModal={() => {}} /> )} @@ -1128,7 +1102,7 @@ const Send: React.FunctionComponent = ({ accessible={true} accessibilityLabel={translate('send.scan-acc') as string} onPress={() => { - setQrcodeModalVisible(true); + setQrcodeModalShow(); }}> @@ -1644,7 +1618,7 @@ const Send: React.FunctionComponent = ({ {memoIcon && ( { - setMemoModalVisible(true); + setMemoModalShow(); }}> = ({ } // waiting while closing the keyboard, just in case. setTimeout(async () => { - setConfirmModalVisible(true); + setConfirmModalShow(); }, 100); }} twoButtons={true} diff --git a/components/Send/components/Confirm.tsx b/components/Send/components/Confirm.tsx index 98f3b3851..00fac54a6 100644 --- a/components/Send/components/Confirm.tsx +++ b/components/Send/components/Confirm.tsx @@ -34,12 +34,11 @@ import { CurrencyEnum } from '../../../app/AppState'; import { RPCAddressKindEnum } from '../../../app/rpc/enums/RPCAddressKindEnum'; import { RPCReceiversEnum } from '../../../app/rpc/enums/RPCReceiversEnum'; import { RPCParseAddressStatusEnum } from '../../../app/rpc/enums/RPCParseAddressStatusEnum'; +import { useMagicModal } from 'react-native-magic-modal'; type ConfirmProps = { calculatedFee: number; donationAmount: number; - closeModal: () => void; - openModal: () => void; confirmSend: (s: SendPageStateClass) => void; sendAllAmount: boolean; calculateFeeWithPropose: ( @@ -52,12 +51,10 @@ type ConfirmProps = { sendPageState: SendPageStateClass; }; const Confirm: React.FunctionComponent = ({ - closeModal, confirmSend, calculatedFee, donationAmount, sendAllAmount, - openModal, calculateFeeWithPropose, sendPageState, }) => { @@ -76,6 +73,7 @@ const Confirm: React.FunctionComponent = ({ language, } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [privacyLevel, setPrivacyLevel] = useState(null); @@ -285,7 +283,7 @@ const Confirm: React.FunctionComponent = ({ noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> = ({ return ( {translate('send.to') as string} - + {donationAmount > 0 && ( <> diff --git a/components/Send/components/ScannerAddress.tsx b/components/Send/components/ScannerAddress.tsx index 6840c7ea0..12f18edfd 100644 --- a/components/Send/components/ScannerAddress.tsx +++ b/components/Send/components/ScannerAddress.tsx @@ -15,22 +15,23 @@ import { ThemeType } from '../../../app/types'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { Code } from 'react-native-vision-camera'; +import { useMagicModal } from 'react-native-magic-modal'; type ScannerAddressProps = { setAddress: (address: string) => void; - closeModal: () => void; }; -const ScannerAddress: React.FunctionComponent = ({ setAddress, closeModal }) => { +const ScannerAddress: React.FunctionComponent = ({ setAddress }) => { const context = useContext(ContextAppLoaded); const { translate, server, language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const validateAddress = async (scannedAddress: string) => { if (scannedAddress.toLowerCase().startsWith(GlobalConst.zcash)) { setAddress(scannedAddress); - closeModal(); + hide(); return; } @@ -41,7 +42,7 @@ const ScannerAddress: React.FunctionComponent = ({ setAddre if (validAddress.isValid) { setAddress(scannedAddress); - closeModal(); + hide(); } }; @@ -56,7 +57,7 @@ const ScannerAddress: React.FunctionComponent = ({ setAddre }; const doCancel = () => { - closeModal(); + hide(); }; return ( diff --git a/components/Settings/Settings.tsx b/components/Settings/Settings.tsx index 62772b6fa..c1f6d221e 100644 --- a/components/Settings/Settings.tsx +++ b/components/Settings/Settings.tsx @@ -46,9 +46,9 @@ import ChainTypeToggle from '../Components/ChainTypeToggle'; import BouncyCheckbox from 'react-native-bouncy-checkbox'; import RNPickerSelect from 'react-native-picker-select'; import { hasRecoveryWalletInfo } from '../../app/recoveryWalletInfo'; +import { useMagicModal } from 'react-native-magic-modal'; type SettingsProps = { - closeModal: () => void; setWalletOption: (walletOption: string, value: string) => Promise; setServerOption: ( value: ServerType, @@ -86,7 +86,6 @@ const Settings: React.FunctionComponent = ({ setSelectServerOption, setRescanMenuOption, setRecoveryWalletInfoOnDeviceOption, - closeModal, }) => { const context = useContext(ContextAppLoaded); const { @@ -164,6 +163,7 @@ const Settings: React.FunctionComponent = ({ } const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(languageContext); const [memos, setMemos] = useState(walletSettings.downloadMemos); @@ -456,7 +456,7 @@ const Settings: React.FunctionComponent = ({ } setTimeout(() => { - closeModal(); + hide(); }, ms); }; @@ -553,7 +553,7 @@ const Settings: React.FunctionComponent = ({ noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> void; }; -const SyncReport: React.FunctionComponent = ({ closeModal }) => { +const SyncReport: React.FunctionComponent = () => { const context = useContext(ContextAppLoaded); const { syncingStatus, wallet, translate, background, language, netInfo } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [maxBlocks, setMaxBlocks] = useState(0); @@ -228,7 +229,7 @@ const SyncReport: React.FunctionComponent = ({ closeModal }) => noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={closeModal} + closeScreen={hide} /> void; @@ -40,7 +40,6 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o const [seedufvkText, setSeedufvkText] = useState(''); const [birthday, setBirthday] = useState(''); - const [qrcodeModalVisible, setQrcodeModalVisible] = useState(false); const [latestBlock, setLatestBlock] = useState(0); useEffect(() => { @@ -108,6 +107,13 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o onClickOK(seedufvkText.trimEnd().trimStart(), Number(birthday)); }; + const setQrcodeModalShow = async () => { + await magicModal.show(() => + ).promise; + }; + return ( = ({ onClickCancel, o height: '100%', backgroundColor: colors.background, }}> - setQrcodeModalVisible(false)}> - setQrcodeModalVisible(false)} /> -
= ({ onClickCancel, o )} { - setQrcodeModalVisible(true); + setQrcodeModalShow(); }}> diff --git a/components/Ufvk/ShowUfvk.tsx b/components/Ufvk/ShowUfvk.tsx index 143fb975b..39a408e26 100644 --- a/components/Ufvk/ShowUfvk.tsx +++ b/components/Ufvk/ShowUfvk.tsx @@ -16,6 +16,7 @@ import 'moment/locale/pt'; import 'moment/locale/ru'; import RegText from '../Components/RegText'; import { ButtonTypeEnum, ChainNameEnum, ModeEnum, UfvkActionEnum } from '../../app/AppState'; +import { useMagicModal } from 'react-native-magic-modal'; type TextsType = { new: string[]; @@ -36,6 +37,7 @@ const ShowUfvk: React.FunctionComponent = ({ onClickOK, onClickCa const context = useContext(ContextAppLoaded); const { translate, wallet, server, mode, addLastSnackbar, language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [times, setTimes] = useState(0); @@ -70,14 +72,24 @@ const ShowUfvk: React.FunctionComponent = ({ onClickOK, onClickCa [ { text: translate('confirm') as string, - onPress: () => onClickOK(), + onPress: () => onClickOKHide(), }, - { text: translate('cancel') as string, onPress: () => onClickCancel(), style: 'cancel' }, + { text: translate('cancel') as string, onPress: () => onClickCancelHide(), style: 'cancel' }, ], { cancelable: false }, ); }; + const onClickCancelHide = () => { + onClickCancel(); + hide(); + }; + + const onClickOKHide = () => { + onClickOK(); + hide(); + }; + return ( = ({ onClickOK, onClickCa noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={onClickCancel} + closeScreen={onClickCancelHide} /> = ({ onClickOK, onClickCa return; } if (times === 0) { - onClickOK(); + onClickOKHide(); } else if (times === 1) { onPressOK(); } diff --git a/components/Ufvk/components/ScannerUfvk.tsx b/components/Ufvk/components/ScannerUfvk.tsx index 49fe89479..1b7584e04 100644 --- a/components/Ufvk/components/ScannerUfvk.tsx +++ b/components/Ufvk/components/ScannerUfvk.tsx @@ -12,15 +12,16 @@ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { useTheme } from '@react-navigation/native'; import { ThemeType } from '../../../app/types'; import { Code } from 'react-native-vision-camera'; +import { useMagicModal } from 'react-native-magic-modal'; type ScannerKeyProps = { setUfvkText: (k: string) => void; - closeModal: () => void; }; -const ScannerKey: React.FunctionComponent = ({ setUfvkText, closeModal }) => { +const ScannerKey: React.FunctionComponent = ({ setUfvkText }) => { const context = useContext(ContextAppLoading); const { translate, language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const onRead = async (codes: Code[]) => { @@ -31,11 +32,11 @@ const ScannerKey: React.FunctionComponent = ({ setUfvkText, clo } setUfvkText(scandata); - closeModal(); + hide(); }; const doCancel = () => { - closeModal(); + hide(); }; return ( diff --git a/package.json b/package.json index 968453a72..50e0d3e6d 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "react-native-keychain": "^9.2.2", "react-native-linear-gradient": "^2.8.3", "react-native-localize": "^3.1.0", + "react-native-magic-modal": "^6.0.3", "react-native-pager-view": "^6.0.1", "react-native-permissions": "^4.1.5", "react-native-picker-select": "^9.1.3", diff --git a/patches/react-native-qrcode-svg+6.3.14.patch b/patches/react-native-qrcode-svg+6.3.14.patch deleted file mode 100644 index 848d669a3..000000000 --- a/patches/react-native-qrcode-svg+6.3.14.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/node_modules/react-native-qrcode-svg/src/LogoSVG/index.native.js b/node_modules/react-native-qrcode-svg/src/LogoSVG/index.native.js -index 6c5b14a..3827574 100644 ---- a/node_modules/react-native-qrcode-svg/src/LogoSVG/index.native.js -+++ b/node_modules/react-native-qrcode-svg/src/LogoSVG/index.native.js -@@ -1,5 +1,5 @@ - import React from "react"; --import { LocalSvg } from "react-native-svg/css"; -+import { LocalSvg } from "react-native-svg"; - import { SvgUri, SvgXml } from "react-native-svg"; - import { isString, isUrlString } from "../utils"; - From f1a14e65fc29d3ebb18b43c33e7677f4a187dc37 Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 27 Feb 2025 10:15:09 -0700 Subject: [PATCH 2/8] fix: snapshot test fixed --- __tests__/History.ValueTransferDetail.unit.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/History.ValueTransferDetail.unit.tsx b/__tests__/History.ValueTransferDetail.unit.tsx index ea3aefb6a..4d4d25b46 100644 --- a/__tests__/History.ValueTransferDetail.unit.tsx +++ b/__tests__/History.ValueTransferDetail.unit.tsx @@ -149,8 +149,8 @@ describe('Component History ValueTransferDetail - test', () => { render( Date: Thu, 27 Feb 2025 11:19:05 -0700 Subject: [PATCH 3/8] fix: adjustments & fixes --- app/LoadedApp/LoadedApp.tsx | 40 +++++++++---------- components/Components/AddressItem.tsx | 6 ++- components/Components/SingleAddress.tsx | 2 +- components/Components/TextInputAddress.tsx | 2 +- components/History/History.tsx | 4 +- .../components/ValueTransferDetail.tsx | 2 +- .../History/components/ValueTransferLine.tsx | 2 +- components/Insight/Insight.tsx | 1 - components/Messages/MessagesAddress.tsx | 3 ++ .../Messages/components/ContactLine.tsx | 2 +- .../Messages/components/ContactList.tsx | 4 +- .../Messages/components/MessageLine.tsx | 3 +- .../Messages/components/MessageList.tsx | 15 ++----- components/Send/Send.tsx | 7 ++-- components/Send/components/Confirm.tsx | 2 +- components/Send/components/ScannerAddress.tsx | 6 +-- components/Ufvk/ImportUfvk.tsx | 2 +- components/Ufvk/components/ScannerUfvk.tsx | 6 +-- 18 files changed, 48 insertions(+), 61 deletions(-) diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index 4535d7da0..a5ec876e0 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -795,7 +795,7 @@ export class LoadedAppClass extends Component + />, { swipeDirection: undefined } ); }; @@ -805,7 +805,7 @@ export class LoadedAppClass extends Component {}} action={UfvkActionEnum.view} setPrivacyOption={this.setPrivacyOption} - /> + />, { swipeDirection: undefined } ); }; @@ -1044,7 +1044,7 @@ export class LoadedAppClass extends Component { - magicModal.show(() => ); + magicModal.show(() => , { swipeDirection: undefined }); }; setInfo = (info: InfoType) => { @@ -1137,9 +1137,9 @@ export class LoadedAppClass extends Component ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Rescan) { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Settings) { return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Info) { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.SyncReport) { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.FundPools) { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Insight) { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.WalletSeedUfvk) { if (this.state.readOnly) { this.setUfvkViewModalShow(); @@ -1176,7 +1176,7 @@ export class LoadedAppClass extends Component {}} action={UfvkActionEnum.change} setPrivacyOption={this.setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; } else { return magicModal.show(() => {}} action={SeedActionEnum.change} setPrivacyOption={this.setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; } } else if (item === MenuItemEnum.RestoreWalletBackup) { @@ -1194,7 +1194,7 @@ export class LoadedAppClass extends Component {}} action={UfvkActionEnum.backup} setPrivacyOption={this.setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; } else { return magicModal.show(() => {}} action={SeedActionEnum.backup} setPrivacyOption={this.setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; } } else if (item === MenuItemEnum.LoadWalletFromSeed) { @@ -1241,7 +1241,7 @@ export class LoadedAppClass extends Component ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.VoteForNym) { let update = false; if ( @@ -1293,7 +1293,7 @@ export class LoadedAppClass extends Component).promise; + />, { swipeDirection: undefined }).promise; } }; @@ -1380,7 +1380,7 @@ export class LoadedAppClass extends Component + />, { swipeDirection: undefined } ).promise; } else { await magicModal.show(() => + />, { swipeDirection: undefined } ).promise; } //console.log(`Error Reading Wallet ${value} - ${error}`); @@ -1674,11 +1674,11 @@ export class LoadedAppClass extends Component { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; }; poolsMoreInfoOnClick = async () => { - return magicModal.show(() => ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; }; setBackgroundError = (title: string, error: string) => { @@ -1711,7 +1711,7 @@ export class LoadedAppClass extends Component ).promise; + return magicModal.show(() => , { swipeDirection: undefined }).promise; }; setScrollToTop = (value: boolean) => { diff --git a/components/Components/AddressItem.tsx b/components/Components/AddressItem.tsx index 519928dd9..df73928ba 100644 --- a/components/Components/AddressItem.tsx +++ b/components/Components/AddressItem.tsx @@ -25,7 +25,7 @@ import 'moment/locale/ru'; type AddressItemProps = { address: string; - closeModal: () => void; + closeModal?: () => void; oneLine?: boolean; onlyContact?: boolean; withIcon?: boolean; @@ -190,7 +190,9 @@ const AddressItem: React.FunctionComponent = ({ const sendPageState = new SendPageStateClass(new ToAddrClass(0)); sendPageState.toaddr.to = address; setSendPageState(sendPageState); - closeModal(); + if (closeModal) { + closeModal(); + } navigation.navigate(RouteEnums.LoadedApp, { screen: translate('loadedapp.send-menu'), initial: false, diff --git a/components/Components/SingleAddress.tsx b/components/Components/SingleAddress.tsx index a59aba0a9..9c62c8457 100644 --- a/components/Components/SingleAddress.tsx +++ b/components/Components/SingleAddress.tsx @@ -198,7 +198,7 @@ const SingleAddress: React.FunctionComponent = ({ address, i justifyContent: 'center', marginBottom: 30, }}> - {}} /> + diff --git a/components/Components/TextInputAddress.tsx b/components/Components/TextInputAddress.tsx index c9fdc2a2a..17b7575af 100644 --- a/components/Components/TextInputAddress.tsx +++ b/components/Components/TextInputAddress.tsx @@ -61,7 +61,7 @@ const TextInputAddress: React.FunctionComponent = ({ }, [address, server.chainName, setError, setUOrchardAddress, translate]); const setQrcodeModalShow = async () => { - await magicModal.show(() => ).promise; + await magicModal.show(() => , { swipeDirection: undefined }).promise; }; //console.log('render input text address'); diff --git a/components/History/History.tsx b/components/History/History.tsx index 05a32c123..b645464e0 100644 --- a/components/History/History.tsx +++ b/components/History/History.tsx @@ -154,7 +154,7 @@ const History: React.FunctionComponent = ({ valueTransfersSliced={valueTransfersSliced} totalLength={valueTransfers !== null ? valueTransfers.length : 0} setPrivacyOption={setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -166,7 +166,7 @@ const History: React.FunctionComponent = ({ address={Utils.messagesAddress(vt)} sendTransaction={sendTransaction} setServerOption={setServerOption} - /> + />, { swipeDirection: undefined } ).promise; }; diff --git a/components/History/components/ValueTransferDetail.tsx b/components/History/components/ValueTransferDetail.tsx index 341553629..6048c6f7b 100644 --- a/components/History/components/ValueTransferDetail.tsx +++ b/components/History/components/ValueTransferDetail.tsx @@ -425,7 +425,7 @@ const ValueTransferDetail: React.FunctionComponent = ( {!thisWalletAddress(memoUA) && ( {translate('addressbook.likely') as string} )} - {}} /> + )} {!contactFound(memoUA) && thisWalletAddress(memoUA) && ( diff --git a/components/History/components/ValueTransferLine.tsx b/components/History/components/ValueTransferLine.tsx index 5a0a3e166..9d7b515f1 100644 --- a/components/History/components/ValueTransferLine.tsx +++ b/components/History/components/ValueTransferLine.tsx @@ -310,7 +310,7 @@ const ValueTransferLine: React.FunctionComponent = ({ {!!vt.address && vt.confirmations > 0 && ( - {}} /> + )} = ({ setPrivacyOption }) => oneLine={true} onlyContact={true} withIcon={true} - closeModal={() => {}} /> )} {!expandAddress[index] && !!item.address && ( diff --git a/components/Messages/MessagesAddress.tsx b/components/Messages/MessagesAddress.tsx index 7faed1493..e97c854f4 100644 --- a/components/Messages/MessagesAddress.tsx +++ b/components/Messages/MessagesAddress.tsx @@ -11,6 +11,7 @@ import moment from 'moment'; import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; +import { useMagicModal } from 'react-native-magic-modal'; type MessagesAddressProps = { setPrivacyOption: (value: boolean) => Promise; @@ -37,6 +38,7 @@ const MessagesAddress: React.FunctionComponent = ({ const context = useContext(ContextAppLoaded); const { language } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); return ( @@ -56,6 +58,7 @@ const MessagesAddress: React.FunctionComponent = ({ address={address} sendTransaction={sendTransaction} setServerOption={setServerOption} + closeModal={hide} /> diff --git a/components/Messages/components/ContactLine.tsx b/components/Messages/components/ContactLine.tsx index 99916c8bf..2109c336c 100644 --- a/components/Messages/components/ContactLine.tsx +++ b/components/Messages/components/ContactLine.tsx @@ -320,7 +320,7 @@ const ContactLine: React.FunctionComponent = ({ {c.label ? ( {c.label} ) : ( - {}} /> + )} {c.time ? moment((c.time || 0) * 1000).format('MMM D, h:mm a') : ''} diff --git a/components/Messages/components/ContactList.tsx b/components/Messages/components/ContactList.tsx index bda85c0bb..9d6b99e6d 100644 --- a/components/Messages/components/ContactList.tsx +++ b/components/Messages/components/ContactList.tsx @@ -278,7 +278,7 @@ const ContactList: React.FunctionComponent = ({ address={Utils.messagesAddress(contactDetail)} sendTransaction={sendTransaction} setServerOption={setServerOption} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -287,7 +287,7 @@ const ContactList: React.FunctionComponent = ({ setPrivacyOption={setPrivacyOption} setScrollToBottom={setScrollToBottom} scrollToBottom={scrollToBottom} - /> + />, { swipeDirection: undefined } ).promise; }; diff --git a/components/Messages/components/MessageLine.tsx b/components/Messages/components/MessageLine.tsx index 35284eb27..3cbb1bd62 100644 --- a/components/Messages/components/MessageLine.tsx +++ b/components/Messages/components/MessageLine.tsx @@ -122,7 +122,7 @@ const MessageLine: React.FunctionComponent = ({ }}> {!!vt.address && !messageAddress && ( - {}} /> + )} {(!!memo || !!memoUA) && ( @@ -171,7 +171,6 @@ const MessageLine: React.FunctionComponent = ({ {}} /> )} diff --git a/components/Messages/components/MessageList.tsx b/components/Messages/components/MessageList.tsx index bd98cc4a6..ebf5d6727 100644 --- a/components/Messages/components/MessageList.tsx +++ b/components/Messages/components/MessageList.tsx @@ -459,12 +459,6 @@ const MessageList: React.FunctionComponent = ({ }); }; - const closeModalAndClean = () => { - if (closeModal) { - closeModal(); - } - }; - useEffect(() => { const stillConf = (totalBalance ? totalBalance.orchardBal : 0) !== (totalBalance ? totalBalance.spendableOrchard : 0) || @@ -488,7 +482,7 @@ const MessageList: React.FunctionComponent = ({ message={memo} includeUAMessage={true} setMessage={setMemo} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -499,7 +493,7 @@ const MessageList: React.FunctionComponent = ({ valueTransfersSliced={messagesSliced} totalLength={messagesFiltered ? messagesFiltered.length : 0} setPrivacyOption={setPrivacyOption} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -537,7 +531,7 @@ const MessageList: React.FunctionComponent = ({ noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={closeModalAndClean} + closeScreen={closeModal} /> = ({ address={address} oneLine={true} withIcon={true} - closeModal={closeModalAndClean} /> @@ -598,7 +591,7 @@ const MessageList: React.FunctionComponent = ({ noDrawMenu={true} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar} - closeScreen={closeModalAndClean} + closeScreen={closeModal} /> = ({ await magicModal.show(() => { updateToField(a, null, null, null, null); }} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -865,7 +865,7 @@ const Send: React.FunctionComponent = ({ message={memoText} includeUAMessage={includeUAMemoBoolean} setMessage={setMemoText} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -885,7 +885,7 @@ const Send: React.FunctionComponent = ({ } calculateFeeWithPropose={calculateFeeWithPropose} sendPageState={buildSendState()} - /> + />, { swipeDirection: undefined } ).promise; }; @@ -950,7 +950,6 @@ const Send: React.FunctionComponent = ({ oneLine={true} onlyContact={true} withIcon={true} - closeModal={() => {}} /> )} diff --git a/components/Send/components/Confirm.tsx b/components/Send/components/Confirm.tsx index 00fac54a6..97b2f06ff 100644 --- a/components/Send/components/Confirm.tsx +++ b/components/Send/components/Confirm.tsx @@ -353,7 +353,7 @@ const Confirm: React.FunctionComponent = ({ return ( {translate('send.to') as string} - + {donationAmount > 0 && ( <> diff --git a/components/Send/components/ScannerAddress.tsx b/components/Send/components/ScannerAddress.tsx index 12f18edfd..e339bcf81 100644 --- a/components/Send/components/ScannerAddress.tsx +++ b/components/Send/components/ScannerAddress.tsx @@ -56,10 +56,6 @@ const ScannerAddress: React.FunctionComponent = ({ setAddre validateAddress(scandata); }; - const doCancel = () => { - hide(); - }; - return ( = ({ setAddre noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={doCancel} + closeScreen={hide} /> diff --git a/components/Ufvk/ImportUfvk.tsx b/components/Ufvk/ImportUfvk.tsx index 0d8c9dde1..ed9adfc7d 100644 --- a/components/Ufvk/ImportUfvk.tsx +++ b/components/Ufvk/ImportUfvk.tsx @@ -110,7 +110,7 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o const setQrcodeModalShow = async () => { await magicModal.show(() => + />, { swipeDirection: undefined } ).promise; }; diff --git a/components/Ufvk/components/ScannerUfvk.tsx b/components/Ufvk/components/ScannerUfvk.tsx index 1b7584e04..2ee392074 100644 --- a/components/Ufvk/components/ScannerUfvk.tsx +++ b/components/Ufvk/components/ScannerUfvk.tsx @@ -35,10 +35,6 @@ const ScannerKey: React.FunctionComponent = ({ setUfvkText }) = hide(); }; - const doCancel = () => { - hide(); - }; - return ( = ({ setUfvkText }) = noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={doCancel} + closeScreen={hide} /> From d2c0bc5a768ccab7a00efc9b6fc31c52bee09448 Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 27 Feb 2025 12:27:05 -0700 Subject: [PATCH 4/8] fix: adjusting modales nuevos as promises --- __tests__/Header.snapshot.tsx | 2 - __tests__/History.snapshot.tsx | 4 -- __tests__/Messages.snapshot.tsx | 2 - __tests__/Receive.snapshot.tsx | 2 +- __tests__/Send.snapshot.tsx | 4 -- app/AppState/AppContextLoaded.ts | 9 ++-- app/LoadedApp/LoadedApp.tsx | 47 +++++++++---------- app/context/contextAppLoaded.tsx | 8 ++-- components/Components/TextInputAddress.tsx | 6 +-- components/Header/Header.tsx | 17 ++++--- components/History/History.tsx | 16 ++----- .../History/components/ValueTransferLine.tsx | 5 +- components/Messages/Messages.tsx | 4 -- components/Messages/MessagesModal.tsx | 4 -- .../Messages/components/ContactLine.tsx | 14 ++---- .../Messages/components/ContactList.tsx | 15 ++---- .../Messages/components/MessageLine.tsx | 3 +- .../Messages/components/MessageList.tsx | 6 +-- components/Receive/Receive.tsx | 4 -- components/Send/Send.tsx | 28 +++++------ components/Ufvk/ImportUfvk.tsx | 4 +- 21 files changed, 80 insertions(+), 124 deletions(-) diff --git a/__tests__/Header.snapshot.tsx b/__tests__/Header.snapshot.tsx index 9a330c474..9a3c0bd06 100644 --- a/__tests__/Header.snapshot.tsx +++ b/__tests__/Header.snapshot.tsx @@ -86,8 +86,6 @@ describe('Component Header - test', () => {
{ { { { { const onFunction = jest.fn(); const receive = render( - + , ); expect(receive.toJSON()).toMatchSnapshot(); diff --git a/__tests__/Send.snapshot.tsx b/__tests__/Send.snapshot.tsx index 7074edbba..ea5f059d1 100644 --- a/__tests__/Send.snapshot.tsx +++ b/__tests__/Send.snapshot.tsx @@ -99,8 +99,6 @@ describe('Component Send - test', () => { sendTransaction={onFunction} clearToAddr={onFunction} toggleMenuDrawer={onFunction} - poolsMoreInfoOnClick={onFunction} - syncingStatusMoreInfoOnClick={onFunction} setPrivacyOption={onFunction} setShieldingAmount={onFunction} setScrollToTop={onFunction} @@ -125,8 +123,6 @@ describe('Component Send - test', () => { sendTransaction={onFunction} clearToAddr={onFunction} toggleMenuDrawer={onFunction} - poolsMoreInfoOnClick={onFunction} - syncingStatusMoreInfoOnClick={onFunction} setPrivacyOption={onFunction} setShieldingAmount={onFunction} setScrollToTop={onFunction} diff --git a/app/AppState/AppContextLoaded.ts b/app/AppState/AppContextLoaded.ts index eb98e2cac..a8c22f732 100644 --- a/app/AppState/AppContextLoaded.ts +++ b/app/AppState/AppContextLoaded.ts @@ -24,6 +24,7 @@ import { ModeEnum } from './enums/ModeEnum'; import { SelectServerEnum } from './enums/SelectServerEnum'; import ValueTransferType from './types/ValueTransferType'; import { RefreshScreenEnum } from './enums/RefreshScreenEnum'; +import { HideReturn } from 'react-native-magic-modal'; export default interface AppContextLoaded { navigation: StackScreenProps['navigation']; @@ -93,7 +94,7 @@ export default interface AppContextLoaded { addressBook: AddressBookFileClass[]; // helpers to open the address book modal from different places in the App - launchAddressBook: (add: string) => void; + launchAddressBook: (add: string) => Promise>; addressBookCurrentAddress: string; // is calculated in the header & needed in the send screen @@ -125,9 +126,11 @@ export default interface AppContextLoaded { recoveryWalletInfoOnDevice: boolean; // modals - setComputingModalShow: () => void; + setComputingModalShow: () => Promise>; closeAllModals: () => void; - setUfvkViewModalShow: () => void; + setUfvkViewModalShow: () => Promise>; + setSyncReportModalShow: () => Promise>; + setPoolsModalShow: () => Promise>; // eslint-disable-next-line semi } diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index a5ec876e0..f464c7ea0 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -491,9 +491,11 @@ export class LoadedAppClass extends Component {}, - closeAllModals: () => {}, - setUfvkViewModalShow: () => {}, + setComputingModalShow: this.setComputingModalShow, + closeAllModals: this.closeAllModals, + setUfvkViewModalShow: this.setUfvkViewModalShow, + setSyncReportModalShow: this.setSyncReportModalShow, + setPoolsModalShow: this.setPoolsModalShow, // context settings server: props.server, @@ -789,24 +791,24 @@ export class LoadedAppClass extends Component { - magicModal.show(() => {}} onClickCancel={() => {}} action={SeedActionEnum.view} setPrivacyOption={this.setPrivacyOption} keepAwake={this.keepAwake} />, { swipeDirection: undefined } - ); + ).promise; }; setUfvkViewModalShow = async () => { - magicModal.show(() => {}} onClickCancel={() => {}} action={UfvkActionEnum.view} setPrivacyOption={this.setPrivacyOption} />, { swipeDirection: undefined } - ); + ).promise; }; setShieldingAmount = (value: number) => { @@ -848,7 +850,7 @@ export class LoadedAppClass extends Component 0) { // I need to check this out in the seed screen. - this.setSeedViewModalShow(); + await this.setSeedViewModalShow(); } } } else { @@ -1044,7 +1046,7 @@ export class LoadedAppClass extends Component { - magicModal.show(() => , { swipeDirection: undefined }); + return magicModal.show(() => , { swipeDirection: undefined }).promise; }; setInfo = (info: InfoType) => { @@ -1165,9 +1167,9 @@ export class LoadedAppClass extends Component , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.WalletSeedUfvk) { if (this.state.readOnly) { - this.setUfvkViewModalShow(); + await this.setUfvkViewModalShow(); } else { - this.setSeedViewModalShow(); + await this.setSeedViewModalShow(); } } else if (item === MenuItemEnum.ChangeWallet) { if (this.state.readOnly) { @@ -1285,7 +1287,6 @@ export class LoadedAppClass extends Component await this.onClickOKServerWallet()} onClickCancel={async () => { // restart all the tasks again, nothing happen. @@ -1381,9 +1382,9 @@ export class LoadedAppClass extends Component, { swipeDirection: undefined } - ).promise; + ); } else { - await magicModal.show(() => await this.onClickOKServerWallet()} onClickCancel={async () => { // restart all the tasks again, nothing happen. @@ -1394,7 +1395,7 @@ export class LoadedAppClass extends Component, { swipeDirection: undefined } - ).promise; + ); } //console.log(`Error Reading Wallet ${value} - ${error}`); if (toast) { @@ -1673,11 +1674,11 @@ export class LoadedAppClass extends Component { + setSyncReportModalShow = async () => { return magicModal.show(() => , { swipeDirection: undefined }).promise; }; - poolsMoreInfoOnClick = async () => { + setPoolsModalShow = async () => { return magicModal.show(() => , { swipeDirection: undefined }).promise; }; @@ -1791,6 +1792,8 @@ export class LoadedAppClass extends Component ( ( ( )} @@ -1954,7 +1952,6 @@ export class LoadedAppClass extends Component ( )} diff --git a/app/context/contextAppLoaded.tsx b/app/context/contextAppLoaded.tsx index 30ef6ca17..ea89494ce 100644 --- a/app/context/contextAppLoaded.tsx +++ b/app/context/contextAppLoaded.tsx @@ -65,7 +65,7 @@ export const defaultAppContextLoaded: AppContextLoaded = { restartApp: () => {}, somePending: false, addressBook: [] as AddressBookFileClass[], - launchAddressBook: () => {}, + launchAddressBook: () => new Promise(resolve => resolve), addressBookCurrentAddress: '', security: {} as SecurityType, selectServer: SelectServerEnum.auto, @@ -76,9 +76,11 @@ export const defaultAppContextLoaded: AppContextLoaded = { doRefresh: () => {}, setZecPrice: () => {}, zenniesDonationAddress: '', - setComputingModalShow: () => {}, + setComputingModalShow: () => new Promise(resolve => resolve), closeAllModals: () => {}, - setUfvkViewModalShow: () => {}, + setUfvkViewModalShow: () => new Promise(resolve => resolve), + setSyncReportModalShow: () => new Promise(resolve => resolve), + setPoolsModalShow: () => new Promise(resolve => resolve), }; export const ContextAppLoaded = React.createContext(defaultAppContextLoaded); diff --git a/components/Components/TextInputAddress.tsx b/components/Components/TextInputAddress.tsx index 17b7575af..b35aa3e6c 100644 --- a/components/Components/TextInputAddress.tsx +++ b/components/Components/TextInputAddress.tsx @@ -60,8 +60,8 @@ const TextInputAddress: React.FunctionComponent = ({ } }, [address, server.chainName, setError, setUOrchardAddress, translate]); - const setQrcodeModalShow = async () => { - await magicModal.show(() => , { swipeDirection: undefined }).promise; + const setQrcodeModalShow = () => { + return magicModal.show(() => , { swipeDirection: undefined }).promise; }; //console.log('render input text address'); @@ -126,7 +126,7 @@ const TextInputAddress: React.FunctionComponent = ({ disabled={disabled} accessible={true} accessibilityLabel={translate('send.scan-acc') as string} - onPress={async () => { + onPress={() => { setQrcodeModalShow(); }}> diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 0e6f973b0..9c131dce6 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -62,10 +62,8 @@ type HeaderProps = { closeScreen?: () => void; // balance noBalance?: boolean; - poolsMoreInfoOnClick?: () => void; // syncing icons noSyncingStatus?: boolean; - syncingStatusMoreInfoOnClick?: () => void; // privacy noPrivacy?: boolean; setPrivacyOption?: (value: boolean) => Promise; @@ -86,8 +84,6 @@ type HeaderProps = { }; const Header: React.FunctionComponent = ({ - poolsMoreInfoOnClick, - syncingStatusMoreInfoOnClick, toggleMenuDrawer, title, noBalance, @@ -129,6 +125,8 @@ const Header: React.FunctionComponent = ({ setComputingModalShow, closeAllModals, setUfvkViewModalShow, + setSyncReportModalShow, + setPoolsModalShow, } = context; let translate: (key: string) => TranslateType, netInfo: NetInfoType, mode: ModeEnum, privacy: boolean; @@ -297,6 +295,7 @@ const Header: React.FunctionComponent = ({ // now zingolib only can shield `transparent`. let pools: PoolToShieldEnum = PoolToShieldEnum.transparentPoolToShield; + // not use await here. setComputingModalShow(); // We need to activate this flag because if the App is syncing // while shielding, then it going to finish the current batch @@ -444,7 +443,7 @@ const Header: React.FunctionComponent = ({ addLastSnackbar({ message: translate('biometrics-error') as string }); } } else { - setUfvkViewModalShow(); + await setUfvkViewModalShow(); } }; @@ -588,7 +587,7 @@ const Header: React.FunctionComponent = ({ ) : ( syncingStatusMoreInfoOnClick && syncingStatusMoreInfoOnClick()}> + onPress={() => setSyncReportModalShow()}> {viewSyncStatus && ( @@ -623,7 +622,7 @@ const Header: React.FunctionComponent = ({ minHeight: 25, }}> syncingStatusMoreInfoOnClick && syncingStatusMoreInfoOnClick()}> + onPress={() => setSyncReportModalShow()}> = ({ size={20} /> ) : ( - syncingStatusMoreInfoOnClick && syncingStatusMoreInfoOnClick()}> + setSyncReportModalShow()}> = ({ (totalBalance.orchardBal !== totalBalance.spendableOrchard || totalBalance.privateBal > 0 || totalBalance.transparentBal > 0) && ( - poolsMoreInfoOnClick && poolsMoreInfoOnClick()}> + setPoolsModalShow()}> void; - // balance - poolsMoreInfoOnClick: () => void; - // syncing - syncingStatusMoreInfoOnClick: () => void; // privacy setPrivacyOption: (value: boolean) => Promise; // addLastSnackbar from context @@ -66,8 +62,6 @@ type HistoryProps = { const History: React.FunctionComponent = ({ toggleMenuDrawer, - poolsMoreInfoOnClick, - syncingStatusMoreInfoOnClick, setPrivacyOption, setShieldingAmount, setScrollToTop, @@ -147,8 +141,8 @@ const History: React.FunctionComponent = ({ setIsAtTop(isTop); }; - const setValueTransferDetailModalShow = async (index: number, vt: ValueTransferType) => { - await magicModal.show(() => { + return magicModal.show(() => = ({ ).promise; }; - const setMessagesAddressModalShow = async (vt: ValueTransferType) => { - await magicModal.show(() => { + return magicModal.show(() => = ({ testID="valuetransfer text" title={translate('history.title') as string} toggleMenuDrawer={toggleMenuDrawer} - poolsMoreInfoOnClick={poolsMoreInfoOnClick} - syncingStatusMoreInfoOnClick={syncingStatusMoreInfoOnClick} setPrivacyOption={setPrivacyOption} addLastSnackbar={addLastSnackbar /* context */} setShieldingAmount={setShieldingAmount} diff --git a/components/History/components/ValueTransferLine.tsx b/components/History/components/ValueTransferLine.tsx index 9d7b515f1..3bd2a35c5 100644 --- a/components/History/components/ValueTransferLine.tsx +++ b/components/History/components/ValueTransferLine.tsx @@ -35,15 +35,16 @@ import 'moment/locale/ru'; import { ContextAppLoaded } from '../../../app/context'; import AddressItem from '../../Components/AddressItem'; import { RPCValueTransfersStatusEnum } from '../../../app/rpc/enums/RPCValueTransfersStatusEnum'; +import { HideReturn } from 'react-native-magic-modal'; //import Utils from '../../../app/utils'; type ValueTransferLineProps = { index: number; month: string; vt: ValueTransferType; - setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => void; + setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => Promise>; nextLineWithSameTxid: boolean; - setMessagesAddressModalShow: (vt: ValueTransferType) => Promise; + setMessagesAddressModalShow: (vt: ValueTransferType) => Promise>; addressProtected?: boolean; }; const ValueTransferLine: React.FunctionComponent = ({ diff --git a/components/Messages/Messages.tsx b/components/Messages/Messages.tsx index d208e9736..a05b1198a 100644 --- a/components/Messages/Messages.tsx +++ b/components/Messages/Messages.tsx @@ -6,8 +6,6 @@ type MessagesProps = { // side menu toggleMenuDrawer: () => void; // balance - // syncing - syncingStatusMoreInfoOnClick: () => void; // privacy setPrivacyOption: (value: boolean) => Promise; // addLastSnackbar from context @@ -28,7 +26,6 @@ type MessagesProps = { const Messages: React.FunctionComponent = ({ toggleMenuDrawer, - syncingStatusMoreInfoOnClick, setPrivacyOption, setScrollToTop, scrollToTop, @@ -40,7 +37,6 @@ const Messages: React.FunctionComponent = ({ return ( void; // privacy setPrivacyOption: (value: boolean) => Promise; // addLastSnackbar from context @@ -29,7 +27,6 @@ type MessagesModalProps = { }; const MessagesModal: React.FunctionComponent = ({ - syncingStatusMoreInfoOnClick, setPrivacyOption, setScrollToTop, scrollToTop, @@ -45,7 +42,6 @@ const MessagesModal: React.FunctionComponent = ({ return ( void; - setMessagesAddressModalShow: () => void; + setMessagesAddressModalShow: (c: ContactType) => Promise>; addressProtected?: boolean; }; const ContactLine: React.FunctionComponent = ({ index, c, month, - setContactDetail, setMessagesAddressModalShow, addressProtected, }) => { @@ -119,8 +118,7 @@ const ContactLine: React.FunctionComponent = ({ if (-value >= dimensions.width * (1 / 2) && messagesAddress) { if (!maxWidthHit.current) { //console.log(value); - setContactDetail(c); - setMessagesAddressModalShow(); + setMessagesAddressModalShow(c); swipeable.reset(); } maxWidthHit.current = true; @@ -150,8 +148,7 @@ const ContactLine: React.FunctionComponent = ({ { - setContactDetail(c); - setMessagesAddressModalShow(); + setMessagesAddressModalShow(c); swipeable.reset(); }}> @@ -250,8 +247,7 @@ const ContactLine: React.FunctionComponent = ({ { - setContactDetail(c); - setMessagesAddressModalShow(); + setMessagesAddressModalShow(c); swipeableRef?.current?.reset(); }}> void; - syncingStatusMoreInfoOnClick: () => void; setPrivacyOption: (value: boolean) => Promise; setScrollToTop: (value: boolean) => void; scrollToTop: boolean; @@ -63,7 +62,6 @@ type ContactListProps = { const ContactList: React.FunctionComponent = ({ toggleMenuDrawer, - syncingStatusMoreInfoOnClick, setPrivacyOption, setScrollToTop, scrollToTop, @@ -80,7 +78,6 @@ const ContactList: React.FunctionComponent = ({ const { colors } = useTheme() as ThemeType; moment.locale(language); - const [contactDetail, setContactDetail] = useState({} as ContactType); const [contacts, setContacts] = useState([]); const [isAtTop, setIsAtTop] = useState(true); const [loading, setLoading] = useState(true); @@ -270,20 +267,20 @@ const ContactList: React.FunctionComponent = ({ setIsAtTop(isTop); }; - const setMessagesAddressModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => , { swipeDirection: undefined } ).promise; }; - const setMessagesAllModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => = ({
= ({ index={index} c={c} month={month} - setContactDetail={(ttt: ContactType) => setContactDetail(ttt)} setMessagesAddressModalShow={setMessagesAddressModalShow} addressProtected={c.address === zenniesDonationAddress} /> diff --git a/components/Messages/components/MessageLine.tsx b/components/Messages/components/MessageLine.tsx index 3cbb1bd62..fd1b6cd5e 100644 --- a/components/Messages/components/MessageLine.tsx +++ b/components/Messages/components/MessageLine.tsx @@ -29,12 +29,13 @@ import AddressItem from '../../Components/AddressItem'; import RegText from '../../Components/RegText'; import Utils from '../../../app/utils'; import { RPCValueTransfersStatusEnum } from '../../../app/rpc/enums/RPCValueTransfersStatusEnum'; +import { HideReturn } from 'react-native-magic-modal'; type MessageLineProps = { index: number; month: string; vt: ValueTransferType; - setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => void; + setValueTransferDetailModalShow: (i: number, v: ValueTransferType) => Promise>; messageAddress?: string; }; const MessageLine: React.FunctionComponent = ({ diff --git a/components/Messages/components/MessageList.tsx b/components/Messages/components/MessageList.tsx index ebf5d6727..b4a102a20 100644 --- a/components/Messages/components/MessageList.tsx +++ b/components/Messages/components/MessageList.tsx @@ -477,8 +477,8 @@ const MessageList: React.FunctionComponent = ({ totalBalance?.spendablePrivate, ]); - const setMemoModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => = ({ }; const setValueTransferDetailModalShow = async (index: number, vt: ValueTransferType) => { - await magicModal.show(() => void; - syncingStatusMoreInfoOnClick: () => void; alone: boolean; }; @@ -29,8 +28,6 @@ const Receive: React.FunctionComponent = ({ // side menu toggleMenuDrawer, // balance - // syncing - syncingStatusMoreInfoOnClick, // privacy // shielding // for receive @@ -331,7 +328,6 @@ const Receive: React.FunctionComponent = ({ : (translate('receive.title-advanced') as string) } toggleMenuDrawer={toggleMenuDrawer} - syncingStatusMoreInfoOnClick={syncingStatusMoreInfoOnClick} noBalance={true} noPrivacy={true} /> diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 1caab4885..91d16d44b 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -65,10 +65,6 @@ import { magicModal } from 'react-native-magic-modal'; type SendProps = { // side menu toggleMenuDrawer: () => void; - // balance - poolsMoreInfoOnClick: () => void; - // syncing - syncingStatusMoreInfoOnClick: () => void; // privacy setPrivacyOption: (value: boolean) => Promise; // addLastSnackbar from context @@ -91,8 +87,6 @@ const Send: React.FunctionComponent = ({ sendTransaction, clearToAddr, toggleMenuDrawer, - syncingStatusMoreInfoOnClick, - poolsMoreInfoOnClick, setPrivacyOption, setShieldingAmount, setScrollToTop, @@ -126,6 +120,7 @@ const Send: React.FunctionComponent = ({ zenniesDonationAddress, setComputingModalShow, closeAllModals, + setPoolsModalShow, } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); @@ -705,7 +700,8 @@ const Send: React.FunctionComponent = ({ } // first interrupt syncing Just in case... await RPC.rpcSetInterruptSyncAfterBatch(GlobalConst.true); - // First, close the confirm modal and show the "computing" modal + + // not use await here. setComputingModalShow(); // call the sendTransaction method in a timeout, allowing the modals to show properly @@ -852,16 +848,16 @@ const Send: React.FunctionComponent = ({ } }; - const setQrcodeModalShow = async () => { - await magicModal.show(() => { + const setQrcodeModalShow = () => { + return magicModal.show(() => { updateToField(a, null, null, null, null); }} />, { swipeDirection: undefined } ).promise; }; - const setMemoModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => = ({ ).promise; }; - const setConfirmModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => = ({
= ({ )} {stillConfirming && ( - poolsMoreInfoOnClick()}> + setPoolsModalShow()}> = ({ )} {showShieldInfo && mode === ModeEnum.advanced && ( - poolsMoreInfoOnClick()}> + setPoolsModalShow()}> = ({ onClickCancel, o onClickOK(seedufvkText.trimEnd().trimStart(), Number(birthday)); }; - const setQrcodeModalShow = async () => { - await magicModal.show(() => { + return magicModal.show(() => , { swipeDirection: undefined } ).promise; From 273f33dfdb29ec3e276eac0db78ae45092b7d24d Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 27 Feb 2025 14:00:18 -0700 Subject: [PATCH 5/8] fix: e2e test for android in CI disabled for now --- .github/workflows/ci.yaml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b8817dc18..8a115b18b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,20 +53,22 @@ jobs: api-level: ${{ matrix.config['api-level'] }} target: ${{ matrix.config.target }} - android-ubuntu-e2e-test-ci: - strategy: - matrix: - config: - - { abi: x86_64, api-level: 30, target: default } - - { abi: x86, api-level: 28, target: default } - uses: ./.github/workflows/android-ubuntu-e2e-test-ci.yaml - needs: [create-timestamp, android-build] - with: - timestamp: ${{ needs.create-timestamp.outputs.timestamp }} - cache-key: ${{ needs.create-cache-key.outputs.cache-key }} - abi: ${{ matrix.config.abi }} - api-level: ${{ matrix.config['api-level'] }} - target: ${{ matrix.config.target }} + # deactivating these for now, until we know how to fix + # detox run in android + #android-ubuntu-e2e-test-ci: + # strategy: + # matrix: + # config: + # - { abi: x86_64, api-level: 30, target: default } + # - { abi: x86, api-level: 28, target: default } + # uses: ./.github/workflows/android-ubuntu-e2e-test-ci.yaml + # needs: [create-timestamp, android-build] + # with: + # timestamp: ${{ needs.create-timestamp.outputs.timestamp }} + # cache-key: ${{ needs.create-cache-key.outputs.cache-key }} + # abi: ${{ matrix.config.abi }} + # api-level: ${{ matrix.config['api-level'] }} + # target: ${{ matrix.config.target }} ios-build: uses: ./.github/workflows/ios-build.yaml From c3f531567a93322d88149f50acc4d0975418458d Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 27 Feb 2025 20:58:11 -0700 Subject: [PATCH 6/8] fix: zingolib updated & fixes --- .../__snapshots__/LoadedApp.snapshot.tsx.snap | 500 +++++++++--------- app/LoadedApp/LoadedApp.tsx | 3 +- app/LoadedApp/components/Menu.tsx | 8 +- components/Ufvk/ImportUfvk.tsx | 19 +- rust/Cargo.lock | 28 +- 5 files changed, 290 insertions(+), 268 deletions(-) diff --git a/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap b/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap index 772894d58..1216c192c 100644 --- a/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap +++ b/__tests__/__snapshots__/LoadedApp.snapshot.tsx.snap @@ -1,324 +1,326 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Component LoadedApp - test LoadedApp - snapshot 1`] = ` - +[ - - + + + + - - - - - - - - text translated - - - + } + > + text translated - - text translated - - + - text translated - - - text translated - - + text translated + + - text translated - - + text translated + + - text translated - - + text translated + + - text translated - - + text translated + + - text translated - + testID="menu.walletseedufvk" + > + text translated + + + text translated + + + text translated + + + text translated + + - - - - + - Version : - - - text translated - - + Version : + + - text translatedtext translated - + > + text translated + + + text translatedtext translated + + - - + , + , +] `; diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index f464c7ea0..a8197b2d5 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -1137,7 +1137,6 @@ export class LoadedAppClass extends Component { // Depending on the menu item, open the appropriate modal - await this.closeDrawer(); if (item === MenuItemEnum.About) { return magicModal.show(() => , { swipeDirection: undefined }).promise; } else if (item === MenuItemEnum.Rescan) { @@ -1960,8 +1959,8 @@ export class LoadedAppClass extends Component )} - + ); diff --git a/app/LoadedApp/components/Menu.tsx b/app/LoadedApp/components/Menu.tsx index a07a322fd..ce56d5c68 100644 --- a/app/LoadedApp/components/Menu.tsx +++ b/app/LoadedApp/components/Menu.tsx @@ -50,6 +50,7 @@ const Menu: React.FunctionComponent = ({ onItemSelected, closeDrawer }; const onItemSelectedWrapper = async (value: MenuItemEnum) => { + await closeDrawer(); if ( (value === MenuItemEnum.WalletSeedUfvk && security.seedUfvkScreen) || (value === MenuItemEnum.Rescan && security.rescanScreen) || @@ -65,13 +66,16 @@ const Menu: React.FunctionComponent = ({ onItemSelected, closeDrawer //console.log('BIOMETRIC --------> ', resultBio); if (resultBio === false) { // snack with Error & closing the menu. - await closeDrawer(); addLastSnackbar({ message: translate('biometrics-error') as string }); } else { onItemSelected(value); } } else { - onItemSelected(value); + // the App/Drawer needs a bit of time to close + // properly + setTimeout(() => { + onItemSelected(value); + }, 200); } }; diff --git a/components/Ufvk/ImportUfvk.tsx b/components/Ufvk/ImportUfvk.tsx index 66cbca12f..5283c23e3 100644 --- a/components/Ufvk/ImportUfvk.tsx +++ b/components/Ufvk/ImportUfvk.tsx @@ -26,16 +26,17 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import { ButtonTypeEnum, GlobalConst, SelectServerEnum } from '../../app/AppState'; -import { magicModal } from 'react-native-magic-modal'; +import { magicModal, useMagicModal } from 'react-native-magic-modal'; type ImportUfvkProps = { onClickCancel: () => void; - onClickOK: (keyText: string, birthday: number) => Promise; + onClickOK: (keyText: string, birthday: number) => void; }; const ImportUfvk: React.FunctionComponent = ({ onClickCancel, onClickOK }) => { const context = useContext(ContextAppLoading); const { translate, netInfo, info, server, mode, addLastSnackbar, language, selectServer } = context; const { colors } = useTheme() as ThemeType; + const { hide } = useMagicModal(); moment.locale(language); const [seedufvkText, setSeedufvkText] = useState(''); @@ -104,7 +105,7 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o addLastSnackbar({ message: translate('loadedapp.connection-error') as string }); return; } - onClickOK(seedufvkText.trimEnd().trimStart(), Number(birthday)); + onClickOKAndHide(seedufvkText.trimEnd().trimStart(), Number(birthday)); }; const setQrcodeModalShow = () => { @@ -114,6 +115,16 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o ).promise; }; + const onClickCancelAndHide = () => { + onClickCancel(); + hide(); + }; + + const onClickOKAndHide = (keyTextParm: string, birthdayParm: number) => { + onClickOK(keyTextParm, birthdayParm); + hide(); + }; + return ( = ({ onClickCancel, o translate={translate} netInfo={netInfo} mode={mode} - closeScreen={onClickCancel} + closeScreen={onClickCancelAndHide} /> Date: Fri, 28 Feb 2025 08:03:09 -0700 Subject: [PATCH 7/8] fix: a couple of libraries updated - iOS --- ios/ZingoMobile.xcodeproj/project.pbxproj | 116 +++++++++++----------- package.json | 4 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ios/ZingoMobile.xcodeproj/project.pbxproj b/ios/ZingoMobile.xcodeproj/project.pbxproj index 34cd2864a..a52cfbdbe 100644 --- a/ios/ZingoMobile.xcodeproj/project.pbxproj +++ b/ios/ZingoMobile.xcodeproj/project.pbxproj @@ -25,9 +25,9 @@ 1FA935B32BE457B100117DF5 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F7D321C2B71D44800D2879C /* SystemConfiguration.framework */; }; 1FC1E2172BE443270064963B /* ZingoMobileTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC1E2162BE443270064963B /* ZingoMobileTest.swift */; }; 1FE8E9AC296B85FC004A256B /* BackgroundTasks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */; }; - 3F52104357277CDA08C36215 /* libPods-ZingoMobile-ZingoMobileTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67B25D6FF6C1668F2EBB6F8E /* libPods-ZingoMobile-ZingoMobileTests.a */; }; + 369B7C1BE19DB13873DFF3B0 /* libPods-ZingoMobile-ZingoMobileTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05F62815E872589F3BBD300C /* libPods-ZingoMobile-ZingoMobileTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; - C907C112B5CDD0C1EEB5F102 /* libPods-ZingoMobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF338E3CDCFF35B6FB95589D /* libPods-ZingoMobile.a */; }; + C3713A46B734C55FB3AD4656 /* libPods-ZingoMobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 065C1B7D7D5340EF16764901 /* libPods-ZingoMobile.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -43,6 +43,9 @@ /* Begin PBXFileReference section */ 00E356EE1AD99517003FC87E /* ZingoMobileTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZingoMobileTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 05F62815E872589F3BBD300C /* libPods-ZingoMobile-ZingoMobileTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZingoMobile-ZingoMobileTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 065C1B7D7D5340EF16764901 /* libPods-ZingoMobile.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZingoMobile.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 08838479BBE9389100160398 /* Pods-ZingoMobile.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile.debug.xcconfig"; path = "Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile.debug.xcconfig"; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* Zingo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Zingo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ZingoMobile/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ZingoMobile/Info.plist; sourceTree = ""; }; @@ -60,14 +63,11 @@ 1FA935B62BE474CD00117DF5 /* ZingoMobileTest-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ZingoMobileTest-Bridging-Header.h"; sourceTree = ""; }; 1FC1E2162BE443270064963B /* ZingoMobileTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZingoMobileTest.swift; sourceTree = ""; }; 1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; }; - 2B7B439EA08C22E933D961C8 /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile-ZingoMobileTests.release.xcconfig"; path = "Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests.release.xcconfig"; sourceTree = ""; }; - 39EAC1CCC988ED9481674E52 /* Pods-ZingoMobile.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile.debug.xcconfig"; path = "Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile.debug.xcconfig"; sourceTree = ""; }; - 67B25D6FF6C1668F2EBB6F8E /* libPods-ZingoMobile-ZingoMobileTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZingoMobile-ZingoMobileTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = ZingoMobile/LaunchScreen.storyboard; sourceTree = ""; }; - BF338E3CDCFF35B6FB95589D /* libPods-ZingoMobile.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZingoMobile.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - D918B36B90266B687536A718 /* Pods-ZingoMobile.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile.release.xcconfig"; path = "Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile.release.xcconfig"; sourceTree = ""; }; + 90C49D80AF8BB6B6C4514A8A /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; path = "Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; sourceTree = ""; }; + E84ABE316BA6E160E81D04EE /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile-ZingoMobileTests.release.xcconfig"; path = "Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests.release.xcconfig"; sourceTree = ""; }; + EB0B6767909390DB102A5E97 /* Pods-ZingoMobile.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile.release.xcconfig"; path = "Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; - F2AAC573B84E5D9C254BBE72 /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; path = "Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -77,7 +77,7 @@ files = ( 1FA935B32BE457B100117DF5 /* SystemConfiguration.framework in Frameworks */, 1FA935B22BE4569D00117DF5 /* libuniffi_zingo.a in Frameworks */, - 3F52104357277CDA08C36215 /* libPods-ZingoMobile-ZingoMobileTests.a in Frameworks */, + 369B7C1BE19DB13873DFF3B0 /* libPods-ZingoMobile-ZingoMobileTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -88,7 +88,7 @@ 1FE8E9AC296B85FC004A256B /* BackgroundTasks.framework in Frameworks */, 1F7D321D2B71D44800D2879C /* SystemConfiguration.framework in Frameworks */, 1F8815602BD31176006490E1 /* libuniffi_zingo.a in Frameworks */, - C907C112B5CDD0C1EEB5F102 /* libPods-ZingoMobile.a in Frameworks */, + C3713A46B734C55FB3AD4656 /* libPods-ZingoMobile.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -136,8 +136,8 @@ 1F7D321C2B71D44800D2879C /* SystemConfiguration.framework */, 1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */, ED297162215061F000B7C4FE /* JavaScriptCore.framework */, - BF338E3CDCFF35B6FB95589D /* libPods-ZingoMobile.a */, - 67B25D6FF6C1668F2EBB6F8E /* libPods-ZingoMobile-ZingoMobileTests.a */, + 065C1B7D7D5340EF16764901 /* libPods-ZingoMobile.a */, + 05F62815E872589F3BBD300C /* libPods-ZingoMobile-ZingoMobileTests.a */, ); name = Frameworks; sourceTree = ""; @@ -179,10 +179,10 @@ 8BB7EBE9935B479E64CBB9A8 /* Pods */ = { isa = PBXGroup; children = ( - 39EAC1CCC988ED9481674E52 /* Pods-ZingoMobile.debug.xcconfig */, - D918B36B90266B687536A718 /* Pods-ZingoMobile.release.xcconfig */, - F2AAC573B84E5D9C254BBE72 /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */, - 2B7B439EA08C22E933D961C8 /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */, + 08838479BBE9389100160398 /* Pods-ZingoMobile.debug.xcconfig */, + EB0B6767909390DB102A5E97 /* Pods-ZingoMobile.release.xcconfig */, + 90C49D80AF8BB6B6C4514A8A /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */, + E84ABE316BA6E160E81D04EE /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -194,12 +194,12 @@ isa = PBXNativeTarget; buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "ZingoMobileTests" */; buildPhases = ( - C79B56099299639C3AE6FA80 /* [CP] Check Pods Manifest.lock */, + B6C7AC448DF2C1F9D80240E7 /* [CP] Check Pods Manifest.lock */, 00E356EA1AD99517003FC87E /* Sources */, 00E356EB1AD99517003FC87E /* Frameworks */, 00E356EC1AD99517003FC87E /* Resources */, - 11166E8F276A09FD8D3F6BA7 /* [CP] Embed Pods Frameworks */, - 2B6A26D1BFE87C4B0D720622 /* [CP] Copy Pods Resources */, + 7C2F3CACB2A8225C1CE6EC10 /* [CP] Embed Pods Frameworks */, + CF269AE1C1DF0B13C3CBBA6B /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -215,14 +215,14 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ZingoMobile" */; buildPhases = ( - DB5AB38DFF949C49671FB1C8 /* [CP] Check Pods Manifest.lock */, + D5B5E5D777B45A509D22DED1 /* [CP] Check Pods Manifest.lock */, FD10A7F022414F080027D42C /* Start Packager */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - 871F5C07D44042487489E841 /* [CP] Embed Pods Frameworks */, - 1C2C0FFA357732B530225CD2 /* [CP] Copy Pods Resources */, + DD2A4EBC2ADF93CC81E20D0E /* [CP] Embed Pods Frameworks */, + 04BE2C98EC4B4A529809D127 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -306,75 +306,80 @@ shellPath = /bin/sh; shellScript = "set -e\n\nexport NODE_BINARY=$(which node)\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; }; - 11166E8F276A09FD8D3F6BA7 /* [CP] Embed Pods Frameworks */ = { + 04BE2C98EC4B4A529809D127 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 1C2C0FFA357732B530225CD2 /* [CP] Copy Pods Resources */ = { + 7C2F3CACB2A8225C1CE6EC10 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 2B6A26D1BFE87C4B0D720622 /* [CP] Copy Pods Resources */ = { + B6C7AC448DF2C1F9D80240E7 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ZingoMobile-ZingoMobileTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 871F5C07D44042487489E841 /* [CP] Embed Pods Frameworks */ = { + CF269AE1C1DF0B13C3CBBA6B /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - C79B56099299639C3AE6FA80 /* [CP] Check Pods Manifest.lock */ = { + D5B5E5D777B45A509D22DED1 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -389,33 +394,28 @@ outputFileListPaths = ( ); outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ZingoMobile-ZingoMobileTests-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-ZingoMobile-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - DB5AB38DFF949C49671FB1C8 /* [CP] Check Pods Manifest.lock */ = { + DD2A4EBC2ADF93CC81E20D0E /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ZingoMobile-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZingoMobile/Pods-ZingoMobile-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; FD10A7F022414F080027D42C /* Start Packager */ = { @@ -477,7 +477,7 @@ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F2AAC573B84E5D9C254BBE72 /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */; + baseConfigurationReference = 90C49D80AF8BB6B6C4514A8A /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = 788KRST4S8; @@ -512,7 +512,7 @@ }; 00E356F71AD99517003FC87E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2B7B439EA08C22E933D961C8 /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */; + baseConfigurationReference = E84ABE316BA6E160E81D04EE /* Pods-ZingoMobile-ZingoMobileTests.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; COPY_PHASE_STRIP = NO; @@ -544,7 +544,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 39EAC1CCC988ED9481674E52 /* Pods-ZingoMobile.debug.xcconfig */; + baseConfigurationReference = 08838479BBE9389100160398 /* Pods-ZingoMobile.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; @@ -585,7 +585,7 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D918B36B90266B687536A718 /* Pods-ZingoMobile.release.xcconfig */; + baseConfigurationReference = EB0B6767909390DB102A5E97 /* Pods-ZingoMobile.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; diff --git a/package.json b/package.json index 50e0d3e6d..e2e30e7a8 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@react-navigation/elements": "^2.2.5", "@react-navigation/native": "^7.0.14", "@react-navigation/stack": "^7.1.1", - "@sayem314/react-native-keep-awake": "^1.1.0", + "@sayem314/react-native-keep-awake": "^1.3.0", "buffer": "^6.0.3", "i18n-js": "^4.1.1", "js-base64": "^3.7.2", @@ -63,7 +63,7 @@ "react-native-qrcode-svg": "^6.3.12", "react-native-reanimated": "^3.16.7", "react-native-safe-area-context": "^4.4.1", - "react-native-screens": "^4.6.0", + "react-native-screens": "^4.9.1", "react-native-snackbar": "^2.6.2", "react-native-svg": "^15.11.1", "react-native-tab-view": "^3.3.0", From d7a52ce2c923d5d6c8587204554140972c1babf9 Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 28 Feb 2025 08:55:05 -0700 Subject: [PATCH 8/8] fix: ison send close all modals fix --- components/AddressBook/AddressBook.tsx | 3 -- .../AddressBook/components/AbSummaryLine.tsx | 6 ++-- components/Components/AddressItem.tsx | 7 ++-- .../components/ValueTransferDetail.tsx | 1 - .../History/components/ValueTransferLine.tsx | 2 ++ .../Messages/components/ContactLine.tsx | 3 +- components/Seed/Seed.tsx | 14 ++++++-- components/Ufvk/ImportUfvk.tsx | 34 +++++++------------ components/Ufvk/components/ScannerUfvk.tsx | 13 ++++--- 9 files changed, 38 insertions(+), 45 deletions(-) diff --git a/components/AddressBook/AddressBook.tsx b/components/AddressBook/AddressBook.tsx index ab701fee1..bb79e8b7c 100644 --- a/components/AddressBook/AddressBook.tsx +++ b/components/AddressBook/AddressBook.tsx @@ -224,7 +224,6 @@ const AddressBook: React.FunctionComponent = ({ setAddressBook item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} /> @@ -243,7 +242,6 @@ const AddressBook: React.FunctionComponent = ({ setAddressBook item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} /> @@ -261,7 +259,6 @@ const AddressBook: React.FunctionComponent = ({ setAddressBook item={aBItem} setCurrentItem={setCurrentItem} setAction={setAction} - closeModal={hide} handleScrollToTop={handleScrollToTop} doAction={doAction} addressProtected={true} diff --git a/components/AddressBook/components/AbSummaryLine.tsx b/components/AddressBook/components/AbSummaryLine.tsx index 6785bade1..05a79ce5d 100644 --- a/components/AddressBook/components/AbSummaryLine.tsx +++ b/components/AddressBook/components/AbSummaryLine.tsx @@ -28,7 +28,6 @@ type AbSummaryLineProps = { item: AddressBookFileClass; setCurrentItem: (b: number) => void; setAction: (action: AddressBookActionEnum) => void; - closeModal: () => void; handleScrollToTop: () => void; doAction: ( action: AddressBookActionEnum, @@ -44,13 +43,12 @@ const AbSummaryLine: React.FunctionComponent = ({ item, setCurrentItem, setAction, - closeModal, handleScrollToTop, doAction, addressProtected, }) => { const context = useContext(ContextAppLoaded); - const { translate, navigation, readOnly, mode, totalBalance, language, selectServer, setSendPageState } = context; + const { translate, navigation, readOnly, mode, totalBalance, language, selectServer, setSendPageState, closeAllModals } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); @@ -161,7 +159,7 @@ const AbSummaryLine: React.FunctionComponent = ({ const sendPageState = new SendPageStateClass(new ToAddrClass(0)); sendPageState.toaddr.to = item.address; setSendPageState(sendPageState); - closeModal(); + closeAllModals(); navigation.navigate(RouteEnums.LoadedApp, { screen: translate('loadedapp.send-menu'), initial: false, diff --git a/components/Components/AddressItem.tsx b/components/Components/AddressItem.tsx index df73928ba..2da87d543 100644 --- a/components/Components/AddressItem.tsx +++ b/components/Components/AddressItem.tsx @@ -25,7 +25,6 @@ import 'moment/locale/ru'; type AddressItemProps = { address: string; - closeModal?: () => void; oneLine?: boolean; onlyContact?: boolean; withIcon?: boolean; @@ -39,7 +38,6 @@ const AddressItem: React.FunctionComponent = ({ onlyContact, withIcon, withSendIcon, - closeModal, addressProtected, }) => { const context = useContext(ContextAppLoaded); @@ -56,6 +54,7 @@ const AddressItem: React.FunctionComponent = ({ language, selectServer, setSendPageState, + closeAllModals, } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); @@ -190,9 +189,7 @@ const AddressItem: React.FunctionComponent = ({ const sendPageState = new SendPageStateClass(new ToAddrClass(0)); sendPageState.toaddr.to = address; setSendPageState(sendPageState); - if (closeModal) { - closeModal(); - } + closeAllModals(); navigation.navigate(RouteEnums.LoadedApp, { screen: translate('loadedapp.send-menu'), initial: false, diff --git a/components/History/components/ValueTransferDetail.tsx b/components/History/components/ValueTransferDetail.tsx index 6048c6f7b..26a909ee3 100644 --- a/components/History/components/ValueTransferDetail.tsx +++ b/components/History/components/ValueTransferDetail.tsx @@ -362,7 +362,6 @@ const ValueTransferDetail: React.FunctionComponent = ( address={valueTransfer.address} withIcon={true} withSendIcon={true} - closeModal={hide} addressProtected={addressProtected} /> diff --git a/components/History/components/ValueTransferLine.tsx b/components/History/components/ValueTransferLine.tsx index 3bd2a35c5..db9b6603d 100644 --- a/components/History/components/ValueTransferLine.tsx +++ b/components/History/components/ValueTransferLine.tsx @@ -67,6 +67,7 @@ const ValueTransferLine: React.FunctionComponent = ({ readOnly, selectServer, setSendPageState, + closeAllModals, } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); @@ -216,6 +217,7 @@ const ValueTransferLine: React.FunctionComponent = ({ const sendPageState = new SendPageStateClass(new ToAddrClass(0)); sendPageState.toaddr.to = vt.address ? vt.address : ''; setSendPageState(sendPageState); + closeAllModals(); navigation.navigate(RouteEnums.LoadedApp, { screen: translate('loadedapp.send-menu'), initial: false, diff --git a/components/Messages/components/ContactLine.tsx b/components/Messages/components/ContactLine.tsx index 8be2f8cb8..c1b4f66cc 100644 --- a/components/Messages/components/ContactLine.tsx +++ b/components/Messages/components/ContactLine.tsx @@ -50,7 +50,7 @@ const ContactLine: React.FunctionComponent = ({ addressProtected, }) => { const context = useContext(ContextAppLoaded); - const { translate, language, navigation, showSwipeableIcons, readOnly, selectServer, setSendPageState } = context; + const { translate, language, navigation, showSwipeableIcons, readOnly, selectServer, setSendPageState, closeAllModals } = context; const { colors } = useTheme() as ThemeType; moment.locale(language); @@ -197,6 +197,7 @@ const ContactLine: React.FunctionComponent = ({ const sendPageState = new SendPageStateClass(new ToAddrClass(0)); sendPageState.toaddr.to = c.address ? c.address : ''; setSendPageState(sendPageState); + closeAllModals(); navigation.navigate(RouteEnums.LoadedApp, { screen: translate('loadedapp.send-menu'), initial: false, diff --git a/components/Seed/Seed.tsx b/components/Seed/Seed.tsx index 7065ee91e..d1e5fc8e4 100644 --- a/components/Seed/Seed.tsx +++ b/components/Seed/Seed.tsx @@ -88,6 +88,8 @@ const Seed: React.FunctionComponent = ({ } const { colors } = useTheme() as ThemeType; + // when this screen is open from LoadingApp (new wallet) + // is using the standard modal from react-native const { hide } = useMagicModal(); moment.locale(language); @@ -177,12 +179,20 @@ const Seed: React.FunctionComponent = ({ const onClickCancelHide = () => { onClickCancel(); - hide(); + // when this screen is open from LoadingApp (new wallet) + // is using the standard modal from react-native + if (action !== SeedActionEnum.new) { + hide(); + } }; const onClickOKHide = (seedPhraseParm: string, birthdayNumberParm: number) => { onClickOK(seedPhraseParm, birthdayNumberParm); - hide(); + // when this screen is open from LoadingApp (new wallet) + // is using the standard modal from react-native + if (action !== SeedActionEnum.new) { + hide(); + } }; //console.log('================================='); diff --git a/components/Ufvk/ImportUfvk.tsx b/components/Ufvk/ImportUfvk.tsx index 5283c23e3..ffaa74b3b 100644 --- a/components/Ufvk/ImportUfvk.tsx +++ b/components/Ufvk/ImportUfvk.tsx @@ -7,6 +7,7 @@ import { TextInput, KeyboardAvoidingView, Platform, + Modal, } from 'react-native'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; @@ -26,7 +27,6 @@ import 'moment/locale/es'; import 'moment/locale/pt'; import 'moment/locale/ru'; import { ButtonTypeEnum, GlobalConst, SelectServerEnum } from '../../app/AppState'; -import { magicModal, useMagicModal } from 'react-native-magic-modal'; type ImportUfvkProps = { onClickCancel: () => void; @@ -36,11 +36,11 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o const context = useContext(ContextAppLoading); const { translate, netInfo, info, server, mode, addLastSnackbar, language, selectServer } = context; const { colors } = useTheme() as ThemeType; - const { hide } = useMagicModal(); moment.locale(language); const [seedufvkText, setSeedufvkText] = useState(''); const [birthday, setBirthday] = useState(''); + const [qrcodeModalVisible, setQrcodeModalVisible] = useState(false); const [latestBlock, setLatestBlock] = useState(0); useEffect(() => { @@ -105,24 +105,7 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o addLastSnackbar({ message: translate('loadedapp.connection-error') as string }); return; } - onClickOKAndHide(seedufvkText.trimEnd().trimStart(), Number(birthday)); - }; - - const setQrcodeModalShow = () => { - return magicModal.show(() => , { swipeDirection: undefined } - ).promise; - }; - - const onClickCancelAndHide = () => { - onClickCancel(); - hide(); - }; - - const onClickOKAndHide = (keyTextParm: string, birthdayParm: number) => { - onClickOK(keyTextParm, birthdayParm); - hide(); + onClickOK(seedufvkText.trimEnd().trimStart(), Number(birthday)); }; return ( @@ -139,6 +122,13 @@ const ImportUfvk: React.FunctionComponent = ({ onClickCancel, o height: '100%', backgroundColor: colors.background, }}> + setQrcodeModalVisible(false)}> + setQrcodeModalVisible(false)} /> +
= ({ onClickCancel, o translate={translate} netInfo={netInfo} mode={mode} - closeScreen={onClickCancelAndHide} + closeScreen={onClickCancel} /> = ({ onClickCancel, o )} { - setQrcodeModalShow(); + setQrcodeModalVisible(true); }}> diff --git a/components/Ufvk/components/ScannerUfvk.tsx b/components/Ufvk/components/ScannerUfvk.tsx index 2ee392074..1ce331f89 100644 --- a/components/Ufvk/components/ScannerUfvk.tsx +++ b/components/Ufvk/components/ScannerUfvk.tsx @@ -12,16 +12,15 @@ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { useTheme } from '@react-navigation/native'; import { ThemeType } from '../../../app/types'; import { Code } from 'react-native-vision-camera'; -import { useMagicModal } from 'react-native-magic-modal'; -type ScannerKeyProps = { +type ScannerUfvkProps = { setUfvkText: (k: string) => void; + closeModal: () => void; }; -const ScannerKey: React.FunctionComponent = ({ setUfvkText }) => { +const ScannerUfvk: React.FunctionComponent = ({ setUfvkText, closeModal }) => { const context = useContext(ContextAppLoading); const { translate, language } = context; const { colors } = useTheme() as ThemeType; - const { hide } = useMagicModal(); moment.locale(language); const onRead = async (codes: Code[]) => { @@ -32,7 +31,7 @@ const ScannerKey: React.FunctionComponent = ({ setUfvkText }) = } setUfvkText(scandata); - hide(); + closeModal(); }; return ( @@ -51,7 +50,7 @@ const ScannerKey: React.FunctionComponent = ({ setUfvkText }) = noSyncingStatus={true} noDrawMenu={true} noPrivacy={true} - closeScreen={hide} + closeScreen={closeModal} /> @@ -59,4 +58,4 @@ const ScannerKey: React.FunctionComponent = ({ setUfvkText }) = ); }; -export default ScannerKey; +export default ScannerUfvk;