|
@@ -1,7 +1,7 @@
|
|
|
import React, { FC, ReactNode } from 'react';
|
|
|
import { Text, TouchableOpacity } from 'react-native';
|
|
|
|
|
|
-import { styling } from './styles';
|
|
|
+import { styles } from './styles';
|
|
|
import { ButtonVariants } from '../../types/components';
|
|
|
|
|
|
type Props = {
|
|
@@ -11,13 +11,42 @@ type Props = {
|
|
|
};
|
|
|
|
|
|
const Button: FC<Props> = ({ children, variant, onPress }) => {
|
|
|
- const styles = styling(variant ?? ButtonVariants.FILL);
|
|
|
-
|
|
|
return (
|
|
|
- <TouchableOpacity style={styles.touchableOpacity} onPress={onPress}>
|
|
|
- <Text style={styles.text}>{children}</Text>
|
|
|
- </TouchableOpacity>
|
|
|
+ <>
|
|
|
+ {variant === ButtonVariants.OPACITY ? (
|
|
|
+ <OpacityButton onPress={onPress} children={children} />
|
|
|
+ ) : variant === ButtonVariants.FILL ? (
|
|
|
+ <FillButton onPress={onPress} children={children} />
|
|
|
+ ) : variant == ButtonVariants.TEXT ? (
|
|
|
+ <TextButton children={children} onPress={onPress} />
|
|
|
+ ) : (
|
|
|
+ <FillButton onPress={onPress} children={children} />
|
|
|
+ )}
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+type VariantProps = {
|
|
|
+ children?: ReactNode;
|
|
|
+ onPress?: () => void;
|
|
|
+};
|
|
|
+
|
|
|
+const OpacityButton: FC<VariantProps> = ({ onPress, children }) => (
|
|
|
+ <TouchableOpacity style={[styles.button, styles.opacityButton]} onPress={onPress}>
|
|
|
+ <Text style={[styles.text, styles.opacityText]}>{children}</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+);
|
|
|
+
|
|
|
+const FillButton: FC<VariantProps> = ({ onPress, children }) => (
|
|
|
+ <TouchableOpacity style={[styles.button, styles.fillButton]} onPress={onPress}>
|
|
|
+ <Text style={[styles.text, styles.fillText]}>{children}</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+);
|
|
|
+
|
|
|
+const TextButton: FC<VariantProps> = ({ onPress, children }) => (
|
|
|
+ <TouchableOpacity style={styles.button} onPress={onPress}>
|
|
|
+ <Text style={[styles.text, styles.textButtonText]}>{children}</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+);
|
|
|
+
|
|
|
export default Button;
|