From 682907db4f119ed7243cfabd69689a7587a5f8ee Mon Sep 17 00:00:00 2001 From: Prathme07 Date: Sun, 12 May 2024 00:07:23 +0530 Subject: [PATCH 1/3] Made the screen flexible for any screen sizes. resolve picture problem due to dark background, removed rectangle from pop up, changes the UI --- lib/pages/atoz.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/atoz.dart b/lib/pages/atoz.dart index e0b1937..d5604e2 100644 --- a/lib/pages/atoz.dart +++ b/lib/pages/atoz.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'dart:async'; From 28f47f7001b13cbfe3558167ce728d6139a2a33d Mon Sep 17 00:00:00 2001 From: Prathme07 Date: Sun, 12 May 2024 00:26:09 +0530 Subject: [PATCH 2/3] made some minor changes --- lib/pages/atoz.dart | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/pages/atoz.dart b/lib/pages/atoz.dart index de50065..d5604e2 100644 --- a/lib/pages/atoz.dart +++ b/lib/pages/atoz.dart @@ -3,7 +3,6 @@ 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/constants.dart'; class ItemTile extends StatelessWidget { final int index; @@ -247,8 +246,9 @@ class AtoZ extends StatefulWidget { class _AtoZState extends State { bool isTimerEnabled = false; - List items = [ + // Add your ItemData list here + // Example: ItemData( iconAsset: 'assets/images/apple.svg', title: 'A', @@ -407,7 +407,6 @@ class _AtoZState extends State { ), ]; - @override Widget build(BuildContext context) { return Scaffold( @@ -416,7 +415,7 @@ class _AtoZState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( - AppConstants.a_z, + 'A-Z', style: TextStyle(fontWeight: FontWeight.bold), ), Expanded( @@ -446,9 +445,8 @@ class _AtoZState extends State { body: Padding( padding: const EdgeInsets.all(9), child: GridView.count( - - crossAxisCount: MediaQuery.of(context).size.width ~/ 200, - childAspectRatio: 1.0, + crossAxisCount: MediaQuery.of(context).size.width ~/ 200, // Adjust the value based on screen width + childAspectRatio: 1.0, // Aspect ratio of items children: List.generate( items.length, (index) => ItemTile( @@ -457,17 +455,6 @@ class _AtoZState extends State { isTimerEnabled: isTimerEnabled, ), ), - - crossAxisCount: 2, - children: [ - for (int i = 0; i < AppConstants.items.length; i++) - ItemTile( - index: i, - items: AppConstants.items, - isTimerEnabled: isTimerEnabled, - ), - ], - ), ), ); From 06f2d77d832d1cd059ae8f2569d82f6ce2650ab9 Mon Sep 17 00:00:00 2001 From: Prathme07 Date: Sun, 12 May 2024 11:06:09 +0530 Subject: [PATCH 3/3] Added the toast that say press back again to exit --- lib/main.dart | 428 +++++++++++++++++++++++-------------------- lib/pages/solar.dart | 22 +-- pubspec.lock | 56 +++++- pubspec.yaml | 1 + 4 files changed, 275 insertions(+), 232 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index a4bce4d..9210bc0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,9 @@ import 'package:learn/pages/solar.dart'; import 'package:learn/utils/routes.dart'; import 'package:learn/widgets/drawer.dart'; import 'package:learn/pages/colours.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +DateTime? currentBackPressTime; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -63,236 +66,255 @@ class _MyHomePageState extends State { bool _isImageClicked3 = false; bool _isImageClicked4 = false; bool _isDarkTheme = false; + + Future _onBackPressed() { + DateTime now = DateTime.now(); + if (currentBackPressTime == null || + now.difference(currentBackPressTime!) > const Duration(seconds: 2)) { + currentBackPressTime = now; + Fluttertoast.showToast( + msg: "Press back again to exit", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + ); + return Future.value(false); + } + return Future.value(true); + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text( - 'Home', - style: TextStyle(fontWeight: FontWeight.bold), - ), - actions: [ - IconButton( - icon: Icon( - _isDarkTheme ? Icons.dark_mode : Icons.light_mode, - ), - onPressed: () { - setState(() { - _isDarkTheme = !_isDarkTheme; - }); - final themeMode = Theme.of(context).brightness == Brightness.dark - ? AdaptiveThemeMode.light - : AdaptiveThemeMode.dark; - AdaptiveTheme.of(context).setThemeMode(themeMode); - }, + return WillPopScope( + onWillPop: _onBackPressed, + child: Scaffold( + appBar: AppBar( + title: const Text( + 'Home', + style: TextStyle(fontWeight: FontWeight.bold), ), - ], - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(38.0), - child: Column( - children: [ - GestureDetector( - onTap: () { - setState(() { - _isImageClicked1 = !_isImageClicked1; - }); - Future.delayed(const Duration(milliseconds: 300), () { - Navigator.pushNamed(context, AllRoutes.atozRoute); - }); - }, - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: _isImageClicked1 ? 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), + actions: [ + IconButton( + icon: Icon( + _isDarkTheme ? Icons.dark_mode : Icons.light_mode, + ), + onPressed: () { + setState(() { + _isDarkTheme = !_isDarkTheme; + }); + final themeMode = Theme.of(context).brightness == Brightness.dark + ? AdaptiveThemeMode.light + : AdaptiveThemeMode.dark; + AdaptiveTheme.of(context).setThemeMode(themeMode); + }, + ), + ], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(38.0), + child: Column( + children: [ + GestureDetector( + onTap: () { + setState(() { + _isImageClicked1 = !_isImageClicked1; + }); + Future.delayed(const Duration(milliseconds: 300), () { + Navigator.pushNamed(context, AllRoutes.atozRoute); + }); + }, + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + height: _isImageClicked1 ? 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/images/alphabets.jpg'), + fit: BoxFit.cover, ), - ], - image: const DecorationImage( - image: AssetImage('assets/images/alphabets.jpg'), - fit: BoxFit.cover, ), ), ), - ), - const SizedBox(height: 20), - 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, - ), - 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), + const SizedBox(height: 20), + 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, + ), + 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: const DecorationImage( + image: AssetImage('assets/images/animals.jpg'), + fit: BoxFit.cover, ), - ], - image: const DecorationImage( - image: AssetImage('assets/images/animals.jpg'), - fit: BoxFit.cover, ), ), ), - ), - const SizedBox(height: 20), - const Text( - 'ANIMALS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - const Text("Learn about animals and their voices"), - const SizedBox( - height: 20, - ), - 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), + const SizedBox(height: 20), + const Text( + 'ANIMALS', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + const Text("Learn about animals and their voices"), + const SizedBox( + height: 20, + ), + 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: const DecorationImage( + image: AssetImage('assets/body/body.jpg'), + fit: BoxFit.cover, ), - ], - image: const DecorationImage( - image: AssetImage('assets/body/body.jpg'), - fit: BoxFit.cover, ), ), ), - ), - const SizedBox(height: 20), - const Text( - 'BODY PARTS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - const Text("Know about body parts and their pronunciation."), - const SizedBox(height: 20), - 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), + const SizedBox(height: 20), + const Text( + 'BODY PARTS', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + const Text("Know about body parts and their pronunciation."), + const SizedBox(height: 20), + 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: const DecorationImage( + image: AssetImage('assets/images/birds.jpg'), + fit: BoxFit.cover, ), - ], - image: const DecorationImage( - image: AssetImage('assets/images/birds.jpg'), - fit: BoxFit.cover, ), ), ), - ), - const SizedBox(height: 20), - const Text( - 'BIRDS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - const Text("Look out for Birds with their sounds."), - - const SizedBox(height: 20), - 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), + const SizedBox(height: 20), + const Text( + 'BIRDS', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + const Text("Look out for Birds with their sounds."), + + const SizedBox(height: 20), + 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: const DecorationImage( + image: AssetImage('assets/images/colours/colors-cover.png'), + fit: BoxFit.cover, ), - ], - image: const DecorationImage( - image: AssetImage('assets/images/colours/colors-cover.png'), - fit: BoxFit.cover, ), ), ), - ), - const SizedBox(height: 20), - const Text( - 'COLOURS', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - const Text("Explore and learn about the colours!"), + const SizedBox(height: 20), + const Text( + 'COLOURS', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + const Text("Explore and learn about the colours!"), - ], + ], + ), ), ), + drawer: const MyDrawer(), ), - drawer: const MyDrawer(), ); } } diff --git a/lib/pages/solar.dart b/lib/pages/solar.dart index c321134..ad6e3f7 100644 --- a/lib/pages/solar.dart +++ b/lib/pages/solar.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; - import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; @@ -82,20 +81,12 @@ class PlanetsPage extends StatelessWidget { PlanetsPage({Key? key}) : super(key: key); -======= -import 'package:learn/utils/constants.dart'; -import 'package:learn/widgets/drawer.dart'; - -class SolarPage extends StatelessWidget { - const SolarPage({Key? key}) : super(key: key); - - @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text( - AppConstants.solar, + 'Solar System', style: TextStyle(fontWeight: FontWeight.bold), ), leading: IconButton( @@ -182,7 +173,6 @@ class _PlanetWidgetState extends State { onPressed: _navigateToPreviousPlanet, icon: const Icon(Icons.arrow_back), ), - const SizedBox(width: 20), ElevatedButton( onPressed: () { @@ -194,16 +184,6 @@ class _PlanetWidgetState extends State { IconButton( onPressed: _navigateToNextPlanet, icon: const Icon(Icons.arrow_forward), - - const SizedBox(height: 20), - const Text( - AppConstants.underConstruction, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), ], ), diff --git a/pubspec.lock b/pubspec.lock index b3514fa..b1849e9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -160,6 +160,14 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + sha256: "81b68579e23fcbcada2db3d50302813d2371664afe6165bc78148050ab94bf66" + url: "https://pub.dev" + source: hosted + version: "8.2.5" google_fonts: dependency: "direct main" description: @@ -208,6 +216,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.9" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -220,34 +252,34 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -565,6 +597,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 09fbb59..0e1c10e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: card_swiper: ^3.0.1 flutter_card_swiper: ^7.0.0 adaptive_theme: ^3.6.0 + fluttertoast: ^8.2.5 dev_dependencies: flutter_test: