-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): onboarding security check
- Loading branch information
Showing
18 changed files
with
511 additions
and
81 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
Binary file not shown.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions
117
suite-native/module-onboarding/src/components/SecurityCheckStepCard.tsx
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,117 @@ | ||
import { ReactNode } from 'react'; | ||
import { FadeIn, FadeOutUp, LinearTransition } from 'react-native-reanimated'; | ||
|
||
import { useNavigation } from '@react-navigation/core'; | ||
|
||
import { | ||
AnimatedCard, | ||
AnimatedVStack, | ||
Button, | ||
Divider, | ||
HStack, | ||
Text, | ||
VStack, | ||
} from '@suite-native/atoms'; | ||
import { Icon, IconName } from '@suite-native/icons'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { | ||
DeviceSuspicionCause, | ||
OnboardingStackParamList, | ||
OnboardingStackRoutes, | ||
StackNavigationProps, | ||
} from '@suite-native/navigation'; | ||
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; | ||
import { Color } from '@trezor/theme'; | ||
|
||
type SecurityCheckStepCardProps = { | ||
header: ReactNode; | ||
description: ReactNode; | ||
isChecked: boolean; | ||
isOpened: boolean; | ||
icon: IconName; | ||
onPressConfirmButton: () => void; | ||
suspicionCause: DeviceSuspicionCause; | ||
}; | ||
|
||
type NavigationProps = StackNavigationProps< | ||
OnboardingStackParamList, | ||
OnboardingStackRoutes.SecurityCheck | ||
>; | ||
|
||
const cardStyle = prepareNativeStyle<{ wasOpened: boolean }>((utils, { wasOpened }) => ({ | ||
backgroundColor: wasOpened | ||
? utils.colors.backgroundSurfaceElevationNegative | ||
: utils.colors.backgroundSurfaceElevation1, | ||
})); | ||
|
||
const buttonStyle = prepareNativeStyle(() => ({ | ||
flex: 1, | ||
})); | ||
|
||
export const SecurityCheckStepCard = ({ | ||
header, | ||
description, | ||
icon, | ||
isChecked, | ||
isOpened, | ||
onPressConfirmButton, | ||
suspicionCause, | ||
}: SecurityCheckStepCardProps) => { | ||
const { applyStyle } = useNativeStyles(); | ||
const navigation = useNavigation<NavigationProps>(); | ||
const iconName = isChecked ? 'check' : icon; | ||
const headerColor: Color = isChecked ? 'textPrimaryDefault' : 'textSubdued'; | ||
|
||
const navigateToSuspiciousDeviceScreen = () => { | ||
navigation.navigate(OnboardingStackRoutes.SuspiciousDevice, { | ||
suspicionCause, | ||
}); | ||
}; | ||
|
||
const isFirstStepCard = suspicionCause === 'untrustedReseller'; | ||
|
||
return ( | ||
<AnimatedCard | ||
layout={LinearTransition} | ||
style={applyStyle(cardStyle, { wasOpened: !isOpened && !isChecked })} | ||
> | ||
<VStack spacing="sp16"> | ||
<VStack spacing="sp12"> | ||
<HStack spacing="sp8" alignItems="center"> | ||
<Icon name={iconName} size="mediumLarge" color={headerColor} /> | ||
<Text variant="callout" color={headerColor}> | ||
{header} | ||
</Text> | ||
</HStack> | ||
{isOpened && <Divider />} | ||
</VStack> | ||
{isOpened && ( | ||
<AnimatedVStack | ||
spacing="sp16" | ||
entering={isFirstStepCard ? undefined : FadeIn.delay(150)} | ||
exiting={FadeOutUp} | ||
> | ||
<Text variant="highlight">{description}</Text> | ||
<HStack flex={1} justifyContent="space-between"> | ||
<Button | ||
size="small" | ||
style={applyStyle(buttonStyle)} | ||
onPress={onPressConfirmButton} | ||
> | ||
<Translation id="generic.buttons.yes" /> | ||
</Button> | ||
<Button | ||
size="small" | ||
style={applyStyle(buttonStyle)} | ||
colorScheme="tertiaryElevation0" | ||
onPress={navigateToSuspiciousDeviceScreen} | ||
> | ||
<Translation id="moduleOnboarding.securityCheckScreen.declineButton" /> | ||
</Button> | ||
</HStack> | ||
</AnimatedVStack> | ||
)} | ||
</VStack> | ||
</AnimatedCard> | ||
); | ||
}; |
Oops, something went wrong.