Skip to content

Commit d842c72

Browse files
committed
Fix code review issues
1 parent f85914c commit d842c72

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

components/AddDeck.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export default class AddDeck extends React.Component {
1212
onSubmit = () => {
1313
const title = this.state.title;
1414
this.setState({ title: '' }, () =>
15-
saveDeckTitle(title).then(() => this.props.navigation.goBack())
15+
saveDeckTitle(title).then(() => {
16+
this.props.navigation.goBack();
17+
this.props.navigation.navigate('DeckDetail', { deckId: title });
18+
})
1619
);
1720
};
1821

components/QuizMode.js

+27-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { StyleSheet, Text, View, TouchableOpacity, Animated } from 'react-native
33
import { black, white, green, red, gray, oldlace, lightGrey } from '../utils/colors';
44
import { setLocalNotification, clearLocalNotification } from '../utils/helpers';
55

6+
const initialState = {
7+
correct: 0,
8+
incorrect: 0,
9+
currentQuestion: 0,
10+
questionCardFace: true,
11+
quizCompleted: false
12+
};
13+
614
export default class QuizMode extends React.Component {
715
static navigationOptions = ({ navigation }) => ({
816
headerTintColor: white,
@@ -12,12 +20,7 @@ export default class QuizMode extends React.Component {
1220
title: `Quiz: ${navigation.state.params.deckId}`
1321
});
1422

15-
state = {
16-
correct: 0,
17-
incorrect: 0,
18-
currentQuestion: 0,
19-
questionCardFace: true
20-
};
23+
state = { ...initialState };
2124

2225
componentWillMount() {
2326
// References
@@ -135,6 +138,14 @@ export default class QuizMode extends React.Component {
135138
{incorrect} answer(s) were incorrect.({(incorrect / totalQuestions * 100).toFixed(2)}%)
136139
</Text>
137140
<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>
138149
</View>
139150
);
140151
} else {
@@ -171,6 +182,16 @@ const quizResultStyles = StyleSheet.create({
171182
fontSize: 12,
172183
fontWeight: 'bold',
173184
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
174195
}
175196
});
176197

0 commit comments

Comments
 (0)