From ded1aebb0086c553fc354262b111dc0fe3444a74 Mon Sep 17 00:00:00 2001 From: Pra_Kas Date: Wed, 29 May 2024 18:50:06 +0530 Subject: [PATCH 1/2] Added past program --- lib/home_page.dart | 20 ++++++++++++++++++++ lib/opso_timeline.dart | 7 +++++++ lib/past_programs.dart | 15 +++++++++++++++ pubspec.lock | 24 ++++++++++++------------ 4 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 lib/past_programs.dart diff --git a/lib/home_page.dart b/lib/home_page.dart index 5b3e319..5081949 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -205,7 +205,9 @@ class _HomePageState extends State { const BookMarkScreen())); }, ), + const SizedBox(height: 15), + ListTile( leading: Transform.rotate( angle: 90 * math.pi/180, @@ -223,7 +225,25 @@ class _HomePageState extends State { ); }, ), + const SizedBox(height: 15), + + ListTile( + leading: + const Icon(FontAwesomeIcons.circleInfo), + title: const Text('Past programs'), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AboutScreen(), + ), + ); + }, + ), + + const SizedBox(height: 15), + ListTile( leading: const Icon(FontAwesomeIcons.circleInfo), diff --git a/lib/opso_timeline.dart b/lib/opso_timeline.dart index b69eafd..324ff98 100644 --- a/lib/opso_timeline.dart +++ b/lib/opso_timeline.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:timeline_tile/timeline_tile.dart'; import 'package:opso/services/notificationService.dart'; @@ -77,12 +79,17 @@ class OpsoTimeLineScreen extends StatelessWidget { }, ]; + final DateTime now = DateTime.now(); + final List> pastEvents = events.where((event) => event['endDate'].isAfter(now)).toList(); + for (var event in events) { NotificationService.scheduleNotificationsForEvent( event['description']!, event['startDate']!, event['endDate']!, ); + print(now); + print("Past programs $pastEvents"); } return Scaffold( diff --git a/lib/past_programs.dart b/lib/past_programs.dart new file mode 100644 index 0000000..5643ba3 --- /dev/null +++ b/lib/past_programs.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class PastPrograms extends StatefulWidget { + const PastPrograms({super.key}); + + @override + State createState() => _PastProgramsState(); +} + +class _PastProgramsState extends State { + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 4a2f4ef..d552f4c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -252,26 +252,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -300,10 +300,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" path: dependency: transitive description: @@ -473,10 +473,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" timeline_tile: dependency: "direct main" description: @@ -593,10 +593,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: From ea86aab9146958b9979c378bbceb99ed25fb6240 Mon Sep 17 00:00:00 2001 From: Pra_Kas Date: Wed, 29 May 2024 18:50:47 +0530 Subject: [PATCH 2/2] Added Past programs --- lib/home_page.dart | 3 +- lib/opso_timeline.dart | 28 ++++++---- lib/past_programs.dart | 51 ++++++++++++++++++- .../google_summer_of_code_screen.dart | 44 ++++++++++++++-- lib/programs screen/linux_foundation.dart | 4 +- lib/programs screen/summer_of_bitcoin.dart | 43 +++++++++++++++- pubspec.lock | 2 +- pubspec.yaml | 1 + 8 files changed, 155 insertions(+), 21 deletions(-) diff --git a/lib/home_page.dart b/lib/home_page.dart index 5081949..73d78a2 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:opso/opso_timeline.dart'; +import 'package:opso/past_programs.dart'; import 'package:opso/programs%20screen/girl_script.dart'; import 'package:opso/programs%20screen/google_season_of_docs_screen.dart'; import 'package:opso/programs%20screen/google_summer_of_code_screen.dart'; @@ -236,7 +237,7 @@ class _HomePageState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => AboutScreen(), + builder: (context) => const PastPrograms(), ), ); }, diff --git a/lib/opso_timeline.dart b/lib/opso_timeline.dart index 324ff98..07da8f6 100644 --- a/lib/opso_timeline.dart +++ b/lib/opso_timeline.dart @@ -7,71 +7,79 @@ import 'widgets/event_card.dart'; class OpsoTimeLineScreen extends StatelessWidget { const OpsoTimeLineScreen({super.key}); - - @override - Widget build(BuildContext context) { - final List> events = [ + static List> events = [ { + 'title' : "Outreachy", 'description': "Outreachy(May Internships)\nApplication Period - 15/01/2024 to 31/01/2024", 'startDate': DateTime.utc(2024, 1, 15), 'endDate': DateTime.utc(2024, 1, 31), }, { + 'title' : "Linux Foundation Mentorship", 'description': "Linux Foundation Mentorship(Spring Term)\nApplication Period - 15/01/2024 to 15/02/2024", 'startDate': DateTime.utc(2024, 1, 15), 'endDate': DateTime.utc(2024, 2, 15), }, { + 'title' : "Summer of Bitcoin", 'description': "Summer of Bitcoin\nApplication Period - 01/02/2024 to 19/02/2024", 'startDate': DateTime.utc(2024, 2, 1), 'endDate': DateTime.utc(2024, 2, 19), }, { + 'title' : "Google Season of Docs", 'description': "Google Season of Docs\nApplication Period - 22/02/2024 to 02/04/2024", 'startDate': DateTime.utc(2024, 2, 22), 'endDate': DateTime.utc(2024, 4, 2), }, { + 'title' : "Google Summer of Code", 'description': "Google Summer of Code\nApplication Period - 18/03/2024 to 02/04/2024", 'startDate': DateTime.utc(2024, 3, 18), 'endDate': DateTime.utc(2024, 4, 2), }, { + 'title' : "MLH Fellowship(Summer Term-B)", 'description': "MLH Fellowship(Summer Term-B)\nApplication Period - 31/03/2024 to 15/04/2024", 'startDate': DateTime.utc(2024, 3, 31), 'endDate': DateTime.utc(2024, 4, 15), }, { + 'title' : "MLH Fellowship(Fall Term)", 'description': "MLH Fellowship(Fall Term)\nApplication Period - 15/04/2024 to 31/05/2024", 'startDate': DateTime.utc(2024, 4, 15), 'endDate': DateTime.utc(2024, 5, 31), }, { + 'title' : "Linux Foundation Mentorship(Summer Term)", 'description': "Linux Foundation Mentorship(Summer Term)\nApplication Period - 15/04/2024 to 15/05/2024", 'startDate': DateTime.utc(2024, 4, 15), 'endDate': DateTime.utc(2024, 5, 15), }, { - 'description': + 'title' : "GirlScript Summer of Code", + 'description': "GirlScript Summer of Code\nApplication Period - 01/05/2024 to 10/05/2024", 'startDate': DateTime.utc(2024, 5, 1), 'endDate': DateTime.utc(2024, 5, 10), }, { - 'description': - "Linux Foundation Mentorship(Fall Term)\nApplication Period - 15/07/2024 to 15/08/2024", + 'title' : "Linux Foundation Mentorship(Fall Term)", + 'description': + "Linux Foundation Mentorship(Fall Term)\c Period - 15/07/2024 to 15/08/2024", 'startDate': DateTime.utc(2024, 7, 15), 'endDate': DateTime.utc(2024, 8, 15), }, { + 'title' : "Outreachy", 'description': "Outreachy(December Internships)\nApplication Period - 01/08/2024 to 31/08/2024", 'startDate': DateTime.utc(2024, 8, 1), @@ -79,8 +87,10 @@ class OpsoTimeLineScreen extends StatelessWidget { }, ]; + @override + Widget build(BuildContext context) { + final DateTime now = DateTime.now(); - final List> pastEvents = events.where((event) => event['endDate'].isAfter(now)).toList(); for (var event in events) { NotificationService.scheduleNotificationsForEvent( @@ -88,8 +98,6 @@ class OpsoTimeLineScreen extends StatelessWidget { event['startDate']!, event['endDate']!, ); - print(now); - print("Past programs $pastEvents"); } return Scaffold( diff --git a/lib/past_programs.dart b/lib/past_programs.dart index 5643ba3..9ab6fde 100644 --- a/lib/past_programs.dart +++ b/lib/past_programs.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'opso_timeline.dart'; class PastPrograms extends StatefulWidget { const PastPrograms({super.key}); @@ -8,8 +10,53 @@ class PastPrograms extends StatefulWidget { } class _PastProgramsState extends State { + // Method to get only past events + List> getPastEvents() { + DateTime now = DateTime.now(); + return OpsoTimeLineScreen.events.where((event) { + DateTime endDate = event['endDate']; + return endDate.isBefore(now); + }).toList(); + } + @override Widget build(BuildContext context) { - return const Placeholder(); + // Get the filtered list of past events + List> pastEvents = getPastEvents(); + + return Scaffold( + appBar: AppBar( + title: const Text("Past Programs"), + ), + body: ListView.builder( + itemCount: pastEvents.length, + itemBuilder: (context, index) { + final event = pastEvents[index]; + // final DateTime endDate = event['endDate']; + + return ListTile( + title: Text(event['title'] as String), + onTap: () { + // Handle tap event if needed + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text(event['title'] as String), + content: Text(event['description'] as String), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('Close'), + ), + ], + ); + }, + ); + }, + ); + }, + ), + ); } -} \ No newline at end of file +} diff --git a/lib/programs screen/google_summer_of_code_screen.dart b/lib/programs screen/google_summer_of_code_screen.dart index d324216..c82821e 100644 --- a/lib/programs screen/google_summer_of_code_screen.dart +++ b/lib/programs screen/google_summer_of_code_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:opso/modals/book_mark_model.dart'; import 'package:opso/widgets/gsoc/GsocProjectWidget.dart'; -import 'package:url_launcher/url_launcher.dart'; import '../modals/GSoC/Gsoc.dart'; import '../services/ApiService.dart'; import '../widgets/SearchandFilterWidget.dart'; @@ -19,6 +19,9 @@ class _GoogleSummerOfCodeScreenState extends State { List gsoc2023 = []; List gsoc2022 = []; List gsoc2021 = []; + bool isBookmarked = true; + String currentProject = "Google Summer Of Code"; + String currectPage = "/google_summer_of_code"; int selectedYear = 2024; List languages = [ 'js', @@ -45,9 +48,17 @@ class _GoogleSummerOfCodeScreenState extends State { @override void initState() { super.initState(); + _checkBookmarkStatus(); _dataFetchFuture = getProjectData(); } + Future _checkBookmarkStatus() async { + bool bookmarkStatus = await HandleBookmark.isBookmarked(currentProject); + setState(() { + isBookmarked = bookmarkStatus; + }); + } + Future getProjectData() async { ApiService apiService = ApiService(); @@ -71,7 +82,6 @@ class _GoogleSummerOfCodeScreenState extends State { } } - void _clearAnimatedList() { for (var i = orgList.length - 1; i >= 0; i--) { _listKey.currentState?.removeItem( @@ -150,8 +160,34 @@ class _GoogleSummerOfCodeScreenState extends State { onRefresh: _refresh, child: Scaffold( appBar: AppBar( - title: Text('Google Summer of Code'), - ), + title: const Text('OpSo'), + actions: [ + IconButton( + icon: (isBookmarked) + ? const Icon(Icons.bookmark_add_rounded) + : const Icon(Icons.bookmark_add_outlined), + onPressed: () { + setState(() { + isBookmarked = !isBookmarked; + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: + Text(isBookmarked ? 'Bookmark added' : 'Bookmark removed'), + duration: + const Duration(seconds: 2), // Adjust the duration as needed + ), + ); + if (isBookmarked) { + print("Adding"); + HandleBookmark.addBookmark(currentProject, currectPage); + } else { + print("Deleting"); + HandleBookmark.deleteBookmark(currentProject); + } + }, + ) + ]), body: FutureBuilder( future: _dataFetchFuture, builder: (context, snapshot) { diff --git a/lib/programs screen/linux_foundation.dart b/lib/programs screen/linux_foundation.dart index 164fcc1..4c2bd9e 100644 --- a/lib/programs screen/linux_foundation.dart +++ b/lib/programs screen/linux_foundation.dart @@ -84,7 +84,9 @@ class _LinuxFoundationState extends State { return RefreshIndicator( onRefresh: _refresh, child: Scaffold( - appBar: AppBar(title: const Text('OpSo'), actions: [ + appBar: AppBar( + title: const Text('OpSo'), + actions: [ IconButton( icon: (isBookmarked) ? const Icon(Icons.bookmark_add_rounded) diff --git a/lib/programs screen/summer_of_bitcoin.dart b/lib/programs screen/summer_of_bitcoin.dart index 304c7ac..adc52fc 100644 --- a/lib/programs screen/summer_of_bitcoin.dart +++ b/lib/programs screen/summer_of_bitcoin.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:opso/modals/book_mark_model.dart'; import 'package:opso/modals/sob_project_modal.dart'; import 'package:opso/widgets/sob_project_widget.dart'; import 'package:opso/widgets/year_button.dart'; @@ -21,6 +22,9 @@ class SummerOfBitcoin extends StatefulWidget { class _SummerOfBitcoinState extends State { + String currectPage = "/summer_of_bitcoin"; + String currentProject = "Summer Of Bitcoin"; + bool isBookmarked = true; List sob2023 = []; List sob2022 = []; List sob2021 = []; @@ -58,6 +62,15 @@ class _SummerOfBitcoinState extends State { void initState() { getProjectFunction = initializeProjectLists(); super.initState(); + _checkBookmarkStatus(); + } + + + Future _checkBookmarkStatus() async { + bool bookmarkStatus = await HandleBookmark.isBookmarked(currentProject); + setState(() { + isBookmarked = bookmarkStatus; + }); } @@ -127,8 +140,34 @@ class _SummerOfBitcoinState extends State { onRefresh: _refresh, child: Scaffold( appBar: AppBar( - title: const Text('Summer of Bitcoin'), - ), + title: const Text('OpSo'), + actions: [ + IconButton( + icon: (isBookmarked) + ? const Icon(Icons.bookmark_add_rounded) + : const Icon(Icons.bookmark_add_outlined), + onPressed: () { + setState(() { + isBookmarked = !isBookmarked; + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: + Text(isBookmarked ? 'Bookmark added' : 'Bookmark removed'), + duration: + const Duration(seconds: 2), // Adjust the duration as needed + ), + ); + if (isBookmarked) { + print("Adding"); + HandleBookmark.addBookmark(currentProject, currectPage); + } else { + print("Deleting"); + HandleBookmark.deleteBookmark(currentProject); + } + }, + ) + ]), body: FutureBuilder( future: getProjectFunction, builder: (context, snapshot) { diff --git a/pubspec.lock b/pubspec.lock index d552f4c..a2d541c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -233,7 +233,7 @@ packages: source: hosted version: "4.1.7" intl: - dependency: transitive + dependency: "direct main" description: name: intl sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf diff --git a/pubspec.yaml b/pubspec.yaml index 18512c6..077650f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,6 +41,7 @@ dependencies: adaptive_theme: ^3.6.0 timeline_tile: ^2.0.0 flutter_svg: ^2.0.10+1 + intl: ^0.19.0 dev_dependencies: awesome_notifications: ^0.9.3+1