From 93e4e47e1e04aaee5385f49e37f5db40fdfd7966 Mon Sep 17 00:00:00 2001 From: Christian Lippa Date: Thu, 30 Jan 2025 15:39:24 -0500 Subject: [PATCH 1/5] feat: enter pin for biometrics change ui update, and fix for white space Signed-off-by: Christian Lippa --- .../App/components/views/KeyboardView.tsx | 3 +- .../legacy/core/App/localization/en/index.ts | 4 ++ packages/legacy/core/App/screens/PINEnter.tsx | 67 +++++++++++++------ .../legacy/core/App/screens/UseBiometry.tsx | 19 ++++-- 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/packages/legacy/core/App/components/views/KeyboardView.tsx b/packages/legacy/core/App/components/views/KeyboardView.tsx index 9551f9bece..d19c8a8187 100644 --- a/packages/legacy/core/App/components/views/KeyboardView.tsx +++ b/packages/legacy/core/App/components/views/KeyboardView.tsx @@ -1,10 +1,11 @@ import React from 'react' import { KeyboardAvoidingView, Platform, ScrollView } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' +import { ColorPallet } from '../../theme' const KeyboardView: React.FC<{ children: React.ReactNode }> = ({ children }) => { return ( - + = ({ setAuthenticated, usage = PINEntryUsage.WalletUnlock, onCancelAuth }) => { @@ -54,19 +55,19 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU const [inlineMessageField, setInlineMessageField] = useState() const [inlineMessages] = useServices([TOKENS.INLINE_ERRORS]) const [alertModalMessage, setAlertModalMessage] = useState('') + // Temporary until all use cases are built with the new design + const isNewDesign = usage === PINEntryUsage.ChangeBiometrics const style = StyleSheet.create({ screenContainer: { height: '100%', backgroundColor: ColorPallet.brand.primaryBackground, padding: 20, - justifyContent: 'space-between', + justifyContent: isNewDesign ? 'flex-start' : 'space-between', }, - // below used as helpful labels for views, no properties needed atp contentContainer: {}, controlsContainer: {}, - buttonContainer: { width: '100%', }, @@ -78,7 +79,10 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU ...TextTheme.normal, alignSelf: 'auto', textAlign: 'left', - marginBottom: 16, + marginBottom: isNewDesign ? 40 : 16, + }, + parenthesisText: { + ...TextTheme.caption, }, modalText: { ...TextTheme.popupModalText, @@ -92,7 +96,8 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU }, title: { ...TextTheme.headingTwo, - marginBottom: 20, + marginTop: isNewDesign ? 20 : 0, + marginBottom: isNewDesign ? 40 : 20, }, subTitle: { ...TextTheme.labelSubtitle, @@ -100,10 +105,22 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU }, subText: { ...TextTheme.bold, - marginBottom: 4, + marginBottom: isNewDesign ? 20 : 4, }, }) + const inputLabelText = { + [PINEntryUsage.ChangeBiometrics]: t('PINEnter.ChangeBiometricsInputLabel'), + [PINEntryUsage.PINCheck]: t('PINEnter.AppSettingChangedEnterPIN'), + [PINEntryUsage.WalletUnlock]: t('PINEnter.EnterPIN'), + } + + const primaryButtonText = { + [PINEntryUsage.ChangeBiometrics]: t('Global.Continue'), + [PINEntryUsage.PINCheck]: t('PINEnter.AppSettingSave'), + [PINEntryUsage.WalletUnlock]: t('PINEnter.Unlock'), + } + const incrementDeveloperMenuCounter = useCallback(() => { if (developerOptionCount.current >= touchCountToEnableBiometrics) { developerOptionCount.current = 0 @@ -194,7 +211,7 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU ) const loadWalletCredentials = useCallback(async () => { - if (usage === PINEntryUsage.PINCheck) { + if (usage === PINEntryUsage.PINCheck || PINEntryUsage.ChangeBiometrics) { return } @@ -360,6 +377,10 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU setAlertModalVisible(false) setAuthenticated(false) break + case PINEntryUsage.ChangeBiometrics: + setAlertModalVisible(false) + setAuthenticated(false) + break default: setAlertModalVisible(false) @@ -414,7 +435,7 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU setContinueEnabled(false) - if (usage === PINEntryUsage.PINCheck) { + if (usage === PINEntryUsage.PINCheck || PINEntryUsage.ChangeBiometrics) { await verifyPIN(PIN) } @@ -459,6 +480,15 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU return {t('PINEnter.AppSettingChanged')} } + if (usage === PINEntryUsage.ChangeBiometrics) { + return ( + <> + {t('PINEnter.ChangeBiometricsHeader')} + {t('PINEnter.ChangeBiometricsSubtext')} + + ) + } + return ( <> {t('PINEnter.Title')} @@ -488,9 +518,10 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU ) : ( displayHelpText() )} - {`${ - usage === PINEntryUsage.PINCheck ? t('PINEnter.AppSettingChangedEnterPIN') : t('PINEnter.EnterPIN') - }`} + + {inputLabelText[usage]} + {usage === PINEntryUsage.ChangeBiometrics && {` `}{t('PINEnter.ChangeBiometricsInputLabelParenthesis')}} + { setPIN(p) @@ -498,10 +529,8 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU Keyboard.dismiss() } }} - testID={testIdWithKey(usage === PINEntryUsage.PINCheck ? 'AppSettingChangedEnterPIN' : 'EnterPIN')} - accessibilityLabel={ - usage === PINEntryUsage.PINCheck ? t('PINEnter.AppSettingChangedEnterPIN') : t('PINEnter.EnterPIN') - } + testID={testIdWithKey(inputLabelText[usage])} + accessibilityLabel={inputLabelText[usage]} autoFocus={true} inlineMessage={inlineMessageField} /> @@ -509,13 +538,11 @@ const PINEnter: React.FC = ({ setAuthenticated, usage = PINEntryU