|
|
@ -1,20 +1,26 @@ |
|
|
|
import React from "react" |
|
|
|
import { View, TouchableOpacity, Text, StyleSheet } from "react-native" |
|
|
|
import { View, TouchableOpacity, Text, StyleSheet, ImageBackground } from "react-native" |
|
|
|
import { colors } from "../components/Variables" |
|
|
|
|
|
|
|
const bgImage = require("../assets/buttonBg.png") |
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
button: { |
|
|
|
backgroundColor: colors.white_alpha, |
|
|
|
borderWidth: 4, |
|
|
|
borderColor: 'transparent', |
|
|
|
borderRadius: 10, |
|
|
|
paddingHorizontal: 20, |
|
|
|
//paddingHorizontal: 20,
|
|
|
|
paddingVertical: 15, |
|
|
|
alignItems: "center", |
|
|
|
justifyContent: "center", |
|
|
|
width: "100%", |
|
|
|
marginTop: 15 |
|
|
|
}, |
|
|
|
noPadding: { |
|
|
|
paddingHorizontal: 0, |
|
|
|
paddingVertical: 0, |
|
|
|
}, |
|
|
|
text: { |
|
|
|
color: colors.white, |
|
|
|
fontSize: 20, |
|
|
@ -36,11 +42,21 @@ const styles = StyleSheet.create({ |
|
|
|
marginTop: 20, |
|
|
|
justifyContent: "space-between", |
|
|
|
overflow: "hidden", |
|
|
|
borderRadius: 10 |
|
|
|
borderRadius: 20 |
|
|
|
}, |
|
|
|
buttonBg: { |
|
|
|
flex: 1, |
|
|
|
paddingVertical: 15, |
|
|
|
height: '100%', |
|
|
|
width: '100%', |
|
|
|
resizeMode: 'cover' |
|
|
|
}, |
|
|
|
buttonPadding: { |
|
|
|
paddingHorizontal: 20 |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
export const Button = ({ text, subtitle = null, isBig = false, colorize = false, color = false, noPadding = false, noBorder = false, halfSize = false, hasShadow = false, onPress = false }) => { |
|
|
|
export const Button = ({ text, subtitle = null, isBig = false, colorize = false, color = false, noPadding = false, noBorder = false, halfSize = false, hasShadow = false, hasBg = false, onPress = false }) => { |
|
|
|
|
|
|
|
const buttonBig = isBig ? {fontSize: 25} : {} |
|
|
|
const isClicked = colorize.clicked == colorize.id |
|
|
@ -65,32 +81,53 @@ export const Button = ({ text, subtitle = null, isBig = false, colorize = false, |
|
|
|
} |
|
|
|
|
|
|
|
if(onPress) { |
|
|
|
if(subtitle) { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text> |
|
|
|
<Text style={[styles.subtitle, hasShadow ? styles.shadow : '']}>{subtitle}</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
if(hasBg) { |
|
|
|
if(subtitle) { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, styles.noPadding, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<ImageBackground source={bgImage} style={styles.buttonBg}> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text> |
|
|
|
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text> |
|
|
|
</ImageBackground> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
} else { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, styles.noPadding, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<ImageBackground source={bgImage} style={styles.buttonBg}> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text> |
|
|
|
</ImageBackground> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
} |
|
|
|
} else { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
if(subtitle) { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text> |
|
|
|
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
} else { |
|
|
|
return ( |
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(subtitle) { |
|
|
|
return ( |
|
|
|
<View style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : ''], {fontWeight: "500"}}>{text}</Text> |
|
|
|
<Text style={[styles.subtitle, hasShadow ? styles.shadow : '']}>{subtitle}</Text> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : ''], {fontWeight: "500"}}>{text}</Text> |
|
|
|
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text> |
|
|
|
</View> |
|
|
|
) |
|
|
|
} else { |
|
|
|
return ( |
|
|
|
<View style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}> |
|
|
|
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text> |
|
|
|
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text> |
|
|
|
</View> |
|
|
|
) |
|
|
|
} |
|
|
@ -100,7 +137,7 @@ export const Button = ({ text, subtitle = null, isBig = false, colorize = false, |
|
|
|
|
|
|
|
export const ButtonContainer = ({ children, isBoxed = false}) => { |
|
|
|
|
|
|
|
let boxedStyle = isBoxed ? {borderWidth: 3, borderColor: colors.white_alpha2} : {} |
|
|
|
let boxedStyle = isBoxed ? {borderWidth: 2, borderColor: colors.white_alpha2} : {} |
|
|
|
|
|
|
|
return ( |
|
|
|
<View style={[styles.buttonContainer, boxedStyle]}>{children}</View> |
|
|
|