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

transportation module #173

Open
wants to merge 1 commit 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/images/modesOfTransport.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101,082 changes: 101,082 additions & 0 deletions assets/transports/airplane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
926 changes: 926 additions & 0 deletions assets/transports/bicycle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59,694 changes: 59,694 additions & 0 deletions assets/transports/boat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110,088 changes: 110,088 additions & 0 deletions assets/transports/bus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/transports/car.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153,559 changes: 153,559 additions & 0 deletions assets/transports/carr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37,783 changes: 37,783 additions & 0 deletions assets/transports/helicopter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93,369 changes: 93,369 additions & 0 deletions assets/transports/motorcycle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131,389 changes: 131,389 additions & 0 deletions assets/transports/ship.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51,834 changes: 51,834 additions & 0 deletions assets/transports/train.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41,045 changes: 41,045 additions & 0 deletions assets/transports/trains.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97,961 changes: 97,961 additions & 0 deletions assets/transports/truck.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:learn/pages/animals.dart';
import 'package:learn/pages/parts.dart';
import 'package:learn/pages/shapes.dart';
import 'package:learn/pages/solar.dart';
import 'package:learn/pages/transport.dart';
import 'package:learn/utils/routes.dart';
import 'package:learn/widgets/drawer.dart';
import 'package:learn/pages/colours.dart';
Expand Down Expand Up @@ -43,6 +44,7 @@ class MyApp extends StatelessWidget {
AllRoutes.solarRoute: (context) => const SolarPage(),
AllRoutes.animalRoute: (context) => AnimalsPage(),
AllRoutes.colourRoute: (context) => const ColoursPage(),
AllRoutes.transportRoute: (context) => TransportPage(),
AllRoutes.aboutRoute: (context) => const AboutPage(),
},
),
Expand Down Expand Up @@ -288,6 +290,44 @@ class _MyHomePageState extends State<MyHomePage> {
),
const Text("Explore and learn about the colours!"),

const SizedBox(height: 20),
GestureDetector(
onTap: () {
setState(() {
_isImageClicked4 = !_isImageClicked4;
});
Future.delayed(const Duration(milliseconds: 300), () {
Navigator.pushNamed(context, AllRoutes.transportRoute);
});
},
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/modesOfTransport.jpeg'),
fit: BoxFit.cover,
),
),
),
),
const SizedBox(height: 20),
const Text(
'MODES OF TRANSPORT',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const Text("Look out for different modes of transport."),
],
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/pages/birds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class Bird {

class BirdsPage extends StatelessWidget {


final FlutterTts flutterTts = FlutterTts();
final AudioPlayer audioPlayer = AudioPlayer();

Expand Down
179 changes: 179 additions & 0 deletions lib/pages/transport.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
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/utils/constants.dart';

class Transport {
final String transportname;
final String transportsvgAsset;
final String transportdesc;
final Color transportbackgroundColor;

Transport({
required this.transportname,
required this.transportsvgAsset,
required this.transportdesc,
required this.transportbackgroundColor,
});
}

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

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

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

class TransportWidget extends StatefulWidget {
final List<Transport> transports;
final FlutterTts flutterTts;
final AudioPlayer audioPlayer;

TransportWidget({
required this.transports,
required this.flutterTts,
required this.audioPlayer,
});

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

class _TransportWidgetState extends State<TransportWidget> {
int currentIndex = 0;

void _navigateToNextTransport() {
setState(() {
currentIndex = (currentIndex + 1) % widget.transports.length;
});
}

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

@override
Widget build(BuildContext context) {
Transport transport = widget.transports[currentIndex];
return SingleChildScrollView(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Color.fromRGBO(13, 71, 161, 1),
Colors.pink
])
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: _navigateToNextTransport,
child: Container(
width: 375,
height: 375,
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(8.0),
color: transport.transportbackgroundColor,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 350,
height: 350,
child: SvgPicture.asset(transport.transportsvgAsset,fit: BoxFit.cover,),
),
],
),
),
),
const SizedBox(height: 20),
// IconButton.outlined(
// highlightColor: Colors.amber,
// onPressed: () {
// readName(
// transport.transportname,
// );
// },
// icon: const Icon(Icons.volume_up_outlined),
// ),
Text(
transport.transportname,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 60,
fontFamily: 'Comic',
),
),
const SizedBox(height: 20),
Text(
transport.transportdesc,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: _navigateToPreviousTransport,
child: const Text(
'Prev',
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold,color: Color.fromRGBO(179, 229, 252, 1)),
),
),
const SizedBox(height: 20),
const SizedBox(width: 20),
TextButton(
onPressed: _navigateToNextTransport,
child: const Text(
'Next',
style: TextStyle(fontSize: 15,fontWeight: FontWeight.bold,color: Color.fromRGBO(179, 229, 252, 1)),
),
),
],
),
],
),
),
),
);
}

Future<void> _playSound(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);
}
}
67 changes: 67 additions & 0 deletions lib/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:ui';

import 'package:flutter/material.dart';

import '../pages/animals.dart';
import '../pages/atoz.dart';
import '../pages/birds.dart';
import '../pages/transport.dart';

class AppConstants {
static const List<String> candidates = [
Expand Down Expand Up @@ -449,6 +452,69 @@ class AppConstants {
),
];

static List<Transport> transports = [
Transport(
transportname: 'Car',
transportsvgAsset: 'assets/transports/carr.svg',
transportdesc: 'A car has four wheels and a motor that helps it move. Cars are used to travel on roads and can carry people and cargo. ',
transportbackgroundColor: const Color.fromRGBO(179, 229, 252, 1),
),
Transport(
transportname: 'Bus',
transportsvgAsset: 'assets/transports/bus.svg',
transportdesc: 'A bus is a larger vehicle with many wheels that can carry many people at once. Buses travel on roads along specific routes and stop at designated stations to pick up and drop off passengers',
transportbackgroundColor: const Color.fromRGBO(248, 187, 208, 1),
),
Transport(
transportname: 'Train',
transportsvgAsset: 'assets/transports/train.svg',
transportdesc: ' A train is a long line of connected cars that travel on tracks. Trains can be powered by electricity or diesel engines. They are great for traveling long distances and can carry passengers or cargo',
transportbackgroundColor: const Color.fromRGBO(179, 229, 252, 1),
),
Transport(
transportname: 'Truck',
transportsvgAsset: 'assets/transports/truck.svg',
transportdesc: 'A truck is a large vehicle with a big engine used to transport goods from one place to another. Trucks come in various sizes, some carrying heavy machinery and others carrying lighter boxes.pen_spark',
transportbackgroundColor: const Color.fromRGBO(248, 187, 208, 1),
),
Transport(
transportname: 'Bicycle',
transportsvgAsset: 'assets/transports/bicycle.svg',
transportdesc: 'A bicycle has two wheels and pedals that you push to make it move. Bicycles are a fun and healthy way to travel short distances.pen_spark',
transportbackgroundColor: const Color.fromRGBO(179, 229, 252, 1),
),
Transport(
transportname: 'Motorcycle',
transportsvgAsset: 'assets/transports/motorcycle.svg',
transportdesc: 'A motorcycle is a two-wheeled vehicle with a motor. It is faster than a bicycle but requires a helmet and following safety rules.',
transportbackgroundColor: const Color.fromRGBO(248, 187, 208, 1),
),
Transport(
transportname: 'Boat',
transportsvgAsset: 'assets/transports/boat.svg',
transportdesc: 'A boat is a vessel that floats on water. Boats come in all sizes, from small rowboats to giant cruise ships. They are used for transportation, fishing, and recreation.',
transportbackgroundColor: const Color.fromRGBO(179, 229, 252, 1),
),
Transport(
transportname: 'Ship',
transportsvgAsset: 'assets/transports/ship.svg',
transportdesc: 'A ship is a very large boat used for traveling long distances on water. Ships carry passengers, cargo, or both. Cruise ships are giant ships designed for vacations and have many fun activities onboard.',
transportbackgroundColor: const Color.fromRGBO(248, 187, 208, 1),
),
Transport(
transportname: 'Airplane',
transportsvgAsset: 'assets/transports/airplane.svg',
transportdesc: 'An airplane is a flying machine with wings and a powerful engine. Airplanes can travel long distances very quickly. They take off from airports and land on runways.',
transportbackgroundColor: const Color.fromRGBO(179, 229, 252, 1),
),
Transport(
transportname: 'Helicopter',
transportsvgAsset: 'assets/transports/helicopter.svg',
transportdesc: 'A helicopter is a flying machine with rotating blades that lift it off the ground. Helicopters can take off and land vertically, making them useful for reaching difficult areas.',
transportbackgroundColor: const Color.fromRGBO(248, 187, 208, 1),
),
];

static const String underConstruction =
'Page Under Construction.\nIt will not take much time.';

Expand All @@ -458,6 +524,7 @@ class AppConstants {
static const String parts = 'Body Parts';
static const String shape = 'Shapes';
static const String solar = 'Solar System';
static const String transport = 'Modes of Transport';
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';
}
2 changes: 1 addition & 1 deletion lib/utils/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class AllRoutes {
static String atozRoute = "/atoz";
static String aboutRoute = "/about";
static String colourRoute = "/colours";

static String transportRoute = "/transports";
}
Loading