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.

94 lines
2.3 KiB

6 years ago
import React from "react"
import { View, StyleSheet, Dimensions, Text } from "react-native"
import { colors, texts } from "../components/Variables"
6 years ago
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: {
6 years ago
backgroundColor: colors.green_alpha,
width: screen.width / 1.1,
6 years ago
height: 320,
borderRadius: 15,
6 years ago
borderColor: colors.white_alpha,
borderWidth: 5,
alignItems: "center",
justifyContent: "center"
},
boxWrong: {
6 years ago
backgroundColor: colors.red_alpha,
width: screen.width / 1.1,
6 years ago
height: 320,
borderRadius: 15,
6 years ago
borderColor: colors.white_alpha,
borderWidth: 5,
alignItems: "center",
justifyContent: "center"
},
boxUnsafe: {
backgroundColor: colors.orange,
width: screen.width / 1.1,
6 years ago
height: 320,
borderRadius: 15,
borderColor: colors.white_alpha,
borderWidth: 5,
alignItems: "center",
justifyContent: "center"
},
text: {
6 years ago
color: colors.white,
fontSize: 25,
textAlign: "center",
letterSpacing: -0.02,
fontWeight: "500",
6 years ago
lineHeight: 50
},
textLabel: {
paddingHorizontal: 20,
paddingVertical: 20
},
correct: {
6 years ago
color: colors.green
},
wrong: {
6 years ago
color: colors.red
},
unsafe: {
color: colors.yellow
}
6 years ago
})
6 years ago
export const Results = ({ total, correct, wrong, visible }) => {
6 years ago
if (!visible) return null
6 years ago
const percentage = total ? (100/total) * correct : 0
const boxStyle = percentage >= 80 ? percentage >= 85 ? styles.box : styles.boxUnsafe : styles.boxWrong
const percentStyle = percentage >= 80 ? percentage >= 85 ? styles.correct : styles.unsafe : styles.wrong
return (
<View style={styles.container}>
<View style={boxStyle}>
<Text style={styles.text}>
6 years ago
<Text style={styles.textLabel}>{`${texts.corrects}: ${correct}`}</Text>
</Text>
<Text style={styles.text}>
6 years ago
<Text style={styles.textLabel}>{`${texts.wrongs}: ${wrong}`}</Text>
</Text>
<Text style={styles.text}>
6 years ago
<Text style={styles.textLabel}>{`${texts.percentage}: ${Math.round(percentage)}%`}</Text>
</Text>
</View>
</View>
6 years ago
)
}