Merge branch 'chore/add-rn-exit-app-library' into 'master'

Chore: add rn-exit-app-v2 library

See merge request bloodyhealth/drip!401
This commit is contained in:
Lisa
2022-06-25 10:19:01 +00:00
8 changed files with 71 additions and 27 deletions
@@ -1,28 +1,32 @@
import { Alert } from 'react-native' import { Alert, Platform } from 'react-native'
import { shared } from '../../../i18n/en/labels' import { shared } from '../../../i18n/en/labels'
import labels from '../../../i18n/en/settings' import labels from '../../../i18n/en/settings'
export default function showBackUpReminder(okHandler, cancelHandler, isDelete) { export default function showBackUpReminder(okHandler, cancelHandler, isDelete) {
let title, message const { title, message } = isDelete
if (isDelete) { ? labels.passwordSettings.deleteBackupReminder
title = labels.passwordSettings.deleteBackupReminderTitle : labels.passwordSettings.backupReminder
message = labels.passwordSettings.deleteBackupReminder
} else { const { backupReminderAppendix } = labels.passwordSettings
title = labels.passwordSettings.backupReminderTitle const appendix =
message = labels.passwordSettings.backupReminder Platform.OS === 'ios'
} ? backupReminderAppendix.ios
: backupReminderAppendix.android
Alert.alert( Alert.alert(
title, title,
message, message + appendix,
[{ [
text: shared.cancel, {
onPress: cancelHandler, text: shared.cancel,
style: 'cancel' onPress: cancelHandler,
}, { style: 'cancel',
text: shared.ok, },
onPress: okHandler {
}], text: shared.ok,
onPress: okHandler,
},
],
{ onDismiss: cancelHandler } { onDismiss: cancelHandler }
) )
} }
+3 -2
View File
@@ -2,7 +2,8 @@ import Realm from 'realm'
import { LocalDate, ChronoUnit } from 'js-joda' import { LocalDate, ChronoUnit } from 'js-joda'
import nodejs from 'nodejs-mobile-react-native' import nodejs from 'nodejs-mobile-react-native'
import fs from 'react-native-fs' import fs from 'react-native-fs'
import restart from 'react-native-restart' import { restartApp } from './restart-app'
import schemas from './schemas' import schemas from './schemas'
import cycleModule from '../lib/cycle' import cycleModule from '../lib/cycle'
import maybeSetNewCycleStart from '../lib/set-new-cycle-start' import maybeSetNewCycleStart from '../lib/set-new-cycle-start'
@@ -213,7 +214,7 @@ export async function changeEncryptionAndRestartApp(hash) {
db.close() db.close()
await fs.unlink(defaultPath) await fs.unlink(defaultPath)
await fs.moveFile(copyPath, defaultPath) await fs.moveFile(copyPath, defaultPath)
restart.Restart() restartApp()
} }
export function isDbEmpty() { export function isDbEmpty() {
+5
View File
@@ -0,0 +1,5 @@
// Current version of react-native-restart doesn't work with our ios setup
// therefore we have a fork and use different libraries on the platforms
import restart from 'react-native-restart'
export const restartApp = restart.Restart
+11
View File
@@ -0,0 +1,11 @@
// Current version of react-native-restart doesn't work with our ios setup
// therefore we have a fork and use different libraries on the platforms
import RNExitApp from 'react-native-exit-app-v2'
import { Alert } from 'react-native'
export const restartApp = () => {
Alert.alert('Closing app', 'App is shutting down. Please restart.')
setTimeout(() => {
RNExitApp.exitApp()
}, 3000)
}
+21 -6
View File
@@ -112,12 +112,27 @@ export default {
enterNew: 'Please enter a new password', enterNew: 'Please enter a new password',
confirmPassword: 'Please confirm your password', confirmPassword: 'Please confirm your password',
passwordsDontMatch: "Password and confirmation don't match", passwordsDontMatch: "Password and confirmation don't match",
backupReminderTitle: 'Read this before making changes to your password', backupReminder: {
backupReminder: title: 'Read this before making changes to your password',
'Just to be safe, please backup your data using the export function before making changes to your password.\n\nLonger passwords are better! Consider using a passphrase.\n\nPlease also make sure you do not lose your password. There is no way to recover your data if you do.\n\nMaking any changes to your password setting will keep your data as it was before and restart the app.', message: `
deleteBackupReminderTitle: 'Read this before deleting your password', Just to be safe, please backup your data using the export function before making any changes to your password.\n
deleteBackupReminder: Longer passwords are better! Consider using a passphrase.\n
'Deleting your password means your data will no longer be encrypted.\n\nJust to be safe, please backup your data using the export function before deleting your password.\n\nMaking any changes to your password setting will keep your data as it was before and restart the app.', Please also make sure you do not lose your password. There is no way to recover your data if you do.\n
Making any changes to your password setting will keep your data as it was before.\n`,
},
deleteBackupReminder: {
title: 'Read this before deleting your password',
message: `
Deleting your password means your data will no longer be encrypted.\n
Just to be safe, please backup your data using the export function before deleting your password.\n
Making any changes to your password setting will keep your data as it was before and restart the app.\n
`,
},
backupReminderAppendix: {
android:
'After the password is updated the app will automatically restart.',
ios: 'After the password is updated the app will automatically close. Please reopen it manually.',
},
}, },
aboutSection: { aboutSection: {
title: 'About', title: 'About',
+2
View File
@@ -525,6 +525,7 @@
"${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework", "${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework",
"${BUILT_PRODUCTS_DIR}/RNCPushNotificationIOS/RNCPushNotificationIOS.framework", "${BUILT_PRODUCTS_DIR}/RNCPushNotificationIOS/RNCPushNotificationIOS.framework",
"${BUILT_PRODUCTS_DIR}/RNDateTimePicker/RNDateTimePicker.framework", "${BUILT_PRODUCTS_DIR}/RNDateTimePicker/RNDateTimePicker.framework",
"${BUILT_PRODUCTS_DIR}/RNExitApp/RNExitApp.framework",
"${BUILT_PRODUCTS_DIR}/RNFS/RNFS.framework", "${BUILT_PRODUCTS_DIR}/RNFS/RNFS.framework",
"${BUILT_PRODUCTS_DIR}/RNShare/RNShare.framework", "${BUILT_PRODUCTS_DIR}/RNShare/RNShare.framework",
"${BUILT_PRODUCTS_DIR}/RNVectorIcons/RNVectorIcons.framework", "${BUILT_PRODUCTS_DIR}/RNVectorIcons/RNVectorIcons.framework",
@@ -563,6 +564,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTTypeSafety.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTTypeSafety.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNCPushNotificationIOS.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNCPushNotificationIOS.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNDateTimePicker.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNDateTimePicker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNExitApp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNFS.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNFS.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNShare.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNShare.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNVectorIcons.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNVectorIcons.framework",
+5
View File
@@ -8561,6 +8561,11 @@
"resolved": "https://registry.npmjs.org/react-native-document-picker/-/react-native-document-picker-4.3.0.tgz", "resolved": "https://registry.npmjs.org/react-native-document-picker/-/react-native-document-picker-4.3.0.tgz",
"integrity": "sha512-ygcY0ijlVuhxzdWnhqd917yMUFT9FF0b4CM81LWoY4/bpQYz5PGUdRAdh25kS0VA+cEUYNL2iI7OpHXq00epPA==" "integrity": "sha512-ygcY0ijlVuhxzdWnhqd917yMUFT9FF0b4CM81LWoY4/bpQYz5PGUdRAdh25kS0VA+cEUYNL2iI7OpHXq00epPA=="
}, },
"react-native-exit-app-v2": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/react-native-exit-app-v2/-/react-native-exit-app-v2-1.2.2.tgz",
"integrity": "sha512-RWCfmus7h99M1aONqBnWG3g3TFRzKsmok6cLAuqN5NVQAxpcgzbJZgAryA/ADpmBrBP5EIJnCBFo64ApQGOZPw=="
},
"react-native-fs": { "react-native-fs": {
"version": "2.19.0", "version": "2.19.0",
"resolved": "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.19.0.tgz", "resolved": "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.19.0.tgz",
+1
View File
@@ -47,6 +47,7 @@
"react-native": "0.61.0", "react-native": "0.61.0",
"react-native-calendars": "^1.19.3", "react-native-calendars": "^1.19.3",
"react-native-document-picker": "^4.2.0", "react-native-document-picker": "^4.2.0",
"react-native-exit-app-v2": "^1.2.2",
"react-native-fs": "^2.19.0", "react-native-fs": "^2.19.0",
"react-native-hyperlink": "0.0.19", "react-native-hyperlink": "0.0.19",
"react-native-modal-datetime-picker": "8.0.0", "react-native-modal-datetime-picker": "8.0.0",