Skip to content

Commit

Permalink
Merge pull request #67 from Rajkumarbhakta/master
Browse files Browse the repository at this point in the history
Flower Section added issue #37
  • Loading branch information
K123Ritesh authored May 17, 2024
2 parents c07b109 + 13ba9f0 commit f2e8f28
Show file tree
Hide file tree
Showing 21 changed files with 3,588 additions and 3 deletions.
1 change: 1 addition & 0 deletions assets/images/flowers/carnation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/daffodil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/daisy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/images/flowers/flower-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/flowers/flower_banner.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/hibiscus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,322 changes: 3,322 additions & 0 deletions assets/images/flowers/lavender.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/lily.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/marigold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/poppy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/rose.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/sunflower.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/flowers/tulip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:learn/cubit/index_cubit.dart';
import 'package:learn/pages/about.dart';
import 'package:learn/pages/flowers.dart';
import 'package:learn/pages/modules/atoz.dart';
import 'package:learn/pages/modules/birds.dart';
import 'package:learn/pages/modules/animals.dart';
Expand All @@ -12,11 +12,10 @@ import 'package:learn/pages/modules/parts.dart';
import 'package:learn/pages/modules/shapes.dart';
import 'package:learn/pages/modules/solar.dart';
import 'package:learn/utils/routes.dart';
import 'package:learn/widgets/drawer.dart';
import 'package:learn/pages/modules/colours.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:learn/widgets/navbar/navbar.dart';

import 'cubit/index_cubit.dart';
import 'pages/home.dart';

DateTime? currentBackPressTime;
Expand Down Expand Up @@ -66,6 +65,7 @@ class MyApp extends StatelessWidget {
AllRoutes.animalRoute: (context) => AnimalsPage(),
AllRoutes.colourRoute: (context) => const ColoursPage(),
AllRoutes.aboutRoute: (context) => const AboutPage(),
AllRoutes.flowerRoute: (context) => const FlowerPage(),
AllRoutes.exploreRoute: (context) => const ExplorePage(),
AllRoutes.favoriteRoute: (context) => const FavoritePage(),
},
Expand Down
154 changes: 154 additions & 0 deletions lib/pages/flowers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_tts/flutter_tts.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});

@override
State<FlowerPage> createState() => _FlowerPageState();
}

class _FlowerPageState extends State<FlowerPage> {

final List<Flower> flowers = [
Flower(name: "Rose", resource: AssetsPath.getFlowerImage("rose.svg"), background: Colors.redAccent),
Flower(name: "Sunflower", resource: AssetsPath.getFlowerImage("sunflower.svg"), background: Colors.yellowAccent),
Flower(name: "Lily", resource: AssetsPath.getFlowerImage("lily.svg"), background: Colors.greenAccent),
Flower(name: "Marigold", resource: AssetsPath.getFlowerImage("marigold.svg"), background: Colors.yellow),
Flower(name: "Carnation", resource: AssetsPath.getFlowerImage("carnation.svg"), background: Colors.redAccent),
Flower(name: "Daffodil", resource: AssetsPath.getFlowerImage("daffodil.svg"), background: Colors.purpleAccent),
Flower(name: "Daisy", resource: AssetsPath.getFlowerImage("daisy.svg"), background: Colors.green),
Flower(name: "Poppy", resource: AssetsPath.getFlowerImage("poppy.svg"), background: Colors.redAccent),
Flower(name: "Tulip", resource: AssetsPath.getFlowerImage("tulip.svg"), background: Colors.pink),
Flower(name: "Lavender", resource: AssetsPath.getFlowerImage("lavender.svg"), background: Colors.purple),
Flower(name: "Hibiscus", resource: AssetsPath.getFlowerImage("hibiscus.svg"), background: Colors.red),

];

final FlutterTts flutterTts = FlutterTts();
int currentIndex = 0;


void _navigateToNextFlower() {
setState(() {
currentIndex = (currentIndex + 1) % flowers.length;
});
}

void _navigateToPreviousFlower() {
setState(() {
currentIndex = (currentIndex - 1 + flowers.length) % flowers.length;
});
}

Future<void> readName(String name) async {
await flutterTts.setVolume(1.0);
await flutterTts.setLanguage("EN-IN");
await flutterTts.setPitch(1.0);
await flutterTts.speak(name);
}

@override
Widget build(BuildContext context) {
Flower flower = flowers[currentIndex];
return Scaffold(
appBar: AppBar(
title: const Text(
'Flowers',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30,
),
),
),
backgroundColor: flower.background,
body: Center(
child: Container(
padding: const EdgeInsets.all(20),
constraints: const BoxConstraints(maxWidth: 400, maxHeight: 700),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.7),
borderRadius: BorderRadius.circular(7.0),
boxShadow: [
BoxShadow(
color: Colors.white.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: _navigateToNextFlower,
child: Container(
width: double.infinity,
height: 300,
child: SvgPicture.asset(
flower.resource,
fit: BoxFit.contain,
),
),
),
const SizedBox(height: 20),
Text(
flower.name,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 60,
fontFamily: 'Comic',
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: _navigateToPreviousFlower,
icon: const Icon(
Icons.arrow_back,
size: 30,
),
),
const SizedBox(width: 20),
IconButton.outlined(
highlightColor: Colors.amber,
onPressed: () {
readName(flower.name);
},
icon: const Icon(
Icons.volume_up_outlined,
size: 40,
),
),
const SizedBox(width: 20),
IconButton(
onPressed: _navigateToNextFlower,
icon: const Icon(
Icons.arrow_forward,
size: 30,
),
),
],
),
],
),
),
),
);
}
}
39 changes: 39 additions & 0 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class _MyHomePageState extends State<MyHomePage> {
bool _isImageClicked2 = false;
bool _isImageClicked3 = false;
bool _isImageClicked4 = false;
bool _isImageClicked5 = false;
bool _isDarkTheme = false;

Future<bool> _onBackPressed() {
Expand Down Expand Up @@ -262,6 +263,44 @@ class _MyHomePageState extends State<MyHomePage> {
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const Text("Explore and learn about the colours!"),
const SizedBox(height: 20),
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: const DecorationImage(
image: AssetImage('assets/images/flowers/flower_banner.jpeg'),
fit: BoxFit.cover,
),
),
),
),
const SizedBox(height: 20),
const Text(
'FLOWERS',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const Text("Explore beauty of nature flowers."),
],
),
),
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/assets_path.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AssetsPath {
static const String _flowerImages = 'assets/images/flowers/';

static String getFlowerImage(String name) {
return _flowerImages + name;
}
}
1 change: 1 addition & 0 deletions lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ 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 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';
}
3 changes: 3 additions & 0 deletions lib/utils/routes.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

class AllRoutes {
static String loginRoute = "/login";
static String homeRoute = "/home";
Expand All @@ -11,4 +12,6 @@ class AllRoutes {
static String atozRoute = "/atoz";
static String aboutRoute = "/about";
static String colourRoute = "/colours";
static String flowerRoute = "/flowers";

}
25 changes: 25 additions & 0 deletions lib/widgets/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:learn/utils/assets_path.dart';
import 'package:learn/utils/routes.dart';

class MyDrawer extends StatelessWidget {
Expand Down Expand Up @@ -98,6 +100,14 @@ class MyDrawer extends StatelessWidget {
},
context: context,
),
_buildListTileSVG(
icon: AssetsPath.getFlowerImage('flower-icon.svg'),
title: "Flowers",
onTap: () {
Navigator.pushNamed(context, AllRoutes.flowerRoute);
},
context: context,
),
_buildListTile(
icon: Icons.question_mark_outlined,
title: "About us",
Expand Down Expand Up @@ -127,4 +137,19 @@ class MyDrawer extends StatelessWidget {
onTap: onTap,
);
}
Widget _buildListTileSVG({
required BuildContext context,
required String icon,
required String title,
required VoidCallback onTap,
}) {
return ListTile(
leading: SvgPicture.asset(icon,height: 24,width: 24,color: const Color(0xFF49454f),),
title: Text(
title,
style: Theme.of(context).textTheme.bodyLarge,
),
onTap: onTap,
);
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ flutter:
- assets/birds/
- assets/solar/
- assets/images/colours/
- assets/images/flowers/


# An image asset can refer to one or more resolution-specific "variants", see
Expand Down

0 comments on commit f2e8f28

Please sign in to comment.