Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Commit

Permalink
#50 add test
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed Jun 1, 2018
1 parent 891f81c commit 79cb7fd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 99 deletions.
81 changes: 0 additions & 81 deletions app/component/answerButton.js
Original file line number Diff line number Diff line change
@@ -1,81 +0,0 @@
import React, { Component } from 'react';
import { TouchableHighlight, Image, View, Text } from 'react-native';
import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/FontAwesome';

/**
Quiz Button
**/
class AnswerButton extends Component {
static propTypes = {
textDisplay: PropTypes.string.isRequired,
textData: PropTypes.object,
selected: PropTypes.bool,
id: PropTypes.string,
isCorrect: PropTypes.number,
styleFormat: PropTypes.string
};

constructor(props) {
super(props);

}

_renderIcon(){
let iconName = '';
console.log(this.props.isCorrect);
switch (this.props.isCorrect) {
case 1:
iconName = 'circle-o';
break;

case 0:
iconName = 'times';
break;

default:
return null;
break;
}

centerIcon = ['quizSquared','quizKanji'];
center = centerIcon.indexOf(this.props.styleFormat) > -1;

return(
<View style={[ styles.quizBtnIconWrapper, this.props.isCorrect ? styles.quizBtnIconCorrect : styles.quizBtnIconWrong, !center && styles.quizBtnIconLeft ]}>
<Icon name={ iconName } style={ [ styles.quizBtnIcon ] } />
</View>
);

}

render(){

return (
<View style={ [ styles.quizBtnContainer ] }>
{ this._renderIcon() }
<TouchableHighlight
style={ [styles.quizBtn, styles.shadow, styles[this.props.styleFormat], this.props.selected && styles.quizBtnPress ] }
onPress={() => this.onSelectAnswer() }
>
<Text
style={ [styles[this.props.styleFormat + 'Text'], this.props.selected && styles.quizBtnTextPress] }>
{ this.props.textDisplay }
</Text>
</TouchableHighlight>
</View>
);
}

onSelectAnswer(){
if(this.props.isCorrect == -1){
this.props.onSelectAnswer(this.props.id);
}

}


}
module.exports = AnswerButton;

const styles = require('../styles/style');
2 changes: 1 addition & 1 deletion app/component/fillButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FillButton extends Component {
}

return(
<View style={[ styles.quizBtnIconWrapper, this.props.isCorrect ? styles.quizBtnIconCorrect : styles.quizBtnIconWrong, this.props.styleFormat != 'quizSquared' && styles.quizBtnIconLeft ]}>
<View style={[ styles.quizBtnIconWrapper, this.props.isCorrect ? styles.quizBtnIconCorrect : styles.quizBtnIconWrong ]}>
<Icon name={ iconName } style={ [ styles.quizBtnIcon ] } />
</View>
);
Expand Down
6 changes: 3 additions & 3 deletions app/component/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Quiz extends Component {
}
else{
return(
<View style={ [styles.displayInlineContainer, styles.answerContainer] }>
<View style={ [ styles.displayInlineContainer, styles.answerContainer ] }>
{ this.props.answerOptions.map((item)=>(
<AnswerButton
key={ item.id }
Expand All @@ -72,9 +72,9 @@ class Quiz extends Component {
render(){

return (
<ScrollView>
<View>
{ this._renderAnswerButtons() }
</ScrollView>
</View>
);
}

Expand Down
18 changes: 9 additions & 9 deletions app/config/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ let topic_title_grammar= [
"id":"tpg1_1",
"type":"grammar",
"romaji":"kanako-san ha gakusei desu.",
"moji":"かなこさんはがくせいです。",
"kanji":"かなこさんは学生です",
"moji":"かなこさん は がくせい です。",
"kanji":"かなこさん は 学生 です",
"english":"Kanako is a student",
"audio":"ne.mp3"
},
{
"id":"tpg1_2",
"type":"grammar",
"romaji":"kanako-san ha jaarimasen.",
"moji":"かなこさんはがくせいじゃありません。",
"moji":"かなこさん は がくせい じゃありません。",
"kanji":"かなこさんは学生じゃありません",
"english":"Kanako is not a student",
"audio":"ne.mp3"
Expand All @@ -137,26 +137,26 @@ let topic_title_grammar= [
"id":"tpg1_3",
"type":"grammar",
"romaji":"kanako-san ha desu ka.",
"moji":"かなこさんはがくせいですか。",
"kanji":"かなこさんは学生ですか",
"moji":"かなこさん は がくせい です か。",
"kanji":"かなこさん は 学生 です か",
"english":"Is kanako a student?",
"audio":"ne.mp3"
},
{
"id":"tpg1_4",
"type":"grammar",
"romaji":"kanako-san ha takumi-san ga wakarimasu.",
"moji":"かなこさんはたくみさんがわかります。",
"kanji":"かなこさんはたくみさんが分かります。",
"moji":"かなこさん は たくみさん が わかります。",
"kanji":"かなこさん は たくみさん が 分かります。",
"english":"Kanako knows Takumi",
"audio":"ne.mp3"
},
{
"id":"tpg1_5",
"type":"grammar",
"romaji":"kanako-san ha takumi-san ga wakarimasen.",
"moji":"かなこさんはたくみさんがわかりません。",
"kanji":"かなこさんはたくみさんが分かりません。",
"moji":"かなこさん は たくみさん が わかりません。",
"kanji":"かなこさん は たくみさん が 分かりません。",
"english":"Kanako does not know Takumi",
"audio":"ne.mp3"
}
Expand Down
11 changes: 7 additions & 4 deletions app/screens/Quiz/quizFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { Component } from 'react';
import {
View,
Text,
TouchableHighlight
TouchableHighlight,
ScrollView
} from 'react-native';
import { List, ListItem, ScrollView } from 'react-native-elements';

import { strings } from '../../config/localization';

import { bindActionCreators } from 'redux';
Expand Down Expand Up @@ -147,7 +148,7 @@ import {
}
</View>

<View style={[ styles.col12, styles.quizAnswerWrapper]}>
<ScrollView style={[ styles.col12 ]}>
<View style={ !timerRun && styles.blocker }></View>

{ !this.state.showCorrect ?
Expand Down Expand Up @@ -175,7 +176,7 @@ import {
)
}

</View>
</ScrollView>

</View>

Expand All @@ -189,6 +190,8 @@ import {

componentWillMount() {
const { navigation } = this.props;

console.log(this.props.navigation);
this.oneType = navigation.getParam('oneType',null);
this.mounted = true;
idList = navigation.getParam('idList', null);
Expand Down
4 changes: 3 additions & 1 deletion app/styles/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ module.exports = StyleSheet.create({
paddingTop:13
},
quizAnswerWrapper:{
position:'relative'
position:'relative',
backgroundColor:'red',
height: window.height - 100
},
blocker:{
position:'absolute',
Expand Down

0 comments on commit 79cb7fd

Please sign in to comment.