From fca4f663098f942e3dbe4740cb5e73839c9360c7 Mon Sep 17 00:00:00 2001 From: Maheen Ilyas Date: Sun, 19 May 2024 20:35:03 +0300 Subject: [PATCH 1/2] The model classes moved to models folder in the lib folder --- lib/models/animal_model.dart | 15 +++++++++++++++ lib/models/bird_model.dart | 15 +++++++++++++++ lib/models/colours_model.dart | 15 +++++++++++++++ lib/models/itemdata_model.dart | 15 +++++++++++++++ lib/models/occupation_model.dart | 15 +++++++++++++++ lib/models/planet_model.dart | 15 +++++++++++++++ lib/models/season_model.dart | 15 +++++++++++++++ lib/pages/modules/animals.dart | 16 +--------------- lib/pages/modules/atoz.dart | 15 +-------------- lib/pages/modules/birds.dart | 16 +--------------- lib/pages/modules/colours.dart | 15 +-------------- lib/pages/modules/occupation.dart | 15 +-------------- lib/pages/modules/planets.dart | 15 +-------------- lib/pages/modules/seasons.dart | 15 +-------------- lib/utils/constants.dart | 6 ++++++ 15 files changed, 118 insertions(+), 100 deletions(-) create mode 100644 lib/models/animal_model.dart create mode 100644 lib/models/bird_model.dart create mode 100644 lib/models/colours_model.dart create mode 100644 lib/models/itemdata_model.dart create mode 100644 lib/models/occupation_model.dart create mode 100644 lib/models/planet_model.dart create mode 100644 lib/models/season_model.dart diff --git a/lib/models/animal_model.dart b/lib/models/animal_model.dart new file mode 100644 index 0000000..6c917ca --- /dev/null +++ b/lib/models/animal_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Animal { + final String name; + final String svgAsset; + final String soundAsset; + final Color backgroundColor; + + Animal({ + required this.name, + required this.svgAsset, + required this.soundAsset, + required this.backgroundColor, + }); +} diff --git a/lib/models/bird_model.dart b/lib/models/bird_model.dart new file mode 100644 index 0000000..f7aa028 --- /dev/null +++ b/lib/models/bird_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Bird { + final String name; + final String svgAsset; + final String soundAsset; + final Color backgroundColor; + + Bird({ + required this.name, + required this.svgAsset, + required this.soundAsset, + required this.backgroundColor, + }); +} diff --git a/lib/models/colours_model.dart b/lib/models/colours_model.dart new file mode 100644 index 0000000..5293a08 --- /dev/null +++ b/lib/models/colours_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Colours { + final String name; + final String jpgAsset; + final Color bgColor; + final Color fontColor; + + Colours({ + required this.name, + required this.jpgAsset, + required this.bgColor, + required this.fontColor, + }); +} diff --git a/lib/models/itemdata_model.dart b/lib/models/itemdata_model.dart new file mode 100644 index 0000000..c0ad7ca --- /dev/null +++ b/lib/models/itemdata_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class ItemData { + final String iconAsset; + final String title; + final String description; + final Color backgroundColor; + + ItemData({ + required this.iconAsset, + required this.title, + required this.description, + required this.backgroundColor, + }); +} diff --git a/lib/models/occupation_model.dart b/lib/models/occupation_model.dart new file mode 100644 index 0000000..0cbf7f6 --- /dev/null +++ b/lib/models/occupation_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Occupation { + final String name; + final String description; + final String svgAsset; + final Color backgroundColor; + + Occupation({ + required this.name, + required this.description, + required this.svgAsset, + required this.backgroundColor, + }); +} diff --git a/lib/models/planet_model.dart b/lib/models/planet_model.dart new file mode 100644 index 0000000..40c8432 --- /dev/null +++ b/lib/models/planet_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Planet { + final String name; + final String svgAsset; + final String description; + final Color backgroundColor; + + Planet({ + required this.name, + required this.svgAsset, + required this.description, + required this.backgroundColor, + }); +} diff --git a/lib/models/season_model.dart b/lib/models/season_model.dart new file mode 100644 index 0000000..9d57a74 --- /dev/null +++ b/lib/models/season_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Season { + final String name; + final String description; + final String imageAsset; + final Color backgroundColor; + + Season({ + required this.name, + required this.description, + required this.imageAsset, + required this.backgroundColor, + }); +} diff --git a/lib/pages/modules/animals.dart b/lib/pages/modules/animals.dart index 099aaa2..3763dde 100644 --- a/lib/pages/modules/animals.dart +++ b/lib/pages/modules/animals.dart @@ -4,22 +4,8 @@ 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'; +import 'package:learn/models/animal_model.dart'; import 'package:learn/utils/constants.dart'; - -class Animal { - final String name; - final String svgAsset; - final String soundAsset; - final Color backgroundColor; - - Animal({ - required this.name, - required this.svgAsset, - required this.soundAsset, - required this.backgroundColor, - }); -} - class AnimalsPage extends StatelessWidget { diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index d5604e2..113c958 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/models/itemdata_model.dart'; class ItemTile extends StatelessWidget { final int index; @@ -222,20 +223,6 @@ class _PopupDialogState extends State<_PopupDialog> { } } -class ItemData { - final String iconAsset; - final String title; - final String description; - final Color backgroundColor; - - ItemData({ - required this.iconAsset, - required this.title, - required this.description, - required this.backgroundColor, - }); -} - class AtoZ extends StatefulWidget { const AtoZ({Key? key}) : super(key: key); diff --git a/lib/pages/modules/birds.dart b/lib/pages/modules/birds.dart index e8a138b..8898679 100644 --- a/lib/pages/modules/birds.dart +++ b/lib/pages/modules/birds.dart @@ -4,25 +4,11 @@ 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'; +import 'package:learn/models/bird_model.dart'; import 'package:learn/utils/constants.dart'; -class Bird { - final String name; - final String svgAsset; - final String soundAsset; - final Color backgroundColor; - - Bird({ - required this.name, - required this.svgAsset, - required this.soundAsset, - required this.backgroundColor, - }); -} - class BirdsPage extends StatelessWidget { - final FlutterTts flutterTts = FlutterTts(); final AudioPlayer audioPlayer = AudioPlayer(); diff --git a/lib/pages/modules/colours.dart b/lib/pages/modules/colours.dart index b283983..17a73d8 100644 --- a/lib/pages/modules/colours.dart +++ b/lib/pages/modules/colours.dart @@ -1,20 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_svg/flutter_svg.dart'; - -class Colours { - final String name; - final String jpgAsset; - final Color bgColor; - final Color fontColor; - - Colours({ - required this.name, - required this.jpgAsset, - required this.bgColor, - required this.fontColor, - }); -} +import 'package:learn/models/colours_model.dart'; class ColoursPage extends StatefulWidget { const ColoursPage({Key? key}) : super(key: key); diff --git a/lib/pages/modules/occupation.dart b/lib/pages/modules/occupation.dart index ee160c6..220964b 100644 --- a/lib/pages/modules/occupation.dart +++ b/lib/pages/modules/occupation.dart @@ -2,22 +2,9 @@ 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'; +import 'package:learn/models/occupation_model.dart'; import 'package:learn/utils/constants.dart'; -class Occupation { - final String name; - final String description; - final String svgAsset; - final Color backgroundColor; - - Occupation({ - required this.name, - required this.description, - required this.svgAsset, - required this.backgroundColor, - }); -} - class OccupationPage extends StatelessWidget { final FlutterTts flutterTts = FlutterTts(); final AudioPlayer audioPlayer = AudioPlayer(); diff --git a/lib/pages/modules/planets.dart b/lib/pages/modules/planets.dart index 4780968..3bc9b56 100644 --- a/lib/pages/modules/planets.dart +++ b/lib/pages/modules/planets.dart @@ -2,20 +2,7 @@ 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'; - -class Planet { - final String name; - final String svgAsset; - final String description; - final Color backgroundColor; - - Planet({ - required this.name, - required this.svgAsset, - required this.description, - required this.backgroundColor, - }); -} +import 'package:learn/models/planet_model.dart'; class PlanetsPage extends StatelessWidget { final List planets = [ diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index 1de3e79..3164c01 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -1,21 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:learn/models/season_model.dart'; import 'package:learn/utils/constants.dart'; -class Season { - final String name; - final String description; - final String imageAsset; - final Color backgroundColor; - - Season({ - required this.name, - required this.description, - required this.imageAsset, - required this.backgroundColor, - }); -} - class SeasonsPage extends StatelessWidget { SeasonsPage({Key? key}) : super(key: key); diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index ea2f386..0c61c52 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -1,5 +1,11 @@ import 'dart:ui'; +import 'package:learn/models/animal_model.dart'; +import 'package:learn/models/bird_model.dart'; +import 'package:learn/models/itemdata_model.dart'; +import 'package:learn/models/occupation_model.dart'; +import 'package:learn/models/season_model.dart'; + import '../explore/quiz.dart'; import 'package:flutter/material.dart'; import 'package:learn/pages/modules/colours.dart'; From f35b3806bb5e5757cbd6e75f2ae84b4062ca8d15 Mon Sep 17 00:00:00 2001 From: Maheen Ilyas Date: Wed, 22 May 2024 11:06:26 +0300 Subject: [PATCH 2/2] Added flower model to models --- lib/models/flower_model.dart | 13 +++++++ lib/pages/modules/flowers.dart | 69 ++++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 lib/models/flower_model.dart diff --git a/lib/models/flower_model.dart b/lib/models/flower_model.dart new file mode 100644 index 0000000..7fe4d6e --- /dev/null +++ b/lib/models/flower_model.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; + +class Flower { + final String name; + final String resource; + final Color background; + + Flower({ + required this.name, + required this.resource, + required this.background, + }); +} diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 41aa7f5..61f4a92 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -1,18 +1,9 @@ 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/assets_path.dart'; - -class Flower{ - final String name; - final String resource; - final Color background; - - Flower({required this.name,required this.resource,required this.background}); -} - - class FlowerPage extends StatefulWidget { const FlowerPage({super.key}); @@ -21,26 +12,56 @@ 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), - + 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;