({
title,
variant = 'default',
disabled,
loading,
center,
onPress,
...props
}: Props)
| 19 | }; |
| 20 | |
| 21 | export default function Button({ |
| 22 | title, |
| 23 | variant = 'default', |
| 24 | disabled, |
| 25 | loading, |
| 26 | center, |
| 27 | onPress, |
| 28 | ...props |
| 29 | }: Props) { |
| 30 | const titleElement = React.isValidElement(title) ? ( |
| 31 | title |
| 32 | ) : ( |
| 33 | <Text style={[styles.text, variant === 'primary' && styles.textPrimary]}> |
| 34 | {title} |
| 35 | </Text> |
| 36 | ); |
| 37 | return ( |
| 38 | <View style={disabled && styles.disabled}> |
| 39 | <TouchableOpacity |
| 40 | disabled={disabled} |
| 41 | style={[ |
| 42 | styles.container, |
| 43 | variant === 'primary' && styles.primaryContainer, |
| 44 | center && styles.centered, |
| 45 | ]} |
| 46 | onPress={onPress} |
| 47 | {...props} |
| 48 | > |
| 49 | {loading ? ( |
| 50 | <ActivityIndicator color={colors.white} size="small" /> |
| 51 | ) : ( |
| 52 | titleElement |
| 53 | )} |
| 54 | </TouchableOpacity> |
| 55 | </View> |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | const styles = StyleSheet.create({ |
| 60 | container: { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…