-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce escrow flow navigation stack (#734)
Why: We would like to be able to allow the user to navigate through the escrow verification code flow This commit: Introduces the navigation stack and the first screen of the escrow verification code flow. Co-Authored-By: Matt Buckley <matt@nicethings.io> Co-Authored-By: Devin Jameson <devin@thoughtbot.com>
- Loading branch information
1 parent
0b6d43d
commit 7d57b15
Showing
7 changed files
with
253 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { | ||
FunctionComponent, | ||
createContext, | ||
useState, | ||
useContext, | ||
} from "react" | ||
|
||
import { ExposureKey } from "../exposureKey" | ||
|
||
type Token = string | ||
type Key = string | ||
|
||
export interface EscrowVerificationContextState { | ||
certificate: Token | null | ||
hmacKey: Key | null | ||
exposureKeys: ExposureKey[] | ||
setExposureKeys: (keys: ExposureKey[]) => void | ||
setExposureSubmissionCredentials: (certificate: Token, hmacKey: Key) => void | ||
} | ||
|
||
export const EscrowVerificationContext = createContext< | ||
EscrowVerificationContextState | undefined | ||
>(undefined) | ||
|
||
export const EscrowVerificationProvider: FunctionComponent = ({ children }) => { | ||
const [exposureKeys, setExposureKeys] = useState<ExposureKey[]>([]) | ||
const [hmacKey, setHmacKey] = useState<Key | null>(null) | ||
const [certificate, setCertificate] = useState<Token | null>(null) | ||
|
||
const setExposureSubmissionCredentials = ( | ||
certificate: Token, | ||
hmacKey: Key, | ||
) => { | ||
setCertificate(certificate) | ||
setHmacKey(hmacKey) | ||
} | ||
|
||
return ( | ||
<EscrowVerificationContext.Provider | ||
value={{ | ||
hmacKey, | ||
certificate, | ||
exposureKeys, | ||
setExposureKeys, | ||
setExposureSubmissionCredentials, | ||
}} | ||
> | ||
{children} | ||
</EscrowVerificationContext.Provider> | ||
) | ||
} | ||
|
||
export const useEscrowVerificationContext = (): EscrowVerificationContextState => { | ||
const context = useContext(EscrowVerificationContext) | ||
if (context === undefined) { | ||
throw new Error("EscrowVerificationContext must be used with a provider") | ||
} | ||
return context | ||
} |
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,123 @@ | ||
import React, { FunctionComponent } from "react" | ||
import { | ||
StyleSheet, | ||
View, | ||
Image, | ||
ScrollView, | ||
TouchableOpacity, | ||
} from "react-native" | ||
import { useTranslation } from "react-i18next" | ||
import { SvgXml } from "react-native-svg" | ||
|
||
import { useStatusBarEffect } from "../navigation" | ||
import { Text } from "../components" | ||
|
||
import { Spacing, Colors, Typography, Buttons, Iconography } from "../styles" | ||
import { Icons, Images } from "../assets" | ||
|
||
export const Start: FunctionComponent = () => { | ||
useStatusBarEffect("dark-content", Colors.background.primaryLight) | ||
const { t } = useTranslation() | ||
|
||
const handleOnPressContinue = () => {} | ||
|
||
const handleOnPressSecondaryButton = () => {} | ||
|
||
return ( | ||
<ScrollView | ||
style={style.container} | ||
contentContainerStyle={style.contentContainer} | ||
alwaysBounceVertical={false} | ||
> | ||
<View> | ||
<Image | ||
source={Images.HowItWorksValueProposition} | ||
style={style.image} | ||
accessible | ||
accessibilityLabel={t("escrow_verification.person_and_health_expert")} | ||
/> | ||
<Text style={style.headerText}> | ||
{t("escrow_verification.start.header")} | ||
</Text> | ||
<Text style={style.bodyText}> | ||
{t("escrow_verification.start.body")} | ||
</Text> | ||
</View> | ||
<View> | ||
<TouchableOpacity | ||
style={style.button} | ||
onPress={handleOnPressContinue} | ||
accessibilityLabel={t("common.continue")} | ||
> | ||
<Text style={style.buttonText}>{t("common.continue")}</Text> | ||
<SvgXml xml={Icons.Arrow} fill={Colors.background.primaryLight} /> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
style={style.secondaryButton} | ||
onPress={handleOnPressSecondaryButton} | ||
accessibilityLabel={t("export.intro.what_is_a")} | ||
> | ||
<View style={style.secondaryButtonIconContainer}> | ||
<SvgXml | ||
xml={Icons.QuestionMark} | ||
fill={Colors.primary.shade125} | ||
width={Iconography.xxxSmall} | ||
height={Iconography.xxxSmall} | ||
/> | ||
</View> | ||
<Text style={style.secondaryButtonText}> | ||
{t("escrow_verification.start.what_is_a_verification_code")} | ||
</Text> | ||
</TouchableOpacity> | ||
</View> | ||
</ScrollView> | ||
) | ||
} | ||
|
||
const imageSize = 140 | ||
|
||
const style = StyleSheet.create({ | ||
container: { | ||
backgroundColor: Colors.background.primaryLight, | ||
}, | ||
contentContainer: { | ||
flexGrow: 1, | ||
justifyContent: "space-between", | ||
paddingHorizontal: Spacing.large, | ||
paddingBottom: Spacing.xxLarge, | ||
backgroundColor: Colors.background.primaryLight, | ||
}, | ||
image: { | ||
resizeMode: "contain", | ||
width: imageSize, | ||
height: imageSize, | ||
marginBottom: Spacing.xSmall, | ||
}, | ||
headerText: { | ||
...Typography.header.x60, | ||
marginBottom: Spacing.small, | ||
}, | ||
bodyText: { | ||
...Typography.body.x30, | ||
marginBottom: Spacing.medium, | ||
}, | ||
button: { | ||
...Buttons.primary.base, | ||
marginBottom: Spacing.small, | ||
}, | ||
buttonText: { | ||
...Typography.button.primary, | ||
marginRight: Spacing.small, | ||
}, | ||
secondaryButton: { | ||
...Buttons.secondary.leftIcon, | ||
}, | ||
secondaryButtonIconContainer: { | ||
...Buttons.circle.base, | ||
}, | ||
secondaryButtonText: { | ||
...Typography.button.secondaryLeftIcon, | ||
}, | ||
}) | ||
|
||
export default Start |
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,37 @@ | ||
import React, { FunctionComponent } from "react" | ||
import { createStackNavigator } from "@react-navigation/stack" | ||
|
||
import { EscrowVerificationProvider } from "../EscrowVerification/EscrowVerificationContext" | ||
import Start from "../EscrowVerification/Start" | ||
|
||
import { EscrowVerificationRoutes } from "." | ||
import { applyHeaderLeftBackButton } from "./HeaderLeftBackButton" | ||
|
||
import { Headers } from "../styles" | ||
|
||
export type EscrowVerificationRouteParamList = { | ||
EscrowVerificationStart: undefined | ||
} | ||
|
||
const Stack = createStackNavigator<EscrowVerificationRouteParamList>() | ||
|
||
const AffectedUserStack: FunctionComponent = () => { | ||
return ( | ||
<EscrowVerificationProvider> | ||
<Stack.Navigator | ||
screenOptions={{ headerShown: false, gestureEnabled: false }} | ||
> | ||
<Stack.Screen | ||
name={EscrowVerificationRoutes.EscrowVerificationStart} | ||
component={Start} | ||
options={{ | ||
...Headers.headerMinimalOptions, | ||
headerLeft: applyHeaderLeftBackButton(), | ||
}} | ||
/> | ||
</Stack.Navigator> | ||
</EscrowVerificationProvider> | ||
) | ||
} | ||
|
||
export default AffectedUserStack |
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