-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CAB): Add landing screen for phone verification (recovery) (#4821)
### Description Add in link phone number landing screen. This will come after successfully completing the recovery flow. Not hooked up yet since [that work](https://linear.app/valora/issue/ACT-781/recovery-success-screen) isn't done. ### Test plan Unit tests added. https://github.com/valora-inc/wallet/assets/140328381/1f1e14ca-bbb6-4453-871e-d85769b4f141 ### Related issues - Fixes #[ACT-768] ### Backwards compatibility Yes, just adding new screen.
- Loading branch information
1 parent
871e186
commit fe2e559
Showing
11 changed files
with
192 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { fireEvent, render } from '@testing-library/react-native' | ||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { OnboardingEvents } from 'src/analytics/Events' | ||
import ValoraAnalytics from 'src/analytics/ValoraAnalytics' | ||
import LinkPhoneNumber from 'src/keylessBackup/LinkPhoneNumber' | ||
import { navigate, navigateHome } from 'src/navigator/NavigationService' | ||
import { Screens } from 'src/navigator/Screens' | ||
import { createMockStore, getMockStackScreenProps } from 'test/utils' | ||
|
||
jest.mock('src/navigator/NavigationService') | ||
jest.mock('src/analytics/ValoraAnalytics') | ||
|
||
describe('LinkPhoneNumber', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('navigates to verification start screen', async () => { | ||
const { getByTestId } = render( | ||
<Provider store={createMockStore()}> | ||
<LinkPhoneNumber {...getMockStackScreenProps(Screens.LinkPhoneNumber)} /> | ||
</Provider> | ||
) | ||
fireEvent.press(getByTestId('LinkPhoneNumberButton')) | ||
|
||
expect(navigate).toHaveBeenCalledTimes(1) | ||
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, { | ||
isOnboarding: false, | ||
}) | ||
expect(ValoraAnalytics.track).toHaveBeenCalledWith(OnboardingEvents.link_phone_number) | ||
}) | ||
|
||
it('navigates to home on later', async () => { | ||
const { getByTestId } = render( | ||
<Provider store={createMockStore()}> | ||
<LinkPhoneNumber {...getMockStackScreenProps(Screens.LinkPhoneNumber)} /> | ||
</Provider> | ||
) | ||
fireEvent.press(getByTestId('LinkPhoneNumberLater')) | ||
|
||
expect(navigateHome).toHaveBeenCalledTimes(1) | ||
expect(ValoraAnalytics.track).toHaveBeenCalledWith(OnboardingEvents.link_phone_number_later) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { NativeStackScreenProps } from '@react-navigation/native-stack' | ||
import React, { useLayoutEffect } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { StyleSheet, Text, View } from 'react-native' | ||
import { SafeAreaView } from 'react-native-safe-area-context' | ||
import { OnboardingEvents } from 'src/analytics/Events' | ||
import ValoraAnalytics from 'src/analytics/ValoraAnalytics' | ||
import BackButton from 'src/components/BackButton' | ||
import Button, { BtnSizes, BtnTypes } from 'src/components/Button' | ||
|
||
import { navigate, navigateHome } from 'src/navigator/NavigationService' | ||
import { Screens } from 'src/navigator/Screens' | ||
import { StackParamList } from 'src/navigator/types' | ||
import colors from 'src/styles/colors' | ||
import { typeScale } from 'src/styles/fonts' | ||
import { Spacing } from 'src/styles/styles' | ||
|
||
type Props = NativeStackScreenProps<StackParamList, Screens.LinkPhoneNumber> | ||
|
||
export default function LinkPhoneNumber({ navigation }: Props) { | ||
const { t } = useTranslation() | ||
|
||
useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
headerLeft: () => <BackButton />, | ||
headerStyle: { | ||
backgroundColor: colors.gray1, | ||
}, | ||
}) | ||
}, [navigation]) | ||
|
||
const continueButtonOnPress = async () => { | ||
ValoraAnalytics.track(OnboardingEvents.link_phone_number) | ||
navigate(Screens.VerificationStartScreen, { isOnboarding: false }) | ||
} | ||
const laterButtonOnPress = async () => { | ||
ValoraAnalytics.track(OnboardingEvents.link_phone_number_later) | ||
navigateHome() | ||
} | ||
|
||
return ( | ||
<SafeAreaView style={styles.safeArea} edges={['bottom']}> | ||
<View> | ||
<View style={styles.viewContainer}> | ||
<View style={styles.screenTextContainer}> | ||
<Text style={styles.screenTitle}>{t('linkPhoneNumber.title')}</Text> | ||
<Text style={styles.screenDescription}>{t('linkPhoneNumber.description')}</Text> | ||
</View> | ||
</View> | ||
<View style={styles.buttonView}> | ||
<Button | ||
text={t('linkPhoneNumber.startButtonLabel')} | ||
onPress={continueButtonOnPress} | ||
style={styles.button} | ||
type={BtnTypes.PRIMARY} | ||
size={BtnSizes.FULL} | ||
testID="LinkPhoneNumberButton" | ||
/> | ||
<Button | ||
text={t('linkPhoneNumber.later')} | ||
onPress={laterButtonOnPress} | ||
style={styles.button} | ||
type={BtnTypes.GRAY_WITH_BORDER} | ||
size={BtnSizes.FULL} | ||
testID="LinkPhoneNumberLater" | ||
/> | ||
</View> | ||
</View> | ||
</SafeAreaView> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
safeArea: { | ||
alignItems: 'center', | ||
backgroundColor: colors.gray1, | ||
flexGrow: 1, | ||
justifyContent: 'space-between', | ||
}, | ||
screenDescription: { | ||
...typeScale.bodyMedium, | ||
textAlign: 'center', | ||
}, | ||
screenTitle: { | ||
...typeScale.titleSmall, | ||
marginTop: Spacing.Thick24, | ||
textAlign: 'center', | ||
}, | ||
screenTextContainer: { | ||
gap: Spacing.Regular16, | ||
}, | ||
viewContainer: { | ||
alignItems: 'center', | ||
flex: 1, | ||
gap: Spacing.Thick24, | ||
paddingHorizontal: Spacing.Thick24, | ||
}, | ||
buttonView: { | ||
padding: Spacing.Thick24, | ||
alignItems: 'center', | ||
}, | ||
button: { marginBottom: Spacing.Thick24, width: '100%' }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters