From 1edf90bf53b1da7055f45d8a56bb7da582428a3e Mon Sep 17 00:00:00 2001 From: Gaurav-Kushwaha-1225 Date: Sun, 26 May 2024 16:04:43 +0530 Subject: [PATCH] New Constants added --- lib/pages/modules/atoz.dart | 2 +- lib/pages/modules/colours.dart | 73 ++----------- lib/pages/modules/flowers.dart | 55 +--------- lib/pages/modules/occupation.dart | 2 +- lib/pages/modules/planets.dart | 61 +---------- lib/pages/modules/seasons.dart | 2 +- lib/utils/constants.dart | 175 +++++++++++++++++++++++++++++- 7 files changed, 192 insertions(+), 178 deletions(-) diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index 219cc01..5137b1c 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -261,7 +261,7 @@ class _AtoZState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( - 'A-Z', + AppConstants.a_z, style: TextStyle(fontWeight: FontWeight.bold), ), Expanded( diff --git a/lib/pages/modules/colours.dart b/lib/pages/modules/colours.dart index 5c407ab..80aa7d8 100644 --- a/lib/pages/modules/colours.dart +++ b/lib/pages/modules/colours.dart @@ -7,6 +7,8 @@ import 'package:learn/utils/assets_path.dart'; import '../../utils/const_dimensions.dart'; import 'package:learn/models/colours_model.dart'; +import '../../utils/constants.dart'; + class ColoursPage extends StatefulWidget { const ColoursPage({Key? key}) : super(key: key); @@ -15,81 +17,20 @@ 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) % colours.length; + currentIndex = (currentIndex + 1) % AppConstants.colours.length; }); } void _navigateToPreviousColour() { setState(() { - currentIndex = (currentIndex - 1 + colours.length) % colours.length; + currentIndex = (currentIndex - 1 + AppConstants.colours.length) % AppConstants.colours.length; }); } @@ -100,11 +41,11 @@ class _ColoursPageState extends State { @override Widget build(BuildContext context) { - Colours colour = colours[currentIndex]; + Colours colour = AppConstants.colours[currentIndex]; return Scaffold( appBar: AppBar( title: Text( - 'Colours', + AppConstants.color, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 30, diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 075f0d2..c6d200e 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -3,6 +3,7 @@ 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/assets_path.dart'; +import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; @@ -14,65 +15,19 @@ 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) % flowers.length; + currentIndex = (currentIndex + 1) % AppConstants.flowers.length; }); } void _navigateToPreviousFlower() { setState(() { - currentIndex = (currentIndex - 1 + flowers.length) % flowers.length; + currentIndex = (currentIndex - 1 + AppConstants.flowers.length) % AppConstants.flowers.length; }); } @@ -85,11 +40,11 @@ class _FlowerPageState extends State { @override Widget build(BuildContext context) { - Flower flower = flowers[currentIndex]; + Flower flower = AppConstants.flowers[currentIndex]; return Scaffold( appBar: AppBar( title: const Text( - 'Flowers', + AppConstants.flower, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 30, diff --git a/lib/pages/modules/occupation.dart b/lib/pages/modules/occupation.dart index 4225e71..7e7b5ee 100644 --- a/lib/pages/modules/occupation.dart +++ b/lib/pages/modules/occupation.dart @@ -17,7 +17,7 @@ class OccupationPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: const Text( - 'Occupations', + AppConstants.occupation, style: TextStyle(fontWeight: FontWeight.bold), ), leading: IconButton( diff --git a/lib/pages/modules/planets.dart b/lib/pages/modules/planets.dart index 2ee6b88..25abc4f 100644 --- a/lib/pages/modules/planets.dart +++ b/lib/pages/modules/planets.dart @@ -5,66 +5,11 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/assets_path.dart'; +import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; import 'package:learn/models/planet_model.dart'; class PlanetsPage extends StatelessWidget { - final List planets = [ - Planet( - name: 'Sun', - svgAsset: AssetsPath.getSolarImage(SolarSystem.sun), - description: 'Sun is the biggest star in the solar system.', - backgroundColor: const Color.fromARGB(255, 208, 211, 23), - ), - Planet( - name: 'Mercury', - svgAsset: AssetsPath.getSolarImage(SolarSystem.mercury), - description: 'Mercury is the closest planet to the Sun.', - backgroundColor: const Color.fromARGB(255, 221, 221, 221), - ), - Planet( - name: 'Venus', - svgAsset: AssetsPath.getSolarImage(SolarSystem.venus), - description: 'Venus is known for its thick atmosphere.', - backgroundColor: const Color.fromARGB(255, 240, 193, 95), - ), - Planet( - name: 'Earth', - svgAsset: AssetsPath.getSolarImage(SolarSystem.earth), - description: 'Earth is the third planet from the Sun.', - backgroundColor: const Color.fromARGB(255, 81, 149, 192), - ), - Planet( - name: 'Mars', - svgAsset: AssetsPath.getSolarImage(SolarSystem.mars), - description: 'Mars is often called the Red Planet.', - backgroundColor: const Color.fromARGB(255, 238, 118, 96), - ), - Planet( - name: 'Jupiter', - svgAsset: AssetsPath.getSolarImage(SolarSystem.jupiter), - description: 'Jupiter is the largest planet in our solar system.', - backgroundColor: const Color.fromARGB(255, 204, 164, 122), - ), - Planet( - name: 'Saturn', - svgAsset: AssetsPath.getSolarImage(SolarSystem.saturn), - description: 'Saturn is known for its beautiful rings.', - backgroundColor: const Color.fromARGB(255, 229, 215, 194), - ), - Planet( - name: 'Uranus', - svgAsset: AssetsPath.getSolarImage(SolarSystem.uranus), - description: 'Uranus is an ice giant with a unique rotation axis.', - backgroundColor: const Color.fromARGB(255, 169, 222, 246), - ), - Planet( - name: 'Neptune', - svgAsset: AssetsPath.getSolarImage(SolarSystem.neptune), - description: 'Neptune is the farthest planet from the Sun.', - backgroundColor: const Color.fromARGB(255, 64, 90, 200), - ), - ]; final FlutterTts flutterTts = FlutterTts(); final AudioPlayer audioPlayer = AudioPlayer(); @@ -76,7 +21,7 @@ class PlanetsPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: const Text( - 'Solar System', + AppConstants.solar, style: TextStyle(fontWeight: FontWeight.bold), ), leading: IconButton( @@ -89,7 +34,7 @@ class PlanetsPage extends StatelessWidget { body: SingleChildScrollView( child: Center( child: PlanetWidget( - planets: planets, + planets: AppConstants.planets, flutterTts: flutterTts, audioPlayer: audioPlayer, ), diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index 5f4c9c4..72f7156 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -14,7 +14,7 @@ class SeasonsPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: const Text( - 'Seasons Serenade', + AppConstants.season, style: TextStyle(fontWeight: FontWeight.bold), ), ), diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 253e5bf..bf81d6f 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -7,6 +7,9 @@ import 'package:learn/models/occupation_model.dart'; import 'package:learn/models/season_model.dart'; import 'package:flutter/material.dart'; import 'package:learn/pages/fruits.dart'; +import '../models/colours_model.dart'; +import '../models/flower_model.dart'; +import '../models/planet_model.dart'; import '../pages/explore/quiz.dart'; import 'package:learn/pages/modules/colours.dart'; import 'package:learn/pages/modules/parts.dart'; @@ -21,6 +24,173 @@ import '../pages/modules/atoz.dart'; import '../pages/modules/birds.dart'; class AppConstants { + static List planets = [ + Planet( + name: 'Sun', + svgAsset: AssetsPath.getSolarImage(SolarSystem.sun), + description: 'Sun is the biggest star in the solar system.', + backgroundColor: const Color.fromARGB(255, 208, 211, 23), + ), + Planet( + name: 'Mercury', + svgAsset: AssetsPath.getSolarImage(SolarSystem.mercury), + description: 'Mercury is the closest planet to the Sun.', + backgroundColor: const Color.fromARGB(255, 221, 221, 221), + ), + Planet( + name: 'Venus', + svgAsset: AssetsPath.getSolarImage(SolarSystem.venus), + description: 'Venus is known for its thick atmosphere.', + backgroundColor: const Color.fromARGB(255, 240, 193, 95), + ), + Planet( + name: 'Earth', + svgAsset: AssetsPath.getSolarImage(SolarSystem.earth), + description: 'Earth is the third planet from the Sun.', + backgroundColor: const Color.fromARGB(255, 81, 149, 192), + ), + Planet( + name: 'Mars', + svgAsset: AssetsPath.getSolarImage(SolarSystem.mars), + description: 'Mars is often called the Red Planet.', + backgroundColor: const Color.fromARGB(255, 238, 118, 96), + ), + Planet( + name: 'Jupiter', + svgAsset: AssetsPath.getSolarImage(SolarSystem.jupiter), + description: 'Jupiter is the largest planet in our solar system.', + backgroundColor: const Color.fromARGB(255, 204, 164, 122), + ), + Planet( + name: 'Saturn', + svgAsset: AssetsPath.getSolarImage(SolarSystem.saturn), + description: 'Saturn is known for its beautiful rings.', + backgroundColor: const Color.fromARGB(255, 229, 215, 194), + ), + Planet( + name: 'Uranus', + svgAsset: AssetsPath.getSolarImage(SolarSystem.uranus), + description: 'Uranus is an ice giant with a unique rotation axis.', + backgroundColor: const Color.fromARGB(255, 169, 222, 246), + ), + Planet( + name: 'Neptune', + svgAsset: AssetsPath.getSolarImage(SolarSystem.neptune), + description: 'Neptune is the farthest planet from the Sun.', + backgroundColor: const Color.fromARGB(255, 64, 90, 200), + ), + ]; + + static 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), + ]; + + static 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, + ), + ]; + static List modules = [ Module( name: 'Quiz', @@ -856,8 +1026,11 @@ class AppConstants { static const String parts = 'Body Parts'; static const String shape = 'Shapes'; static const String solar = 'Solar System'; - static const String flowers = 'Flowers'; + static const String color = 'Colours'; + static const String flower = 'Flowers'; static const String fruit = 'Fruits & Vegetables'; + static const String occupation = 'Occupations'; + static const String season = 'Seasons Serenade'; static const String description = 'Interactive app to let your kids learn various things like\n\n - A - Z alphabets.\n - Animals and their sounds.\n - Birds and their sounds.\n - Various shapes.\n - Body parts.\n - Solar system.\n'; }