From 04f8fb36276e57f3a296fb0e43f36e7fd53d90d9 Mon Sep 17 00:00:00 2001 From: Gaurav-Kushwaha-1225 Date: Mon, 20 May 2024 22:12:40 +0530 Subject: [PATCH 1/3] Dimensions made constant --- lib/pages/about.dart | 40 ++++++++++++++++--------------- lib/pages/explore.dart | 10 ++++---- lib/pages/explore/explore.dart | 10 ++++---- lib/pages/explore/quiz.dart | 19 ++++++++------- lib/pages/fruits.dart | 14 ++++++----- lib/pages/home.dart | 27 +++++++++++---------- lib/pages/modules/animals.dart | 18 +++++++------- lib/pages/modules/atoz.dart | 15 ++++++------ lib/pages/modules/birds.dart | 18 +++++++------- lib/pages/modules/colours.dart | 12 ++++++---- lib/pages/modules/flowers.dart | 12 ++++++---- lib/pages/modules/occupation.dart | 16 +++++++------ lib/pages/modules/parts.dart | 22 +++++++++-------- lib/pages/modules/planets.dart | 12 ++++++---- lib/pages/modules/seasons.dart | 14 ++++++----- lib/pages/modules/shapes.dart | 4 +++- lib/utils/const_dimensions.dart | 19 +++++++++++++++ lib/utils/constants.dart | 7 ------ 18 files changed, 165 insertions(+), 124 deletions(-) create mode 100644 lib/utils/const_dimensions.dart diff --git a/lib/pages/about.dart b/lib/pages/about.dart index 14800ba..faef72e 100644 --- a/lib/pages/about.dart +++ b/lib/pages/about.dart @@ -3,6 +3,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../utils/const_dimensions.dart'; + class AboutPage extends StatelessWidget { const AboutPage({Key? key}) : super(key: key); @@ -27,17 +29,17 @@ class AboutPage extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - const SizedBox(height: 16.0), + const SizedBox(height: ConstantDimensions.heightSmall_Medium), const Text( 'Version: 1.1.0', style: TextStyle(fontSize: 18.0), ), - const SizedBox(height: 8.0), + const SizedBox(height: ConstantDimensions.heightSmall_Medium / 2), const Text( 'Developed by: sapatevaibhav', style: TextStyle(fontSize: 18.0), ), - const SizedBox(height: 16.0), + const SizedBox(height: ConstantDimensions.heightSmall_Medium), const Text( 'Description:', style: TextStyle( @@ -45,12 +47,12 @@ class AboutPage extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - const SizedBox(height: 8.0), + const SizedBox(height: ConstantDimensions.heightSmall_Medium / 2), const Text( AppConstants.description, style: TextStyle(fontSize: 18.0), ), - const SizedBox(height: 6.0), + const SizedBox(height: ConstantDimensions.heightExtraSmall), const Text( 'Source code:', style: TextStyle( @@ -64,14 +66,14 @@ class AboutPage extends StatelessWidget { }, child: SvgPicture.asset( 'assets/images/git.svg', - width: 32.0, - height: 32.0, + width: ConstantDimensions.widthSmall_Medium * 2, + height: ConstantDimensions.heightSmall_Medium * 2, color: Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.black, ), ), - const SizedBox(height: 16.0), + const SizedBox(height: ConstantDimensions.heightSmall_Medium), const Text( 'Connect:', style: TextStyle( @@ -87,28 +89,28 @@ class AboutPage extends StatelessWidget { }, child: SvgPicture.asset( 'assets/images/github.svg', - width: 32.0, - height: 32.0, + width: ConstantDimensions.widthSmall_Medium * 2, + height: ConstantDimensions.heightSmall_Medium * 2, color: Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.black, ), ), - const SizedBox(width: 16.0), + const SizedBox(width: ConstantDimensions.widthSmall_Medium), GestureDetector( onTap: () { _launchURL(context, "mailto:sapatevaibhav@duck.com"); }, child: SvgPicture.asset( 'assets/images/email.svg', - width: 32.0, - height: 32.0, + width: ConstantDimensions.widthSmall_Medium * 2, + height: ConstantDimensions.heightSmall_Medium * 2, color: Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.black , ), ), - const SizedBox(width: 16.0), + const SizedBox(width: ConstantDimensions.widthSmall_Medium), GestureDetector( onTap: () { _launchURL( @@ -116,19 +118,19 @@ class AboutPage extends StatelessWidget { }, child: SvgPicture.asset( 'assets/images/linkedin.svg', - width: 32.0, - height: 32.0, + width: ConstantDimensions.widthSmall_Medium * 2, + height: ConstantDimensions.heightSmall_Medium * 2, ), ), - const SizedBox(width: 16.0), + const SizedBox(width: ConstantDimensions.widthSmall_Medium), GestureDetector( onTap: () { _launchURL(context, "https://instagram.com/v.d.r.sapate"); }, child: SvgPicture.asset( 'assets/images/instagram.svg', - width: 32.0, - height: 32.0, + width: ConstantDimensions.widthSmall_Medium * 2, + height: ConstantDimensions.heightSmall_Medium * 2, color: Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.black, diff --git a/lib/pages/explore.dart b/lib/pages/explore.dart index beca601..7decc31 100644 --- a/lib/pages/explore.dart +++ b/lib/pages/explore.dart @@ -4,6 +4,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; +import '../utils/const_dimensions.dart'; + // Explore Page class ExplorePage extends StatelessWidget { const ExplorePage({super.key}); @@ -36,7 +38,7 @@ class ExplorePage extends StatelessWidget { child: Container( margin: const EdgeInsets.symmetric( horizontal: 24, vertical: 12), - height: 200, + height: ConstantDimensions.heightExtraLarge * 4, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), boxShadow: [ @@ -127,11 +129,11 @@ class ExplorePage extends StatelessWidget { child: Row( children: [ SizedBox( - width: 50, - height: 50, + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, child: SvgPicture.asset('assets/explore/notebook.svg'), ), - const SizedBox(width: 28.0), + const SizedBox(width: ConstantDimensions.widthMedium_Large), const Text( 'Quiz', style: TextStyle( diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index 0a84b9e..f8b868b 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -4,6 +4,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + // Explore Page class ExplorePage extends StatelessWidget { const ExplorePage({super.key}); @@ -43,12 +45,12 @@ class ExplorePage extends StatelessWidget { child: Row( children: [ SizedBox( - width: 50, - height: 50, + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, child: SvgPicture.asset('assets/explore/notebook.svg'), ), - const SizedBox(width: 28.0), + const SizedBox(width: ConstantDimensions.widthMedium_Large), const Text( 'Quiz', style: TextStyle( @@ -76,7 +78,7 @@ class ExplorePage extends StatelessWidget { child: Container( margin: const EdgeInsets.symmetric( horizontal: 24, vertical: 12), - height: 200, + height: ConstantDimensions.heightExtraLarge * 4, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), boxShadow: [ diff --git a/lib/pages/explore/quiz.dart b/lib/pages/explore/quiz.dart index be0516d..8deb126 100644 --- a/lib/pages/explore/quiz.dart +++ b/lib/pages/explore/quiz.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; -import 'dart:math'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + class QuizQuestion { final String question; final List options; @@ -91,7 +92,7 @@ class _QuizPageState extends State { fontSize: 24, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), ElevatedButton( onPressed: () { Navigator.of(context).pop(); @@ -108,12 +109,12 @@ class _QuizPageState extends State { style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( _questions[_currentQuestionIndex].question, style: const TextStyle(fontSize: 18), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Column( children: List.generate( _questions[_currentQuestionIndex].options.length, @@ -130,12 +131,12 @@ class _QuizPageState extends State { child: Row( children: [ SizedBox( - width: 30, - height: 30, + width: ConstantDimensions.widthLarge, + height: ConstantDimensions.heightLarge, child: SvgPicture.asset('assets/explore/dot.svg'), ), - const SizedBox(width: 12.0), + const SizedBox(width: ConstantDimensions.heightExtraSmall * 2), Expanded( child: Text( _questions[_currentQuestionIndex] @@ -149,7 +150,7 @@ class _QuizPageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), if (_feedbackMessage.isNotEmpty) Container( padding: const EdgeInsets.all(12.0), @@ -167,7 +168,7 @@ class _QuizPageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), if (_answered && !_quizCompleted) ElevatedButton( onPressed: _nextQuestion, diff --git a/lib/pages/fruits.dart b/lib/pages/fruits.dart index 40dbbea..9954f88 100644 --- a/lib/pages/fruits.dart +++ b/lib/pages/fruits.dart @@ -6,6 +6,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/constants.dart'; +import '../utils/const_dimensions.dart'; + class Fruit { final String name; final String svgAsset; @@ -66,8 +68,8 @@ class _FruitsPageState extends State { GestureDetector( onTap: _navigateToNextBird, child: Container( - width: 375, - height: 375, + width: ConstantDimensions.exceptions[1], + height: ConstantDimensions.exceptions[1], decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(8.0), @@ -77,8 +79,8 @@ class _FruitsPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 350, - height: 350, + width: ConstantDimensions.widthExtraLarge * 7, + height: ConstantDimensions.heightExtraLarge * 7, child: SvgPicture.asset( AppConstants.Fruits[_currentIndex].svgAsset), ), @@ -86,7 +88,7 @@ class _FruitsPageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), IconButton.outlined( onPressed: () { readName( @@ -103,7 +105,7 @@ class _FruitsPageState extends State { fontFamily: 'Comic', ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ diff --git a/lib/pages/home.dart b/lib/pages/home.dart index e9a8a88..276454d 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -4,6 +4,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:learn/main.dart'; import 'package:learn/utils/assets_path.dart'; +import '../utils/const_dimensions.dart'; import '../utils/routes.dart'; import '../widgets/drawer.dart'; @@ -104,14 +105,14 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'ALPHABETS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Learn A to Z with pronunciation and an example"), const SizedBox( - height: 20, + height: ConstantDimensions.heightMedium, ), GestureDetector( onTap: () { @@ -144,14 +145,14 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'ANIMALS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Learn about animals and their voices"), const SizedBox( - height: 20, + height: ConstantDimensions.heightMedium, ), GestureDetector( onTap: () { @@ -184,13 +185,13 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'BODY PARTS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Know about body parts and their pronunciation."), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), GestureDetector( onTap: () { setState(() { @@ -222,13 +223,13 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'BIRDS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Look out for Birds with their sounds."), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), GestureDetector( onTap: () { setState(() { @@ -261,13 +262,13 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'COLOURS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Explore and learn about the colours!"), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), GestureDetector( onTap: () { setState(() { @@ -299,13 +300,13 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'FLOWERS', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const Text("Explore beauty of nature flowers."), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), GestureDetector( onTap: () { setState(() { @@ -337,7 +338,7 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( 'Fruits & Vegetables', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), diff --git a/lib/pages/modules/animals.dart b/lib/pages/modules/animals.dart index 099aaa2..3abedaf 100644 --- a/lib/pages/modules/animals.dart +++ b/lib/pages/modules/animals.dart @@ -6,6 +6,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + class Animal { final String name; final String svgAsset; @@ -55,11 +57,11 @@ class AnimalsPage extends StatelessWidget { child: Row( children: [ SizedBox( - width: 50, - height: 50, + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, child: SvgPicture.asset(AppConstants.animals[index].svgAsset), ), - const SizedBox(width: 28.0), + const SizedBox(width: ConstantDimensions.widthMedium_Large), Text( AppConstants.animals[index].name, style: const TextStyle( @@ -150,15 +152,15 @@ class _AnimalPopupState extends State { }); }, child: SizedBox( - width: 200, - height: 200, + width: ConstantDimensions.widthExtraLarge * 4, + height: ConstantDimensions.heightExtraLarge * 4, child: SvgPicture.asset( widget.animal.svgAsset, color: isTapped ? const Color.fromARGB(81, 118, 96, 94) : null, ), ), ), - const SizedBox(height: 16), + const SizedBox(height: ConstantDimensions.heightSmall_Medium), ElevatedButton( onPressed: () { _playAnimalSound(widget.animal.soundAsset); @@ -173,8 +175,8 @@ class _AnimalPopupState extends State { }, icon: const Icon(Icons.arrow_back), ), - const SizedBox( - width: 135, + SizedBox( + width: ConstantDimensions.exceptions[0], ), IconButton( onPressed: () { diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index aa1def7..ba2f857 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -3,6 +3,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/utils/const_dimensions.dart'; import 'package:learn/utils/constants.dart'; class ItemTile extends StatelessWidget { @@ -49,14 +50,14 @@ class ItemTile extends StatelessWidget { ), textAlign: TextAlign.center, ), - const SizedBox(height: 3), + const SizedBox(height: ConstantDimensions.heightExtraSmall / 2), SvgPicture.asset( item.iconAsset, width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.width * 0.3, alignment: Alignment.center, ), - const SizedBox(height: 3), + const SizedBox(height: ConstantDimensions.heightExtraSmall / 2), Text(item.description, textAlign: TextAlign.center), ], ), @@ -164,7 +165,7 @@ class _PopupDialogState extends State<_PopupDialog> { ), textAlign: TextAlign.center, ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), GestureDetector( onTap: () { _speakText(currentItem.description); @@ -176,7 +177,7 @@ class _PopupDialogState extends State<_PopupDialog> { alignment: Alignment.center, ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( currentItem.description, textAlign: TextAlign.center, @@ -184,7 +185,7 @@ class _PopupDialogState extends State<_PopupDialog> { fontSize: 28, ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -198,7 +199,7 @@ class _PopupDialogState extends State<_PopupDialog> { ), ], ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -213,7 +214,7 @@ class _PopupDialogState extends State<_PopupDialog> { style: TextStyle(color: Colors.white), ), ), - const SizedBox(height: 50), + const SizedBox(height: ConstantDimensions.heightExtraLarge), ], ), ), diff --git a/lib/pages/modules/birds.dart b/lib/pages/modules/birds.dart index e8a138b..8f86711 100644 --- a/lib/pages/modules/birds.dart +++ b/lib/pages/modules/birds.dart @@ -6,6 +6,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + class Bird { final String name; final String svgAsset; @@ -89,8 +91,8 @@ class _BirdWidgetState extends State { GestureDetector( onTap: _navigateToNextBird, child: Container( - width: 375, - height: 375, + width: ConstantDimensions.exceptions[1], + height: ConstantDimensions.exceptions[1], decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(8.0), @@ -100,15 +102,15 @@ class _BirdWidgetState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 350, - height: 350, + width:ConstantDimensions.widthExtraLarge * 7, + height: ConstantDimensions.heightExtraLarge * 7, child: SvgPicture.asset(bird.svgAsset), ), ], ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), IconButton.outlined( highlightColor: Colors.amber, onPressed: () { @@ -126,7 +128,7 @@ class _BirdWidgetState extends State { fontFamily: 'Comic', ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -134,14 +136,14 @@ class _BirdWidgetState extends State { onPressed: _navigateToPreviousBird, icon: const Icon(Icons.arrow_back), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), ElevatedButton( onPressed: () { _playBirdSound(bird.soundAsset); }, child: const Text('Play Sound'), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton( onPressed: _navigateToNextBird, icon: const Icon(Icons.arrow_forward), diff --git a/lib/pages/modules/colours.dart b/lib/pages/modules/colours.dart index 4c9a2df..474a47f 100644 --- a/lib/pages/modules/colours.dart +++ b/lib/pages/modules/colours.dart @@ -3,6 +3,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/assets_path.dart'; +import '../../utils/const_dimensions.dart'; + class Colours { final String name; final String jpgAsset; @@ -146,14 +148,14 @@ class _ColoursPageState extends State { onTap: _navigateToNextColour, child: Container( width: double.infinity, - height: 300, + height: ConstantDimensions.heightExtraLarge * 6, child: SvgPicture.asset( colour.jpgAsset, fit: BoxFit.contain, ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( colour.name, style: TextStyle( @@ -163,7 +165,7 @@ class _ColoursPageState extends State { color: colour.fontColor, ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -174,7 +176,7 @@ class _ColoursPageState extends State { size: 30, ), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton.outlined( highlightColor: Colors.amber, onPressed: () { @@ -185,7 +187,7 @@ class _ColoursPageState extends State { size: 40, ), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton( onPressed: _navigateToNextColour, icon: const Icon( diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 41aa7f5..6a46589 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -3,6 +3,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:learn/utils/assets_path.dart'; +import '../../utils/const_dimensions.dart'; + class Flower{ final String name; @@ -97,14 +99,14 @@ class _FlowerPageState extends State { onTap: _navigateToNextFlower, child: Container( width: double.infinity, - height: 300, + height: ConstantDimensions.heightExtraLarge * 6, child: SvgPicture.asset( flower.resource, fit: BoxFit.contain, ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( flower.name, style: const TextStyle( @@ -113,7 +115,7 @@ class _FlowerPageState extends State { fontFamily: 'Comic', ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -124,7 +126,7 @@ class _FlowerPageState extends State { size: 30, ), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton.outlined( highlightColor: Colors.amber, onPressed: () { @@ -135,7 +137,7 @@ class _FlowerPageState extends State { size: 40, ), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton( onPressed: _navigateToNextFlower, icon: const Icon( diff --git a/lib/pages/modules/occupation.dart b/lib/pages/modules/occupation.dart index ee160c6..77bab34 100644 --- a/lib/pages/modules/occupation.dart +++ b/lib/pages/modules/occupation.dart @@ -4,6 +4,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + class Occupation { final String name; final String description; @@ -72,9 +74,9 @@ class _OccupationWidgetState extends State { Occupation occupation = widget.occupations[currentIndex]; return Column( children: [ - const SizedBox(height: 10.0), + const SizedBox(height: ConstantDimensions.heightSmall), Container( - width: 350, + width: ConstantDimensions.widthExtraLarge * 7, height: MediaQuery.of(context).size.height / 2, decoration: BoxDecoration( border: Border.all(color: Colors.black), @@ -89,7 +91,7 @@ class _OccupationWidgetState extends State { ), ), ), - const SizedBox(height: 20.0), + const SizedBox(height: ConstantDimensions.heightMedium), Text( occupation.name, style: const TextStyle( @@ -97,7 +99,7 @@ class _OccupationWidgetState extends State { fontWeight: FontWeight.bold, ), ), - const SizedBox(height: 10.0), + const SizedBox(height: ConstantDimensions.heightSmall), Padding( padding: const EdgeInsets.only( right: 8.0, @@ -111,7 +113,7 @@ class _OccupationWidgetState extends State { ), ), ), - const SizedBox(height: 30.0), + const SizedBox(height: ConstantDimensions.heightLarge), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -119,14 +121,14 @@ class _OccupationWidgetState extends State { onPressed: _previousOccupation, icon: const Icon(Icons.arrow_back), ), - const SizedBox(width: 20.0), + const SizedBox(width: ConstantDimensions.widthMedium), ElevatedButton( onPressed: () { _playOccupationName(occupation.name); }, child: const Text("Play Sound"), ), - const SizedBox(width: 20.0), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton( onPressed: _nextOccupation, icon: const Icon(Icons.arrow_forward), diff --git a/lib/pages/modules/parts.dart b/lib/pages/modules/parts.dart index 34a6708..d26e7e7 100644 --- a/lib/pages/modules/parts.dart +++ b/lib/pages/modules/parts.dart @@ -9,6 +9,8 @@ import 'package:learn/utils/constants.dart'; import 'package:learn/utils/functions.dart'; import 'package:learn/utils/responsive_screen_provider.dart'; +import '../../utils/const_dimensions.dart'; + void main() { runApp( const MaterialApp( @@ -135,7 +137,7 @@ class _PartsPagePageState extends State { fontSize: 50, fontWeight: FontWeight.bold), ), const SizedBox( - width: 150, + width: ConstantDimensions.widthExtraLarge * 3, ), Row( children: [ @@ -150,7 +152,7 @@ class _PartsPagePageState extends State { }, ), const SizedBox( - width: 25, + width: ConstantDimensions.widthExtraLarge / 2, ), IconButton( onPressed: controller.undo, @@ -162,10 +164,10 @@ class _PartsPagePageState extends State { ), ], ), - const SizedBox(height: 10), - const SizedBox(height: 5), + const SizedBox(height: ConstantDimensions.heightSmall), + SizedBox(height: ConstantDimensions.exceptions[2]), SizedBox( - height: 200, + height: ConstantDimensions.heightExtraLarge * 4, child: SingleChildScrollView( clipBehavior: Clip.hardEdge, child: Text( @@ -231,19 +233,19 @@ class PartsPageCard extends StatelessWidget { child: Card( color: color, child: SizedBox( - width: 300, - height: 300, + width: ConstantDimensions.widthExtraLarge * 6, + height: ConstantDimensions.heightExtraLarge * 6, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: SvgPicture.asset( AssetsPath.getBodyImage("$name.svg"), - width: 250, - height: 250, + width: ConstantDimensions.widthExtraLarge * 5, + height: ConstantDimensions.heightExtraLarge * 5, ), ), - const SizedBox(height: 10), + const SizedBox(height: ConstantDimensions.heightSmall), ], ), ), diff --git a/lib/pages/modules/planets.dart b/lib/pages/modules/planets.dart index e16818d..c6bd0fd 100644 --- a/lib/pages/modules/planets.dart +++ b/lib/pages/modules/planets.dart @@ -4,6 +4,8 @@ import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/assets_path.dart'; +import '../../utils/const_dimensions.dart'; + class Planet { final String name; final String svgAsset; @@ -138,7 +140,7 @@ class _PlanetWidgetState extends State { onTap: _navigateToNextPlanet, child: AnimatedContainer( duration: _animationDuration, - width: 350, + width: ConstantDimensions.widthExtraLarge * 7, height: MediaQuery.of(context).size.height * 0.6, decoration: BoxDecoration( border: Border.all(color: Colors.black), @@ -156,7 +158,7 @@ class _PlanetWidgetState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( planet.description, style: const TextStyle( @@ -165,7 +167,7 @@ class _PlanetWidgetState extends State { ), textAlign: TextAlign.center, ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -173,14 +175,14 @@ class _PlanetWidgetState extends State { onPressed: _navigateToPreviousPlanet, icon: const Icon(Icons.arrow_back), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), ElevatedButton( onPressed: () { _playPlanetName(planet.name); }, child: const Text('Play Sound'), ), - const SizedBox(width: 20), + const SizedBox(width: ConstantDimensions.widthMedium), IconButton( onPressed: _navigateToNextPlanet, icon: const Icon(Icons.arrow_forward), diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index 1de3e79..da97828 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; +import '../../utils/const_dimensions.dart'; + class Season { final String name; final String description; @@ -46,12 +48,12 @@ class SeasonsPage extends StatelessWidget { child: Row( children: [ SizedBox( - width: 50, - height: 50, + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, child: SvgPicture.asset( AppConstants.seasons[index].imageAsset), ), - const SizedBox(width: 28.0), + const SizedBox(width: ConstantDimensions.widthMedium_Large), Text( AppConstants.seasons[index].name, style: const TextStyle( @@ -122,11 +124,11 @@ class _SeasonPopupState extends State { mainAxisSize: MainAxisSize.min, children: [ SizedBox( - width: 200, - height: 200, + width: ConstantDimensions.widthExtraLarge * 4, + height: ConstantDimensions.heightExtraLarge * 4, child: SvgPicture.asset(currentSeason.imageAsset), ), - const SizedBox(height: 16), + const SizedBox(height: ConstantDimensions.heightSmall_Medium), Text( currentSeason.description, style: const TextStyle(fontSize: 16.0), diff --git a/lib/pages/modules/shapes.dart b/lib/pages/modules/shapes.dart index f98184d..97b3c1d 100644 --- a/lib/pages/modules/shapes.dart +++ b/lib/pages/modules/shapes.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:learn/utils/constants.dart'; import 'package:learn/widgets/drawer.dart'; +import '../../utils/const_dimensions.dart'; + class ShapesPage extends StatelessWidget { const ShapesPage({Key? key}) : super(key: key); @@ -22,7 +24,7 @@ class ShapesPage extends StatelessWidget { Image.asset( 'assets/images/shape.gif', ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), const Text( AppConstants.underConstruction, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), diff --git a/lib/utils/const_dimensions.dart b/lib/utils/const_dimensions.dart new file mode 100644 index 0000000..118a879 --- /dev/null +++ b/lib/utils/const_dimensions.dart @@ -0,0 +1,19 @@ +class ConstantDimensions { + static const double heightExtraSmall = 6; + static const double heightSmall = 10; + static const double heightSmall_Medium = 16; + static const double heightMedium = 20; + static const double heightMedium_Large = 28; + static const double heightLarge = 30; + static const double heightExtraLarge = 50; + + static const double widthExtraSmall = 6; + static const double widthSmall = 10; + static const double widthSmall_Medium = 16; + static const double widthMedium = 20; + static const double widthMedium_Large = 28; + static const double widthLarge = 30; + static const double widthExtraLarge = 50; + + static const List exceptions = [135, 375, 5]; +} \ No newline at end of file diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index a53654e..746aee4 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -3,17 +3,10 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:learn/pages/fruits.dart'; -import 'package:flutter/material.dart'; -import 'package:learn/pages/fruits.dart'; -import 'package:flutter/material.dart'; -import 'package:learn/pages/fruits.dart'; -import 'package:flutter/material.dart'; -import 'package:learn/pages/fruits.dart'; import '../pages/explore/quiz.dart'; -import 'package:flutter/material.dart'; import 'package:learn/pages/modules/colours.dart'; import 'package:learn/pages/modules/parts.dart'; import 'package:learn/pages/modules/planets.dart'; From dbd4416c7653ff36fb06ccd3634b73249acd2d3c Mon Sep 17 00:00:00 2001 From: Sapate Vaibhav Date: Sat, 25 May 2024 16:26:24 +0530 Subject: [PATCH 2/3] Update home.dart --- lib/pages/home.dart | 284 +++++++++----------------------------------- 1 file changed, 57 insertions(+), 227 deletions(-) diff --git a/lib/pages/home.dart b/lib/pages/home.dart index bc7f4ab..bf0100a 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:learn/main.dart'; import 'package:learn/utils/assets_path.dart'; +import 'package:learn/utils/const_dimensions.dart'; -import '../utils/const_dimensions.dart'; import '../utils/routes.dart'; import '../widgets/drawer.dart'; @@ -79,245 +79,73 @@ class _MyHomePageState extends State { route: AllRoutes.atozRoute, index: 0, ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'ALPHABETS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - const Text("Learn A to Z with pronunciation and an example"), - const SizedBox( height: ConstantDimensions.heightMedium, ), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked2 = !_isImageClicked2; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.animalRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked2 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: DecorationImage( - image: AssetImage(AssetsPath.getAnimalImage(Animals.animals)), - fit: BoxFit.cover, - ), - ), - ), - ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'ANIMALS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - + categoryCard( + context: context, + title: "ANIMALS", + image: AssetsPath.getAnimalImage(Animals.animals), + shortDescription: "Learn about animals and their voices", + route: AllRoutes.animalRoute, + index: 1, ), const SizedBox( height: ConstantDimensions.heightMedium, ), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked3 = !_isImageClicked3; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.partsRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked3 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: DecorationImage( - image: AssetImage(AssetsPath.getBodyImage(Body.body)), - fit: BoxFit.cover, - ), - ), - ), - ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'BODY PARTS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + categoryCard( + context: context, + title: "BODY PARTS", + image: AssetsPath.getBodyImage(Body.body), + shortDescription: + "Know about body parts and their pronunciation.", + route: AllRoutes.partsRoute, + index: 2, ), - const Text("Know about body parts and their pronunciation."), - const SizedBox(height: ConstantDimensions.heightMedium), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked4 = !_isImageClicked4; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.birdsRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked4 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: DecorationImage( - image: AssetImage(AssetsPath.getBirdImage(Birds.birds)), - fit: BoxFit.cover, - ), - ), - ), + const SizedBox( + height: ConstantDimensions.heightMedium, ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'BIRDS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + categoryCard( + context: context, + title: "BIRDS", + image: AssetsPath.getBirdImage(Birds.birds), + shortDescription: "Look out for Birds with their sounds.", + route: AllRoutes.birdsRoute, + index: 3, ), - const Text("Look out for Birds with their sounds."), - const SizedBox(height: ConstantDimensions.heightMedium), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked4 = !_isImageClicked4; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.colourRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked4 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: DecorationImage( - image: AssetImage( - AssetsPath.getColoursImage(ColorImages.colorsCover)), - fit: BoxFit.cover, - ), - ), - ), + const SizedBox( + height: ConstantDimensions.heightMedium, ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'COLOURS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + categoryCard( + context: context, + title: "COLOURS", + image: AssetsPath.getColoursImage(ColorImages.colorsCover), + shortDescription: "Explore and learn about the colours!", + route: AllRoutes.colourRoute, + index: 4, ), - const Text("Explore and learn about the colours!"), - const SizedBox(height: ConstantDimensions.heightMedium), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked5 = !_isImageClicked5; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.flowerRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked5 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: DecorationImage( - image: AssetImage(AssetsPath.getFlowerImage(Flowers.flowerBanner)), - fit: BoxFit.cover, - ), - ), - ), + const SizedBox( + height: ConstantDimensions.heightMedium, ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'FLOWERS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + categoryCard( + context: context, + title: "FLOWERS", + image: AssetsPath.getFlowerImage(Flowers.flowerBanner), + shortDescription: "Explore beauty of nature flowers.", + route: AllRoutes.flowerRoute, + index: 5, ), - const Text("Explore beauty of nature flowers."), - const SizedBox(height: ConstantDimensions.heightMedium), - GestureDetector( - onTap: () { - setState(() { - _isImageClicked4 = !_isImageClicked4; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.fruitRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked4 ? 325 : 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.black, width: 2), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - image: const DecorationImage( - image: AssetImage('assets/fruitsVeges/cover.jpg'), - fit: BoxFit.cover, - ), - ), - ), + const SizedBox( + height: ConstantDimensions.heightMedium, ), - const SizedBox(height: ConstantDimensions.heightMedium), - const Text( - 'Fruits & Vegetables', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - + categoryCard( + context: context, + title: "FRUITS & VEGETABLES", + image: 'assets/fruitsVeges/cover.jpg', + shortDescription: + "Explore and learn about Fruits and Vegetables!", + route: AllRoutes.fruitRoute, + index: 6, ), ], ), @@ -350,7 +178,9 @@ class _MyHomePageState extends State { child: AnimatedContainer( duration: const Duration(milliseconds: 300), curve: Curves.easeInOut, - height: _isImageClicked[index] ? 325 : 350, + height: _isImageClicked[index] + ? ConstantDimensions.heightSmallImage + : ConstantDimensions.heightBigImage, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.black, width: 2), @@ -369,7 +199,7 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 20), + const SizedBox(height: ConstantDimensions.heightMedium), Text( title, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), From 22253468c845a27f8748cb89fefa43521f12919a Mon Sep 17 00:00:00 2001 From: Sapate Vaibhav Date: Sat, 25 May 2024 16:27:18 +0530 Subject: [PATCH 3/3] Update const_dimensions.dart --- lib/utils/const_dimensions.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils/const_dimensions.dart b/lib/utils/const_dimensions.dart index 118a879..bb30064 100644 --- a/lib/utils/const_dimensions.dart +++ b/lib/utils/const_dimensions.dart @@ -15,5 +15,9 @@ class ConstantDimensions { static const double widthLarge = 30; static const double widthExtraLarge = 50; + + static const double heightSmallImage = 325; + static const double heightBigImage = 350; + static const List exceptions = [135, 375, 5]; -} \ No newline at end of file +}