Browse Source

button colors background

master
Dslak 6 years ago
parent
commit
2384b93849
  1. 14
      vds-app/App/components/Button.js
  2. 8
      vds-app/App/components/Variables.js

14
vds-app/App/components/Button.js

@ -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,
@ -34,21 +36,23 @@ const styles = StyleSheet.create({
export const Button = ({ text, subtitle = null, isBig = false, colorize = 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} let buttonColor = {backgroundColor: colors.white_alpha}
if(colorize && colorize.answered) { if(colorize && colorize.answered) {
//console.log(colorize)
if(colorize.isCorrect) { if(colorize.isCorrect) {
buttonColor = {backgroundColor: colors.green_light}
buttonColor = {backgroundColor: colors.green_light, borderColor: isClicked ? colors.white_alpha : 'transparent'}
} else { } else {
if(colorize.clicked == colorize.id) {
buttonColor = {backgroundColor: colors.red_light}
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, {backgroundColor: colors.white_alpha}]}>
<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>

8
vds-app/App/components/Variables.js

@ -4,21 +4,21 @@ export const colors = {
black: "#000", black: "#000",
purple: "#8c0072", purple: "#8c0072",
purple_light: "#a30085", purple_light: "#a30085",
blue: "#15a7f0",
blue: "#1385d0",
dark_blue: "#1279be", dark_blue: "#1279be",
red: "#af321e", red: "#af321e",
red_alpha: "rgba(175, 50, 30, 0.9)", red_alpha: "rgba(175, 50, 30, 0.9)",
red_light: "#af442f",
red_light: "#af5d44",
green: "#28A125", green: "#28A125",
green_alpha: "rgba(40, 160, 40, 0.9)", green_alpha: "rgba(40, 160, 40, 0.9)",
green_light: "#5bc135",
green_light: "#6cc155",
yellow: "#e1ff3c", yellow: "#e1ff3c",
yellow_alpha: "rgba(225, 255, 60, 0.9)", yellow_alpha: "rgba(225, 255, 60, 0.9)",
orange: "#ff9b32" orange: "#ff9b32"
} }
export const texts = { export const texts = {
quizzes: "Seleziona un quiz",
quizzes: "Seleziona un argomento",
section_quizzes: "Quiz per argomento", section_quizzes: "Quiz per argomento",
exam: "Simulazione esame", exam: "Simulazione esame",
exam_simulation: "30 domande in 30min", exam_simulation: "30 domande in 30min",

Loading…
Cancel
Save