-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(suite-native): extract layout component for device settings …
…card
- Loading branch information
Showing
3 changed files
with
68 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { Icon, IconName } from '@suite-common/icons-deprecated'; | ||
import { AlertBox, AlertBoxProps, Box, Card, HStack, Text, VStack } from '@suite-native/atoms'; | ||
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; | ||
|
||
const contentStyle = prepareNativeStyle(() => ({ | ||
flexGrow: 1, | ||
})); | ||
|
||
export type DeviceSettingsCardProps = { | ||
icon: IconName; | ||
title: ReactNode; | ||
children: ReactNode; | ||
alertBoxProps?: Omit<AlertBoxProps, 'borderRadius'>; | ||
}; | ||
|
||
export const DeviceSettingsCard = ({ | ||
icon, | ||
title, | ||
children, | ||
alertBoxProps, | ||
}: DeviceSettingsCardProps) => { | ||
const { applyStyle } = useNativeStyles(); | ||
|
||
return ( | ||
<Card noPadding> | ||
<HStack margin="sp16" spacing="sp12"> | ||
<Box marginVertical="sp2"> | ||
<Icon name={icon} size="mediumLarge" /> | ||
</Box> | ||
<VStack spacing={0} style={applyStyle(contentStyle)}> | ||
<Text variant="highlight">{title}</Text> | ||
{children} | ||
</VStack> | ||
</HStack> | ||
{alertBoxProps && ( | ||
<Box margin="sp4"> | ||
<AlertBox {...alertBoxProps} borderRadius="r12" /> | ||
</Box> | ||
)} | ||
</Card> | ||
); | ||
}; |