@@ -3,6 +3,14 @@ import { StyleSheet, Text, View, TouchableOpacity, Animated } from 'react-native
3
3
import { black , white , green , red , gray , oldlace , lightGrey } from '../utils/colors' ;
4
4
import { setLocalNotification , clearLocalNotification } from '../utils/helpers' ;
5
5
6
+ const initialState = {
7
+ correct : 0 ,
8
+ incorrect : 0 ,
9
+ currentQuestion : 0 ,
10
+ questionCardFace : true ,
11
+ quizCompleted : false
12
+ } ;
13
+
6
14
export default class QuizMode extends React . Component {
7
15
static navigationOptions = ( { navigation } ) => ( {
8
16
headerTintColor : white ,
@@ -12,12 +20,7 @@ export default class QuizMode extends React.Component {
12
20
title : `Quiz: ${ navigation . state . params . deckId } `
13
21
} ) ;
14
22
15
- state = {
16
- correct : 0 ,
17
- incorrect : 0 ,
18
- currentQuestion : 0 ,
19
- questionCardFace : true
20
- } ;
23
+ state = { ...initialState } ;
21
24
22
25
componentWillMount ( ) {
23
26
// References
@@ -135,6 +138,14 @@ export default class QuizMode extends React.Component {
135
138
{ incorrect } answer(s) were incorrect.({ ( incorrect / totalQuestions * 100 ) . toFixed ( 2 ) } %)
136
139
</ Text >
137
140
< Text style = { quizResultStyles . total } > { totalQuestions } Total questions.</ Text >
141
+ < View style = { quizResultStyles . actions } >
142
+ < TouchableOpacity onPress = { ( ) => this . props . navigation . goBack ( ) } >
143
+ < Text style = { quizResultStyles . actionsBtn } > Go Back!</ Text >
144
+ </ TouchableOpacity >
145
+ < TouchableOpacity onPress = { ( ) => this . setState ( { ...initialState } ) } >
146
+ < Text style = { quizResultStyles . actionsBtn } > Restart Quiz</ Text >
147
+ </ TouchableOpacity >
148
+ </ View >
138
149
</ View >
139
150
) ;
140
151
} else {
@@ -171,6 +182,16 @@ const quizResultStyles = StyleSheet.create({
171
182
fontSize : 12 ,
172
183
fontWeight : 'bold' ,
173
184
color : gray
185
+ } ,
186
+ actions : {
187
+ flexDirection : 'row'
188
+ } ,
189
+ actionsBtn : {
190
+ backgroundColor : black ,
191
+ color : white ,
192
+ margin : 10 ,
193
+ padding : 20 ,
194
+ borderWidth : 1
174
195
}
175
196
} ) ;
176
197
0 commit comments