Skip to content

Commit

Permalink
feat: enable wallet naming via onboarding dev mode
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath committed Aug 17, 2023
1 parent 5331f9f commit ca6f3d4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
1 change: 0 additions & 1 deletion app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const configuration: ConfigurationContext = {
useCustomNotifications: useNotifications,
proofRequestTemplates,
enableTours: true,
enableWalletNaming: false,
}

export default { theme, localization, configuration }
24 changes: 24 additions & 0 deletions app/src/screens/Developer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Settings: React.FC = () => {
!!store.preferences.useConnectionInviterCapability
)
const [useDevVerifierTemplates, setDevVerifierTemplates] = useState(!!store.preferences.useDevVerifierTemplates)
const [enableWalletNaming, setEnableWalletNaming] = useState(!!store.preferences.enableWalletNaming)

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -193,6 +194,14 @@ const Settings: React.FC = () => {
setDevVerifierTemplates((previousState) => !previousState)
}

const toggleWalletNamingSwitch = () => {
dispatch({
type: DispatchAction.ENABLE_WALLET_NAMING,
payload: [!enableWalletNaming],
})
setEnableWalletNaming((previousState) => !previousState)
}

return (
<SafeAreaView edges={['bottom', 'left', 'right']}>
<Modal
Expand Down Expand Up @@ -286,6 +295,21 @@ const Settings: React.FC = () => {
value={useDevVerifierTemplates}
/>
</SectionRow>
{!store.onboarding.didCreatePIN && (
<SectionRow
title={t('NameWallet.EnableWalletNaming')}
accessibilityLabel={t('NameWallet.ToggleWalletNaming')}
testID={testIdWithKey('ToggleWalletNamingSwitch')}
>
<Switch
trackColor={{ false: ColorPallet.grayscale.lightGrey, true: ColorPallet.brand.primaryDisabled }}
thumbColor={enableWalletNaming ? ColorPallet.brand.primary : ColorPallet.grayscale.mediumGrey}
ios_backgroundColor={ColorPallet.grayscale.lightGrey}
onValueChange={toggleWalletNamingSwitch}
value={enableWalletNaming}
/>
</SectionRow>
)}
</View>
</SafeAreaView>
)
Expand Down
43 changes: 25 additions & 18 deletions app/src/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const Splash: React.FC = () => {
const navigation = useNavigation()
const { getWalletCredentials } = useAuth()
const { ColorPallet, Assets } = useTheme()
const { indyLedgers, enableWalletNaming } = useConfiguration()
const { indyLedgers } = useConfiguration()
const [stepText, setStepText] = useState<string>(t('Init.Starting'))
const [progressPercent, setProgressPercent] = useState(0)
const [initOnboardingCount, setInitOnboardingCount] = useState(0)
Expand Down Expand Up @@ -258,30 +258,37 @@ const Splash: React.FC = () => {
payload: [dataAsJSON],
})

if (onboardingComplete(dataAsJSON) && !attemptData?.lockoutDate) {
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: Screens.EnterPIN }],
})
)
return
} else if (onboardingComplete(dataAsJSON) && attemptData?.lockoutDate) {
// return to lockout screen if lockout date is set
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: Screens.AttemptLockout }],
})
)
if (onboardingComplete(dataAsJSON)) {
// if they previously completed onboarding before wallet naming was enabled, mark complete
if (!store.onboarding.didNameWallet) {
dispatch({ type: DispatchAction.DID_NAME_WALLET, payload: [true] })
}

if (!attemptData?.lockoutDate) {
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: Screens.EnterPIN }],
})
)
} else {
// return to lockout screen if lockout date is set
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: Screens.AttemptLockout }],
})
)
}

return
}

// If onboarding was interrupted we need to pickup from where we left off.
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: resumeOnboardingAt(dataAsJSON, enableWalletNaming) }],
routes: [{ name: resumeOnboardingAt(dataAsJSON, store.preferences.enableWalletNaming) }],
})
)

Expand Down

0 comments on commit ca6f3d4

Please sign in to comment.