Files
inji-wallet/screens/Settings/DataBackupAndRestore.tsx
KiruthikaJeyashankar 68488f3f0c [INJIMOB-2381] fix compile and target SDK 34 is causing app crash in debug build (#1877)
* [INJIMOB-2381] update package.json and resolve dependencies for react 0.73.0

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-2381] setup for 0.73.6

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-2381] fix font & image not loading issue

changes include
- move common image assets to android & iOS folders
- update gradle version to 8.2
- add expo-font asset for Inter regular
- replace useFont with expo-font
- remove flipper (reason: 0.74 react native decoupled flipper)
- npm package updates
- close icon changed to close text in QRScanner.tsx

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-2381] update android:mosip script as per updated react native version

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix android build failure issue

Changes include:
- rename android assets folder as per convention
- remove unused biometrics dependency
- use env from react-native-dotenv as per module registered in babel config
- revert conversion of close icon to image in QRScanner component

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix iOS build issue

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] rm unused local images linking in adnroid

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix splash screen not rendering issue in android

Issue: Local assets were not loaded via React Native Image component in android, to fix this @react-native/assets-registry has been added
Reference: https://github.com/expo/expo/issues/31240#issuecomment-2459049911

Other changes:
- remove usage of expo-image as we dont have any explicit usecase for expo-image and its unused

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] rm unused intro slider image assets

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] revert back using local font assets in android

Reason: Previously expo-font was used for fonts, to bring back the same compatiblity it is bought back

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] use GestureHandlerRootView in root level to handle gestures

ref - https://docs.swmansion.com/react-native-gesture-handler/docs/1.x/#js

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove custom assets and linking for images in iOS

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] use default parameters instead of defaultProps

Reason: React 18 has marked defaultProps as deprecated and it is removed in React 19 version. To avoid the issue of deprated usage, its modified.

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove unused terminal option in android build script

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove font assets in android

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] optimize import

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix failing test

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] set package.resolved version to 2

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix setting of camera view in face scanner

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix setting of camera view in face compare

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove flipper config file

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove unused debug logs

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] refactor use component instead of type

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] refactor use GestureHandlerRootView only on root level

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] refactor remove unused config linking of font assets

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] refactor remove unused image assets

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] fix camera persmission issue in QRScanner

use expo-camera to request and getstatus of camera permission instead of expo-barcode-scanner to avoid multiple re-renders of scan screen in flow of camera permission denial

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove package expo-barcode-scanner

expo-barcode-scanner is deprecated and its suggested to use expo-camera to handle the scanning flows. The existing bar-code-scanner implementations have been replaced with expo-camera.

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] use extracted enums instead of legacy expo-camera

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove patch for react-native-0.71.8

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] revert date-fs version to 2.28.0

date-fns is not supporting filipino langauge, so we are maintaining patch for that. The patch created is for version 2.28.0 and updating the version of date-fns is causing conflicts in patch application if updated as well. To avoid this issue, version is kept as 2.28.0

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] update readme

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] remove usage of legacy expo-camera in getting image type

Other changes
- remove resolutions block from package.json
- sync pbxproj

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-2381] add active prop to expo-camera as per suggestions

expo-camera suggests "Only one Camera preview can be active at any given time. If you have multiple screens in your app, you should unmount Camera components whenever a screen is unfocused.". To handle this active prop is used which is set to false on unMount of the component whenever rendering Camera from expo-camera

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

---------

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
Signed-off-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Co-authored-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
Co-authored-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
2025-04-10 14:37:41 +05:30

139 lines
5.0 KiB
TypeScript

import React from 'react';
import {useTranslation} from 'react-i18next';
import {Pressable} from 'react-native';
import {Icon, ListItem} from 'react-native-elements';
import {Row, Text} from '../../components/ui';
import {Error} from '../../components/ui/Error';
import {Loader} from '../../components/ui/Loader';
import {Theme} from '../../components/ui/styleUtils';
import {SvgImage} from '../../components/ui/svg';
import {AccountSelectionConfirmation} from '../backupAndRestore/AccountSelectionConfirmation';
import {useBackupAndRestoreSetup} from '../backupAndRestore/BackupAndRestoreSetupController';
import BackupAndRestoreScreen from '../backupAndRestore/BackupAndRestoreScreen';
import testIDProps, {getDriveName} from '../../shared/commonUtil';
import {useOverlayVisibleAfterTimeout} from '../../shared/hooks/useOverlayVisibleAfterTimeout';
import {isAndroid, isIOS} from '../../shared/constants';
export const DataBackupAndRestore: React.FC = ({} = () => {
const controller = useBackupAndRestoreSetup();
const delay = isAndroid() ? 0 : 1000;
const {t} = useTranslation('DataBackupScreen');
const accountSelectionModalVisible = useOverlayVisibleAfterTimeout(
controller.showAccountSelectionConfirmation,
delay,
);
const isLoaderVisible = useOverlayVisibleAfterTimeout(
controller.isLoading,
delay,
);
const isSigningInSuccessful = useOverlayVisibleAfterTimeout(
controller.isSigningInSuccessful,
delay,
);
const isSigningIn = useOverlayVisibleAfterTimeout(
controller.isSigningIn,
delay,
);
return (
<React.Fragment>
<Pressable
accessible={false}
{...testIDProps('dataBackupAndRestore')}
onPress={controller.BACKUP_AND_RESTORE}>
<ListItem topDivider bottomDivider>
{SvgImage.backUpAndRestoreIcon(24, 24)}
<ListItem.Content>
<ListItem.Title
accessible={false}
{...testIDProps('dataBackupAndRestoreText')}>
<Row>
<Text
testID="dataBackupAndRestoreText"
weight="semibold"
color={Theme.Colors.settingsLabel}
style={{paddingRight: 10, paddingTop: 10}}>
{t('dataBackupAndRestore')}
</Text>
</Row>
</ListItem.Title>
</ListItem.Content>
<Icon
name="chevron-right"
size={21}
{...testIDProps('dataBackupAndRestoreChevronRight')}
color={Theme.Colors.chevronRightColor}
style={{marginRight: 15}}
/>
</ListItem>
</Pressable>
{((controller.isSigningInFailed && !isIOS()) ||
controller.isCloudSignInFailed) && (
<Error
isModal
alignActionsOnEnd
showClose={false}
isVisible={controller.isSigningInFailed}
title={t('errors.permissionDenied.title')}
message={t('errors.permissionDenied.message', {
driveName: getDriveName(),
})}
helpText={t('errors.permissionDenied.helpText')}
image={SvgImage.PermissionDenied()}
primaryButtonText={
'DataBackupScreen:errors.permissionDenied.actions.allowAccess'
}
primaryButtonEvent={
isAndroid()
? controller.RECONFIGURE_ACCOUNT
: controller.OPEN_SETTINGS
}
textButtonText={
'DataBackupScreen:errors.permissionDenied.actions.notNow'
}
textButtonEvent={controller.GO_BACK}
onDismiss={controller.GO_BACK}
primaryButtonTestID="allowAccess"
textButtonTestID="notNow"
customImageStyles={{paddingBottom: 0, marginBottom: -6}}
customStyles={{marginTop: '20%'}}
testID="CloudBackupConsentDenied"
/>
)}
{controller.isNetworkError && (
<Error
testID="networkOffError"
primaryButtonTestID="tryAgain"
primaryButtonText="tryAgain"
primaryButtonEvent={controller.TRY_AGAIN}
isVisible={controller.isNetworkError}
isModal={true}
showClose
title={t('errors.noInternetConnection.title')}
message={t('errors.noInternetConnection.message')}
onDismiss={controller.DISMISS}
image={SvgImage.NoInternetConnection()}
/>
)}
{(isSigningIn || isSigningInSuccessful) &&
!controller.isCloudSignInFailed && (
<BackupAndRestoreScreen
profileInfo={controller.profileInfo}
onBackPress={controller.GO_BACK}
isSigningIn={controller.isSigningIn}
shouldTriggerAutoBackup={controller.shouldTriggerAutoBackup}
/>
)}
{isLoaderVisible && <Loader title={t('loadingSubtitle')} isModal />}
<AccountSelectionConfirmation
isVisible={accountSelectionModalVisible}
onProceed={controller.PROCEED_ACCOUNT_SELECTION}
goBack={controller.GO_BACK}
/>
</React.Fragment>
);
});