-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8b81a3
commit 20ecd1c
Showing
10 changed files
with
317 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from 'react'; | ||
import { Dimensions, Text, View } from 'react-native'; | ||
import { useStyles } from '../../hooks/useStyles'; | ||
import { createStyles } from '../BrandConfigProvider'; | ||
import { tID } from '../../common/testID'; | ||
import { Card } from 'react-native-paper'; | ||
import { BoxTileProps } from './Tile'; | ||
|
||
export function BoxTile({ | ||
onPress, | ||
id, | ||
title, | ||
tileMode = 'halfLength', | ||
style: instanceStyles, | ||
Icon, | ||
showBadge, | ||
badge, | ||
}: BoxTileProps) { | ||
const { styles } = useStyles(defaultStyles, instanceStyles); | ||
const backgroundColor = | ||
showBadge || !!badge | ||
? styles.tileNotificationView?.backgroundColor | ||
: styles.tileSpacingView?.backgroundColor; | ||
|
||
return ( | ||
<Card | ||
testID={tID(`tile-button-${id}`)} | ||
onPress={onPress} | ||
disabled={!onPress} | ||
style={[ | ||
styles.tileSpacingView, | ||
tileMode === 'fullLength' | ||
? { width: tileWidth * 2 + spaceBetweenTiles } | ||
: { width: tileWidth }, | ||
{ backgroundColor: backgroundColor }, | ||
]} | ||
> | ||
<Card.Content | ||
style={styles.tileContentView} | ||
testID={tID(`tile-view-${id}`)} | ||
> | ||
<View style={styles.iconView}>{Icon && <Icon />}</View> | ||
<Text numberOfLines={2} style={styles.titleText}> | ||
{title} | ||
</Text> | ||
</Card.Content> | ||
</Card> | ||
); | ||
} | ||
|
||
export const spaceBetweenTiles = 16; | ||
export const tileWidth = | ||
Math.floor(Dimensions.get('window').width - spaceBetweenTiles * 3) / 2; | ||
|
||
const defaultStyles = createStyles('BoxTile', (theme) => ({ | ||
tileColor: { | ||
backgroundColor: theme.colors.surface, | ||
}, | ||
tileSpacingView: { | ||
marginHorizontal: theme.spacing.small, | ||
marginBottom: theme.spacing.medium, | ||
backgroundColor: theme.colors.surface, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
tileNotificationView: { | ||
backgroundColor: theme.colors.surfaceVariant, | ||
}, | ||
tileContentView: { | ||
height: 130, | ||
flexDirection: 'row', | ||
justifyContent: 'center', | ||
}, | ||
titleText: { | ||
position: 'absolute', | ||
paddingTop: 100, | ||
textAlign: 'center', | ||
...theme.fonts.bodySmall, | ||
fontWeight: 'bold', | ||
}, | ||
iconView: { | ||
alignItems: 'center', | ||
alignContent: 'center', | ||
alignSelf: 'center', | ||
}, | ||
})); | ||
|
||
declare module '@styles' { | ||
interface ComponentStyles | ||
extends ComponentNamedStyles<typeof defaultStyles> {} | ||
} | ||
|
||
export type BoxTileStyles = NamedStylesProp<typeof defaultStyles>; |
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,114 @@ | ||
import React from 'react'; | ||
import { TouchableOpacity, View, ViewStyle } from 'react-native'; | ||
import { Badge, Text, shadow } from 'react-native-paper'; | ||
import { useStyles } from '../../hooks/useStyles'; | ||
import { createStyles, useIcons } from '../BrandConfigProvider'; | ||
import { tID } from '../../common/testID'; | ||
import { ListTileProps } from './Tile'; | ||
|
||
export const ListTile = ({ | ||
Icon, | ||
title, | ||
id, | ||
testID, | ||
children, | ||
onPress, | ||
showBadge, | ||
badge, | ||
style: instanceStyles, | ||
}: ListTileProps) => { | ||
const { ChevronRight } = useIcons(); | ||
const { styles } = useStyles(defaultStyles, instanceStyles); | ||
|
||
return ( | ||
<TouchableOpacity | ||
onPress={onPress} | ||
disabled={!onPress} | ||
testID={tID(`tile-button-${id}`)} | ||
> | ||
<View style={styles.container} id={id} testID={testID}> | ||
<View style={styles.contentsWrapper}> | ||
<View style={styles.contentsView}> | ||
<View style={styles.iconContainer}> | ||
{Icon && <Icon style={styles.icon} />} | ||
</View> | ||
<Text numberOfLines={2} style={styles.titleText}> | ||
{title} | ||
</Text> | ||
<View style={{ paddingRight: 24 }}> | ||
{showBadge && <Badge size={12} testID={tID('tile-badge')} />} | ||
{badge?.()} | ||
</View> | ||
{onPress ? ( | ||
<View | ||
style={styles.arrowIconView} | ||
testID={tID('tile-chevron-icon-container')} | ||
> | ||
<ChevronRight | ||
height={styles.arrowImage?.height} | ||
stroke={styles.arrowImage?.overlayColor} | ||
/> | ||
</View> | ||
) : ( | ||
<View style={styles.arrowIconView} /> | ||
)} | ||
</View> | ||
</View> | ||
</View> | ||
{children} | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
const defaultStyles = createStyles('ListTile', (theme) => ({ | ||
contentsView: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingLeft: theme.spacing.large, | ||
}, | ||
contentsWrapper: { | ||
flex: 1, | ||
borderRadius: 10, | ||
overflow: 'hidden', | ||
}, | ||
container: { | ||
height: 55, | ||
borderRadius: 10, | ||
backgroundColor: theme.colors.surface, | ||
marginBottom: theme.spacing.large, | ||
...shadow(3), | ||
} as ViewStyle, | ||
titleText: { | ||
...theme.fonts.titleMedium, | ||
color: theme.colors.text, | ||
paddingLeft: theme.spacing.small, | ||
flex: 1, | ||
}, | ||
iconContainer: { | ||
width: 38, | ||
paddingRight: theme.spacing.small, | ||
}, | ||
icon: { | ||
resizeMode: 'cover', | ||
marginLeft: 0, | ||
marginRight: theme.spacing.small, | ||
}, | ||
arrowIconView: { | ||
height: '100%', | ||
aspectRatio: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: theme.colors.primarySource, | ||
}, | ||
arrowImage: { | ||
height: '100%', | ||
overlayColor: theme.colors.onPrimary, | ||
}, | ||
})); | ||
|
||
declare module '@styles' { | ||
interface ComponentStyles | ||
extends ComponentNamedStyles<typeof defaultStyles> {} | ||
} | ||
|
||
export type ListTileStyles = NamedStylesProp<typeof defaultStyles>; |
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.