From 98b068ce251225d9249835c17b674eeda26a2dd9 Mon Sep 17 00:00:00 2001 From: Jean Regisser Date: Wed, 23 Oct 2019 13:05:40 +0200 Subject: [PATCH] [Wallet] Use exit on iOS since we can't restart like Android (#1424) --- packages/mobile/ios/Podfile | 1 + packages/mobile/ios/Podfile.lock | 8 +++++++- packages/mobile/ios/celo.xcodeproj/project.pbxproj | 2 ++ packages/mobile/locales/en-US/global.json | 1 + packages/mobile/locales/es-419/global.json | 1 + packages/mobile/package.json | 1 + packages/mobile/src/app/AppLoading.tsx | 10 ++++++---- packages/mobile/src/app/ErrorScreen.tsx | 4 ++-- .../src/app/__snapshots__/AppLoading.test.tsx.snap | 4 ++-- packages/mobile/src/utils/AppRestart.ts | 11 ++++++++++- yarn.lock | 5 +++++ 11 files changed, 38 insertions(+), 10 deletions(-) diff --git a/packages/mobile/ios/Podfile b/packages/mobile/ios/Podfile index 896d6a1d5a8..baed20b1df9 100644 --- a/packages/mobile/ios/Podfile +++ b/packages/mobile/ios/Podfile @@ -58,6 +58,7 @@ target 'celo' do pod 'CeloBlockchain', :path => '../../../node_modules/@celo/client/CeloBlockchain.podspec' pod 'RNSecureKeyStore', :path => '../../../node_modules/react-native-secure-key-store/ios' pod 'react-native-safe-area-context', :path => '../../../node_modules/react-native-safe-area-context' + pod 'RNExitApp', :path => '../../../node_modules/react-native-exit-app' pod 'Firebase/Core', '~> 5.20.2' pod 'Firebase/Auth' diff --git a/packages/mobile/ios/Podfile.lock b/packages/mobile/ios/Podfile.lock index a5429a024de..4a4319fd490 100644 --- a/packages/mobile/ios/Podfile.lock +++ b/packages/mobile/ios/Podfile.lock @@ -208,6 +208,8 @@ PODS: - Segment-Firebase - RNDeviceInfo (2.1.0): - React + - RNExitApp (1.1.0): + - React - RNFirebase (5.5.4): - Firebase/Core - React @@ -288,6 +290,7 @@ DEPENDENCIES: - "RNAnalytics (from `../../../node_modules/@segment/analytics-react-native`)" - "RNAnalyticsIntegration-Firebase (from `../../../node_modules/@segment/analytics-react-native-firebase`)" - RNDeviceInfo (from `../../../node_modules/react-native-device-info`) + - RNExitApp (from `../../../node_modules/react-native-exit-app`) - RNFirebase (from `../../../node_modules/react-native-firebase/ios`) - RNFS (from `../../../node_modules/react-native-fs`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) @@ -366,6 +369,8 @@ EXTERNAL SOURCES: :path: "../../../node_modules/@segment/analytics-react-native-firebase" RNDeviceInfo: :path: "../../../node_modules/react-native-device-info" + RNExitApp: + :path: "../../../node_modules/react-native-exit-app" RNFirebase: :path: "../../../node_modules/react-native-firebase/ios" RNFS: @@ -430,6 +435,7 @@ SPEC CHECKSUMS: RNAnalytics: 05243c1fa17186f07be3eae30514b43aeb2e0578 RNAnalyticsIntegration-Firebase: 82b879019b012d1aa1cbcb6dfc466acd7233bb97 RNDeviceInfo: 2b4f76adc479657bf37bfc927bbfb027b17515d4 + RNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3 RNFirebase: 7d4733713a0f436d55388b55ca3744385c70fd2d RNFS: 0f4d630b538e93e0e9e3519ff0b7b7b48760d8ed RNGestureHandler: b65d391f4f570178d657b99a16ec99d09b8656b0 @@ -444,6 +450,6 @@ SPEC CHECKSUMS: SentryReactNative: 07237139c00366ea2e75ae3e5c566e7a71c27a90 yoga: 684513b14b03201579ba3cee20218c9d1298b0cc -PODFILE CHECKSUM: 02a0ed956675dc8aa46eab297cf94e8823e80147 +PODFILE CHECKSUM: 4fd5dd293e11126639ca80f4cd528455f4af5ffa COCOAPODS: 1.7.5 diff --git a/packages/mobile/ios/celo.xcodeproj/project.pbxproj b/packages/mobile/ios/celo.xcodeproj/project.pbxproj index abe887e2507..bf5fc4aed80 100644 --- a/packages/mobile/ios/celo.xcodeproj/project.pbxproj +++ b/packages/mobile/ios/celo.xcodeproj/project.pbxproj @@ -462,6 +462,7 @@ "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", "${BUILT_PRODUCTS_DIR}/RNDeviceInfo/RNDeviceInfo.framework", + "${BUILT_PRODUCTS_DIR}/RNExitApp/RNExitApp.framework", "${BUILT_PRODUCTS_DIR}/RNFS/RNFS.framework", "${BUILT_PRODUCTS_DIR}/RNGestureHandler/RNGestureHandler.framework", "${BUILT_PRODUCTS_DIR}/RNLocalize/RNLocalize.framework", @@ -500,6 +501,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNDeviceInfo.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNExitApp.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNFS.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNGestureHandler.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNLocalize.framework", diff --git a/packages/mobile/locales/en-US/global.json b/packages/mobile/locales/en-US/global.json index 1f8680a22e1..8077afd3a5b 100644 --- a/packages/mobile/locales/en-US/global.json +++ b/packages/mobile/locales/en-US/global.json @@ -65,6 +65,7 @@ "verifyFailed": "Failed to verify", "canNotRequestFromUnverified": "Can not request from unverified users", "restartApp": "Restart App", + "quitApp": "Quit", "loading": "Loading…", "inviteFailed": "Failure sending invite", "importContactsFailed": "Failed to import contacts", diff --git a/packages/mobile/locales/es-419/global.json b/packages/mobile/locales/es-419/global.json index 0076dc4d25f..6b2a4b0fe3b 100755 --- a/packages/mobile/locales/es-419/global.json +++ b/packages/mobile/locales/es-419/global.json @@ -65,6 +65,7 @@ "verifyFailed": "Falla durante la verificación", "canNotRequestFromUnverified": "No se puede solicitar a usuarios no verificados.", "restartApp": "Reiniciar la aplicación", + "quitApp": "Dejar", "loading": "Cargando…", "inviteFailed": "Falló el envío de la invitación", "importContactsFailed": "Error al importar contactos", diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 2f6f923c6d7..6109e3cf3cf 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -89,6 +89,7 @@ "react-native-confirm-device-credentials": "^2.0.0", "react-native-contacts": "git://github.com/celo-org/react-native-contacts#4989b0b", "react-native-device-info": "^2.1.0", + "react-native-exit-app": "^1.1.0", "react-native-firebase": "5.5.4", "react-native-flag-secure-android": "git://github.com/kristiansorens/react-native-flag-secure-android#e234251", "react-native-fs": "^2.12.1", diff --git a/packages/mobile/src/app/AppLoading.tsx b/packages/mobile/src/app/AppLoading.tsx index 421ae38fdc1..accef6de110 100644 --- a/packages/mobile/src/app/AppLoading.tsx +++ b/packages/mobile/src/app/AppLoading.tsx @@ -3,8 +3,10 @@ import colors from '@celo/react-components/styles/colors' import * as React from 'react' import { withNamespaces, WithNamespaces } from 'react-i18next' import { StyleSheet, View } from 'react-native' +import SafeAreaView from 'react-native-safe-area-view' import { Namespaces } from 'src/i18n' -import { restartApp } from 'src/utils/AppRestart' +import { RESTART_APP_I18N_KEY, restartApp } from 'src/utils/AppRestart' + const SHOW_RESTART_BUTTON_TIMEOUT = 10000 interface State { @@ -40,19 +42,19 @@ export class AppLoading extends React.Component { const { t } = this.props return ( - + {this.state.showRestartButton && (