Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable wallet naming via onboarding dev mode #1391

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion bifold
Loading