-
-
Notifications
You must be signed in to change notification settings - Fork 266
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): add Device Settings to toggle FW revision check
- Loading branch information
Showing
13 changed files
with
300 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
36 changes: 36 additions & 0 deletions
36
suite-native/module-device-settings/src/components/DeviceAdvancedSettingsSection.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,36 @@ | ||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import { Translation } from '@suite-native/intl'; | ||
import { | ||
DeviceAuthenticityStackParamList, | ||
DeviceAuthenticityStackRoutes, | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes, | ||
StackToStackCompositeNavigationProps, | ||
} from '@suite-native/navigation'; | ||
import { SettingsSection, SettingsSectionItem } from '@suite-native/settings'; | ||
|
||
type NavigationProp = StackToStackCompositeNavigationProps< | ||
DeviceAuthenticityStackParamList, | ||
DeviceAuthenticityStackRoutes, | ||
DeviceSettingsStackParamList | ||
>; | ||
|
||
export const DeviceAdvancedSettingsSection = () => { | ||
const navigation = useNavigation<NavigationProp>(); | ||
|
||
const handleAdvancedSettingsPress = () => { | ||
navigation.navigate(DeviceStackRoutes.AdvancedSettings); | ||
}; | ||
|
||
return ( | ||
<SettingsSection title={<Translation id="moduleDeviceSettings.additionalSettings" />}> | ||
<SettingsSectionItem | ||
iconName="wrench" | ||
title={<Translation id="moduleDeviceSettings.advancedSettings.title" />} | ||
subtitle={<Translation id="moduleDeviceSettings.advancedSettings.subtitle" />} | ||
onPress={handleAdvancedSettingsPress} | ||
></SettingsSectionItem> | ||
</SettingsSection> | ||
); | ||
}; |
84 changes: 84 additions & 0 deletions
84
suite-native/module-device-settings/src/components/TurnOffFirmwareAuthencityCheckCard.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,84 @@ | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import { | ||
selectIsFirmwareAuthenticityCheckDisabled, | ||
setCheckFirmwareAuthenticity, | ||
} from '@suite-native/settings'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { Button, HStack, Text, VStack } from '@suite-native/atoms'; | ||
import { | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes, | ||
StackNavigationProps, | ||
} from '@suite-native/navigation'; | ||
import { useOpenLink } from '@suite-native/link'; | ||
import { HELP_CENTER_FIRMWARE_REVISION_CHECK } from '@trezor/urls'; | ||
|
||
import { DeviceSettingsCardLayout } from './DeviceSettingsCardLayout'; | ||
|
||
const LearnMoreButton = () => { | ||
const openLink = useOpenLink(); | ||
const handleButtonPress = () => openLink(HELP_CENTER_FIRMWARE_REVISION_CHECK); | ||
|
||
return ( | ||
<Button onPress={handleButtonPress} colorScheme="tertiaryElevation0"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.buttonLearnMore" /> | ||
</Button> | ||
); | ||
}; | ||
|
||
const TurnOnButton = () => { | ||
const dispatch = useDispatch(); | ||
const handleButtonPress = () => { | ||
dispatch(setCheckFirmwareAuthenticity(false)); | ||
}; | ||
|
||
return ( | ||
<Button onPress={handleButtonPress} colorScheme="primary"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.buttonTurnOn" /> | ||
</Button> | ||
); | ||
}; | ||
|
||
type NavigationProp = StackNavigationProps< | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes.TurnOffFirmwareAuthencityCheck | ||
>; | ||
|
||
const TurnOffButton = () => { | ||
const navigation = useNavigation<NavigationProp>(); | ||
const handleButtonPress = () => { | ||
navigation.navigate(DeviceStackRoutes.TurnOffFirmwareAuthencityCheck); | ||
}; | ||
|
||
return ( | ||
<Button onPress={handleButtonPress} colorScheme="redElevation0"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.buttonTurnOff" /> | ||
</Button> | ||
); | ||
}; | ||
|
||
export const TurnOffFirmwareAuthencityCheckCard = () => { | ||
const isFwAuthenticityCheckDisabled = useSelector(selectIsFirmwareAuthenticityCheckDisabled); | ||
|
||
return ( | ||
<DeviceSettingsCardLayout | ||
icon="shieldCheck" | ||
title={ | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.title" /> | ||
} | ||
> | ||
<VStack spacing="sp16"> | ||
<Text variant="body" color="textSubdued"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.subtitle" /> | ||
</Text> | ||
<HStack spacing="sp8"> | ||
{isFwAuthenticityCheckDisabled ? <TurnOnButton /> : <TurnOffButton />} | ||
<LearnMoreButton /> | ||
</HStack> | ||
</VStack> | ||
</DeviceSettingsCardLayout> | ||
); | ||
}; |
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
18 changes: 18 additions & 0 deletions
18
suite-native/module-device-settings/src/screens/DeviceAdvancedSettingsScreen.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,18 @@ | ||
import { Screen, ScreenHeader } from '@suite-native/navigation'; | ||
import { useTranslate } from '@suite-native/intl'; | ||
|
||
import { TurnOffFirmwareAuthencityCheckCard } from '../components/TurnOffFirmwareAuthencityCheckCard'; | ||
|
||
export const DeviceAdvancedSettingsScreen = () => { | ||
const { translate } = useTranslate(); | ||
|
||
return ( | ||
<Screen | ||
header={ | ||
<ScreenHeader content={translate('moduleDeviceSettings.advancedSettings.title')} /> | ||
} | ||
> | ||
<TurnOffFirmwareAuthencityCheckCard /> | ||
</Screen> | ||
); | ||
}; |
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
107 changes: 107 additions & 0 deletions
107
...e-native/module-device-settings/src/screens/TurnOffFirmwareAuthencityCheckModalScreen.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,107 @@ | ||
import { useState } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import { TouchableOpacity } from 'react-native'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import { | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes, | ||
Screen, | ||
ScreenHeader, | ||
StackNavigationProps, | ||
} from '@suite-native/navigation'; | ||
import { | ||
Box, | ||
Button, | ||
CheckBox, | ||
IconListItem, | ||
Text, | ||
HStack, | ||
VStack, | ||
Card, | ||
} from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { setCheckFirmwareAuthenticity } from '@suite-native/settings'; | ||
|
||
type NavigationProp = StackNavigationProps< | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes.AdvancedSettings | ||
>; | ||
|
||
export const TurnOffFirmwareAuthencityCheckModalScreen = () => { | ||
const [isChecked, setIsChecked] = useState(false); | ||
const navigation = useNavigation<NavigationProp>(); | ||
const dispatch = useDispatch(); | ||
|
||
const handleCheckboxPress = () => setIsChecked(prev => !prev); | ||
|
||
const handleButtonPress = () => { | ||
dispatch(setCheckFirmwareAuthenticity(true)); | ||
if (navigation.canGoBack()) { | ||
navigation.goBack(); | ||
} else { | ||
navigation.navigate(DeviceStackRoutes.AdvancedSettings); | ||
} | ||
}; | ||
|
||
return ( | ||
<Screen header={<ScreenHeader closeActionType="close" />}> | ||
<VStack spacing="sp32" flex={1}> | ||
<Box> | ||
<Text variant="titleMedium"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.title" /> | ||
</Text> | ||
<Text variant="body"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.content" /> | ||
</Text> | ||
</Box> | ||
<VStack spacing="sp24"> | ||
<IconListItem | ||
icon="warning" | ||
variant="yellow" | ||
iconSize="large" | ||
verticalAlign="flex-start" | ||
> | ||
<Text variant="highlight"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.item1" /> | ||
{'\n'} | ||
</Text> | ||
<Text> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.item1Explanation" /> | ||
</Text> | ||
</IconListItem> | ||
<IconListItem | ||
icon="code" | ||
variant="yellow" | ||
iconSize="large" | ||
verticalAlign="flex-start" | ||
> | ||
<Text variant="highlight"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.item2" /> | ||
{'\n'} | ||
</Text> | ||
<Text> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.item2Explanation" /> | ||
</Text> | ||
</IconListItem> | ||
</VStack> | ||
<TouchableOpacity onPress={handleCheckboxPress}> | ||
<Card> | ||
<HStack spacing="sp16"> | ||
<CheckBox isChecked={isChecked} onChange={handleCheckboxPress} /> | ||
<Text variant="highlight"> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.acknowledgement" /> | ||
</Text> | ||
</HStack> | ||
</Card> | ||
</TouchableOpacity> | ||
</VStack> | ||
{isChecked && ( | ||
<Button colorScheme="yellowBold" onPress={handleButtonPress}> | ||
<Translation id="moduleDeviceSettings.advancedSettings.firmwareAuthenticityCheck.turnOffModal.buttonTurnOff" /> | ||
</Button> | ||
)} | ||
</Screen> | ||
); | ||
}; |
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
Oops, something went wrong.