diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..5ae2905 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Sun Jun 23 18:56:31 IST 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/lib/main.dart b/lib/main.dart index d1900fb..d6204a6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,6 +4,7 @@ import 'package:learn/landing_page.dart'; import 'package:learn/pages/main_home.dart'; import 'package:learn/utils/route/routes.dart'; import 'package:learn/theme_provider.dart'; +// ignore: depend_on_referenced_packages import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/lib/pages/explore/drawingboard.dart b/lib/pages/explore/drawingboard.dart index b3c33de..4bf2e8f 100644 --- a/lib/pages/explore/drawingboard.dart +++ b/lib/pages/explore/drawingboard.dart @@ -1,13 +1,16 @@ +// ignore_for_file: library_private_types_in_public_api + import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class DrawingBoardPage extends StatelessWidget { - const DrawingBoardPage({Key? key}); + const DrawingBoardPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return DrawingBoard(); + return const DrawingBoard(); } } @@ -20,7 +23,7 @@ class DrawingBoard extends StatefulWidget { class _DrawingBoardState extends State { Color selectedColor = Colors.black; - double strokeWidth = 5; + double strokeWidth = 5.0; bool isEraser = false; List drawingPoints = []; List colors = [ @@ -38,22 +41,20 @@ class _DrawingBoardState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("Drawing Board"), + title: const Text("Drawing Board"), actions: [ TextButton.icon( onPressed: () => setState(() => drawingPoints = []), - icon: Icon(Icons.clear), - label: Text("Clear Board"), + icon: const Icon(Icons.clear), + label: const Text("Clear Board"), style: TextButton.styleFrom( - backgroundColor: Color(0xfff7f2fa), + foregroundColor: Colors.black, // Changed for better visibility + backgroundColor: const Color(0xfff7f2fa), ), - ), - SizedBox( - width: 10, ), + const SizedBox(width: 10), ], - ), - + ), body: Stack( children: [ GestureDetector( @@ -63,7 +64,7 @@ class _DrawingBoardState extends State { DrawingPoint( details.localPosition, Paint() - ..color = isEraser? Color(0xfffef7ff) : selectedColor + ..color = isEraser ? const Color(0xfffef7ff) : selectedColor ..isAntiAlias = true ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round, @@ -71,14 +72,13 @@ class _DrawingBoardState extends State { ); }); }, - onPanUpdate: (details) { setState(() { drawingPoints.add( DrawingPoint( details.localPosition, Paint() - ..color = isEraser? Color(0xfffef7ff) : selectedColor + ..color = isEraser ? const Color(0xfffef7ff) : selectedColor ..isAntiAlias = true ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round, @@ -86,72 +86,65 @@ class _DrawingBoardState extends State { ); }); }, - onPanEnd: (details) { setState(() { drawingPoints.add(null); }); }, - child: CustomPaint( painter: _DrawingPainter(drawingPoints), - child: Container( + child: SizedBox( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ), ), ), - Positioned( top: 20, right: 10, left: 10, child: Row( children: [ - Slider( - min: 0, - max: 40, - value: strokeWidth, - onChanged: (val) => setState(() => strokeWidth = val), - ), - SizedBox( - width: 50 + Expanded( + child: Slider( + min: 0, + max: 40, + value: strokeWidth, + onChanged: (val) => setState(() => strokeWidth = val), + ), ), + const SizedBox(width: 10), ElevatedButton.icon( onPressed: () { setState(() { - isEraser =!isEraser; + isEraser = !isEraser; if (isEraser) { - selectedColor = Color(0xfffef7ff); + selectedColor = const Color(0xfffef7ff); } }); }, - icon: Icon(FontAwesomeIcons.eraser), - label: Text("Eraser"), + icon: const Icon(FontAwesomeIcons.eraser), + label: const Text("Eraser"), ), ], ), ), ], ), - bottomNavigationBar: BottomAppBar( child: Container( color: Colors.grey[200], - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: List.generate( - colors.length, - (index) => _buildColorChoser(colors[index]), - ), + children: colors.map((color) => _buildColorChooser(color)).toList(), ), ), ), ); } - GestureDetector _buildColorChoser(Color color) { + GestureDetector _buildColorChooser(Color color) { bool isSelected = selectedColor == color; return GestureDetector( onTap: () { @@ -168,9 +161,9 @@ class _DrawingBoardState extends State { shape: BoxShape.circle, border: isSelected ? Border.all( - color: Colors.white, - width: 3, - ) + color: Colors.white, + width: 3, + ) : null, ), ), @@ -207,8 +200,8 @@ class _DrawingPainter extends CustomPainter { } class DrawingPoint { - Offset offset; - Paint paint; + final Offset offset; + final Paint paint; DrawingPoint(this.offset, this.paint); } diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index 85ae2b0..9061223 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -44,8 +44,41 @@ class _ExplorePageState extends State { [ GestureDetector( onTap: () { - Navigator.pushNamed( - context, AllRoutesConstant.drawingboardRoute); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const Quiz()))); + }, + child: Container( + margin: const EdgeInsets.all(5.0), + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + border: Border.all(color: Colors.black, width: 1.0), + borderRadius: BorderRadius.circular(8.0), + color: Colors.blueAccent, + ), + child: Row( + children: [ + SizedBox( + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, + child: + SvgPicture.asset('assets/explore/notebook.svg'), + ), + const SizedBox(width: ConstantDimensions.widthMedium_Large), + const Text( + 'Quiz', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 30.0, + fontFamily: 'Comic', + color: Colors.white, + ), + ), + ], + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.drawingboardRoute); }, child: Container( margin: const EdgeInsets.all(5.0), @@ -60,11 +93,9 @@ class _ExplorePageState extends State { SizedBox( width: ConstantDimensions.widthExtraLarge, height: ConstantDimensions.heightExtraLarge, - child: SvgPicture.asset( - 'assets/explore/drawing_board.svg'), + child: SvgPicture.asset('assets/explore/drawing_board.svg'), ), - const SizedBox( - width: ConstantDimensions.widthMedium_Large), + const SizedBox(width: ConstantDimensions.widthMedium_Large), const Text( 'Drawing Board', style: TextStyle( @@ -83,57 +114,38 @@ class _ExplorePageState extends State { ), SliverList( delegate: SliverChildBuilderDelegate( - (context, index) { + (context, index) { return GestureDetector( onTap: () { - try { + try{ switch (index) { case 0: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const Quiz()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const Quiz()))); break; case 1: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const AtoZ()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const AtoZ()))); break; case 2: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => BirdsPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => BirdsPage()))); break; case 3: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const ColoursPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const ColoursPage()))); break; case 4: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => BirdsPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => BirdsPage()))); break; case 5: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const ShapesPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const ShapesPage()))); break; case 6: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => PlanetsPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => PlanetsPage()))); break; default: break; } - } catch (e) { + } + catch (e) { + // ignore: avoid_print print(e); } }, @@ -160,7 +172,7 @@ class _ExplorePageState extends State { children: [ ImageFiltered( imageFilter: - ImageFilter.blur(sigmaX: 5, sigmaY: 5), + ImageFilter.blur(sigmaX: 5, sigmaY: 5), child: Image.asset( AppConstants.modules[index].thumbnailPath, fit: BoxFit.cover, diff --git a/lib/pages/fruits.dart b/lib/pages/fruits.dart index 9954f88..96e7087 100644 --- a/lib/pages/fruits.dart +++ b/lib/pages/fruits.dart @@ -175,3 +175,7 @@ class _FruitsPageState extends State { bgColorInit(); } } + +class WidgetStateProperty { + static all(Size size) {} +} diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 9bd354e..f2d4f37 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -1,7 +1,10 @@ +// ignore: unused_import +import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; import 'package:learn/utils/assets_path.dart'; import 'package:learn/utils/const_dimensions.dart'; import 'package:learn/utils/route/route_constant.dart'; +// ignore: depend_on_referenced_packages import 'package:provider/provider.dart'; import '../widgets/drawer.dart'; import '../theme_provider.dart'; diff --git a/lib/pages/main_home.dart b/lib/pages/main_home.dart index f9bc566..602fa21 100644 --- a/lib/pages/main_home.dart +++ b/lib/pages/main_home.dart @@ -1,3 +1,5 @@ + + import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/pages/modules/animals.dart b/lib/pages/modules/animals.dart index c40495b..bbe0cd6 100644 --- a/lib/pages/modules/animals.dart +++ b/lib/pages/modules/animals.dart @@ -8,6 +8,7 @@ import 'package:learn/models/animal_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'animals_test.dart'; class AnimalsPage extends StatelessWidget { final FlutterTts flutterTts = FlutterTts(); @@ -23,6 +24,17 @@ class AnimalsPage extends StatelessWidget { AppConstants.animal, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const AnimalsTestPage()), + ); + }, + ), + ], ), body: ListView.builder( itemCount: AppConstants.animals.length, diff --git a/lib/pages/modules/animals_test.dart b/lib/pages/modules/animals_test.dart new file mode 100644 index 0000000..2bc5200 --- /dev/null +++ b/lib/pages/modules/animals_test.dart @@ -0,0 +1,233 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AnimalQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + AnimalQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class AnimalsTestPage extends StatefulWidget { + const AnimalsTestPage({Key? key}) : super(key: key); + + @override + _AnimalsTestPageState createState() => _AnimalsTestPageState(); +} + +class _AnimalsTestPageState extends State { + List allQuestions = [ + AnimalQuestion( + imageAsset: 'assets/images/animal/lion.svg', + options: ['Lion', 'Tiger', 'Leopard', 'Cheetah'], + correctAnswer: 'Lion', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/elephant.svg', + options: ['Rhino', 'Hippo', 'Elephant', 'Giraffe'], + correctAnswer: 'Elephant', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/cat.svg', + options: ['Dog', 'Cat', 'Rabbit', 'Squirrel'], + correctAnswer: 'Cat', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/deer.svg', + options: ['Deer', 'Moose', 'Antelope', 'Elk'], + correctAnswer: 'Deer', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/dog.svg', + options: ['Wolf', 'Dog', 'Fox', 'Coyote'], + correctAnswer: 'Dog', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/fox.svg', + options: ['Wolf', 'Dog', 'Coyote', 'Fox'], + correctAnswer: 'Fox', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/giraffe.svg', + options: ['Giraffe', 'Elephant', 'Zebra', 'Camel'], + correctAnswer: 'Giraffe', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/monkey.svg', + options: ['Gorilla', 'Chimpanzee', 'Monkey', 'Baboon'], + correctAnswer: 'Monkey', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/pig.svg', + options: ['Pig', 'Boar', 'Hog', 'Warthog'], + correctAnswer: 'Pig', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/rabbit.svg', + options: ['Hare', 'Squirrel', 'Guinea Pig', 'Rabbit'], + correctAnswer: 'Rabbit', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/bear.svg', + options: ['Wolf', 'Fox', 'Bear', 'Dog'], + correctAnswer: 'Bear', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/cow.svg', + options: ['Goat', 'Sheep', 'Buffalo', 'Cow'], + correctAnswer: 'Cow', + ), + ]; + + List questions = []; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + AnimalQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Animals Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index f9b5711..f7678ec 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'dart:async'; import 'package:flutter_tts/flutter_tts.dart'; +import 'package:learn/pages/fruits.dart'; import 'package:learn/utils/const_dimensions.dart'; import 'package:learn/models/itemdata_model.dart'; import 'package:learn/utils/constants.dart'; @@ -213,21 +214,7 @@ class _PopupDialogState extends State<_PopupDialog> { child: const Text('Next'), ), ], - ), - const SizedBox(height: ConstantDimensions.heightMedium), - ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - const Color.fromARGB(216, 233, 101, 92), - ), - ), - onPressed: () { - Navigator.pop(context); - }, - child: const Text( - 'Close', - style: TextStyle(color: Colors.white), - ), + ), ], ), @@ -259,7 +246,7 @@ class _AtoZState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( - AppConstants.a_z, + 'A-Z', style: TextStyle(fontWeight: FontWeight.bold), ), Expanded( @@ -269,7 +256,7 @@ class _AtoZState extends State { style: ButtonStyle( backgroundColor: isTimerEnabled ? MaterialStateProperty.all(Colors.green) - : MaterialStateProperty.all(Colors.red), + : MaterialStateProperty.all(Colors.red ), ), onPressed: () { setState(() { diff --git a/lib/pages/modules/birds.dart b/lib/pages/modules/birds.dart index df80096..2c6f66e 100644 --- a/lib/pages/modules/birds.dart +++ b/lib/pages/modules/birds.dart @@ -8,6 +8,7 @@ import 'package:learn/models/bird_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'birds_test.dart'; class BirdsPage extends StatelessWidget { @@ -24,6 +25,17 @@ class BirdsPage extends StatelessWidget { AppConstants.bird, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const BirdsTestPage()), + ); + }, + ), + ], ), body: Center( child: BirdWidget( diff --git a/lib/pages/modules/birds_test.dart b/lib/pages/modules/birds_test.dart new file mode 100644 index 0000000..ec40af0 --- /dev/null +++ b/lib/pages/modules/birds_test.dart @@ -0,0 +1,254 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class BirdQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + BirdQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class BirdsTestPage extends StatefulWidget { + const BirdsTestPage({Key? key}) : super(key: key); + + @override + _BirdsTestPageState createState() => _BirdsTestPageState(); +} + +class _BirdsTestPageState extends State { + List allQuestions = [ + BirdQuestion( + imageAsset: 'assets/images/birds/duck.svg', + options: ['Owl', 'Parrot', 'Pigeon', 'Duck'], + correctAnswer: 'Duck', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/hen.svg', + options: ['Maina', 'Ostrich', 'Hen', 'Parrot'], + correctAnswer: 'Hen', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/maina.svg', + options: ['Vulture', 'Maina', 'Eagle', 'Goose'], + correctAnswer: 'Maina', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/pigeon.svg', + options: ['Crow', 'Duck', 'Pigeon', 'Eagle'], + correctAnswer: 'Pigeon', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/sparrow.svg', + options: ['Goose', 'Hen', 'Sparrow', 'Koel'], + correctAnswer: 'Sparrow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/bagula.svg', + options: ['Bagula', 'Bulbul', 'Crow', 'Duck'], + correctAnswer: 'Bagula', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/bulbul.svg', + options: ['Eagle', 'Goose', 'Bulbul', 'Hen'], + correctAnswer: 'Bulbul', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/crow.svg', + options: ['Koel', 'Maina', 'Crow', 'Ostrich'], + correctAnswer: 'Crow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/eagle.svg', + options: ['Eagle', 'Sparrow', 'Swan', 'Vulture'], + correctAnswer: 'Eagle', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/goose.svg', + options: ['Crow', 'Goose', 'Hen', 'Koel'], + correctAnswer: 'Goose', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/koel.svg', + options: ['Pigeon', 'Koel', 'Sparrow', 'Swan'], + correctAnswer: 'Koel', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/ostrich.svg', + options: ['Duck', 'Ostrich', 'Owl', 'Parrot'], + correctAnswer: 'Ostrich', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/owl.svg', + options: ['Pigeon', 'Owl', 'Sparrow', 'Swan'], + correctAnswer: 'Owl', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/parrot.svg', + options: ['Vulture', 'Bagula', 'Parrot', 'Bulbul'], + correctAnswer: 'Parrot', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/swan.svg', + options: ['Maina', 'Ostrich', 'Swan', 'Owl'], + correctAnswer: 'Swan', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/vulture.svg', + options: ['Parrot', 'Pigeon', 'Vulture', 'Sparrow'], + correctAnswer: 'Vulture', + ), + ]; + + List questions = []; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + BirdQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Birds Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/colours.dart b/lib/pages/modules/colours.dart index 347a1bd..f8b0e59 100644 --- a/lib/pages/modules/colours.dart +++ b/lib/pages/modules/colours.dart @@ -3,10 +3,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_svg/flutter_svg.dart'; -// import '../../utils/const_dimensions.dart'; -import 'package:learn/models/colours_model.dart'; +import 'package:learn/utils/assets_path.dart'; -import '../../utils/constants.dart'; +import 'package:learn/models/colours_model.dart'; class ColoursPage extends StatefulWidget { const ColoursPage({Key? key}) : super(key: key); @@ -16,20 +15,81 @@ class ColoursPage extends StatefulWidget { } class _ColoursPageState extends State { - + final List colours = [ + Colours( + name: 'Blue', + jpgAsset: AssetsPath.getColoursImage(ColorImages.blue), + bgColor: Colors.lightBlueAccent, + fontColor: Colors.lightBlueAccent, + ), + Colours( + name: 'Yellow', + jpgAsset: AssetsPath.getColoursImage(ColorImages.yellow), + bgColor: Colors.yellow.shade600, + fontColor: Colors.yellow.shade600, + ), + Colours( + name: 'Black', + jpgAsset: AssetsPath.getColoursImage(ColorImages.black), + bgColor: Colors.black, + fontColor: Colors.black, + ), + Colours( + name: 'Green', + jpgAsset: AssetsPath.getColoursImage(ColorImages.green), + bgColor: Colors.green, + fontColor: Colors.green, + ), + Colours( + name: 'Pink', + jpgAsset: AssetsPath.getColoursImage(ColorImages.pink), + bgColor: Colors.pink.shade300, + fontColor: Colors.pink.shade300, + ), + Colours( + name: 'White', + jpgAsset: AssetsPath.getColoursImage(ColorImages.white), + bgColor: Colors.grey.shade400, + fontColor: Colors.grey.shade400, + ), + Colours( + name: 'Red', + jpgAsset: AssetsPath.getColoursImage(ColorImages.red), + bgColor: Colors.red, + fontColor: Colors.red, + ), + Colours( + name: 'Violet', + jpgAsset: AssetsPath.getColoursImage(ColorImages.violet), + bgColor: Colors.deepPurple, + fontColor: Colors.deepPurple, + ), + Colours( + name: 'Brown', + jpgAsset: AssetsPath.getColoursImage(ColorImages.brown), + bgColor: const Color(0xFF964B00), + fontColor: const Color(0xFF964B00), + ), + Colours( + name: 'Orange', + jpgAsset: AssetsPath.getColoursImage(ColorImages.orange), + bgColor: Colors.orange, + fontColor: Colors.orange, + ), + ]; final FlutterTts flutterTts = FlutterTts(); int currentIndex = 0; void _navigateToNextColour() { setState(() { - currentIndex = (currentIndex + 1) % AppConstants.colours.length; + currentIndex = (currentIndex + 1) % colours.length; }); } void _navigateToPreviousColour() { setState(() { - currentIndex = (currentIndex - 1 + AppConstants.colours.length) % AppConstants.colours.length; + currentIndex = (currentIndex - 1 + colours.length) % colours.length; }); } @@ -40,11 +100,11 @@ class _ColoursPageState extends State { @override Widget build(BuildContext context) { - Colours colour = AppConstants.colours[currentIndex]; + Colours colour = colours[currentIndex]; return Scaffold( appBar: AppBar( title: Text( - AppConstants.color, + 'Colours', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 30, diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 1112dfb..713c452 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -1,9 +1,12 @@ + +// ignore_for_file: unused_element + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:learn/models/flower_model.dart'; -import 'package:learn/utils/constants.dart'; - +import 'package:learn/utils/assets_path.dart'; +import 'flowers_test.dart'; class FlowerPage extends StatefulWidget { const FlowerPage({super.key}); @@ -13,19 +16,76 @@ class FlowerPage extends StatefulWidget { } class _FlowerPageState extends State { + final List flowers = [ + Flower( + name: "Rose", + resource: AssetsPath.getFlowerImage(Flowers.rose), + background: Colors.redAccent, + ), + Flower( + name: "Sunflower", + resource: AssetsPath.getFlowerImage(Flowers.sunflower), + background: Colors.yellowAccent, + ), + Flower( + name: "Lily", + resource: AssetsPath.getFlowerImage(Flowers.lily), + background: Colors.greenAccent, + ), + Flower( + name: "Marigold", + resource: AssetsPath.getFlowerImage(Flowers.marigold), + background: Colors.yellow, + ), + Flower( + name: "Carnation", + resource: AssetsPath.getFlowerImage(Flowers.carnation), + background: Colors.redAccent, + ), + Flower( + name: "Daffodil", + resource: AssetsPath.getFlowerImage(Flowers.daffodil), + background: Colors.purpleAccent, + ), + Flower( + name: "Daisy", + resource: AssetsPath.getFlowerImage(Flowers.daisy), + background: Colors.green, + ), + Flower( + name: "Poppy", + resource: AssetsPath.getFlowerImage(Flowers.poppy), + background: Colors.redAccent, + ), + Flower( + name: "Tulip", + resource: AssetsPath.getFlowerImage(Flowers.tulip), + background: Colors.pink, + ), + Flower( + name: "Lavender", + resource: AssetsPath.getFlowerImage(Flowers.lavender), + background: Colors.purple, + ), + Flower( + name: "Hibiscus", + resource: AssetsPath.getFlowerImage(Flowers.hibiscus), + background: Colors.red, + ), + ]; final FlutterTts flutterTts = FlutterTts(); int currentIndex = 0; void _navigateToNextFlower() { setState(() { - currentIndex = (currentIndex + 1) % AppConstants.flowers.length; + currentIndex = (currentIndex + 1) % flowers.length; }); } void _navigateToPreviousFlower() { setState(() { - currentIndex = (currentIndex - 1 + AppConstants.flowers.length) % AppConstants.flowers.length; + currentIndex = (currentIndex - 1 + flowers.length) % flowers.length; }); } @@ -36,101 +96,116 @@ class _FlowerPageState extends State { await flutterTts.speak(name); } + void _navigateToFlowersTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const FlowersTestPage()), + ); + } + @override Widget build(BuildContext context) { - Flower flower = AppConstants.flowers[currentIndex]; + Flower flower = flowers[currentIndex]; + String flowerImagePath = flower.resource; + // ignore: avoid_print + print('Flower image path: $flowerImagePath'); // Debug print + return Scaffold( appBar: AppBar( title: const Text( - AppConstants.flower, + 'Flowers', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 30, ), ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToFlowersTestPage(context); + }, + ), + ], ), backgroundColor: flower.background, - - body: Center( - child: SingleChildScrollView( - child: Center( - child: Container( - padding: const EdgeInsets.all(20), - constraints: const BoxConstraints(maxWidth: 400, maxHeight: 700), - decoration: BoxDecoration( - color: Colors.white.withOpacity(0.7), - borderRadius: BorderRadius.circular(7.0), - boxShadow: [ - BoxShadow( - color: Colors.white.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: _navigateToNextFlower, - child: Container( - width: double.infinity, - height: 300, - child: SvgPicture.asset( - flower.resource, - fit: BoxFit.contain, - ), + body: SingleChildScrollView( + child: Center( + child: Container( + padding: const EdgeInsets.all(20), + constraints: const BoxConstraints(maxWidth: 400, maxHeight: 700), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.7), + borderRadius: BorderRadius.circular(7.0), + boxShadow: [ + BoxShadow( + color: Colors.white.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: _navigateToNextFlower, + child: SizedBox( + width: double.infinity, + height: 300, + child: SvgPicture.asset( + flowerImagePath, + fit: BoxFit.contain, ), ), - const SizedBox(height: 20), - Text( - flower.name, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 60, - fontFamily: 'Comic', - color: flower.background, - ), + ), + const SizedBox(height: 20), + Text( + flower.name, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 60, + fontFamily: 'Comic', ), - const SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - IconButton( - onPressed: _navigateToPreviousFlower, - icon: const Icon( - Icons.arrow_back, - size: 30, - ), + ), + const SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + onPressed: _navigateToPreviousFlower, + icon: const Icon( + Icons.arrow_back, + size: 30, ), - const SizedBox(width: 20), - IconButton.outlined( - highlightColor: Colors.amber, - onPressed: () { - readName(flower.name); - }, - icon: const Icon( - Icons.volume_up_outlined, - size: 40, - ), + ), + const SizedBox(width: 20), + IconButton.outlined( + highlightColor: Colors.amber, + onPressed: () { + readName(flower.name); + }, + icon: const Icon( + Icons.volume_up_outlined, + size: 40, ), - const SizedBox(width: 20), - IconButton( - onPressed: _navigateToNextFlower, - icon: const Icon( - Icons.arrow_forward, - size: 30, - ), - ) - ], - ), - ], - ), + ), + const SizedBox(width: 20), + IconButton( + onPressed: _navigateToNextFlower, + icon: const Icon( + Icons.arrow_forward, + size: 30, + ), + ) + ], + ), + ], ), ), ), ), ); } -} \ No newline at end of file +} diff --git a/lib/pages/modules/flowers_test.dart b/lib/pages/modules/flowers_test.dart new file mode 100644 index 0000000..d2f49aa --- /dev/null +++ b/lib/pages/modules/flowers_test.dart @@ -0,0 +1,228 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class FlowerQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + FlowerQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class FlowersTestPage extends StatefulWidget { + const FlowersTestPage({Key? key}) : super(key: key); + + @override + _FlowersTestPageState createState() => _FlowersTestPageState(); +} + +class _FlowersTestPageState extends State { + List allQuestions = [ + FlowerQuestion( + imageAsset: 'assets/images/flowers/carnation.svg', + options: ['Carnation', 'Daffodil', 'Daisy', 'Hibiscus'], + correctAnswer: 'Carnation', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/daffodil.svg', + options: ['Lavender', 'Lily', 'Marigold', 'Daffodil'], + correctAnswer: 'Daffodil', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/lily.svg', + options: ['Lily', 'Carnation', 'Sunflower', 'Marigold'], + correctAnswer: 'Lily', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/rose.svg', + options: ['Tulip', 'Poppy', 'Rose', 'Hibiscus'], + correctAnswer: 'Rose', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/sunflower.svg', + options: ['Sunflower', 'Hibiscus', 'Lavender', 'Daisy'], + correctAnswer: 'Sunflower', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/daisy.svg', + options: ['Poppy', 'Tulip', 'Sunflower', 'Daisy'], + correctAnswer: 'Daisy', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/hibiscus.svg', + options: ['Carnation', 'Daffodil', 'Hibiscus', 'Lavender'], + correctAnswer: 'Hibiscus', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/lavender.svg', + options: ['Lily', 'Lavender', 'Marigold', 'Rose'], + correctAnswer: 'Lavender', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/marigold.svg', + options: ['Rose', 'Marigold', 'Daisy', 'Sunflower'], + correctAnswer: 'Marigold', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/poppy.svg', + options: ['Poppy', 'Carnation', 'Sunflower', 'Daffodil'], + correctAnswer: 'Poppy', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/tulip.svg', + options: ['Lily', 'Tulip', 'Marigold', 'Sunflower'], + correctAnswer: 'Tulip', + ), + ]; + + List questions = []; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + FlowerQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Flowers Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/occupation.dart b/lib/pages/modules/occupation.dart index 7e7b5ee..8aa1959 100644 --- a/lib/pages/modules/occupation.dart +++ b/lib/pages/modules/occupation.dart @@ -6,6 +6,7 @@ import 'package:learn/models/occupation_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'occupations_test.dart'; class OccupationPage extends StatelessWidget { final FlutterTts flutterTts = FlutterTts(); @@ -26,6 +27,17 @@ class OccupationPage extends StatelessWidget { Navigator.pop(context); }, ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const OccupationsTestPage()), + ); + }, + ), + ], ), body: SingleChildScrollView( child: Center( diff --git a/lib/pages/modules/occupations_test.dart b/lib/pages/modules/occupations_test.dart new file mode 100644 index 0000000..04a1b41 --- /dev/null +++ b/lib/pages/modules/occupations_test.dart @@ -0,0 +1,251 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class OccupationQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + OccupationQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class OccupationsTestPage extends StatefulWidget { + const OccupationsTestPage({Key? key}) : super(key: key); + + @override + _OccupationsTestPageState createState() => _OccupationsTestPageState(); +} + +class _OccupationsTestPageState extends State { + List> questionSets = [ + [ + OccupationQuestion( + imageAsset: 'assets/images/occupations/artist.svg', + options: ['Artist', 'Author', 'Carpenter', 'Electrician'], + correctAnswer: 'Artist', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/engineer.svg', + options: ['Engineer', 'Pilot', 'Farmer', 'Lawyer'], + correctAnswer: 'Engineer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/farmer.svg', + options: ['Teacher', 'Vet', 'Farmer', 'Photographer'], + correctAnswer: 'Farmer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/police.svg', + options: ['Engineer', 'Pilot', 'Police', 'Barber'], + correctAnswer: 'Police', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/teacher.svg', + options: ['Teacher', 'Vet', 'Photographer', 'Author'], + correctAnswer: 'Teacher', + ), + ], + [ + OccupationQuestion( + imageAsset: 'assets/images/occupations/author.svg', + options: ['Pilot', 'Police', 'Teacher', 'Author'], + correctAnswer: 'Author', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/carpenter.svg', + options: ['Farmer', 'Engineer', 'Carpenter', 'Vet'], + correctAnswer: 'Carpenter', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/electrician.svg', + options: ['Engineer', 'Electrician', 'Farmer', 'Teacher'], + correctAnswer: 'Electrician', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/vet.svg', + options: ['Engineer', 'Lawyer', 'Vet', 'Author'], + correctAnswer: 'Vet', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/photographer.svg', + options: ['Pilot', 'Photographer', 'Carpenter', 'Barber'], + correctAnswer: 'Photographer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/photographer.svg', + options: ['Pilot', 'Photographer', 'Carpenter', 'Barber'], + correctAnswer: 'Photographer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/lawyer.svg', + options: ['Lawyer', 'Carpenter', 'Electrician', 'Farmer'], + correctAnswer: 'Lawyer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/barber.svg', + options: ['Teacher', 'Barber', 'Vet', 'Author'], + correctAnswer: 'Barber', + ), + ], + + ]; + + int currentQuestionSetIndex = 0; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _shuffleQuestions(); + } + + void _shuffleQuestions() { + for (var questionSet in questionSets) { + questionSet.shuffle(); + } + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questionSets[currentQuestionSetIndex][currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questionSets[currentQuestionSetIndex].length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + if (currentQuestionSetIndex < questionSets.length - 1) { + currentQuestionSetIndex++; + currentQuestionIndex = 0; + } else { + showFeedback = false; + _showFinalScore(context); + return; + } + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionSetIndex = 0; + currentQuestionIndex = 0; + correctAnswers = 0; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questionSets[currentQuestionSetIndex].length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + OccupationQuestion currentQuestion = questionSets[currentQuestionSetIndex][currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Occupations Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} + diff --git a/lib/pages/modules/parts.dart b/lib/pages/modules/parts.dart index 04715b2..f9ca972 100644 --- a/lib/pages/modules/parts.dart +++ b/lib/pages/modules/parts.dart @@ -1,3 +1,5 @@ +// ignore_for_file: unused_element + import 'package:flutter/material.dart'; import 'package:flutter_card_swiper/flutter_card_swiper.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -8,6 +10,7 @@ import 'package:learn/utils/functions.dart'; import 'package:learn/utils/responsive_screen_provider.dart'; import '../../utils/const_dimensions.dart'; +import 'parts_test.dart'; void main() { runApp( @@ -57,6 +60,12 @@ class _PartsPagePageState extends State { controller.dispose(); super.dispose(); } + void _navigateToPartsTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const PartsTestPage()), + ); + } @override Widget build(BuildContext context) { @@ -66,6 +75,14 @@ class _PartsPagePageState extends State { AppConstants.parts, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToPartsTestPage(context); + }, + ), + ], ), body: SafeArea( child: Column( diff --git a/lib/pages/modules/parts_test.dart b/lib/pages/modules/parts_test.dart new file mode 100644 index 0000000..a59824c --- /dev/null +++ b/lib/pages/modules/parts_test.dart @@ -0,0 +1,269 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class PartQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + PartQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class PartsTestPage extends StatefulWidget { + const PartsTestPage({Key? key}) : super(key: key); + + @override + _PartsTestPageState createState() => _PartsTestPageState(); +} + +class _PartsTestPageState extends State { + List allQuestions = [ + // Define all PartQuestion objects here + PartQuestion( + imageAsset: 'assets/images/body/arm.svg', + options: ['Ankle', 'Back', 'Arm', 'Belly'], + correctAnswer: 'Arm', + ), + PartQuestion( + imageAsset: 'assets/images/body/eye.svg', + options: ['Ear', 'Eye', 'Nose', 'Mouth'], + correctAnswer: 'Eye', + ), + PartQuestion( + imageAsset: 'assets/images/body/foot.svg', + options: ['Hand', 'Fingers', 'Toes', 'Foot'], + correctAnswer: 'Foot', + ), + PartQuestion( + imageAsset: 'assets/images/body/nose.svg', + options: ['Nose', 'Mouth', 'Ear', 'Eye'], + correctAnswer: 'Nose', + ), + PartQuestion( + imageAsset: 'assets/images/body/tongue.svg', + options: ['Teeth', 'Lips', 'Tongue', 'Mouth'], + correctAnswer: 'Tongue', + ), + PartQuestion( + imageAsset: 'assets/images/body/ankle.svg', + options: ['Ankle', 'Arm', 'Back', 'Belly'], + correctAnswer: 'Ankle', + ), + PartQuestion( + imageAsset: 'assets/images/body/back.svg', + options: ['Back', 'Ankle', 'Arm', 'Belly'], + correctAnswer: 'Back', + ), + PartQuestion( + imageAsset: 'assets/images/body/belly.svg', + options: ['Belly', 'Ankle', 'Arm', 'Back'], + correctAnswer: 'Belly', + ), + PartQuestion( + imageAsset: 'assets/images/body/ear.svg', + options: ['Ear', 'Eye', 'Nose', 'Mouth'], + correctAnswer: 'Ear', + ), + PartQuestion( + imageAsset: 'assets/images/body/chest.svg', + options: ['Chest', 'Back', 'Stomach', 'Neck'], + correctAnswer: 'Chest', + ), + PartQuestion( + imageAsset: 'assets/images/body/chin.svg', + options: ['Chin', 'Jaw', 'Lips', 'Nose'], + correctAnswer: 'Chin', + ), + PartQuestion( + imageAsset: 'assets/images/body/fingers.svg', + options: ['Fingers', 'Toes', 'Hand', 'Feet'], + correctAnswer: 'Fingers', + ), + PartQuestion( + imageAsset: 'assets/images/body/lips.svg', + options: ['Lips', 'Nose', 'Chin', 'Teeth'], + correctAnswer: 'Lips', + ), + PartQuestion( + imageAsset: 'assets/images/body/knee.svg', + options: ['Knee', 'Ankle', 'Leg', 'Elbow'], + correctAnswer: 'Knee', + ), + PartQuestion( + imageAsset: 'assets/images/body/hips.svg', + options: ['Hips', 'Waist', 'Legs', 'Thighs'], + correctAnswer: 'Hips', + ), + PartQuestion( + imageAsset: 'assets/images/body/stomach.svg', + options: ['Stomach', 'Chest', 'Back', 'Neck'], + correctAnswer: 'Stomach', + ), + PartQuestion( + imageAsset: 'assets/images/body/neck.svg', + options: ['Neck', 'Shoulder', 'Head', 'Chest'], + correctAnswer: 'Neck', + ), + PartQuestion( + imageAsset: 'assets/images/body/teeth.svg', + options: ['Teeth', 'Tongue', 'Lips', 'Mouth'], + correctAnswer: 'Teeth', + ), + PartQuestion( + imageAsset: 'assets/images/body/wrist.svg', + options: ['Wrist', 'Elbow', 'Arm', 'Hand'], + correctAnswer: 'Wrist', + ), + ]; + + List questions = []; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + PartQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Parts Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/planets.dart b/lib/pages/modules/planets.dart index 7bae0a4..f340022 100644 --- a/lib/pages/modules/planets.dart +++ b/lib/pages/modules/planets.dart @@ -7,6 +7,7 @@ import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; import 'package:learn/models/planet_model.dart'; +import 'planets_test.dart'; class PlanetsPage extends StatelessWidget { @@ -14,7 +15,12 @@ class PlanetsPage extends StatelessWidget { final AudioPlayer audioPlayer = AudioPlayer(); PlanetsPage({Key? key}) : super(key: key); - + void _navigateToPlanetsTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const PlanetsTestPage()), + ); + } @override Widget build(BuildContext context) { return Scaffold( @@ -29,6 +35,14 @@ class PlanetsPage extends StatelessWidget { Navigator.pop(context); }, ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToPlanetsTestPage(context); + }, + ), + ], ), body: SingleChildScrollView( child: Center( diff --git a/lib/pages/modules/planets_test.dart b/lib/pages/modules/planets_test.dart new file mode 100644 index 0000000..f726ed4 --- /dev/null +++ b/lib/pages/modules/planets_test.dart @@ -0,0 +1,218 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class PlanetQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + PlanetQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class PlanetsTestPage extends StatefulWidget { + const PlanetsTestPage({Key? key}) : super(key: key); + + @override + _PlanetsTestPageState createState() => _PlanetsTestPageState(); +} + +class _PlanetsTestPageState extends State { + List allQuestions = [ + PlanetQuestion( + imageAsset: 'assets/images/solar/earth.svg', + options: ['Earth', 'Mars', 'Jupiter', 'Neptune'], + correctAnswer: 'Earth', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/mars.svg', + options: ['Mercury', 'Mars', 'Saturn', 'Jupiter'], + correctAnswer: 'Mars', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/jupiter.svg', + options: ['Saturn', 'Uranus', 'Jupiter', 'Neptune'], + correctAnswer: 'Jupiter', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/neptune.svg', + options: ['Neptune', 'Mercury', 'Venus', 'Uranus'], + correctAnswer: 'Neptune', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/sun.svg', + options: ['Venus', 'Earth', 'Mercury', 'Sun'], + correctAnswer: 'Sun', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/venus.svg', + options: ['Mars', 'Venus', 'Uranus', 'Neptune'], + correctAnswer: 'Venus', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/uranus.svg', + options: ['Saturn', 'Jupiter', 'Neptune', 'Uranus'], + correctAnswer: 'Uranus', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/mercury.svg', + options: ['Venus', 'Mercury', 'Sun', 'Earth'], + correctAnswer: 'Mercury', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/saturn.svg', + options: ['Jupiter', 'Mars', 'Saturn', 'Sun'], + correctAnswer: 'Saturn', + ), + ]; + + List questions = []; + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + _shuffleQuestions(); + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + PlanetQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Planets Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index 72f7156..3ad143b 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/models/season_model.dart'; +import 'package:learn/pages/fruits.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; @@ -14,7 +15,7 @@ class SeasonsPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: const Text( - AppConstants.season, + 'Seasons Serenade', style: TextStyle(fontWeight: FontWeight.bold), ), ), diff --git a/lib/utils/assets_path.dart b/lib/utils/assets_path.dart index 34ddc1b..255a61c 100644 --- a/lib/utils/assets_path.dart +++ b/lib/utils/assets_path.dart @@ -256,9 +256,10 @@ class Flowers { static const String dandelion = 'dandelion.svg'; static const String jasmine = 'jasmine.svg'; static const String lotus = 'lotus.svg'; - static const String poppy = 'poppy.svg'; - static const String carnation= 'carnation.svg'; - static const String daffodil= 'daffodil.svg'; + static const String carnation= 'carnation.svg'; + static const String poppy= 'poppy.svg'; + static const String daffodil = 'daffodil.svg'; + } class SolarSystem { diff --git a/lib/utils/route/route_constant.dart b/lib/utils/route/route_constant.dart index 788a35d..be739c1 100644 --- a/lib/utils/route/route_constant.dart +++ b/lib/utils/route/route_constant.dart @@ -18,5 +18,5 @@ class AllRoutesConstant { static const String fruitRoute = "/fruit"; static const String drawingboardRoute = "/drawingboard"; static const String landingRoute = '/landing_page'; - static const String mainhomeRoute = '/mainhome'; + static const String mainhomeRoute = '/main_home'; } diff --git a/lib/utils/route/routes.dart b/lib/utils/route/routes.dart index 0fdd352..baedfe9 100644 --- a/lib/utils/route/routes.dart +++ b/lib/utils/route/routes.dart @@ -60,8 +60,10 @@ class Routers { return slidePageRoute(const DrawingBoardPage()); case AllRoutesConstant.landingRoute: return slidePageRoute(const LandingPage()); - case AllRoutesConstant.mainhomeRoute: - return slidePageRoute(MainHome()); + case AllRoutesConstant.mainhomeRoute: + return slidePageRoute(const MainHome()); + + default: return MaterialPageRoute( builder: (context) => const Scaffold( diff --git a/lib/widgets/drawer.dart b/lib/widgets/drawer.dart index a299f2a..108eb0e 100644 --- a/lib/widgets/drawer.dart +++ b/lib/widgets/drawer.dart @@ -1,190 +1,183 @@ -import 'package:flutter/material.dart'; -import 'package:learn/utils/route/route_constant.dart'; - -class MyDrawer extends StatelessWidget { - const MyDrawer({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Drawer( - child: SafeArea( - child: SingleChildScrollView( - child: Container( - color: Theme.of(context).canvasColor, - child: Column( - children: [ - DrawerHeader( - padding: const EdgeInsets.all(0), - decoration: - BoxDecoration(color: Theme.of(context).canvasColor), - child: UserAccountsDrawerHeader( - margin: const EdgeInsets.all(0), - decoration: - BoxDecoration(color: Theme.of(context).canvasColor), - accountName: Text( - "Learning App for kids", - style: Theme.of(context) - .textTheme - .titleLarge - ?.copyWith(fontWeight: FontWeight.bold), - ), - accountEmail: Text( - "Made by sapatevaibhav", - style: Theme.of(context).textTheme.bodyLarge, - ), - currentAccountPicture: const CircleAvatar( - backgroundImage: AssetImage("assets/images/dp.png"), - ), - ), - ), - _buildListTile( - icon: Icons.home, - title: "Home", - onTap: () { - Navigator.pushReplacementNamed( - context, AllRoutesConstant.homeRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.text_fields, - title: "A - Z", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.atozRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.pest_control_rodent_outlined, - title: "Animals", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.animalRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.egg, - title: "Birds", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.birdsRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.cloud, - title: "Seasons", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.seasonRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.pentagon_outlined, - title: "Shapes", - onTap: () { - Navigator.pushReplacementNamed( - context, AllRoutesConstant.shapesRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.back_hand_rounded, - title: "Body parts", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.partsRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.work, - title: "Occupations", - onTap: () { - Navigator.pushNamed( - context, AllRoutesConstant.occupationRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.sunny, - title: "Solar System", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.solarRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.palette, - title: "Colours", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.colourRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.local_florist, - title: "Flowers", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.flowerRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.question_mark_outlined, - title: "About us", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.aboutRoute); - }, - context: context, - ), - _buildListTile( - icon: Icons.question_mark_outlined, - title: "Quiz", - onTap: () { - Navigator.pushNamed(context, AllRoutesConstant.quizRoute); - }, - context: context, - ), - ], - ), - ), - ), - ), - ); - } - - Widget _buildListTile({ - required BuildContext context, - required IconData icon, - required String title, - required VoidCallback onTap, - }) { - return ListTile( - leading: Icon(icon), - title: Text( - title, - style: Theme.of(context).textTheme.bodyLarge, - ), - onTap: onTap, - ); - } - - // Widget _buildListTileSVG({ - // required BuildContext context, - // required String icon, - // required String title, - // required VoidCallback onTap, - // }) { - // return ListTile( - // leading: SvgPicture.asset( - // icon, - // width: 24, - // height: 24, - // ), - // title: Text( - // title, - // style: Theme.of(context).textTheme.bodyLarge, - // ), - // onTap: onTap, - // ); - // } -} +import 'package:flutter/material.dart'; +// import 'package:flutter_svg/flutter_svg.dart'; +// ignore: unused_import +import 'package:learn/utils/assets_path.dart'; +import 'package:learn/utils/route/route_constant.dart'; + +class MyDrawer extends StatelessWidget { + const MyDrawer({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Drawer( + child: SafeArea( + child: SingleChildScrollView( + child: Container( + color: Theme.of(context).canvasColor, + child: Column( + children: [ + DrawerHeader( + padding: const EdgeInsets.all(0), + decoration: + BoxDecoration(color: Theme.of(context).canvasColor), + child: UserAccountsDrawerHeader( + margin: const EdgeInsets.all(0), + decoration: + BoxDecoration(color: Theme.of(context).canvasColor), + accountName: Text( + "Learning App for kids", + style: Theme.of(context) + .textTheme + .titleLarge + ?.copyWith(fontWeight: FontWeight.bold), + ), + accountEmail: Text( + "Made by sapatevaibhav", + style: Theme.of(context).textTheme.bodyLarge, + ), + currentAccountPicture: const CircleAvatar( + backgroundImage: AssetImage("assets/images/dp.png"), + ), + ), + ), + _buildListTile( + icon: Icons.home, + title: "Home", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.homeRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.text_fields, + title: "A - Z", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.atozRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.pest_control_rodent_outlined, + title: "Animals", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.animalRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.egg, + title: "Birds", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.birdsRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.cloud, + title: "Seasons", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.seasonRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.pentagon_outlined, + title: "Shapes", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.shapesRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.back_hand_rounded, + title: "Body parts", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.partsRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.work, + title: "Occupations", + onTap: () { + Navigator.pushNamed( + context, AllRoutesConstant.occupationRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.sunny, + title: "Solar System", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.solarRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.palette, + title: "Colours", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.colourRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.local_florist, + title: "Flowers", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.flowerRoute); + }, + context: context, + ), + _buildListTile( + icon: Icons.question_mark_outlined, + title: "About us", + onTap: () { + Navigator.pushNamed(context, AllRoutesConstant.aboutRoute); + }, + context: context, + ), + ], + ), + ), + ), + ), + ); + } + + Widget _buildListTile({ + required BuildContext context, + required IconData icon, + required String title, + required VoidCallback onTap, + }) { + return ListTile( + leading: Icon(icon), + title: Text( + title, + style: Theme.of(context).textTheme.bodyLarge, + ), + onTap: onTap, + ); + } + + // Widget _buildListTileSVG({ + // required BuildContext context, + // required String icon, + // required String title, + // required VoidCallback onTap, + // }) { + // return ListTile( + // leading: SvgPicture.asset( + // icon, + // width: 24, + // height: 24, + // ), + // title: Text( + // title, + // style: Theme.of(context).textTheme.bodyLarge, + // ), + // onTap: onTap, + // ); + // } +}