Skip to content

Commit

Permalink
[C-3899] Fix android able to go back on signup (#7727)
Browse files Browse the repository at this point in the history
  • Loading branch information
DejayJD authored Feb 27, 2024
1 parent d04b4bc commit 8f73c19
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 33 deletions.
82 changes: 49 additions & 33 deletions packages/mobile/src/screens/sign-on-screen/SignOnStack.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useCallback, useState } from 'react'

import { accountSelectors } from '@audius/common/store'
import type { NativeStackNavigationOptions } from '@react-navigation/native-stack'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { getSignOn } from 'audius-client/src/common/store/pages/signon/selectors'
import { useSelector } from 'react-redux'

import { ScreenOptionsContext, defaultScreenOptions } from 'app/app/navigation'

Expand All @@ -15,6 +18,7 @@ import { ReviewHandleScreen } from './screens/ReviewHandleScreen'
import { SelectArtistsScreen } from './screens/SelectArtistScreen'
import { SelectGenresScreen } from './screens/SelectGenresScreen'
import { SignOnScreen } from './screens/SignOnScreen'
const { getAccountUser } = accountSelectors

const Stack = createNativeStackNavigator()
const screenOptionsOverrides = { animationTypeForReplace: 'pop' as const }
Expand All @@ -31,11 +35,18 @@ export const SignOnStack = (props: SignOnStackProps) => {
...screenOptionsOverrides
})

const signUpState = useSelector(getSignOn)
const user = useSelector(getAccountUser)
const hasAccount = !!user

const pastPhase1 = signUpState.finishedPhase1 || hasAccount

const updateOptions = useCallback(
(newOptions: NativeStackNavigationOptions) => {
setScreenOptions({
...defaultScreenOptions,
...screenOptionsOverrides,
gestureEnabled: false,
...newOptions
})
},
Expand All @@ -47,39 +58,44 @@ export const SignOnStack = (props: SignOnStackProps) => {
value={{ options: screenOptions, updateOptions }}
>
<Stack.Navigator initialRouteName='SignOn' screenOptions={screenOptions}>
<Stack.Group>
<Stack.Screen name='SignOn' options={{ headerShown: false }}>
{() => (
<SignOnScreen isSplashScreenDismissed={isSplashScreenDismissed} />
)}
</Stack.Screen>
<Stack.Screen name='ConfirmEmail' component={ConfirmEmailScreen} />
</Stack.Group>
<Stack.Group>
<Stack.Screen
name='CreatePassword'
component={CreatePasswordScreen}
/>
<Stack.Screen name='PickHandle' component={PickHandleScreen} />
<Stack.Screen name='ReviewHandle' component={ReviewHandleScreen} />
<Stack.Screen
name='CreateLoginDetails'
component={CreateLoginDetailsScreen}
/>
<Stack.Screen name='FinishProfile' component={FinishProfileScreen} />
<Stack.Screen
name='SelectGenre'
component={SelectGenresScreen}
options={{ headerLeft: () => null, gestureEnabled: false }}
/>
<Stack.Screen name='SelectArtists' component={SelectArtistsScreen} />
<Stack.Screen
name='AccountLoading'
component={AccountLoadingScreen}
// animation: none here is a workaround to prevent "white screen of death" on Android
options={{ headerShown: false, animation: 'none' }}
/>
</Stack.Group>
{!pastPhase1 ? (
<Stack.Group>
<Stack.Screen name='SignOn' options={{ headerShown: false }}>
{() => (
<SignOnScreen
isSplashScreenDismissed={isSplashScreenDismissed}
/>
)}
</Stack.Screen>
<Stack.Screen name='ConfirmEmail' component={ConfirmEmailScreen} />
<Stack.Screen
name='CreatePassword'
component={CreatePasswordScreen}
/>
<Stack.Screen name='PickHandle' component={PickHandleScreen} />
<Stack.Screen name='ReviewHandle' component={ReviewHandleScreen} />
<Stack.Screen
name='CreateLoginDetails'
component={CreateLoginDetailsScreen}
/>
<Stack.Screen
name='FinishProfile'
component={FinishProfileScreen}
/>
</Stack.Group>
) : undefined}
<Stack.Screen
name='SelectGenre'
component={SelectGenresScreen}
options={{ headerLeft: () => null, gestureEnabled: false }}
/>
<Stack.Screen name='SelectArtists' component={SelectArtistsScreen} />
<Stack.Screen
name='AccountLoading'
component={AccountLoadingScreen}
// animation: none here is a workaround to prevent "white screen of death" on Android
options={{ headerShown: false, animation: 'none' }}
/>
</Stack.Navigator>
</ScreenOptionsContext.Provider>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'audius-client/src/common/store/pages/signon/selectors'
import {
setField,
setFinishedPhase1,
setValueField,
signUp
} from 'common/store/pages/signon/actions'
Expand Down Expand Up @@ -64,6 +65,7 @@ export const FinishProfileScreen = () => {
const { displayName } = values
dispatch(setValueField('name', displayName))
dispatch(signUp())
dispatch(setFinishedPhase1(true))
navigation.navigate('SelectGenre')
},
[dispatch, navigation]
Expand Down

0 comments on commit 8f73c19

Please sign in to comment.