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.
217 lines
5.0 KiB
217 lines
5.0 KiB
import React from "react"
|
|
import { View, ScrollView, StyleSheet, StatusBar, Text, CheckBox, SafeAreaView, Dimensions, Image, BackHandler, AsyncStorage} from "react-native"
|
|
|
|
import { Button, ButtonContainer } from "../components/Button"
|
|
import { colors, texts, examScheme, resultsScheme} from "../components/Variables"
|
|
|
|
const screen = Dimensions.get("window")
|
|
const header = require("../assets/header.png")
|
|
|
|
const pkg = require('../../app.json')
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
backgroundColor: colors.dark_blue,
|
|
flex: 1
|
|
},
|
|
safearea: {
|
|
flex: 1,
|
|
marginTop: 25,
|
|
justifyContent: "space-between",
|
|
paddingHorizontal: 10
|
|
},
|
|
|
|
box: {
|
|
width: screen.width-20,
|
|
paddingHorizontal: 10
|
|
},
|
|
text: {
|
|
color: colors.white,
|
|
fontSize: 16,
|
|
textAlign: "center",
|
|
fontWeight: "400",
|
|
lineHeight: 20,
|
|
textShadowColor: 'rgba(0, 0, 0, 0.75)',
|
|
textShadowOffset: {width: -1, height: 1},
|
|
textShadowRadius: 5
|
|
},
|
|
title: {
|
|
paddingTop: 30,
|
|
color: colors.white,
|
|
fontSize: 18,
|
|
textTransform: "uppercase",
|
|
textAlign: "center",
|
|
fontWeight: "400",
|
|
lineHeight: 20,
|
|
textShadowColor: 'rgba(0, 0, 0, 0.75)',
|
|
textShadowOffset: {width: -1, height: 1},
|
|
textShadowRadius: 5
|
|
},
|
|
textSmall: {
|
|
lineHeight: 23,
|
|
marginTop: 15,
|
|
borderRadius: 20,
|
|
backgroundColor: colors.white,
|
|
borderWidth: 0,
|
|
borderColor: colors.white_alpha,
|
|
fontSize: 16,
|
|
color: colors.white,
|
|
fontWeight: "400",
|
|
textAlign: "center",
|
|
paddingHorizontal: 20,
|
|
paddingVertical: 20,
|
|
textShadowColor: 'rgba(0, 0, 0, 0.75)',
|
|
textShadowOffset: {width: -1, height: 1},
|
|
textShadowRadius: 5
|
|
},
|
|
textItems: {
|
|
fontSize: 16,
|
|
fontWeight: "400",
|
|
lineHeight: 23,
|
|
color: colors.white,
|
|
textAlign: "center",
|
|
paddingBottom: 10,
|
|
marginBottom: 10,
|
|
borderBottomColor: colors.white_alpha,
|
|
borderBottomWidth: 1,
|
|
textShadowColor: 'rgba(0, 0, 0, 0.55)',
|
|
textShadowOffset: {width: -1, height: 1},
|
|
textShadowRadius: 2
|
|
},
|
|
noBorder: {
|
|
borderBottomWidth: 0
|
|
},
|
|
item: {
|
|
width: "100%"
|
|
},
|
|
noPadding: {
|
|
paddingVertical: 0,
|
|
},
|
|
textLabel: {
|
|
paddingHorizontal: 20,
|
|
paddingVertical: 20
|
|
},
|
|
bold: {
|
|
lineHeight: 30,
|
|
fontSize: 26,
|
|
fontWeight: "600"
|
|
},
|
|
|
|
checkboxContainer: {
|
|
flexDirection: "row",
|
|
paddingBottom: 10,
|
|
marginBottom: 10,
|
|
borderBottomColor: colors.black_alpha,
|
|
borderBottomWidth: 1,
|
|
},
|
|
checkbox: {
|
|
alignSelf: "center",
|
|
color: "white"
|
|
},
|
|
checkboxLabel: {
|
|
marginLeft: 8,
|
|
marginRight: 8
|
|
}
|
|
})
|
|
|
|
const B = (props) => <Text style={{fontWeight: 'bold'}}>{props.children}</Text>
|
|
|
|
class Setup extends React.Component {
|
|
|
|
state = {
|
|
setupData: {}
|
|
}
|
|
|
|
componentDidMount() {
|
|
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton)
|
|
AsyncStorage.getItem('setupData').then((value) => {
|
|
let setupData = {}
|
|
|
|
if(!value) {
|
|
setupData = {
|
|
randomQuestions: true,
|
|
excludeDelta: false
|
|
}
|
|
AsyncStorage.setItem('setupData', JSON.stringify(setupData))
|
|
} else {
|
|
setupData = JSON.parse(value)
|
|
}
|
|
|
|
this.setState( (state) => {
|
|
return {
|
|
setupData: setupData
|
|
}
|
|
})
|
|
}).done()
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton)
|
|
}
|
|
|
|
handleBackButton = () => {
|
|
this.props.navigation.navigate("Splash")
|
|
return true
|
|
}
|
|
|
|
changeSetup = (item) => {
|
|
setupData = this.state.setupData
|
|
setupData[item] = !this.state.setupData[item]
|
|
|
|
this.setState( (state) => {
|
|
return {
|
|
setupData: setupData
|
|
}
|
|
})
|
|
|
|
AsyncStorage.setItem('setupData', JSON.stringify(setupData))
|
|
}
|
|
|
|
render() {
|
|
|
|
return (
|
|
<View style={styles.container} >
|
|
|
|
<SafeAreaView style={styles.safearea}>
|
|
<ScrollView>
|
|
<View style={styles.box}>
|
|
|
|
<Text style={styles.title}>
|
|
{texts.setupScheme}
|
|
</Text>
|
|
|
|
<View style={styles.textSmall}>
|
|
|
|
<View style={styles.checkboxContainer}>
|
|
<CheckBox
|
|
value={this.state.setupData.randomQuestions}
|
|
onValueChange={() => this.changeSetup('randomQuestions')}
|
|
style={styles.checkbox}
|
|
/>
|
|
<Text style={styles.checkboxLabel}>{texts.setupRandomCheck}</Text>
|
|
</View>
|
|
|
|
<View style={styles.checkboxContainer}>
|
|
<CheckBox
|
|
value={this.state.setupData.excludeDelta}
|
|
onValueChange={() => this.changeSetup('excludeDelta')}
|
|
style={styles.checkbox}
|
|
/>
|
|
<Text style={styles.checkboxLabel}>{texts.setupExcludeDelta}</Text>
|
|
</View>
|
|
|
|
|
|
</View>
|
|
|
|
</View>
|
|
</ScrollView>
|
|
|
|
</SafeAreaView>
|
|
|
|
</View>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default Setup
|