mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-08 21:18:14 -05:00
* feat(INJI-473) - Removed unused injiTourGuide action. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Removed unused logKey action. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Removed unused backendInfo api and state. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - simplify isPasscodeSet logic. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Move logState to commonUtil to remove cyclic dependency. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Delete unused code. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Refactor code to use util function for iOS or isAndroid. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Move Issuers_Key_Ref into utils. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Remove profile related resource from setting screen Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Remove unused code for locales. Signed-off-by: Swati Goel <meet2swati@gmail.com> --------- Signed-off-by: Swati Goel <meet2swati@gmail.com>
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import {useSelector} from '@xstate/react';
|
|
import {useContext} from 'react';
|
|
import {
|
|
AuthEvents,
|
|
selectBiometrics,
|
|
selectLanguagesetup,
|
|
selectPasscode,
|
|
selectSettingUp,
|
|
} from '../machines/auth';
|
|
import {
|
|
SettingsEvents,
|
|
selectBiometricUnlockEnabled,
|
|
} from '../machines/settings';
|
|
import {RootRouteProps} from '../routes';
|
|
import {GlobalContext} from '../shared/GlobalContext';
|
|
import {
|
|
getStartEventData,
|
|
getImpressionEventData,
|
|
getInteractEventData,
|
|
sendImpressionEvent,
|
|
sendInteractEvent,
|
|
sendStartEvent,
|
|
} from '../shared/telemetry/TelemetryUtils';
|
|
|
|
export function useWelcomeScreen(props: RootRouteProps) {
|
|
const {appService} = useContext(GlobalContext);
|
|
const authService = appService.children.get('auth');
|
|
const settingsService = appService.children.get('settings');
|
|
|
|
const isSettingUp = useSelector(authService, selectSettingUp);
|
|
const passcode = useSelector(authService, selectPasscode);
|
|
|
|
const isPasscodeSet = () => !!passcode;
|
|
|
|
const biometrics = useSelector(authService, selectBiometrics);
|
|
const isLanguagesetup = useSelector(authService, selectLanguagesetup);
|
|
const isBiometricUnlockEnabled = useSelector(
|
|
settingsService,
|
|
selectBiometricUnlockEnabled,
|
|
);
|
|
|
|
return {
|
|
isSettingUp,
|
|
isLanguagesetup,
|
|
isPasscodeSet,
|
|
NEXT: () => {
|
|
authService.send(AuthEvents.NEXT()), props.navigation.navigate('Auth');
|
|
},
|
|
SELECT: () => {
|
|
authService.send(AuthEvents.SELECT()),
|
|
props.navigation.navigate('IntroSliders');
|
|
},
|
|
BACK: () => {
|
|
settingsService.send(SettingsEvents.BACK()),
|
|
props.navigation.navigate('Main');
|
|
},
|
|
unlockPage: () => {
|
|
// prioritize biometrics
|
|
if (!isSettingUp && isBiometricUnlockEnabled && biometrics !== '') {
|
|
props.navigation.navigate('Biometric', {setup: isSettingUp});
|
|
} else if (!isSettingUp && passcode !== '') {
|
|
sendStartEvent(getStartEventData('App Login'));
|
|
sendInteractEvent(
|
|
getInteractEventData(
|
|
'App Login',
|
|
'TOUCH',
|
|
'Unlock application button',
|
|
),
|
|
);
|
|
props.navigation.navigate('Passcode', {setup: isSettingUp});
|
|
} else {
|
|
props.navigation.navigate('Auth');
|
|
}
|
|
},
|
|
};
|
|
}
|