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

Bookmark feature added for the Summer of Bitcoin and the GSOC screen #167

Merged
merged 1 commit into from
May 30, 2024
Merged
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 modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Sun May 12 13:50:43 IST 2024
gradle.version=8.1.1
#Wed May 29 23:39:38 IST 2024
gradle.version=8.4
43 changes: 40 additions & 3 deletions lib/programs screen/google_summer_of_code_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:url_launcher/url_launcher.dart';
import '../modals/GSoC/Gsoc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../modals/book_mark_model.dart';
import '../services/ApiService.dart';
import '../widgets/SearchandFilterWidget.dart';
import '../widgets/year_button.dart';
Expand All @@ -20,7 +21,11 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
List<Organization> gsoc2023 = [];
List<Organization> gsoc2022 = [];
List<Organization> gsoc2021 = [];
String currectPage = "/google_summer_of_code";
String currentProject = "Google Summer of Code";
bool isBookmarked = true;
int selectedYear = 2024;

List<String> languages = [
'js',
'python',
Expand All @@ -46,6 +51,14 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
void initState() {
super.initState();
_dataFetchFuture = getProjectData();
_checkBookmarkStatus();
}

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

Future<void> getProjectData() async {
Expand Down Expand Up @@ -149,9 +162,33 @@ class _GoogleSummerOfCodeScreenState extends State<GoogleSummerOfCodeScreen> {
return RefreshIndicator(
onRefresh: _refresh,
child: Scaffold(
appBar: AppBar(
title: Text('Google Summer of Code'),
),
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), // Adjust the duration as needed
),
);
if (isBookmarked) {
print("Adding");
HandleBookmark.addBookmark(currentProject, currectPage);
} else {
print("Deleting");
HandleBookmark.deleteBookmark(currentProject);
}
},
)
]),
body: FutureBuilder<void>(
future: _dataFetchFuture,
builder: (context, snapshot) {
Expand Down
42 changes: 39 additions & 3 deletions lib/programs screen/summer_of_bitcoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:opso/modals/sob_project_modal.dart';
import 'package:opso/widgets/sob_project_widget.dart';
import 'package:opso/widgets/year_button.dart';

import '../modals/book_mark_model.dart';
import '../widgets/SearchandFilterWidget.dart';

class SummerOfBitcoin extends StatefulWidget {
Expand All @@ -19,6 +20,9 @@ class _SummerOfBitcoinState extends State<SummerOfBitcoin> {
List<SobProjectModal> sob2023 = [];
List<SobProjectModal> sob2022 = [];
List<SobProjectModal> sob2021 = [];
String currectPage = "/summer_of_bitcoin";
String currentProject = "Summer of Bitcoin";
bool isBookmarked = true;
int selectedYear = 2023;

List<SobProjectModal> projectList = [];
Expand Down Expand Up @@ -49,6 +53,14 @@ class _SummerOfBitcoinState extends State<SummerOfBitcoin> {
void initState() {
getProjectFunction = initializeProjectLists();
super.initState();
_checkBookmarkStatus();
}

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

void searchTag(String searchTag) {
Expand Down Expand Up @@ -120,9 +132,33 @@ class _SummerOfBitcoinState extends State<SummerOfBitcoin> {
return RefreshIndicator(
onRefresh: _refresh,
child: Scaffold(
appBar: AppBar(
title: const Text('Summer of Bitcoin'),
),
appBar: AppBar(title: const Text('Summer of Bitcoin'), 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), // Adjust the duration as needed
),
);
if (isBookmarked) {
print("Adding");
HandleBookmark.addBookmark(currentProject, currectPage);
} else {
print("Deleting");
HandleBookmark.deleteBookmark(currentProject);
}
},
)
]),
body: FutureBuilder<void>(
future: getProjectFunction,
builder: (context, snapshot) {
Expand Down
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed May 29 23:39:41 IST 2024
sdk.dir=C\:\\Users\\Lenovo\\AppData\\Local\\Android\\Sdk
Loading