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

Fine tune compose

This commit is contained in:
Zhiyuan Zheng
2020-12-06 21:42:19 +01:00
parent add331ef0e
commit e5eaf162f4
18 changed files with 586 additions and 407 deletions

View File

@ -1,82 +1,4 @@
import { Feather } from '@expo/vector-icons'
import React from 'react'
import { Pressable, StyleSheet, Text } from 'react-native'
import { StyleConstants } from 'src/utils/styles/constants'
import { useTheme } from 'src/utils/styles/ThemeManager'
import ButtonRound from './Button/ButtonRound'
import ButtonRow from './Button/ButtonRow'
type PropsBase = {
onPress: () => void
disabled?: boolean
buttonSize?: 'S' | 'M'
}
export interface PropsText extends PropsBase {
text: string
icon?: string
size?: 'S' | 'M' | 'L'
}
export interface PropsIcon extends PropsBase {
text?: string
icon: string
size?: 'S' | 'M' | 'L'
}
const Button: React.FC<PropsText | PropsIcon> = ({
onPress,
disabled = false,
buttonSize = 'M',
text,
icon,
size = 'M'
}) => {
const { theme } = useTheme()
return (
<Pressable
{...(!disabled && { onPress })}
style={[
styles.button,
{
borderColor: disabled ? theme.secondary : theme.primary,
paddingTop: StyleConstants.Spacing[buttonSize === 'M' ? 'S' : 'XS'],
paddingBottom: StyleConstants.Spacing[buttonSize === 'M' ? 'S' : 'XS']
}
]}
>
{icon ? (
<Feather
name={icon}
size={StyleConstants.Font.Size[size]}
color={disabled ? theme.secondary : theme.primary}
/>
) : (
<Text
style={[
styles.text,
{
color: disabled ? theme.secondary : theme.primary,
fontSize: StyleConstants.Font.Size[size]
}
]}
>
{text}
</Text>
)}
</Pressable>
)
}
const styles = StyleSheet.create({
button: {
paddingLeft: StyleConstants.Spacing.M,
paddingRight: StyleConstants.Spacing.M,
borderWidth: 1,
borderRadius: 100
},
text: {
textAlign: 'center'
}
})
export default Button
export { ButtonRound, ButtonRow }