diff --git a/components/AddCard.js b/components/AddCard.js index 967e2b1..734ac58 100644 --- a/components/AddCard.js +++ b/components/AddCard.js @@ -44,16 +44,16 @@ class AddCard extends Component { const {cardQuestion,cardAnswer} = this.state; return ( - + What is your question? - What is your answer?? - { + const {navigation,route} = this.props; + const { title } = route.params; + navigation.navigate("Deck", { title }); + } + handleRestartQ = ()=>{ + const {navigation,route,deck} = this.props; + const { title } = route.params; + this.setState({ qNumber: 0, + showQ: false, + correctA: 0, + incA: 0}) + } render() { const { route, numberOfQuestions, questions, navigation, deck } = this.props; const { title } = route.params; const { showQ, qNumber } = this.state; const number = qNumber + 1; - if(numberOfQuestions===0){ -return( - Sorry, you cannot take a quiz because there are no cards in the deck. -) + if (numberOfQuestions === 0) { + return ( + + Sorry, you cannot take a quiz because there are no cards in the deck. + + ) } - else if(qNumber === numberOfQuestions){ - const {incA,correctA} = this.state; - return( - You got {correctA} correct answers and {incA} incorrect answers. - - Restart Quiz - - - Back to Deck - + else if (qNumber === numberOfQuestions) { + const { incA, correctA } = this.state; + return ( + + You got {correctA} correct answers and {incA} incorrect answers. + + Restart Quiz + + + Back to Deck + + ) } return ( + Progress: {number}/{numberOfQuestions} - {number}/{numberOfQuestions} + { - !showQ ? {deck.questions[qNumber].cardQuestion} - Show Answer - : {deck.questions[qNumber].cardAnswer} - Show Question + !showQ ? Question: "{deck.questions[qNumber].cardQuestion}" + Show Answer + : Answer: "{deck.questions[qNumber].cardAnswer}" + Show Question } - this.handleSubmitA(true)} - style={styles.button} + + this.handleSubmitA(true)} + style={styles.greenButton} > - Correct + Correct - this.handleSubmitA(false)} - style={styles.button} + + this.handleSubmitA(false)} + style={styles.redButton} > - Incorrect + Incorrect + ); } @@ -91,7 +112,7 @@ const styles = StyleSheet.create({ }, card: { flex: 1, - justifyContent: "space-around", + justifyContent: "space-evenly", alignItems: "center", backgroundColor: blue, alignSelf: "stretch", @@ -102,14 +123,31 @@ const styles = StyleSheet.create({ } }, numberOfQuestions: { - fontSize: 16, - color: white, - marginTop: 24, - textAlign: "center" + color: "black", + margin: 3, + }, + buttons:{ + alignItems: "flex-start", + + }, + greenButton:{ + backgroundColor:green, + padding:16, + margin:10, + borderRadius:3 + }, + redButton:{ + backgroundColor:red, + padding:16, + margin:10, + borderRadius:3 + }, + orangeButton:{ + backgroundColor:orange, + padding:16, + margin:10, + borderRadius:3 }, - question: { - top: 0 - } }); function mapStateToProps(decks, { route }) { const { title } = route.params; diff --git a/middleware/Logger.js b/middleware/Logger.js index 8ba9b46..94ac562 100644 --- a/middleware/Logger.js +++ b/middleware/Logger.js @@ -4,7 +4,6 @@ const logger = (store) => (next) => (action) =>{ console.log('The action: ', action); //updates the state const returnValue = next(action) - console.log('The new state:', store.getState()); console.groupEnd(); return returnValue; } diff --git a/utils/api.js b/utils/api.js index 71ecded..5dfa622 100644 --- a/utils/api.js +++ b/utils/api.js @@ -32,7 +32,6 @@ export function deleteDeckTitle(title){ }) } export function saveDeckCard(title, question) { - console.log(title,'<-title',question,'<-question') return AsyncStorage.getItem(FLASHCARDS_FLASHCARD_DB).then(results => { const data = JSON.parse(results); Object.keys(data).map(dTitle => {