Skip to content

Commit

Permalink
Bookmark Added (Google summer of code)
Browse files Browse the repository at this point in the history
  • Loading branch information
samarsajad committed Aug 10, 2024
1 parent f7753d4 commit 4101b0b
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions lib/programs screen/google_summer_of_code_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'dart:ffi';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:opso/modals/book_mark_model.dart';
import 'package:opso/programs_info_pages/gsoc_info.dart';
import 'package:opso/widgets/gsoc/GsocProjectWidget.dart';
import 'package:url_launcher/url_launcher.dart';
Expand All @@ -19,6 +22,9 @@ class GoogleSummerOfCodeScreen extends StatefulWidget {

class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
bool _isRefreshing = false;
bool isBookmarked = true;
String currentPage = "/Google_summer_of_code";
String currentProject = "GoogleSummerOfCodeScreen";
String selectedOrg = ''; // Ensure this is defined
List<Organization> gsoc2024 = [];
List<Organization> gsoc2023 = [];
Expand Down Expand Up @@ -56,8 +62,15 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
super.initState();
_refresh();
_dataFetchFuture = getProjectData();
_checkBookmarkStatus();
}

Future<void> _checkBookmarkStatus() async {
bool bookmarkStatus = await HandleBookmark.isBookmarked(currentProject);
setState(() {
isBookmarked = bookmarkStatus;
});
}



Expand Down Expand Up @@ -115,7 +128,6 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {




// Update organization filter based on selected languages
allOrganizations = [
..._getOrganizationsByYear(selectedYear)
Expand Down Expand Up @@ -202,9 +214,33 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
return RefreshIndicator(
onRefresh: _refresh,
child: Scaffold(
appBar: AppBar(
appBar: AppBar(
title: const Text('Google Summer of Code'),
actions: <Widget>[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),
),
);
if (isBookmarked) {
print("Adding");
HandleBookmark.addBookmark(currentProject, currentPage);
} else {
print("Deleting");
HandleBookmark.deleteBookmark(currentProject);
}
},
),
IconButton(
icon: const Icon(Icons.info_outline),
onPressed: () {
Navigator.push(
Expand Down

0 comments on commit 4101b0b

Please sign in to comment.