1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Created basic tests

This commit is contained in:
Zhiyuan Zheng
2020-12-28 00:59:57 +01:00
parent 0ee30de03e
commit 66385fd0f4
15 changed files with 3803 additions and 125 deletions

View File

@ -20,18 +20,17 @@ export interface Props {
onPress?: () => void
}
const Core: React.FC<Props> = ({
const MenuRow: React.FC<Props> = ({
iconFront,
iconFrontColor,
iconFrontColor = 'primary',
title,
content,
iconBack,
iconBackColor,
loading = false
iconBackColor = 'secondary',
loading = false,
onPress
}) => {
const { theme } = useTheme()
iconFrontColor = iconFrontColor || 'primary'
iconBackColor = iconBackColor || 'secondary'
const loadingSpinkit = useMemo(
() => (
@ -45,64 +44,63 @@ const Core: React.FC<Props> = ({
[theme]
)
return (
<View style={styles.core}>
<View style={styles.front}>
{iconFront && (
<Feather
name={iconFront}
size={StyleConstants.Font.Size.M + 2}
color={theme[iconFrontColor]}
style={styles.iconFront}
/>
)}
<Text style={[styles.text, { color: theme.primary }]} numberOfLines={1}>
{title}
</Text>
</View>
{(content || iconBack) && (
<View style={styles.back}>
{content && content.length ? (
<>
<Text
style={[
styles.content,
{
color: theme.secondary,
opacity: !iconBack && loading ? 0 : 1
}
]}
numberOfLines={1}
>
{content}
</Text>
{loading && !iconBack && loadingSpinkit}
</>
) : null}
{iconBack && (
<>
<Feather
name={iconBack}
size={StyleConstants.Font.Size.M + 2}
color={theme[iconBackColor]}
style={[styles.iconBack, { opacity: loading ? 0 : 1 }]}
/>
{loading && loadingSpinkit}
</>
)}
</View>
)}
</View>
)
}
const MenuRow: React.FC<Props> = ({ ...props }) => {
return (
<Pressable
style={styles.base}
{...(!props.loading && props.onPress && { onPress: props.onPress })}
onPress={onPress}
disabled={loading}
testID='base'
>
<Core {...props} />
<View style={styles.core}>
<View style={styles.front}>
{iconFront && (
<Feather
name={iconFront}
size={StyleConstants.Font.Size.M + 2}
color={theme[iconFrontColor]}
style={styles.iconFront}
/>
)}
<Text
style={[styles.text, { color: theme.primary }]}
numberOfLines={1}
>
{title}
</Text>
</View>
{(content || iconBack) && (
<View style={styles.back}>
{content && content.length ? (
<>
<Text
style={[
styles.content,
{
color: theme.secondary,
opacity: !iconBack && loading ? 0 : 1
}
]}
numberOfLines={1}
>
{content}
</Text>
{loading && !iconBack && loadingSpinkit}
</>
) : null}
{iconBack && (
<>
<Feather
name={iconBack}
size={StyleConstants.Font.Size.M + 2}
color={theme[iconBackColor]}
style={[styles.iconBack, { opacity: loading ? 0 : 1 }]}
/>
{loading && loadingSpinkit}
</>
)}
</View>
)}
</View>
</Pressable>
)
}