Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-035-CoviDefender
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
1
Merge Requests
1
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
2021-035
2021-035-CoviDefender
Commits
b278e65d
Commit
b278e65d
authored
Jun 26, 2021
by
Piyumi Dayarathna
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stracker - Complete the game functionality for mask wearing part
parent
9d6fbbbd
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
711 additions
and
7 deletions
+711
-7
lib/STracker/finalResult.dart
lib/STracker/finalResult.dart
+153
-0
lib/STracker/levelsDashboard.dart
lib/STracker/levelsDashboard.dart
+9
-6
lib/STracker/maskWearingQuizPage.dart
lib/STracker/maskWearingQuizPage.dart
+274
-0
lib/STracker/maskWearingQuizStartPage.dart
lib/STracker/maskWearingQuizStartPage.dart
+86
-0
lib/STracker/maskWearingResultPage.dart
lib/STracker/maskWearingResultPage.dart
+122
-0
lib/STracker/resultpage.dart
lib/STracker/resultpage.dart
+12
-0
lib/STracker/variables.dart
lib/STracker/variables.dart
+6
-0
lib/assets/pythonMaskWearing.json
lib/assets/pythonMaskWearing.json
+48
-0
lib/home_screen.dart
lib/home_screen.dart
+1
-1
No files found.
lib/STracker/finalResult.dart
0 → 100644
View file @
b278e65d
import
'package:flutter/material.dart'
;
import
'levelsDashboard.dart'
;
import
'variables.dart'
;
class
finalResult
extends
StatefulWidget
{
int
marks
;
finalResult
()
:
super
();
@override
_finalResultState
createState
()
=>
_finalResultState
();
}
class
_finalResultState
extends
State
<
finalResult
>
{
int
marks
;
_finalResultState
();
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"Final Result"
,
),
),
body:
Column
(
children:
<
Widget
>[
Expanded
(
flex:
20
,
child:
Material
(
elevation:
10.0
,
child:
Container
(
width:
300.0
,
height:
300.0
,
child:
Column
(
children:
<
Widget
>[
Material
(
child:
Container
(
width:
300.0
,
height:
300.0
,
child:
ClipRRect
(
child:
Image
(
image:
AssetImage
(
"lib/assets/images/gameover.jpg"
),
),
),
),
),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"Hand Washing -
$marks1
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"Mask Wearing -
$marks2
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"Social Distance -
$marks3
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"Public places -
$marks4
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"Symptoms -
$marks5
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
],
)),
),
),
Expanded
(
flex:
4
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
OutlineButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=>
levelsDashboard
(),
));
},
child:
Text
(
"Continue"
,
style:
TextStyle
(
fontSize:
18.0
,
),
),
padding:
EdgeInsets
.
symmetric
(
vertical:
10.0
,
horizontal:
25.0
,
),
borderSide:
BorderSide
(
width:
3.0
,
color:
Colors
.
indigo
),
splashColor:
Colors
.
indigoAccent
,
)
],
),
)
],
),
);
}
}
lib/STracker/levelsDashboard.dart
View file @
b278e65d
import
'package:covidefender/STracker/maskWearingQuizStartPage.dart'
;
import
'package:flutter/material.dart'
;
import
'home.dart'
;
...
...
@@ -94,12 +95,14 @@ class _levelsDashboardState extends State<levelsDashboard> {
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => EAnalyzerDash()),
// );
// },
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
maskWearingQuizStartPage
()),
);
},
child:
Image
.
asset
(
'lib/assets/images/maskWearing.png'
),
),
...
...
lib/STracker/maskWearingQuizPage.dart
0 → 100644
View file @
b278e65d
import
'dart:async'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'maskWearingResultPage.dart'
;
class
getjsonMaskWearing
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
FutureBuilder
(
future:
DefaultAssetBundle
.
of
(
context
)
.
loadString
(
"lib/assets/pythonMaskWearing.json"
),
builder:
(
context
,
snapshot
)
{
List
mydata
=
json
.
decode
(
snapshot
.
data
.
toString
());
if
(
mydata
==
null
)
{
return
Scaffold
(
body:
Center
(
child:
Text
(
"Loading"
,
),
),
);
// return quizpage();
}
else
{
return
quizpageMaskWearing
(
mydata:
mydata
);
}
});
}
}
class
quizpageMaskWearing
extends
StatefulWidget
{
var
mydata
;
quizpageMaskWearing
({
Key
key
,
@required
this
.
mydata
})
:
super
(
key:
key
);
@override
_quizpageMaskWearingState
createState
()
=>
_quizpageMaskWearingState
(
mydata
);
}
class
_quizpageMaskWearingState
extends
State
<
quizpageMaskWearing
>
{
var
mydata
;
_quizpageMaskWearingState
(
this
.
mydata
);
Color
colortoshow
=
Colors
.
indigoAccent
;
Color
right
=
Colors
.
green
;
Color
wrong
=
Colors
.
red
;
int
marks
=
0
;
int
i
=
1
;
int
x
=
0
;
int
timer
=
60
;
String
showtimer
=
"60"
;
int
hangState
=
0
;
Map
<
String
,
Color
>
btncolor
=
{
"a"
:
Colors
.
indigoAccent
,
"b"
:
Colors
.
indigoAccent
,
"c"
:
Colors
.
indigoAccent
,
"d"
:
Colors
.
indigoAccent
};
bool
canceltimer
=
false
;
@override
void
initState
()
{
starttimer
();
super
.
initState
();
}
void
starttimer
()
async
{
const
onesec
=
Duration
(
seconds:
1
);
Timer
.
periodic
(
onesec
,
(
Timer
t
)
{
setState
(()
{
if
(
timer
<
1
)
{
t
.
cancel
();
nextquestion
();
}
else
if
(
canceltimer
==
true
)
{
t
.
cancel
();
}
else
{
timer
=
timer
-
1
;
}
showtimer
=
timer
.
toString
();
});
});
}
void
nextquestion
()
{
canceltimer
=
false
;
timer
=
60
;
setState
(()
{
if
(
i
<
5
)
{
i
++;
}
else
{
Navigator
.
of
(
context
).
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=>
maskWearingResultPage
(
marks:
marks
),
));
}
btncolor
[
"a"
]
=
Colors
.
indigoAccent
;
btncolor
[
"b"
]
=
Colors
.
indigoAccent
;
btncolor
[
"c"
]
=
Colors
.
indigoAccent
;
btncolor
[
"d"
]
=
Colors
.
indigoAccent
;
});
starttimer
();
}
void
checkanswer
(
String
k
)
{
if
(
mydata
[
2
][
i
.
toString
()]
==
mydata
[
1
][
i
.
toString
()][
k
])
{
marks
=
marks
+
5
;
colortoshow
=
right
;
}
else
{
colortoshow
=
wrong
;
x
=
x
+
1
;
showHangman
(
x
);
}
setState
(()
{
btncolor
[
k
]
=
colortoshow
;
canceltimer
=
true
;
});
Timer
(
Duration
(
seconds:
2
),
nextquestion
);
}
void
showHangman
(
x
)
{
if
(
x
==
1
)
{
hangState
=
1
;
}
else
if
(
x
==
2
)
{
hangState
=
2
;
}
else
if
(
x
==
3
)
{
hangState
=
3
;
}
else
if
(
x
==
4
)
{
hangState
=
4
;
}
else
{
hangState
=
5
;
}
}
Widget
choicebutton
(
String
k
)
{
return
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
10.0
,
horizontal:
20.0
,
),
child:
MaterialButton
(
onPressed:
()
=>
checkanswer
(
k
),
child:
Text
(
mydata
[
1
][
i
.
toString
()][
k
],
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
,
),
maxLines:
1
,
),
color:
btncolor
[
k
],
splashColor:
Colors
.
indigo
[
700
],
highlightColor:
Colors
.
indigo
[
700
],
minWidth:
200.0
,
height:
45.0
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
20.0
)),
),
);
}
@override
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setPreferredOrientations
(
[
DeviceOrientation
.
portraitDown
,
DeviceOrientation
.
portraitUp
]);
return
WillPopScope
(
onWillPop:
()
{
return
showDialog
(
context:
context
,
builder:
(
context
)
=>
AlertDialog
(
title:
Text
(
"QuizStar - Warning"
,
),
content:
Text
(
"You can't go back at this stage"
),
actions:
<
Widget
>[
FlatButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
child:
Text
(
'OK'
,
),
)
],
));
},
child:
Scaffold
(
body:
Column
(
children:
<
Widget
>[
Expanded
(
flex:
5
,
child:
Material
(
elevation:
20.0
,
child:
Container
(
width:
200.0
,
height:
150.0
,
child:
Column
(
children:
<
Widget
>[
Material
(
child:
Container
(
width:
200.0
,
height:
200.0
,
child:
ClipRRect
(
child:
Image
(
image:
AssetImage
(
"lib/assets/images/
$hangState
.png"
),
),
),
),
),
],
)),
),
),
Expanded
(
flex:
2
,
child:
Container
(
padding:
EdgeInsets
.
all
(
15.0
),
alignment:
Alignment
.
bottomLeft
,
child:
Text
(
mydata
[
0
][
i
.
toString
()],
style:
TextStyle
(
fontSize:
16.0
,
fontWeight:
FontWeight
.
w700
,
),
),
decoration:
BoxDecoration
(
color:
Colors
.
blueAccent
,
),
),
),
Expanded
(
flex:
6
,
child:
Container
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
choicebutton
(
'a'
),
choicebutton
(
'b'
),
choicebutton
(
'c'
),
choicebutton
(
'd'
),
],
),
),
),
Expanded
(
flex:
1
,
child:
Container
(
alignment:
Alignment
.
topCenter
,
child:
Center
(
child:
Text
(
showtimer
,
style:
TextStyle
(
fontSize:
35.0
,
fontWeight:
FontWeight
.
w700
,
),
),
),
decoration:
BoxDecoration
(
color:
Colors
.
red
,
),
),
),
],
),
),
);
}
}
lib/STracker/maskWearingQuizStartPage.dart
0 → 100644
View file @
b278e65d
import
'package:covidefender/STracker/maskWearingQuizPage.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
class
maskWearingQuizStartPage
extends
StatefulWidget
{
@override
_maskWearingQuizStartPageState
createState
()
=>
_maskWearingQuizStartPageState
();
}
class
_maskWearingQuizStartPageState
extends
State
<
maskWearingQuizStartPage
>
{
List
<
String
>
images
=
[
"lib/assets/images/startQuiz.png"
,
];
Widget
customcard
(
String
type
,
String
image
)
{
return
Padding
(
padding:
EdgeInsets
.
all
(
20.0
,
),
child:
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=>
getjsonMaskWearing
(),
));
},
child:
Material
(
color:
Colors
.
indigoAccent
,
elevation:
10.0
,
borderRadius:
BorderRadius
.
circular
(
20.0
),
child:
Container
(
child:
Column
(
children:
<
Widget
>[
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
10.0
,
),
child:
Material
(
elevation:
5.0
,
borderRadius:
BorderRadius
.
circular
(
100.0
),
child:
Container
(
height:
100.0
,
width:
100.0
,
child:
ClipOval
(
child:
Image
(
fit:
BoxFit
.
contain
,
image:
AssetImage
(
image
,
),
),
),
),
),
),
Center
(
child:
Text
(
type
,
style:
TextStyle
(
fontSize:
24.0
,
fontWeight:
FontWeight
.
w700
,
),
),
),
],
),
),
),
),
);
}
@override
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setPreferredOrientations
(
[
DeviceOrientation
.
portraitDown
,
DeviceOrientation
.
portraitUp
]);
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"STracker"
),
),
body:
ListView
(
children:
<
Widget
>[
customcard
(
"Start Quiz"
,
images
[
0
]),
],
),
);
}
}
lib/STracker/maskWearingResultPage.dart
0 → 100644
View file @
b278e65d
import
'package:covidefender/STracker/finalResult.dart'
;
import
'package:flutter/material.dart'
;
import
'levelsDashboard.dart'
;
import
'variables.dart'
;
class
maskWearingResultPage
extends
StatefulWidget
{
int
marks
;
maskWearingResultPage
({
Key
key
,
@required
this
.
marks
})
:
super
(
key:
key
);
@override
_maskWearingResultPageState
createState
()
=>
_maskWearingResultPageState
(
marks
);
}
class
_maskWearingResultPageState
extends
State
<
maskWearingResultPage
>
{
int
marks
;
_maskWearingResultPageState
(
this
.
marks
);
@override
void
initState
()
{
testMethod
();
super
.
initState
();
}
void
testMethod
()
{
marks2
=
this
.
marks
;
}
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"Result for Mask Wearing"
,
),
),
body:
Column
(
children:
<
Widget
>[
Expanded
(
flex:
7
,
child:
Material
(
elevation:
10.0
,
child:
Container
(
width:
300.0
,
height:
300.0
,
child:
Column
(
children:
<
Widget
>[
Material
(
child:
Container
(
width:
300.0
,
height:
300.0
,
child:
ClipRRect
(
child:
Image
(
image:
AssetImage
(
"lib/assets/images/gameover.jpg"
),
),
),
),
),
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
5.0
,
horizontal:
15.0
,
),
child:
Center
(
child:
Text
(
"You Scored
$marks
marks"
,
style:
TextStyle
(
fontSize:
20.0
,
fontWeight:
FontWeight
.
w700
,
),
),
)),
// Padding(
// padding: EdgeInsets.symmetric(
// vertical: 5.0,
// horizontal: 15.0,
// ),
// child: Center(
// child: Text(
// "You Scored $marks2 marks",
// style: TextStyle(
// fontSize: 20.0,
// fontWeight: FontWeight.w700,
// ),
// ),
// ))
],
)),
),
),
Expanded
(
flex:
4
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
OutlineButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=>
finalResult
(),
));
},
child:
Text
(
"Continue"
,
style:
TextStyle
(
fontSize:
18.0
,
),
),
padding:
EdgeInsets
.
symmetric
(
vertical:
10.0
,
horizontal:
25.0
,
),
borderSide:
BorderSide
(
width:
3.0
,
color:
Colors
.
indigo
),
splashColor:
Colors
.
indigoAccent
,
)
],
),
)
],
),
);
}
}
lib/STracker/resultpage.dart
View file @
b278e65d
import
'package:covidefender/STracker/quizpage.dart'
;
import
'package:flutter/material.dart'
;
import
'levelsDashboard.dart'
;
import
'variables.dart'
;
class
resultpage
extends
StatefulWidget
{
int
marks
;
...
...
@@ -12,7 +14,17 @@ class resultpage extends StatefulWidget {
class
_resultpageState
extends
State
<
resultpage
>
{
int
marks
;
_resultpageState
(
this
.
marks
);
@override
void
initState
()
{
testMethod
();
super
.
initState
();
}
void
testMethod
()
{
marks1
=
this
.
marks
;
}
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
...
...
lib/STracker/variables.dart
0 → 100644
View file @
b278e65d
//global variables for STracker
int
marks1
=
0
;
int
marks2
=
0
;
int
marks3
=
0
;
int
marks4
=
0
;
int
marks5
=
0
;
lib/assets/pythonMaskWearing.json
0 → 100644
View file @
b278e65d
[
{
"1"
:
"Question 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
"2"
:
"Question 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
,
"3"
:
"Question 3: ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
,
"4"
:
"Question 4: ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
,
"5"
:
"Question 5: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
},
{
"1"
:
{
"a"
:
"Keep my hands beautiful"
,
"b"
:
"Wash my hands of germs"
,
"c"
:
"To get smooth feel to hand"
,
"d"
:
"To get a new look on hand"
},
"2"
:
{
"a"
:
"Operate by hand"
,
"b"
:
"Operate by mouth"
,
"c"
:
"Operate by nose"
,
"d"
:
"Operate by leg"
},
"3"
:
{
"a"
:
"May be"
,
"b"
:
"Sometimes"
,
"c"
:
"Yes, it is must"
,
"d"
:
"Never"
},
"4"
:
{
"a"
:
"Yes. must to do"
,
"b"
:
"Sometimes"
,
"c"
:
"No need to do always"
,
"d"
:
"Not applicable"
},
"5"
:
{
"a"
:
"Tank water"
,
"b"
:
"Filtered water"
,
"c"
:
"Clean, running water"
,
"d"
:
"Well water"
}
},
{
"1"
:
"Wash my hands of germs"
,
"2"
:
"Operate by leg"
,
"3"
:
"Yes, it is must"
,
"4"
:
"Yes. must to do"
,
"5"
:
"Clean, running water"
}
]
\ No newline at end of file
lib/home_screen.dart
View file @
b278e65d
...
...
@@ -25,7 +25,7 @@ class _HomeScreenState extends State<HomeScreen> {
body:
Stack
(
children:
<
Widget
>[
Container
(
height:
size
.
height
*
.
4
,
height:
size
.
height
*
.
2
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
alignment:
Alignment
.
topCenter
,
...
...
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