Skip to content

Commit

Permalink
fix: added missing back buttons to settings pages (#1387)
Browse files Browse the repository at this point in the history
Signed-off-by: al-rosenthal <alfred.k.rosenthal@gmail.com>
  • Loading branch information
al-rosenthal authored Jan 14, 2025
1 parent 4c4f078 commit cf55823
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 28 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
16 changes: 1 addition & 15 deletions packages/legacy/core/App/navigators/SettingStack.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { createStackNavigator } from '@react-navigation/stack'
import React, { useEffect, useState } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { DeviceEventEmitter } from 'react-native'

import { EventTypes } from '../constants'
import { useTheme } from '../contexts/theme'
import HistorySettings from '../modules/history/ui/HistorySettings'
import DataRetention from '../screens/DataRetention'
Expand All @@ -25,7 +23,6 @@ import AutoLock from '../screens/AutoLock'
const SettingStack: React.FC = () => {
const Stack = createStackNavigator<SettingStackParams>()
const theme = useTheme()
const [biometryUpdatePending, setBiometryUpdatePending] = useState<boolean>(false)
const { t } = useTranslation()
const [pages, { screen: terms }, UseBiometry, developer, ScreenOptionsDictionary] = useServices([
TOKENS.SCREEN_ONBOARDING_PAGES,
Expand All @@ -38,16 +35,6 @@ const SettingStack: React.FC = () => {
const OnboardingTheme = theme.OnboardingTheme
const carousel = createCarouselStyle(OnboardingTheme)

useEffect(() => {
const handleBiometry = DeviceEventEmitter.addListener(EventTypes.BIOMETRY_UPDATE, (value: boolean) => {
setBiometryUpdatePending(value)
})

return () => {
handleBiometry.remove()
}
}, [])

return (
<Stack.Navigator screenOptions={{ ...defaultStackOptions }}>
<Stack.Screen
Expand Down Expand Up @@ -109,7 +96,6 @@ const SettingStack: React.FC = () => {
component={UseBiometry}
options={{
title: t('Screens.Biometry'),
headerLeft: biometryUpdatePending ? () => null : undefined,
headerBackTestID: testIdWithKey('Back'),
...ScreenOptionsDictionary[Screens.UseBiometry],
}}
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
5 changes: 1 addition & 4 deletions packages/legacy/core/App/screens/UseBiometry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { CommonActions, useNavigation } from '@react-navigation/native'
import { StackNavigationProp } from '@react-navigation/stack'
import React, { useState, useEffect, useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, View, Modal, ScrollView, DeviceEventEmitter, Linking, Platform } from 'react-native'
import { StyleSheet, Text, View, Modal, ScrollView, Linking, Platform } from 'react-native'
import { PERMISSIONS, RESULTS, request, check, PermissionStatus } from 'react-native-permissions'
import { SafeAreaView } from 'react-native-safe-area-context'

import Button, { ButtonType } from '../components/buttons/Button'
import ToggleButton from '../components/buttons/ToggleButton'
import { EventTypes } from '../constants'
import { useAnimatedComponents } from '../contexts/animated-components'
import { useAuth } from '../contexts/auth'
import { DispatchAction } from '../contexts/reducers/store'
Expand Down Expand Up @@ -153,7 +152,6 @@ const UseBiometry: React.FC = () => {
(newValue: boolean) => {
if (screenUsage === UseBiometryUsage.ToggleOnOff) {
setCanSeeCheckPIN(true)
DeviceEventEmitter.emit(EventTypes.BIOMETRY_UPDATE, true)
if (
historyEventsLogger.logToggleBiometry &&
store.onboarding.didAgreeToTerms &&
Expand Down Expand Up @@ -249,7 +247,6 @@ const UseBiometry: React.FC = () => {
if (status) {
setBiometryEnabled((previousState) => !previousState)
}
DeviceEventEmitter.emit(EventTypes.BIOMETRY_UPDATE, false)
if (
historyEventsLogger.logToggleBiometry &&
store.onboarding.didAgreeToTerms &&
Expand Down

0 comments on commit cf55823

Please sign in to comment.