Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #25 : Created the Greetings Page #146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/Greetings/all_the_best.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
872 changes: 872 additions & 0 deletions assets/Greetings/all_the_best.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/Greetings/congrats.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions assets/Greetings/congrats.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/Greetings/greetings_cover.jpg
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/Greetings/hi.jpg
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/Greetings/hi.mp3
Binary file not shown.
134 changes: 134 additions & 0 deletions assets/Greetings/hi.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/Greetings/please.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions assets/Greetings/please.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,020 changes: 1,020 additions & 0 deletions assets/Greetings/say_cheese.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/Greetings/say_cheeze.jpg
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/Greetings/sorry.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,458 changes: 2,458 additions & 0 deletions assets/Greetings/sorry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import 'package:flutter/material.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:learn/pages/about.dart';
import 'package:learn/pages/modules/flowers.dart';
import 'package:learn/pages/explore/quiz.dart';
import 'package:learn/pages/modules/atoz.dart';
import 'package:learn/pages/modules/birds.dart';
import 'package:learn/pages/modules/animals.dart';
import 'package:learn/pages/fruits.dart';
import 'package:learn/pages/explore.dart';
import 'package:learn/pages/favorite.dart';
import 'package:learn/pages/modules/flowers.dart';
import 'package:learn/pages/modules/greetings.dart';
import 'package:learn/pages/modules/occupation.dart';
import 'package:learn/pages/modules/parts.dart';
import 'package:learn/pages/modules/seasons.dart';
Expand All @@ -19,9 +20,7 @@ import 'package:learn/pages/modules/colours.dart';
import 'package:learn/widgets/navbar/navbar.dart';

import 'cubit/index_cubit.dart';
import 'pages/explore/quiz.dart';
import 'pages/home.dart';
import 'landing_page.dart';

DateTime? currentBackPressTime;

Expand Down Expand Up @@ -51,7 +50,6 @@ class MyApp extends StatelessWidget {
title: 'Home',
theme: theme,
darkTheme: darkTheme,
initialRoute: '/landing_page',
home: Scaffold(
body: const [
MyHomePage(),
Expand All @@ -74,11 +72,10 @@ class MyApp extends StatelessWidget {
AllRoutes.flowerRoute: (context) => const FlowerPage(),
AllRoutes.exploreRoute: (context) => const ExplorePage(),
AllRoutes.favoriteRoute: (context) => const FavoritePage(),
AllRoutes.quizRoute: (context) => const QuizPage(),
AllRoutes.seasonRoute: (context) => const SeasonsPage(),
AllRoutes.quizRoute: (context) => QuizPage(),
AllRoutes.seasonRoute: (context) => SeasonsPage(),
AllRoutes.occupationRoute: (context) => OccupationPage(),
AllRoutes.fruitRoute: (context) => FruitsPage(),
"/landing_page": (context) => const LandingPage(),
AllRoutes.greetingsRoute:(context) => GreetingsPage(),
},
);
},
Expand Down
16 changes: 14 additions & 2 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,24 @@ class _MyHomePageState extends State<MyHomePage> {
categoryCard(
context: context,
title: "FRUITS & VEGETABLES",
image: 'assets/fruitsVeges/cover.jpg',
image: 'assets/fruitsVeges/cover.jpg',
shortDescription:
"Explore and learn about Fruits and Vegetables!",
"Learn about different types of expressions",
route: AllRoutes.fruitRoute,
index: 6,
),
const SizedBox(
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
title: "Greetings",
image: 'assets/Greetings/greetings_cover.jpg',
shortDescription:
"Learn about differnet types of expressions",
route: AllRoutes.greetingsRoute,
index: 6,
),
],
),
),
Expand Down
210 changes: 210 additions & 0 deletions lib/pages/modules/greetings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:just_audio/just_audio.dart';
import 'package:flutter_svg/flutter_svg.dart';

import '../../utils/constants.dart';

class Greetings {
final String name;
final String imgAsset;
final String soundAsset;
final Color backgroundColor;

Greetings({
required this.name,
required this.imgAsset,
required this.soundAsset,
required this.backgroundColor,
});
}

class AppConstants {
static const String greetings = 'Greetings';
static final List<Greetings> greetingList = [
Greetings(
name: 'Hello',
imgAsset: 'assets/Greetings/hi.svg',
soundAsset: 'assets/sounds/hi.mp3',
backgroundColor: Colors.white,
),
Greetings(
name: 'Say Cheese',
imgAsset: 'assets/Greetings/say_cheese.svg',
soundAsset: 'assets/sounds/good_morning.mp3',
backgroundColor: Colors.orange,
),
Greetings(
name: 'Best of Luck',
imgAsset: 'assets/Greetings/all_the_best.svg',
soundAsset: 'assets/sounds/good_night.mp3',
backgroundColor: Colors.blue,
),
Greetings(
name: 'Sorry',
imgAsset: 'assets/Greetings/sorry.svg',
soundAsset: 'assets/sounds/good_night.mp3',
backgroundColor: Colors.orange,
),
Greetings(
name: 'Please',
imgAsset: 'assets/Greetings/please.svg',
soundAsset: 'assets/sounds/good_night.mp3',
backgroundColor: Colors.blue,
),
Greetings(
name: 'Congratulations',
imgAsset: 'assets/Greetings/congrats.svg',
soundAsset: 'assets/sounds/good_night.mp3',
backgroundColor: Colors.red,
),
];
}

class GreetingsPage extends StatelessWidget {
final FlutterTts flutterTts = FlutterTts();
final AudioPlayer audioPlayer = AudioPlayer();

GreetingsPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
AppConstants.greetings,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
body: Center(
child: GreetingsWidget(
greetings: AppConstants.greetingList,
flutterTts: flutterTts,
audioPlayer: audioPlayer,
),
),
);
}
}

class GreetingsWidget extends StatefulWidget {
final List<Greetings> greetings;
final FlutterTts flutterTts;
final AudioPlayer audioPlayer;

GreetingsWidget({
required this.greetings,
required this.flutterTts,
required this.audioPlayer,
});

@override
_GreetingsWidgetState createState() => _GreetingsWidgetState();
}

class _GreetingsWidgetState extends State<GreetingsWidget> {
int currentIndex = 0;

void _navigateToNextGreeting() {
setState(() {
currentIndex = (currentIndex + 1) % widget.greetings.length;
});
}

void _navigateToPreviousGreeting() {
setState(() {
currentIndex = (currentIndex - 1 + widget.greetings.length) % widget.greetings.length;
});
}

@override
Widget build(BuildContext context) {
Greetings greeting = widget.greetings[currentIndex];
return SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: _navigateToNextGreeting,
child: Container(
width: 375,
height: 375,
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(8.0),
color: greeting.backgroundColor,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 350,
height: 350,
child: greeting.imgAsset.endsWith('.svg')
? SvgPicture.asset(greeting.imgAsset)
: Image.asset(greeting.imgAsset),
),
],
),
),
),
const SizedBox(height: 20),
Text(
greeting.name,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 45,
fontFamily: 'Comic',
),
),
const SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: _navigateToPreviousGreeting,
icon: const Icon(Icons.arrow_back),
),
const SizedBox(width: 20),
ElevatedButton(
onPressed: () {
readName(greeting.name);
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, backgroundColor: Colors.grey, // Text color
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
elevation: 5,
),
child: const Text(
'Pronounce',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(width: 20),
IconButton(
onPressed: _navigateToNextGreeting,
icon: const Icon(Icons.arrow_forward),
),
],
),
],
),
);
}

Future<void> _playGreetingSound(String soundAsset) async {
await widget.audioPlayer.setAsset(soundAsset);
await widget.audioPlayer.play();
}

Future<void> readName(String name) async {
await widget.flutterTts.setLanguage("EN-IN");
await widget.flutterTts.speak(name);
}
}
3 changes: 2 additions & 1 deletion lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ class AppConstants {
static const String solar = 'Solar System';
static const String flowers = 'Flowers';
static const String fruit = 'Fruits & Vegetables';
static const String greeting = 'Greetings';
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';
'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 - ';
}
1 change: 1 addition & 0 deletions lib/utils/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ class AllRoutes {
static const String seasonRoute = "/seasons";
static const String occupationRoute = '/occupations';
static const String fruitRoute = "/fruit";
static const String greetingsRoute='/greetings';
}
12 changes: 4 additions & 8 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dependencies:
fluttertoast: ^8.2.5
google_nav_bar: ^5.0.6
flutter_bloc: ^8.1.5
animated_text_kit: ^4.2.2

dev_dependencies:
flutter_test:
Expand All @@ -71,21 +70,18 @@ flutter:

# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
- assets/sounds/animals/
- assets/sounds/birds/
- assets/images/alphabet/
- assets/images/animal/
- assets/sounds/
- assets/images/body/
- assets/images/birds/
- assets/images/solar/
- assets/colours/
- assets/images/flowers/
- assets/explore/
- assets/seasons/
- assets/occupations/

- assets/fruitsVeges/
- assets/Greetings/
- assets/images/animal/


# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down