Skip to content

Commit

Permalink
Added Season Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-2024 committed May 17, 2024
1 parent f2e8f28 commit c9c87fd
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 64 deletions.
33 changes: 18 additions & 15 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (flutterVersionName == null) {
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
Expand Down Expand Up @@ -54,30 +54,33 @@ android {
applicationId "vdrs.sappu.lafk.learn"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}

}

flutter {
source '../..'
}

dependencies {}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
25 changes: 25 additions & 0 deletions assets/seasons/autumn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/seasons/spring.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/seasons/summer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/seasons/winter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
5 changes: 2 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:learn/pages/modules/animals.dart';
import 'package:learn/pages/explore.dart';
import 'package:learn/pages/favorite.dart';
import 'package:learn/pages/modules/parts.dart';
import 'package:learn/pages/modules/seasons.dart';
import 'package:learn/pages/modules/shapes.dart';
import 'package:learn/pages/modules/solar.dart';
import 'package:learn/utils/routes.dart';
Expand Down Expand Up @@ -68,6 +69,7 @@ class MyApp extends StatelessWidget {
AllRoutes.flowerRoute: (context) => const FlowerPage(),
AllRoutes.exploreRoute: (context) => const ExplorePage(),
AllRoutes.favoriteRoute: (context) => const FavoritePage(),
AllRoutes.seasonRoute: (context) => SeasonsPage(),
},
);
},
Expand All @@ -76,6 +78,3 @@ class MyApp extends StatelessWidget {
);
}
}



178 changes: 178 additions & 0 deletions lib/pages/modules/seasons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.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);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Seasons Serenade',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
body: ListView.builder(
itemCount: AppConstants.seasons.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
_showSeasonPopup(context, index);
},
child: Container(
margin: const EdgeInsets.all(5.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1.0),
borderRadius: BorderRadius.circular(8.0),
color: AppConstants.seasons[index].backgroundColor,
),
child: Row(
children: [
SizedBox(
width: 50,
height: 50,
child: SvgPicture.asset(
AppConstants.seasons[index].imageAsset),
),
const SizedBox(width: 28.0),
Text(
AppConstants.seasons[index].name,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30.0,
fontFamily: 'Comic',
),
),
],
),
),
);
},
),
);
}

void _showSeasonPopup(BuildContext context, int index) {
showDialog(
context: context,
builder: (BuildContext context) {
return SeasonPopup(
currentIndex: index,
seasons: AppConstants.seasons,
);
},
);
}
}

class SeasonPopup extends StatefulWidget {
final int currentIndex;
final List<Season> seasons;

SeasonPopup({
required this.currentIndex,
required this.seasons,
});

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

class _SeasonPopupState extends State<SeasonPopup> {
late int currentIndex;

@override
void initState() {
super.initState();
currentIndex = widget.currentIndex;
}

@override
Widget build(BuildContext context) {
Season currentSeason = widget.seasons[currentIndex];

return AlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
currentSeason.name,
style: const TextStyle(fontWeight: FontWeight.bold),
),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 200,
height: 200,
child: SvgPicture.asset(currentSeason.imageAsset),
),
const SizedBox(height: 16),
Text(
currentSeason.description,
style: const TextStyle(fontSize: 16.0),
),
],
),
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: _navigateToPreviousSeason,
icon: const Icon(Icons.arrow_back),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
),
onPressed: () {
Navigator.of(context).pop();
},
child: const Text(
'Close',
style: TextStyle(color: Colors.white),
),
),
IconButton(
onPressed: _navigateToNextSeason,
icon: const Icon(Icons.arrow_forward),
),
],
),
],
);
}

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

void _navigateToNextSeason() {
setState(() {
currentIndex = (currentIndex + 1) % widget.seasons.length;
});
}
}
Loading

0 comments on commit c9c87fd

Please sign in to comment.