Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
21_22-J 38
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 38
21_22-J 38
Commits
9811d84b
Commit
9811d84b
authored
Apr 24, 2022
by
Neranga K.T.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0ec28150
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
4 deletions
+57
-4
frontend/src/constants/Levels.js
frontend/src/constants/Levels.js
+5
-0
frontend/src/screen/auth/Login.js
frontend/src/screen/auth/Login.js
+1
-1
frontend/src/screen/memory/GameOverScreen.js
frontend/src/screen/memory/GameOverScreen.js
+25
-1
frontend/src/screen/memory/elementry/GameScreenOne.js
frontend/src/screen/memory/elementry/GameScreenOne.js
+9
-0
frontend/src/store/actions/memory.js
frontend/src/store/actions/memory.js
+5
-0
frontend/src/store/reducers/memory.js
frontend/src/store/reducers/memory.js
+12
-2
No files found.
frontend/src/constants/Levels.js
0 → 100644
View file @
9811d84b
export
default
{
elementry
:
'
elementry_level
'
,
level2
:
'
level_two
'
,
level3
:
'
level_three
'
}
\ No newline at end of file
frontend/src/screen/auth/Login.js
View file @
9811d84b
...
...
@@ -149,7 +149,7 @@ const Login = () => {
<
/View
>
<
View
style
=
{
styles
.
form_input
}
>
<
TouchableOpacity
onPress
=
{
submitForm
}
style
=
{
styles
.
btn
}
>
<
TouchableOpacity
onPress
=
{
()
=>
{
navigation
.
navigate
(
"
Start
"
);}
}
style
=
{
styles
.
btn
}
>
<
Text
style
=
{
styles
.
btn_text
}
>
Sign
In
<
/Text
>
...
...
frontend/src/screen/memory/GameOverScreen.js
View file @
9811d84b
...
...
@@ -8,10 +8,13 @@ const GameOverScreen = ({navigation}) => {
const
dispatch
=
useDispatch
();
const
passedLevel
=
useSelector
(
state
=>
state
.
memory
.
gameLevel
);
const
passedData
=
useSelector
(
state
=>
state
.
memory
.
memoryData
);
const
passedTime
=
useSelector
(
state
=>
state
.
time
.
screenTime
);
console
.
log
(
passedData
);
console
.
log
(
passedTime
);
console
.
log
(
passedLevel
);
let
totalTime
=
0
;
...
...
@@ -27,9 +30,10 @@ const GameOverScreen = ({navigation}) => {
console
.
log
(
seconds
);
const
[
data
,
setData
]
=
useState
([]);
// const [level, setLevel] = useState('');
const
[
loading
,
setIsLoading
]
=
useState
(
true
);
let
disorderLevel
;
let
disorderLevel
;
let
resultText
;
const
gameData
=
{
...
...
@@ -48,6 +52,7 @@ const GameOverScreen = ({navigation}) => {
})
.
then
(
resp
=>
resp
.
json
())
.
then
(
data
=>
{
console
.
log
(
'
level :
'
,
data
.
results
[
0
].
level
);
setData
(
data
.
results
[
0
].
level
)
setIsLoading
(
false
)
})
...
...
@@ -62,7 +67,26 @@ const GameOverScreen = ({navigation}) => {
disorderLevel
=
'
low
'
}
const
insertData
=
()
=>
{
fetch
(
'
http://192.168.8.170:5000/add
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
({
name
:
'
child 1
'
,
age
:
'
5
'
,
game_level
:
passedLevel
,
time_duration
:
seconds
,
result
:
disorderLevel
})
})
.
then
(
resp
=>
resp
.
json
())
.
catch
(
error
=>
console
.
log
(
error
))
}
if
(
!
loading
){
insertData
();
resultText
=
(
<
Text
style
=
{
styles
.
resultText
}
>
<
Text
>
Child
'
s disorder level is </Text> <Text style={styles.highlight}>{disorderLevel}</Text>
...
...
frontend/src/screen/memory/elementry/GameScreenOne.js
View file @
9811d84b
...
...
@@ -2,6 +2,9 @@ import React, {useState, useEffect} from 'react';
import
{
View
,
Text
,
StyleSheet
,
Image
,
BackHandler
}
from
'
react-native
'
;
import
Header
from
'
../../../component/memory/Header
'
;
import
CountDown
from
'
react-native-countdown-component
'
;
import
{
useDispatch
}
from
'
react-redux
'
;
import
*
as
memoryActions
from
'
../../../store/actions/memory
'
;
import
Levels
from
'
../../../constants/Levels
'
;
const
GameScreenOne
=
({
navigation
})
=>
{
...
...
@@ -10,6 +13,12 @@ const GameScreenOne = ({navigation}) => {
// return () => backHandler.remove()
// },[]);
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
dispatch
(
memoryActions
.
setGameLevel
(
Levels
.
elementry
))
})
return
(
<
View
style
=
{
styles
.
sreen
}
>
<
Text
><
/Text
>
...
...
frontend/src/store/actions/memory.js
View file @
9811d84b
export
const
SET_ANSWERS
=
'
SET_ANSWERS
'
;
export
const
SET_TIME
=
'
SET_TIME
'
;
export
const
CLEAR_DATA
=
'
CLEAR_DATA
'
;
export
const
SET_GAME_LEVEL
=
'
SET_GAME_LEVEL
'
;
export
const
setGameLevel
=
(
level
)
=>
{
return
{
type
:
SET_GAME_LEVEL
,
level
:
level
}
}
export
const
setAnswers
=
(
data
)
=>
{
return
{
type
:
SET_ANSWERS
,
data
:
data
}
...
...
frontend/src/store/reducers/memory.js
View file @
9811d84b
import
{
CLEAR_DATA
,
SET_ANSWERS
,
SET_TIME
}
from
"
../actions/memory
"
;
import
{
CLEAR_DATA
,
SET_ANSWERS
,
SET_
GAME_LEVEL
,
SET_
TIME
}
from
"
../actions/memory
"
;
const
initialState
=
{
gameLevel
:
null
,
memoryData
:
{},
screenTime
:
{}
}
const
memoryReducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
){
case
SET_GAME_LEVEL
:
const
level
=
action
.
level
;
return
{
...
state
,
gameLevel
:
level
}
case
SET_ANSWERS
:
const
addedAnswer
=
action
.
data
;
const
question
=
addedAnswer
.
question
;
...
...
@@ -31,7 +40,8 @@ const memoryReducer = (state=initialState, action) => {
return
{
...
state
,
memoryData
:
{},
screenTime
:
{}
screenTime
:
{},
gameLevel
:
null
}
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment