Skip to content

Commit a0c31dd

Browse files
author
mercy
committed
Feat: Add functionality to trivia questions
1 parent be56f45 commit a0c31dd

File tree

10 files changed

+292
-43
lines changed

10 files changed

+292
-43
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ https://askubuntu.com/questions/1029117/unable-to-install-package-snap-package-h
55
https://www.youtube.com/watch?v=FV5k56IJWsk
66
# learn-flutter-development
77
Fundermantal Flutter practices
8+
9+
# Git fundermentals
10+
https://www.freecodecamp.org/news/pushing-to-github-made-simple-enough-for-poets/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import 'package:audioplayers/audio_cache.dart';
2+
import 'package:flutter/material.dart';
23

34
void playSound(int soundNumber) {
45
final AudioCache player = AudioCache();
56
player.play('note$soundNumber.wav');
67
}
8+
9+
void routeFunction(BuildContext context, String route) {
10+
Navigator.pushNamed(context, route);
11+
}

lib/application/theme/colors.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
const Color white = Color(0xFFFFFFFF);
4+
const Color green = Colors.green;
5+
const Color red = Colors.red;
46
const Color statusBackgroundColor = Color(0xFF10B8B8);
57
const Color grey = Color.fromRGBO(220, 220, 220, 1.0);

lib/presentation/dashboard.dart

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/presentation/pages/dashboard.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import 'dart:ui';
2+
3+
import 'package:app_name/application/theme/colors.dart';
4+
import 'package:app_name/presentation/router/routes.dart';
5+
import 'package:app_name/presentation/widget/widgets.dart';
6+
import 'package:flutter/material.dart';
7+
8+
class Dashboard extends StatelessWidget {
9+
const Dashboard({Key key}) : super(key: key);
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
appBar: AppBar(
15+
centerTitle: true,
16+
title: Text(
17+
'DASHBOARD',
18+
style: TextStyle(color: white),
19+
),
20+
),
21+
body: Container(
22+
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 2.0),
23+
child: GridView.count(
24+
crossAxisCount: 2,
25+
padding: EdgeInsets.all(3.0),
26+
children: <Widget>[
27+
makeDashboardItem(
28+
context,
29+
pianoPageRoute,
30+
"Piano",
31+
Icons.alarm,
32+
),
33+
makeDashboardItem(
34+
context,
35+
quizePageRoute,
36+
"Quize",
37+
Icons.book,
38+
),
39+
makeDashboardItem(
40+
context,
41+
pianoPageRoute,
42+
"Alphabet",
43+
Icons.alarm,
44+
),
45+
makeDashboardItem(
46+
context,
47+
pianoPageRoute,
48+
"Alphabet",
49+
Icons.alarm,
50+
),
51+
makeDashboardItem(
52+
context,
53+
pianoPageRoute,
54+
"Alphabet",
55+
Icons.alarm,
56+
),
57+
makeDashboardItem(
58+
context,
59+
pianoPageRoute,
60+
"Alphabet",
61+
Icons.alarm,
62+
),
63+
],
64+
),
65+
),
66+
);
67+
}
68+
}

lib/presentation/pages/piano.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class _XyloPhoneAppState extends State<XyloPhoneApp> {
2323
),
2424
body: SafeArea(
2525
child: Container(
26+
padding: EdgeInsets.only(top: 20),
2627
child: Column(
2728
crossAxisAlignment: CrossAxisAlignment.stretch,
2829
children: <Widget>[

lib/presentation/pages/quize.dart

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import 'package:app_name/application/theme/colors.dart';
2+
import 'package:app_name/presentation/widget/widgets.dart';
3+
import 'package:flutter/material.dart';
4+
5+
class Quizzler extends StatefulWidget {
6+
Quizzler({Key key}) : super(key: key);
7+
8+
@override
9+
_QuizzlerState createState() => _QuizzlerState();
10+
}
11+
12+
class _QuizzlerState extends State<Quizzler> {
13+
int triviaQuestionNo = 0;
14+
int listLength = bibleTrivia.length;
15+
16+
@override
17+
Widget build(BuildContext context) {
18+
return Scaffold(
19+
backgroundColor: Colors.black,
20+
appBar: AppBar(
21+
centerTitle: true,
22+
backgroundColor: green,
23+
title: Text(
24+
'Bible Trivia',
25+
style: TextStyle(
26+
color: Colors.white,
27+
),
28+
),
29+
),
30+
body: SafeArea(
31+
child: Padding(
32+
padding: EdgeInsets.symmetric(horizontal: 10),
33+
child: Column(
34+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
35+
crossAxisAlignment: CrossAxisAlignment.stretch,
36+
children: <Widget>[
37+
textWidget(
38+
questionNo[triviaQuestionNo],
39+
white,
40+
),
41+
textWidget(
42+
bibleTrivia[triviaQuestionNo],
43+
white,
44+
),
45+
textWidget(
46+
choices[triviaQuestionNo],
47+
white,
48+
),
49+
Expanded(
50+
child: Padding(
51+
padding: const EdgeInsets.all(10.0),
52+
child: TextButton(
53+
onPressed: () {
54+
bool correctAnswer =
55+
triviaAnswers[triviaQuestionNo];
56+
if (correctAnswer == true) {
57+
setState(() {
58+
scoreKeeper.add(
59+
Icon(
60+
Icons.check,
61+
color: green,
62+
),
63+
);
64+
65+
triviaQuestionNo++;
66+
});
67+
} else {
68+
setState(() {
69+
scoreKeeper
70+
.add(Icon(Icons.close, color: red));
71+
triviaQuestionNo++;
72+
});
73+
}
74+
},
75+
child: Text(
76+
"True",
77+
style: TextStyle(
78+
color: Colors.white,
79+
fontSize: 20.0,
80+
),
81+
),
82+
style: TextButton.styleFrom(
83+
backgroundColor: green,
84+
),
85+
),
86+
),
87+
),
88+
Expanded(
89+
child: Padding(
90+
padding: const EdgeInsets.all(10.0),
91+
child: TextButton(
92+
onPressed: () {
93+
bool correctAnswer =
94+
triviaAnswers[triviaQuestionNo];
95+
if (correctAnswer == false) {
96+
setState(() {
97+
scoreKeeper
98+
.add(Icon(Icons.check, color: green));
99+
triviaQuestionNo++;
100+
});
101+
} else {
102+
setState(() {
103+
scoreKeeper
104+
.add(Icon(Icons.close, color: red));
105+
triviaQuestionNo++;
106+
});
107+
}
108+
},
109+
child: Text(
110+
'False',
111+
style: TextStyle(
112+
color: Colors.white,
113+
fontSize: 20.0,
114+
),
115+
),
116+
style: TextButton.styleFrom(
117+
backgroundColor: red,
118+
),
119+
),
120+
),
121+
),
122+
Row(children: scoreKeeper)
123+
]))));
124+
}
125+
}

lib/presentation/router/router_generator.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import 'package:app_name/presentation/dashboard.dart';
1+
import 'package:app_name/presentation/pages/dashboard.dart';
22
import 'package:app_name/presentation/pages/error.dart';
33
import 'package:app_name/presentation/pages/piano.dart';
4+
import 'package:app_name/presentation/pages/quize.dart';
45
import 'package:app_name/presentation/router/routes.dart';
56
import 'package:flutter/material.dart';
67

@@ -10,9 +11,12 @@ class RouterNavigator {
1011
case '/':
1112
return MaterialPageRoute<Dashboard>(builder: (context) => Dashboard());
1213

13-
case homePageRoute:
14+
case dashboardPageRoute:
1415
return MaterialPageRoute<Dashboard>(builder: (context) => Dashboard());
1516

17+
case quizePageRoute:
18+
return MaterialPageRoute<Quizzler>(builder: (context) => Quizzler());
19+
1620
case pianoPageRoute:
1721
return MaterialPageRoute<XyloPhoneApp>(
1822
builder: (context) => XyloPhoneApp());

lib/presentation/router/routes.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const String pianoPageRoute = '/piano';
22

3-
const String homePageRoute = '/';
4-
53
const String dashboardPageRoute = '/dashboard';
64

7-
const String resetPinRoute = '/resetPin';
5+
const String quizePageRoute = '/quize';
86

97
const String phoneSignupRoute = '/phoneSignup';

0 commit comments

Comments
 (0)