Commit ed273f91 authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Merge branch 'master' of http://gitlab.sliit.lk/21_22-j-38/21_22j-38 into it18257632

parents 45d89364 71a14976
...@@ -4,7 +4,7 @@ import Colors from '../../constants/Colors' ...@@ -4,7 +4,7 @@ import Colors from '../../constants/Colors'
const MainButton = (props) => { const MainButton = (props) => {
return( return(
<TouchableOpacity onPress={props.onPress}> <TouchableOpacity disabled={props.disabled} onPress={props.onPress}>
<View style={{...styles.button, ...props.styles}}> <View style={{...styles.button, ...props.styles}}>
<Text style={styles.buttonText}>{props.children}</Text> <Text style={styles.buttonText}>{props.children}</Text>
</View> </View>
......
...@@ -2,10 +2,26 @@ import { Center, Column, Row } from 'native-base'; ...@@ -2,10 +2,26 @@ import { Center, Column, Row } from 'native-base';
import React, {useState} from 'react'; import React, {useState} from 'react';
import {Text, View, StyleSheet, Button, ScrollView, Image,ImageBackground, TouchableOpacity, Modal, Alert, Pressable} from 'react-native'; import {Text, View, StyleSheet, Button, ScrollView, Image,ImageBackground, TouchableOpacity, Modal, Alert, Pressable} from 'react-native';
import MainButton from '../../component/memory/MainButton'; import MainButton from '../../component/memory/MainButton';
import { useDispatch, useSelector } from 'react-redux';
import { Icon } from 'react-native-elements';
const GameLevel = ({navigation}) => { const GameLevel = ({navigation}) => {
const [modalVisible, setModalVisible] = useState(false); const [modalVisible, setModalVisible] = useState(false);
const [mediumModalVisible, setMediumModalVisible] = useState(false); const [mediumModalVisible, setMediumModalVisible] = useState(false);
const status = useSelector(state=>state.memory.is_passed.status);
const level = useSelector(state=>state.memory.is_passed.level);
console.log(status);
console.log(level);
React.useEffect(() => {
const unsubscribe = navigation.addListener('focus', () => {
});
return unsubscribe;
}, [navigation]);
return ( return (
<ScrollView> <ScrollView>
<Modal <Modal
...@@ -81,15 +97,15 @@ const GameLevel = ({navigation}) => { ...@@ -81,15 +97,15 @@ const GameLevel = ({navigation}) => {
</View> </View>
</View> </View>
<View style={styles.screen} > <View style={styles.screen} >
<MainButton styles={styles.elementryBtn} onPress={() => setModalVisible(true)}> <MainButton disabled={false} styles={styles.elementryBtn} onPress={() => setModalVisible(true)}>
Elementry <Icon name="unlock-alt" type="font-awesome" size={36} color="white" /> Elementry
</MainButton> </MainButton>
<MainButton styles={styles.mediumBtn} onPress={()=>{setMediumModalVisible(true)}}> <MainButton disabled={!status ? true : false} styles={styles.mediumBtn} onPress={()=>{setMediumModalVisible(true)}}>
{/* navigation.navigate('MediumLevelStart') */} {/* navigation.navigate('MediumLevelStart') */}
Medium <Icon name={ status ? 'unlock-alt' : 'lock'} type="font-awesome" size={36} color="white" /> Medium
</MainButton> </MainButton>
<MainButton styles={styles.advanceBtn} onPress={()=>{navigation.navigate('AdvanceLevelStart')}}> <MainButton disabled={true} styles={styles.advanceBtn} onPress={()=>{navigation.navigate('AdvanceLevelStart')}}>
Advance <Icon name="lock" type="font-awesome" size={36} color="white" /> Advance
</MainButton> </MainButton>
</View> </View>
</ScrollView> </ScrollView>
......
...@@ -60,9 +60,9 @@ const GameOverScreen = ({navigation}) => { ...@@ -60,9 +60,9 @@ const GameOverScreen = ({navigation}) => {
.catch(err=>console.log(err)); .catch(err=>console.log(err));
} }
if(data>=3.0){ if(data>=2.9){
disorderLevel = 'High'; disorderLevel = 'High';
}else if (data>=1.5) { }else if (data>=1.99) {
disorderLevel = 'Medium'; disorderLevel = 'Medium';
} else { } else {
disorderLevel = 'low'; disorderLevel = 'low';
...@@ -88,6 +88,7 @@ const GameOverScreen = ({navigation}) => { ...@@ -88,6 +88,7 @@ const GameOverScreen = ({navigation}) => {
if(!loading){ if(!loading){
insertData(); insertData();
dispatch(memoryActions.levelPassed({level: disorderLevel, status: true}));
resultText=( resultText=(
// <Text style={styles.resultText}> // <Text style={styles.resultText}>
// <Text>Child's disorder level is </Text> <Text style={styles.highlight}>{disorderLevel}</Text> // <Text>Child's disorder level is </Text> <Text style={styles.highlight}>{disorderLevel}</Text>
......
...@@ -9,10 +9,10 @@ import Countdown from '../../../constants/Countdown'; ...@@ -9,10 +9,10 @@ import Countdown from '../../../constants/Countdown';
const GameScreenOne = ({navigation}) => { const GameScreenOne = ({navigation}) => {
// useEffect(()=>{ useEffect(()=>{
// const backHandler = BackHandler.addEventListener('hardwareBackPress', () => true) const backHandler = BackHandler.addEventListener('hardwareBackPress', () => true)
// return () => backHandler.remove() return () => backHandler.remove()
// },[]); },[]);
const dispatch = useDispatch(); const dispatch = useDispatch();
......
...@@ -2,6 +2,7 @@ export const SET_ANSWERS = 'SET_ANSWERS'; ...@@ -2,6 +2,7 @@ export const SET_ANSWERS = 'SET_ANSWERS';
export const SET_TIME = 'SET_TIME'; export const SET_TIME = 'SET_TIME';
export const CLEAR_DATA = 'CLEAR_DATA'; export const CLEAR_DATA = 'CLEAR_DATA';
export const SET_GAME_LEVEL = 'SET_GAME_LEVEL'; export const SET_GAME_LEVEL = 'SET_GAME_LEVEL';
export const PASS = 'PASS';
export const setGameLevel = (level) => { export const setGameLevel = (level) => {
return {type: SET_GAME_LEVEL, level: level} return {type: SET_GAME_LEVEL, level: level}
...@@ -17,4 +18,8 @@ export const setTime = (time) => { ...@@ -17,4 +18,8 @@ export const setTime = (time) => {
export const clearData = () => { export const clearData = () => {
return {type: CLEAR_DATA} return {type: CLEAR_DATA}
}
export const levelPassed = (status) => {
return {type: PASS, status: status}
} }
\ No newline at end of file
import { CLEAR_DATA, SET_ANSWERS, SET_GAME_LEVEL, SET_TIME } from "../actions/memory"; import { CLEAR_DATA, SET_ANSWERS, SET_GAME_LEVEL, SET_TIME, PASS } from "../actions/memory";
const initialState = { const initialState = {
gameLevel: null, gameLevel: null,
memoryData: {}, memoryData: {},
screenTime: {} screenTime: {},
is_passed: {
level: null,
status: false
}
} }
const memoryReducer = (state=initialState, action) => { const memoryReducer = (state=initialState, action) => {
...@@ -44,6 +48,19 @@ const memoryReducer = (state=initialState, action) => { ...@@ -44,6 +48,19 @@ const memoryReducer = (state=initialState, action) => {
gameLevel: null gameLevel: null
} }
case PASS:
const levelPassed = action.level;
const PassedStatus = action.status;
return{
...state,
is_passed: {
level: levelPassed,
status: PassedStatus
}
}
default: default:
return state return state
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment