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

Commit

Permalink
Merge pull request #40 from ZendyLim/feature/#21_quiz_list_screen
Browse files Browse the repository at this point in the history
Feature/#21 quiz list screen
  • Loading branch information
avoidborredom authored May 22, 2018
2 parents 5cc84cf + c7ca386 commit adb0374
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/config/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,8 +2099,8 @@ export const katakanaList = [
{
"id":"k_mi",
"type":"katakana",
"romaji":"",
"moji":"",
"romaji":"mi",
"moji":"",
"audio":"mi.mp3",
"title":"mi",
},
Expand Down
16 changes: 9 additions & 7 deletions app/config/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ import HiraganaLearnScreen from '../screens/Learn/hiraganalearn';
import KatakanaLearnScreen from '../screens/Learn/katakanalearn';

const styles = require('../styles/style');

export const QuizStack = TabNavigator({
QuizHiraganaList: QuizHiraganaListScreen,
QuizKarakanaList: QuizKatakanaListScreen
}, {
tabBarPosition: 'top',
});

//import
const StudyStack = StackNavigator({
StudyList: StudyListScreen,
Expand All @@ -46,7 +54,7 @@ const StudyStack = StackNavigator({
QuizFlash: QuizFlashScreen,
LearnListScreen: LearnListScreen,
QuizMain: QuizMainScreen,
QuizList: QuizListScreen,
QuizList: QuizStack,
LearnHiraganaModule:
{
screen: LearnHiraganaModule,
Expand Down Expand Up @@ -115,12 +123,6 @@ export const AppStack = TabNavigator({
}
});

export const QuizStack = TabNavigator({
QuizHiraganaList: QuizHiraganaListScreen,
QuizKarakanaList: QuizKatakanaListScreen
}, {
tabBarPosition: 'top',
});

export const MainStack = StackNavigator({
AppStack: {
Expand Down
59 changes: 43 additions & 16 deletions app/screens/Quiz/quizHiraganaList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { hiraganaList } from '../../config/data';
import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';


class QuizHiraganaListScreen extends Component {

static navigationOptions = {
Expand All @@ -31,7 +30,7 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
constructor(props){
super(props);
this.checkItems = [hiraganaList.map.length];
// this.CheckRows = [hiraganaList.map.length];
this.checkRows=[hiraganaList.map.length];
}

render() {
Expand All @@ -44,7 +43,9 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
>
<Text style={quizStyles.buttonText}>{this.state.checkAllText}</Text>
</TouchableOpacity>
<TouchableOpacity style={quizStyles.menuButton}>
<TouchableOpacity style={quizStyles.menuButton}
onPress={this.proceed}
>
<Text style={quizStyles.buttonText}>Proceed ></Text>
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -89,51 +90,77 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
if(this.checkItems[key]){
this.checkItems[key] = false;
this.setState({ stsList: this.checkItems});
this.selectedList(key)
}
else{
this.checkItems[key] = true;
this.setState({ stsList: this.checkItems});
this.selectedList(key)
}
};
checkAll(){
this.setState({statusCheckAll: !this.state.statusCheckAll})
if(this.state.statusCheckAll){
{hiraganaList.map((item, key)=>(
hiraganaList.map((item, key)=>(
this.checkItems[key] = false,
this.setState({ stsList: this.checkItems })
))};
this.setState({ stsList: this.checkItems }),
this.selectedList(key)
));
this.setState({ checkAllText: "Check All" })
}else{
{hiraganaList.map((item, key)=>(
this.checkItems[key] = true,
this.setState({ stsList: this.checkItems })
this.setState({ stsList: this.checkItems }),
this.selectedList(key)
))};
this.setState({ checkAllText: "Uncheck All" })
}
};

checkRow(key){
if(this.checkItems[key]){
this.checkItems[key] = false,
this.setState({ statusPerRow: this.checkItems })
if(this.checkRows[key]){
this.checkRows[key] = false,
this.setState({ statusPerRow: this.checkRows })
for(x=0;x<5;x++){
this.checkItems[key] = false,
this.setState({ stsList: this.checkItems })
key=key-1
this.selectedList(key)
key=key-1;
}
}else{
this.checkItems[key] = true,
this.setState({ statusPerRow: this.checkItems })
this.checkRows[key] = true,
this.setState({ statusPerRow: this.checkRows })
for(x=0;x<5;x++){
this.checkItems[key] = true,
this.setState({ stsList: this.checkItems })
this.selectedList(key)
key=key-1
}
}
}
getActiveid(){
this.sta
}

proceed = () => {
this.props.navigation.navigate('QuizFlash',this.state.idList);
};

selectedList(key){
if(this.checkItems[key]){
if(hiraganaList[key].id !=""){
this.setState((previousState) => {
previousState.idList.push(hiraganaList[key].id);
return previousState;
})
}
}else{
if(hiraganaList[key].id !=""){
this.setState((previousState) => {
var idIndex = previousState.idList.indexOf(hiraganaList[key].id);
previousState.idList.splice(idIndex,1);
return previousState;
})
}
}
}
}

const quizStyles = require('../../styles/quizStyle');
Expand Down
59 changes: 51 additions & 8 deletions app/screens/Quiz/quizKatakanaList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
statusCheckAll: false,
stsList : false,
statusPerRow: false,
idList:[],
}

componentDidMount() {
const { navigation } = this.props;
this.setState({
test: navigation.getParam('idList', null),
});
console.log(this.state.test,"niamak")
}

constructor(props){
super(props);
this.checkItems = [katakanaList.map.length];
this.checkRows = [katakanaList.map.length];
}

render() {
Expand All @@ -43,7 +53,9 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
>
<Text style={quizStyles.buttonText}>{this.state.checkAllText}</Text>
</TouchableOpacity>
<TouchableOpacity style={quizStyles.menuButton}>
<TouchableOpacity style={quizStyles.menuButton}
onPress={this.proceed}
>
<Text style={quizStyles.buttonText}>Proceed ></Text>
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -88,47 +100,78 @@ import CircleCheckBox, {LABEL_POSITION} from 'react-native-circle-checkbox';
if(this.checkItems[key]){
this.checkItems[key] = false;
this.setState({ stsList: this.checkItems });
this.selectedList(key)
}
else{
this.checkItems[key] = true;
this.setState({ stsList: this.checkItems });
this.selectedList(key)
}
};
checkAll(){
this.setState({statusCheckAll: !this.state.statusCheckAll})
if(this.state.statusCheckAll){
{katakanaList.map((item, key)=>(
this.checkItems[key] = false,
this.setState({ stsList: this.checkItems })
this.setState({ stsList: this.checkItems }),
this.selectedList(key)
))};
this.setState({ checkAllText: "Check All" })
}else{
{katakanaList.map((item, key)=>(
this.checkItems[key] = true,
this.setState({ stsList: this.checkItems })
this.setState({ stsList: this.checkItems }),
this.selectedList(key)
))};
this.setState({ checkAllText: "Uncheck All" })
}
};
checkRow(key){
if(this.checkItems[key]){
this.checkItems[key] = false,
this.setState({ statusPerRow: this.checkItems })
if(this.checkRows[key]){
this.checkRows[key] = false,
this.setState({ statusPerRow: this.checkRows })
for(x=0;x<5;x++){
this.checkItems[key] = false,
this.setState({ stsList: this.checkItems })
this.selectedList(key)
key=key-1
}
}else{
this.checkItems[key] = true,
this.setState({ statusPerRow: this.checkItems })
this.checkRows[key] = true,
this.setState({ statusPerRow: this.checkRows })
for(x=0;x<5;x++){
this.checkItems[key] = true,
this.setState({ stsList: this.checkItems })
this.selectedList(key)
key=key-1
}
}
}

proceed = () => {
this.props.navigation.navigate('QuizFlash',this.state.idList);
};

selectedList(key){
if(this.checkItems[key]){
if(katakanaList[key].id !=""){
this.setState((previousState) => {
previousState.idList.push(katakanaList[key].id);
return previousState;
})
}
}else{
if(katakanaList[key].id !=""){
this.setState((previousState) => {
var idIndex = previousState.idList.indexOf(katakanaList[key].id);
previousState.idList.splice(idIndex,1);
return previousState;
})
}
}
}


}

const quizStyles = require('../../styles/quizStyle');
Expand Down
2 changes: 1 addition & 1 deletion app/screens/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
this.props.navigation.navigate('HiraganaExp');
};
quiz = () => {
this.props.navigation.navigate('QuizList');
this.props.navigation.navigate('QuizMain');
};
scoreScreen = () => {
this.props.navigation.navigate('ScoreScreen',{
Expand Down

0 comments on commit adb0374

Please sign in to comment.