Skip to content

Commit

Permalink
refactor: moved screen option responsibility
Browse files Browse the repository at this point in the history
Moved back navigation special case logic to onboarding flow and left back navigation apart of the default screen options

Signed-off-by: al-rosenthal <[email protected]>
  • Loading branch information
al-rosenthal committed Jan 14, 2025
1 parent b056698 commit d5130f2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/legacy/app/container-imp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AppContainer implements Container {

//This is an example of how to customize the screen layout and use custom header for wallets who wnat to hide default navigation header
//To hide navigation header for a specific page, use headerShown: false in the screen options like this
/*
/**
this.container.registerInstance(TOKENS.OBJECT_SCREEN_CONFIG, {
...DefaultScreenOptionsDictionary,
[Screens.Terms]: {
Expand Down Expand Up @@ -51,7 +51,7 @@ export class AppContainer implements Container {
}

public resolve<K extends keyof TokenMapping>(token: K): TokenMapping[K] {
return this._container.resolve(token) as TokenMapping[K]
return this._container.resolve(token)
}
public resolveAll<K extends keyof TokenMapping, T extends K[]>(
tokens: [...T]
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy/core/App/container-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class MainContainer implements Container {
}

public resolve<K extends keyof TokenMapping>(token: K): TokenMapping[K] {
return this._container.resolve(token) as TokenMapping[K]
return this._container.resolve(token)
}
public resolveAll<K extends keyof TokenMapping, T extends K[]>(
tokens: [...T]
Expand Down
6 changes: 6 additions & 0 deletions packages/legacy/core/App/navigators/OnboardingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const OnboardingStack: React.FC = () => {
return {
...ScreenOptionsDictionary[Screens.Onboarding],
title: t('Screens.Onboarding'),
headerLeft: () => false,
}
},
},
Expand All @@ -125,6 +126,7 @@ const OnboardingStack: React.FC = () => {
options: () => ({
...ScreenOptionsDictionary[Screens.Terms],
title: t('Screens.Terms'),
headerLeft: () => false,
}),
component: Terms,
},
Expand All @@ -135,13 +137,15 @@ const OnboardingStack: React.FC = () => {
options: () => ({
...ScreenOptionsDictionary[Screens.CreatePIN],
title: t('Screens.CreatePIN'),
headerLeft: () => false,
}),
},
{
name: Screens.NameWallet,
options: () => ({
...ScreenOptionsDictionary[Screens.NameWallet],
title: t('Screens.NameWallet'),
headerLeft: () => false,
}),
component: NameWallet,
},
Expand All @@ -150,6 +154,7 @@ const OnboardingStack: React.FC = () => {
options: () => ({
...ScreenOptionsDictionary[Screens.UseBiometry],
title: t('Screens.Biometry'),
headerLeft: () => false,
}),
component: useBiometry,
},
Expand All @@ -158,6 +163,7 @@ const OnboardingStack: React.FC = () => {
options: () => ({
...ScreenOptionsDictionary[Screens.UsePushNotifications],
title: t('Screens.UsePushNotifications'),
headerLeft: () => false,
}),
children: PushNotification as any,
},
Expand Down
4 changes: 0 additions & 4 deletions packages/legacy/core/App/navigators/SettingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const SettingStack: React.FC = () => {
title: t('Screens.Biometry'),
headerBackTestID: testIdWithKey('Back'),
...ScreenOptionsDictionary[Screens.UseBiometry],
headerLeft: undefined,
}}
/>
<Stack.Screen
Expand All @@ -108,7 +107,6 @@ const SettingStack: React.FC = () => {
title: t('Screens.ChangePIN'),
headerBackTestID: testIdWithKey('Back'),
...ScreenOptionsDictionary[Screens.CreatePIN],
headerLeft: undefined,
}}
/>
<Stack.Screen
Expand All @@ -118,7 +116,6 @@ const SettingStack: React.FC = () => {
title: t('Screens.UsePushNotifications'),
headerBackTestID: testIdWithKey('Back'),
...ScreenOptionsDictionary[Screens.UsePushNotifications],
headerLeft: undefined,
}}
/>
<Stack.Screen
Expand All @@ -128,7 +125,6 @@ const SettingStack: React.FC = () => {
title: t('Screens.Terms'),
headerBackTestID: testIdWithKey('Back'),
...ScreenOptionsDictionary[Screens.Terms],
headerLeft: undefined,
}}
/>
<Stack.Screen
Expand Down
11 changes: 5 additions & 6 deletions packages/legacy/core/App/navigators/defaultStackOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,29 @@ export const DefaultScreenOptionsDictionary: ScreenOptionsType = {
[Screens.Onboarding]: {
headerTintColor: OnboardingTheme.headerTintColor,
gestureEnabled: false,
headerLeft: () => false,
},
[Screens.Terms]: {
headerTintColor: OnboardingTheme.headerTintColor,
headerLeft: () => false,
headerBackTestID: testIdWithKey('Back'),
},
[Screens.CreatePIN]: {
headerLeft: () => false,
headerBackTestID: testIdWithKey('Back'),
},
[Screens.NameWallet]: {
headerTintColor: OnboardingTheme.headerTintColor,
headerLeft: () => false,
headerBackTestID: testIdWithKey('Back'),
},
[Screens.UseBiometry]: {
headerTintColor: OnboardingTheme.headerTintColor,
headerLeft: () => false,
headerBackTestID: testIdWithKey('Back'),
},
[Screens.Developer]: {
headerTintColor: OnboardingTheme.headerTintColor,
headerBackTestID: testIdWithKey('Back'),
},
[Screens.UsePushNotifications]: {
headerTintColor: OnboardingTheme.headerTintColor,
headerLeft: () => false,
headerBackTestID: testIdWithKey('Back'),
},
}

Expand Down

0 comments on commit d5130f2

Please sign in to comment.