Skip to content

Commit

Permalink
Merge branch 'quiz' of https://github.com/Prashant-2024/learn into quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-2024 committed May 18, 2024
2 parents 227b735 + c2f1c6c commit 574dd73
Show file tree
Hide file tree
Showing 15 changed files with 332 additions and 34 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/autocomment-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Auto Comment on PR Merge

on:
pull_request:
types: [closed]

permissions:
issues: write
pull-requests: write

jobs:
comment:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Add Comment to Issue
env:
GITHUB_TOKEN: ${{ secrets.WORK }}
run: |
COMMENT=$(cat <<EOF
{
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"
}
EOF
)
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT"
2 changes: 1 addition & 1 deletion .github/workflows/greetings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token: ${{ secrets.WORK }}
issue-message: "Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible."
pr-message: "Welcome to Our repository.🎊 Thank you so much for taking the time to point this out."
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.
2 changes: 2 additions & 0 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 @@ -70,6 +71,7 @@ class MyApp extends StatelessWidget {
AllRoutes.exploreRoute: (context) => const ExplorePage(),
AllRoutes.favoriteRoute: (context) => const FavoritePage(),
AllRoutes.quizRoute: (context) => QuizPage(),
AllRoutes.seasonRoute: (context) => SeasonsPage(),
},
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/modules/birds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class _BirdWidgetState extends State<BirdWidget> {
onPressed: _navigateToPreviousBird,
icon: const Icon(Icons.arrow_back),
),
const SizedBox(height: 20),
const SizedBox(width: 20),
ElevatedButton(
onPressed: () {
_playBirdSound(bird.soundAsset);
Expand Down
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;
});
}
}
33 changes: 16 additions & 17 deletions lib/pages/modules/solar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ 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/main.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,
});
}

class PlanetsPage extends StatelessWidget {
final List<Planet> planets = [
Planet(
Expand Down Expand Up @@ -75,12 +74,12 @@ class PlanetsPage extends StatelessWidget {
backgroundColor: const Color.fromARGB(255, 64, 90, 200),
),
];

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

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

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -106,28 +105,28 @@ class PlanetsPage extends StatelessWidget {
);
}
}

class PlanetWidget extends StatefulWidget {
final List<Planet> planets;
final FlutterTts flutterTts;
final AudioPlayer audioPlayer;

const PlanetWidget({
Key? key,
required this.planets,
required this.flutterTts,
required this.audioPlayer,
}) : super(key: key);

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

class _PlanetWidgetState extends State<PlanetWidget> {
int currentIndex = 0;

final _animationDuration = const Duration(milliseconds: 500);

@override
Widget build(BuildContext context) {
Planet planet = widget.planets[currentIndex];
Expand Down Expand Up @@ -190,22 +189,22 @@ class _PlanetWidgetState extends State<PlanetWidget> {
],
);
}

void _navigateToNextPlanet() {
setState(() {
currentIndex = (currentIndex + 1) % widget.planets.length;
});
}

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

Future<void> _playPlanetName(String name) async {
await widget.flutterTts.setLanguage("en-US");
await widget.flutterTts.speak(name);
}
}
}
Loading

0 comments on commit 574dd73

Please sign in to comment.