diff --git a/lib/src/pages/quiz_app/category.dart b/lib/src/pages/quiz_app/category.dart new file mode 100644 index 00000000..ee1194d8 --- /dev/null +++ b/lib/src/pages/quiz_app/category.dart @@ -0,0 +1,9 @@ +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class Category{ + final int id; + final String name; + final dynamic icon; + Category(this.id, this.name, {this.icon}); + +} diff --git a/lib/src/pages/quiz_app/check_answers.dart b/lib/src/pages/quiz_app/check_answers.dart new file mode 100644 index 00000000..53a89837 --- /dev/null +++ b/lib/src/pages/quiz_app/check_answers.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_custom_clippers/flutter_custom_clippers.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/home.dart'; +import 'question.dart'; + +class CheckAnswersPage extends StatelessWidget { + final List questions; + final Map answers; + + const CheckAnswersPage({Key key, @required this.questions, @required this.answers}) : super(key: key); + + @override + Widget build(BuildContext context){ + return Scaffold( + appBar: AppBar( + title: Text('Check Answers'), + elevation: 0, + ), + body: Stack( + children: [ + ClipPath( + clipper: WaveClipperTwo(), + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).primaryColor + ), + height: 200, + ), + ), + ListView.builder( + padding: const EdgeInsets.all(16.0), + itemCount: questions.length+1, + itemBuilder: _buildItem, + + ) + ], + ), + ); + } + Widget _buildItem(BuildContext context, int index) { + if(index == questions.length) { + return RaisedButton( + child: Text("Done"), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0) + ), + color: Theme.of(context).primaryColor, + textColor: Colors.white, + onPressed: (){ + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (_) => QuizHomePage() + )); + }, + ); + } + Question question = questions[index]; + bool correct = question.correctAnswer == answers[index]; + return Card( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(question.question, style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w500, + fontSize: 16.0 + ),), + SizedBox(height: 5.0), + Text("${answers[index]}", style: TextStyle( + color: correct ? Colors.green : Colors.red, + fontSize: 18.0, + fontWeight: FontWeight.bold + ),), + SizedBox(height: 5.0), + correct ? Container(): Text.rich(TextSpan( + children: [ + TextSpan(text: "Answer: "), + TextSpan(text:question.correctAnswer , style: TextStyle( + fontWeight: FontWeight.w500 + )) + ] + ),style: TextStyle( + fontSize: 16.0 + ),) + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/src/pages/quiz_app/demo_values.dart b/lib/src/pages/quiz_app/demo_values.dart new file mode 100644 index 00000000..2ee7c5a8 --- /dev/null +++ b/lib/src/pages/quiz_app/demo_values.dart @@ -0,0 +1,154 @@ + +//questions taken from https://opentdb.com +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import 'category.dart'; +import 'question.dart'; + +const Map demoAnswers = { + 0:"Multi Pass", + 1:1, + 2:"Motherboard", + 3:"Cascading Style Sheet", + 4:"Marshmallow", + 5:"140", + 6:"Python", + 7:"True", + 8:"Jakarta" +}; + +final List categories = [ + Category(9,"General Knowledge", icon: FontAwesomeIcons.globeAsia), + Category(10,"Books", icon: FontAwesomeIcons.bookOpen), + Category(11,"Film", icon: FontAwesomeIcons.video), + Category(12,"Music", icon: FontAwesomeIcons.music), + Category(13,"Musicals & Theatres", icon: FontAwesomeIcons.theaterMasks), + Category(14,"Television", icon: FontAwesomeIcons.tv), + Category(15,"Video Games", icon: FontAwesomeIcons.gamepad), + Category(16,"Board Games", icon: FontAwesomeIcons.chessBoard), + Category(17,"Science & Nature", icon: FontAwesomeIcons.microscope), + Category(18,"Computer", icon: FontAwesomeIcons.laptopCode), + Category(19,"Maths", icon: FontAwesomeIcons.sortNumericDown), + Category(20,"Mythology"), + Category(21,"Sports", icon: FontAwesomeIcons.footballBall), + Category(22,"Geography", icon: FontAwesomeIcons.mountain), + Category(23,"History", icon: FontAwesomeIcons.monument), + Category(24,"Politics"), + Category(25,"Art", icon: FontAwesomeIcons.paintBrush), + Category(26,"Celebrities"), + Category(27,"Animals", icon: FontAwesomeIcons.dog), + Category(28,"Vehicles", icon: FontAwesomeIcons.carAlt), + Category(29,"Comics"), + Category(30,"Gadgets", icon: FontAwesomeIcons.mobileAlt), + Category(31,"Japanese Anime & Manga"), + Category(32,"Cartoon & Animation"), +]; + +final List demoQuestions = Question.fromData([ + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "What does the \"MP\" stand for in MP3?", + "correct_answer": "Moving Picture", + "incorrect_answers": [ + "Music Player", + "Multi Pass", + "Micro Point" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "What amount of bits commonly equals one byte?", + "correct_answer": "8", + "incorrect_answers": [ + "1", + "2", + "64" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "Which computer hardware device provides an interface for all other connected devices to communicate?", + "correct_answer": "Motherboard", + "incorrect_answers": [ + "Central Processing Unit", + "Hard Disk Drive", + "Random Access Memory" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "In web design, what does CSS stand for?", + "correct_answer": "Cascading Style Sheet", + "incorrect_answers": [ + "Counter Strike: Source", + "Corrective Style Sheet", + "Computer Style Sheet" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "What is the code name for the mobile operating system Android 7.0?", + "correct_answer": "Nougat", + "incorrect_answers": [ + "Ice Cream Sandwich", + "Jelly Bean", + "Marshmallow" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "On Twitter, what is the character limit for a Tweet?", + "correct_answer": "140", + "incorrect_answers": [ + "120", + "160", + "100" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "Which computer language would you associate Django framework with?", + "correct_answer": "Python", + "incorrect_answers": [ + "C#", + "C++", + "Java" + ] + }, + { + "category": "Science: Computers", + "type": "boolean", + "difficulty": "easy", + "question": "The Windows 7 operating system has six main editions.", + "correct_answer": "True", + "incorrect_answers": [ + "False" + ] + }, + { + "category": "Science: Computers", + "type": "multiple", + "difficulty": "easy", + "question": "Which programming language shares its name with an island in Indonesia?", + "correct_answer": "Java", + "incorrect_answers": [ + "Python", + "C", + "Jakarta" + ] + } + ]); \ No newline at end of file diff --git a/lib/src/pages/quiz_app/home.dart b/lib/src/pages/quiz_app/home.dart new file mode 100644 index 00000000..2bbcc4cf --- /dev/null +++ b/lib/src/pages/quiz_app/home.dart @@ -0,0 +1,115 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_custom_clippers/flutter_custom_clippers.dart'; +import 'category.dart'; +import 'demo_values.dart'; +import 'quiz_options.dart'; + +class QuizHomePage extends StatelessWidget { + final List tileColors = [ + Colors.green, + Colors.blue, + Colors.purple, + Colors.pink, + Colors.indigo, + Colors.lightBlue, + Colors.amber, + Colors.deepOrange, + Colors.red, + Colors.brown + ]; + + @override + Widget build(BuildContext context){ + return Scaffold( + appBar: AppBar( + title: Text('OpenTrivia'), + elevation: 0, + ), + body: Stack( + children: [ + ClipPath( + clipper: WaveClipperTwo(), + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).primaryColor + ), + height: 200, + ), + ), + CustomScrollView( + physics: BouncingScrollPhysics(), + slivers: [ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0,vertical: 8.0), + child: Text("Select a category to start the quiz", style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 16.0 + ),), + ), + ), + SliverPadding( + padding: const EdgeInsets.all(16.0), + sliver: SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 1.2, + crossAxisSpacing: 10.0, + mainAxisSpacing: 10.0 + ), + delegate: SliverChildBuilderDelegate( + _buildCategoryItem, + childCount: categories.length, + + ) + + ), + ), + ], + ), + ], + ) + ); + } + + Widget _buildCategoryItem(BuildContext context, int index) { + Category category = categories[index]; + return MaterialButton( + elevation: 1.0, + highlightElevation: 1.0, + onPressed: () => _categoryPressed(context,category), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + color: Colors.grey.shade800, + textColor: Colors.white70, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if(category.icon != null) + Icon(category.icon), + if(category.icon != null) + SizedBox(height: 5.0), + Text( + category.name, + textAlign: TextAlign.center, + maxLines: 3,), + ], + ), + ); + } + + _categoryPressed(BuildContext context,Category category) { + showModalBottomSheet( + context: context, + builder: (sheetContext) => BottomSheet( + builder: (_) => QuizOptionsDialog(category: category,), + onClosing: (){}, + + ), + + ); + + } +} \ No newline at end of file diff --git a/lib/src/pages/quiz_app/question.dart b/lib/src/pages/quiz_app/question.dart new file mode 100644 index 00000000..ecafab9a --- /dev/null +++ b/lib/src/pages/quiz_app/question.dart @@ -0,0 +1,34 @@ +enum Type { + multiple, + boolean +} + +enum Difficulty { + easy, + medium, + hard +} + +class Question { + final String categoryName; + final Type type; + final Difficulty difficulty; + final String question; + final String correctAnswer; + final List incorrectAnswers; + + Question({this.categoryName, this.type, this.difficulty, this.question, this.correctAnswer, this.incorrectAnswers}); + + Question.fromMap(Map data): + categoryName = data["category"], + type = data["type"] == "multiple" ? Type.multiple : Type.boolean, + difficulty = data["difficulty"] == "easy" ? Difficulty.easy : data["difficulty"] == "medium" ? Difficulty.medium : Difficulty.hard, + question = data["question"], + correctAnswer = data["correct_answer"], + incorrectAnswers = data["incorrect_answers"]; + + static List fromData(List> data){ + return data.map((question) => Question.fromMap(question)).toList(); + } + +} \ No newline at end of file diff --git a/lib/src/pages/quiz_app/quiz_finished.dart b/lib/src/pages/quiz_app/quiz_finished.dart new file mode 100644 index 00000000..08ac4422 --- /dev/null +++ b/lib/src/pages/quiz_app/quiz_finished.dart @@ -0,0 +1,132 @@ +import 'package:flutter/material.dart'; +import 'question.dart'; +import 'check_answers.dart'; + +class QuizFinishedPage extends StatelessWidget { + final List questions; + final Map answers; + + QuizFinishedPage({Key key, @required this.questions, @required this.answers}): super(key: key) { + + } + + @override + Widget build(BuildContext context){ + int correct = 0; + this.answers.forEach((index,value){ + if(this.questions[index].correctAnswer == value) + correct++; + }); + final TextStyle titleStyle = TextStyle( + color: Colors.black87, + fontSize: 16.0, + fontWeight: FontWeight.w500 + ); + final TextStyle trailingStyle = TextStyle( + color: Theme.of(context).primaryColor, + fontSize: 20.0, + fontWeight: FontWeight.bold + ); + + return Scaffold( + appBar: AppBar( + title: Text('Result'), + elevation: 0, + ), + body: Container( + height: double.infinity, + width: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).primaryColor, + Theme.of(context).accentColor + ], + begin: Alignment.topCenter, + end: Alignment.bottomCenter + ) + ), + child: SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0) + ), + child: ListTile( + contentPadding: const EdgeInsets.all(16.0), + title: Text("Total Questions", style: titleStyle), + trailing: Text("${questions.length}", style: trailingStyle), + ), + ), + SizedBox(height: 10.0), + Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0) + ), + child: ListTile( + contentPadding: const EdgeInsets.all(16.0), + title: Text("Score", style: titleStyle), + trailing: Text("${correct/questions.length * 100}%", style: trailingStyle), + ), + ), + SizedBox(height: 10.0), + Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0) + ), + child: ListTile( + contentPadding: const EdgeInsets.all(16.0), + title: Text("Correct Answers", style: titleStyle), + trailing: Text("$correct/${questions.length}", style: trailingStyle), + ), + ), + SizedBox(height: 10.0), + Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0) + ), + child: ListTile( + contentPadding: const EdgeInsets.all(16.0), + title: Text("Incorrect Answers", style: titleStyle), + trailing: Text("${questions.length - correct}/${questions.length}", style: trailingStyle), + ), + ), + SizedBox(height: 20.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + RaisedButton( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + color: Colors.pink.withOpacity(0.8), + textColor: Colors.white, + child: Text("Goto Home"), + onPressed: () => Navigator.pop(context), + ), + RaisedButton( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + color: Colors.deepPurple.withOpacity(0.8), + textColor: Colors.white, + child: Text("Check Answers"), + onPressed: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => CheckAnswersPage(questions: questions, answers: answers,) + )); + }, + ), + ], + ) + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/src/pages/quiz_app/quiz_options.dart b/lib/src/pages/quiz_app/quiz_options.dart new file mode 100644 index 00000000..900c5808 --- /dev/null +++ b/lib/src/pages/quiz_app/quiz_options.dart @@ -0,0 +1,167 @@ +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'category.dart'; +import 'demo_values.dart'; +import 'question.dart'; +import 'quiz_page.dart'; + +class QuizOptionsDialog extends StatefulWidget { + final Category category; + + const QuizOptionsDialog({Key key, this.category}) : super(key: key); + + @override + _QuizOptionsDialogState createState() => _QuizOptionsDialogState(); +} + +class _QuizOptionsDialogState extends State { + int _noOfQuestions; + String _difficulty; + bool processing; + + @override + void initState() { + super.initState(); + _noOfQuestions = 10; + _difficulty = "easy"; + processing = false; + } + + @override + Widget build(BuildContext context){ + return SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + padding: const EdgeInsets.all(16.0), + color: Colors.grey.shade200, + child: Text(widget.category.name, style: Theme.of(context).textTheme.title.copyWith(),), + ), + SizedBox(height: 10.0), + Text("Select Total Number of Questions"), + SizedBox( + width: double.infinity, + child: Wrap( + alignment: WrapAlignment.center, + runAlignment: WrapAlignment.center, + runSpacing: 16.0, + spacing: 16.0, + children: [ + SizedBox(width: 0.0), + ActionChip( + label: Text("10"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _noOfQuestions == 10 ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectNumberOfQuestions(10), + ), + ActionChip( + label: Text("20"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _noOfQuestions == 20 ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectNumberOfQuestions(20), + ), + ActionChip( + label: Text("30"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _noOfQuestions == 30 ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectNumberOfQuestions(30), + ), + ActionChip( + label: Text("40"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _noOfQuestions == 40 ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectNumberOfQuestions(40), + ), + ActionChip( + label: Text("50"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _noOfQuestions == 50 ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectNumberOfQuestions(50), + ), + + ], + ), + ), + SizedBox(height: 20.0), + Text("Select Difficulty"), + SizedBox( + width: double.infinity, + child: Wrap( + alignment: WrapAlignment.center, + runAlignment: WrapAlignment.center, + runSpacing: 16.0, + spacing: 16.0, + children: [ + SizedBox(width: 0.0), + ActionChip( + label: Text("Any"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _difficulty == null ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectDifficulty(null), + ), + ActionChip( + label: Text("Easy"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _difficulty == "easy" ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectDifficulty("easy"), + ), + ActionChip( + label: Text("Medium"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _difficulty == "medium" ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectDifficulty("medium"), + ), + ActionChip( + label: Text("Hard"), + labelStyle: TextStyle(color: Colors.white), + backgroundColor: _difficulty == "hard" ? Colors.indigo : Colors.grey.shade600, + onPressed: () => _selectDifficulty("hard"), + ), + + ], + ), + ), + SizedBox(height: 20.0), + processing ? CircularProgressIndicator() : RaisedButton( + child: Text("Start Quiz"), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0) + ), + color: Theme.of(context).primaryColor, + textColor: Colors.white, + onPressed: _startQuiz, + ), + SizedBox(height: 20.0), + ], + ), + ); + } + + _selectNumberOfQuestions(int i) { + setState(() { + _noOfQuestions = i; + }); + } + + _selectDifficulty(String s) { + setState(() { + _difficulty=s; + }); + } + + void _startQuiz() async { + setState(() { + processing=true; + }); + + List questions = demoQuestions; + Navigator.pop(context); + Navigator.push(context, MaterialPageRoute( + builder: (_) => QuizPage(questions: questions, category: widget.category,) + )); + setState(() { + processing=false; + }); + } +} \ No newline at end of file diff --git a/lib/src/pages/quiz_app/quiz_page.dart b/lib/src/pages/quiz_app/quiz_page.dart new file mode 100644 index 00000000..53b1e76f --- /dev/null +++ b/lib/src/pages/quiz_app/quiz_page.dart @@ -0,0 +1,160 @@ +import 'package:flutter/material.dart'; +import 'category.dart'; +import 'question.dart'; +import 'package:flutter_custom_clippers/flutter_custom_clippers.dart'; +import 'quiz_finished.dart'; + +class QuizPage extends StatefulWidget { + final List questions; + final Category category; + + const QuizPage({Key key, @required this.questions, this.category}) : super(key: key); + + @override + _QuizPageState createState() => _QuizPageState(); +} + +class _QuizPageState extends State { + final TextStyle _questionStyle = TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.w500, + color: Colors.white + ); + + int _currentIndex = 0; + final Map _answers = {}; + final GlobalKey _key = GlobalKey(); + + + @override + Widget build(BuildContext context){ + Question question = widget.questions[_currentIndex]; + final List options = question.incorrectAnswers; + if(!options.contains(question.correctAnswer)) { + options.add(question.correctAnswer); + options.shuffle(); + } + + return WillPopScope( + onWillPop: _onWillPop, + child: Scaffold( + key: _key, + appBar: AppBar( + title: Text(widget.category.name), + elevation: 0, + ), + body: Stack( + children: [ + ClipPath( + clipper: WaveClipperTwo(), + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).primaryColor + ), + height: 200, + ), + ), + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Row( + children: [ + CircleAvatar( + backgroundColor: Colors.white70, + child: Text("${_currentIndex+1}"), + ), + SizedBox(width: 16.0), + Expanded( + child: Text(widget.questions[_currentIndex].question, + softWrap: true, + style: _questionStyle,), + ), + ], + ), + + SizedBox(height: 20.0), + Card( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ...options.map((option)=>RadioListTile( + title: Text("$option"), + groupValue: _answers[_currentIndex], + value: option, + onChanged: (value){ + setState(() { + _answers[_currentIndex] = option; + }); + }, + )), + ], + ), + ), + Expanded( + child: Container( + alignment: Alignment.bottomCenter, + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0) + ), + color: Theme.of(context).primaryColor, + textColor: Colors.white, + child: Text( _currentIndex == (widget.questions.length - 1) ? "Submit" : "Next"), + onPressed: _nextSubmit, + ), + ), + ) + ], + ), + ) + ], + ), + ), + ); + } + + void _nextSubmit() { + if(_answers[_currentIndex] == null) { + _key.currentState.showSnackBar(SnackBar( + content: Text("You must select an answer to continue."), + )); + return; + } + if(_currentIndex < (widget.questions.length - 1)){ + setState(() { + _currentIndex++; + }); + } else { + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (_) => QuizFinishedPage(questions: widget.questions, answers: _answers) + )); + } + } + + Future _onWillPop() async { + return showDialog( + context: context, + builder: (_) { + return AlertDialog( + content: Text("Are you sure you want to quit the quiz? All your progress will be lost."), + title: Text("Warning!"), + actions: [ + FlatButton( + child: Text("Yes"), + onPressed: (){ + Navigator.pop(context,true); + }, + ), + FlatButton( + child: Text("No"), + onPressed: (){ + Navigator.pop(context,false); + }, + ), + ], + ); + } + ); + } +} \ No newline at end of file diff --git a/lib/src/widgets/main_menu.dart b/lib/src/widgets/main_menu.dart index 09b6b0cf..9629dd94 100644 --- a/lib/src/widgets/main_menu.dart +++ b/lib/src/widgets/main_menu.dart @@ -1,5 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_ui_challenges/src/pages/login/auth1.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/check_answers.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/demo_values.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/home.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/quiz_finished.dart'; +import 'package:flutter_ui_challenges/src/pages/quiz_app/quiz_page.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_ui_challenges/src/pages/blog/article1.dart'; @@ -76,6 +82,12 @@ class _MainMenuState extends State { SubMenuItem("Recipe Details", RecipeDetailsPage()), SubMenuItem("Food Delivery", FoodDeliveryHomePage()), ]), + MenuItem(title: "Quiz app", icon: FontAwesomeIcons.question, items: [ + SubMenuItem("Quiz Home", QuizHomePage()), + SubMenuItem("Quiz Page", QuizPage(questions: demoQuestions, category: categories[9],)), + SubMenuItem("Quiz Result", QuizFinishedPage(questions: demoQuestions, answers: demoAnswers,)), + SubMenuItem("Check Answers", CheckAnswersPage(questions: demoQuestions, answers: demoAnswers,)), + ]), MenuItem(title: "Travel", icon: Icons.airplanemode_active, items: [ SubMenuItem("Travel Home", TravelHomePage()), SubMenuItem("Travel Nepal", TravelNepalPage()),