|
@ -5,6 +5,8 @@ import { colors } from "../components/Variables" |
|
|
const styles = StyleSheet.create({ |
|
|
const styles = StyleSheet.create({ |
|
|
button: { |
|
|
button: { |
|
|
backgroundColor: colors.white_alpha, |
|
|
backgroundColor: colors.white_alpha, |
|
|
|
|
|
borderWidth: 4, |
|
|
|
|
|
borderColor: 'transparent', |
|
|
borderRadius: 10, |
|
|
borderRadius: 10, |
|
|
paddingHorizontal: 10, |
|
|
paddingHorizontal: 10, |
|
|
paddingVertical: 10, |
|
|
paddingVertical: 10, |
|
@ -31,20 +33,33 @@ const styles = StyleSheet.create({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
export const Button = ({ text, subtitle = null, isBig = false, onPress = () => {} }) => { |
|
|
|
|
|
|
|
|
export const Button = ({ text, subtitle = null, isBig = false, colorize = false, onPress = () => {} }) => { |
|
|
|
|
|
|
|
|
const buttonBig = isBig ? {fontSize: 25} : {} |
|
|
const buttonBig = isBig ? {fontSize: 25} : {} |
|
|
|
|
|
const isClicked = colorize.clicked == colorize.id |
|
|
|
|
|
let buttonColor = {backgroundColor: colors.white_alpha} |
|
|
|
|
|
|
|
|
|
|
|
if(colorize && colorize.answered) { |
|
|
|
|
|
|
|
|
|
|
|
if(colorize.isCorrect) { |
|
|
|
|
|
buttonColor = {backgroundColor: colors.green_light, borderColor: isClicked ? colors.white_alpha : 'transparent'} |
|
|
|
|
|
} else { |
|
|
|
|
|
if(isClicked) { |
|
|
|
|
|
buttonColor = {backgroundColor: colors.red_light, borderColor: isClicked ? colors.white_alpha : 'transparent'} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(subtitle) { |
|
|
if(subtitle) { |
|
|
return ( |
|
|
return ( |
|
|
<TouchableOpacity onPress={onPress} style={styles.button}> |
|
|
|
|
|
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor]}> |
|
|
<Text style={[styles.text, buttonBig]}>{text}</Text> |
|
|
<Text style={[styles.text, buttonBig]}>{text}</Text> |
|
|
<Text style={styles.subtitle}>{subtitle}</Text> |
|
|
<Text style={styles.subtitle}>{subtitle}</Text> |
|
|
</TouchableOpacity> |
|
|
</TouchableOpacity> |
|
|
) |
|
|
) |
|
|
} else { |
|
|
} else { |
|
|
return ( |
|
|
return ( |
|
|
<TouchableOpacity onPress={onPress} style={styles.button}> |
|
|
|
|
|
|
|
|
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor]}> |
|
|
<Text style={[styles.text, buttonBig]}>{text}</Text> |
|
|
<Text style={[styles.text, buttonBig]}>{text}</Text> |
|
|
</TouchableOpacity> |
|
|
</TouchableOpacity> |
|
|
) |
|
|
) |
|
|