You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

90 lines
2.1 KiB

import React from "react"
import { View, StyleSheet, Dimensions, Text } from "react-native"
import { colors, texts } from "../components/Variables"
const screen = Dimensions.get("window")
const styles = StyleSheet.create({
container: {
position: "absolute",
top: 0,
bottom: 0,
left: 0,
right: 0,
flex: 1,
alignItems: "center",
justifyContent: "center"
},
box: {
backgroundColor: colors.green_alpha,
width: screen.width / 1.1,
height: screen.height / 2,
borderRadius: 5,
borderColor: colors.white_alpha,
borderWidth: 5,
alignItems: "center",
justifyContent: "center"
},
boxLooser: {
backgroundColor: colors.red_alpha,
width: screen.width / 1.1,
height: screen.height / 2,
borderRadius: 5,
borderColor: colors.white_alpha,
borderWidth: 5,
alignItems: "center",
justifyContent: "center"
},
text: {
color: colors.white,
fontSize: 25,
textAlign: "center",
letterSpacing: -0.02,
fontWeight: "500",
lineHeight: 90
},
textLabel: {
paddingHorizontal: 20,
paddingVertical: 20
},
correct: {
color: colors.green
},
wrong: {
color: colors.red
}
})
export const Results = ({ correct, wrong, visible }) => {
if (!visible) return null
const total = wrong+correct
const percentage = (100/total) * correct
const boxStyle = percentage > 80 ? styles.box : styles.boxLooser
const percentStyle = percentage > 80 ? styles.correct : styles.wrong
return (
<View style={styles.container}>
<View style={boxStyle}>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.corrects}: `}</Text>
<Text >
{`${correct}`}
</Text>
</Text>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.wrongs}: `}</Text>
<Text>
{`${wrong}`}
</Text>
</Text>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.percentage}: `}</Text>
<Text >
{`${Math.round(percentage)}%`}
</Text>
</Text>
</View>
</View>
)
}