Added bookmark options to search and tag bookmarks
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/delete_bookmark_modal.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/favicon_loader.provider.dart';
|
||||
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
@@ -18,10 +17,14 @@ import 'package:linkdy/utils/open_url.dart';
|
||||
|
||||
class BookmarkItem extends ConsumerWidget {
|
||||
final Bookmark bookmark;
|
||||
final void Function(Bookmark bookmark) onDelete;
|
||||
final void Function(Bookmark bookmark) onReadUnread;
|
||||
|
||||
const BookmarkItem({
|
||||
Key? key,
|
||||
required this.bookmark,
|
||||
required this.onDelete,
|
||||
required this.onReadUnread,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -36,34 +39,27 @@ class BookmarkItem extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void openDeleteBookmarkModal(BuildContext ctx) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DeleteBookmarkModal(bookmark: bookmark),
|
||||
);
|
||||
}
|
||||
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const DrawerMotion(),
|
||||
extentRatio: 0.75,
|
||||
extentRatio: 0.5,
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (ctx) => ref.read(bookmarksProvider.notifier).markAsReadUnread(bookmark),
|
||||
onPressed: (_) => onReadUnread(bookmark),
|
||||
backgroundColor: Colors.blue,
|
||||
label: bookmark.unread == true ? t.bookmarks.bookmarkOptions.read : t.bookmarks.bookmarkOptions.unread,
|
||||
icon: bookmark.unread == true ? Icons.mark_email_read_rounded : Icons.mark_as_unread_rounded,
|
||||
padding: const EdgeInsets.all(4),
|
||||
),
|
||||
// SlidableAction(
|
||||
// onPressed: (ctx) => {},
|
||||
// backgroundColor: Colors.grey,
|
||||
// label: t.bookmarks.bookmarkOptions.archive,
|
||||
// icon: Icons.archive_rounded,
|
||||
// padding: const EdgeInsets.all(4),
|
||||
// ),
|
||||
SlidableAction(
|
||||
onPressed: (ctx) => {},
|
||||
backgroundColor: Colors.grey,
|
||||
label: t.bookmarks.bookmarkOptions.archive,
|
||||
icon: Icons.archive_rounded,
|
||||
padding: const EdgeInsets.all(4),
|
||||
),
|
||||
SlidableAction(
|
||||
onPressed: (ctx) => {},
|
||||
onPressed: (ctx) => Share.shareUri(Uri.parse(bookmark.url!)),
|
||||
backgroundColor: Colors.orange,
|
||||
label: t.bookmarks.bookmarkOptions.share,
|
||||
icon: Icons.share_rounded,
|
||||
@@ -83,7 +79,7 @@ class BookmarkItem extends ConsumerWidget {
|
||||
padding: const EdgeInsets.all(4),
|
||||
),
|
||||
SlidableAction(
|
||||
onPressed: openDeleteBookmarkModal,
|
||||
onPressed: (_) => onDelete(bookmark),
|
||||
backgroundColor: Colors.red,
|
||||
label: t.bookmarks.bookmarkOptions.delete,
|
||||
icon: Icons.delete_rounded,
|
||||
@@ -228,13 +224,23 @@ class BookmarkItem extends ConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
child: Text(
|
||||
t.bookmarks.bookmarkOptions.unread,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.mark_as_unread_rounded,
|
||||
size: 12,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
t.bookmarks.bookmarkOptions.unread,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -7,11 +7,13 @@ import 'package:linkdy/constants/enums.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/add_bookmark_modal.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/delete_bookmark_modal.dart';
|
||||
import 'package:linkdy/widgets/error_screen.dart';
|
||||
import 'package:linkdy/widgets/no_data_screen.dart';
|
||||
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/providers/router.provider.dart';
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
import 'package:linkdy/router/paths.dart';
|
||||
|
||||
class BookmarksScreen extends ConsumerWidget {
|
||||
@@ -39,6 +41,8 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void openDeleteBookmarkModal(Bookmark bookmark) {}
|
||||
|
||||
bool scrollListener(ScrollUpdateNotification scrollNotification) {
|
||||
if (scrollNotification.metrics.extentAfter < 100 &&
|
||||
bookmarks.loadingMore == false &&
|
||||
@@ -118,7 +122,17 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
// Bottom gap for FAB
|
||||
return const SizedBox(height: 80);
|
||||
}
|
||||
return BookmarkItem(bookmark: bookmarks.bookmarks[index]);
|
||||
return BookmarkItem(
|
||||
bookmark: bookmarks.bookmarks[index],
|
||||
onReadUnread: ref.read(bookmarksProvider.notifier).markAsReadUnread,
|
||||
onDelete: (bookmark) => showDialog(
|
||||
context: context,
|
||||
builder: (context) => DeleteBookmarkModal(
|
||||
bookmark: bookmark,
|
||||
onDelete: ref.read(bookmarksProvider.notifier).deleteBookmark,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
|
||||
class DeleteBookmarkModal extends ConsumerWidget {
|
||||
class DeleteBookmarkModal extends StatelessWidget {
|
||||
final Bookmark bookmark;
|
||||
final void Function(Bookmark) onDelete;
|
||||
|
||||
const DeleteBookmarkModal({
|
||||
Key? key,
|
||||
required this.bookmark,
|
||||
required this.onDelete,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Column(
|
||||
children: [
|
||||
@@ -57,7 +56,7 @@ class DeleteBookmarkModal extends ConsumerWidget {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(bookmarksProvider.notifier).deleteBookmark(bookmark);
|
||||
onDelete(bookmark);
|
||||
},
|
||||
child: Text(t.generic.confirm),
|
||||
),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:linkdy/screens/bookmarks/provider/search_bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/delete_bookmark_modal.dart';
|
||||
import 'package:linkdy/widgets/enter_search_term_screen.dart';
|
||||
import 'package:linkdy/widgets/error_screen.dart';
|
||||
|
||||
@@ -113,6 +114,14 @@ class SearchBookmarksScreen extends ConsumerWidget {
|
||||
}
|
||||
return BookmarkItem(
|
||||
bookmark: provider.bookmarks[index],
|
||||
onReadUnread: ref.read(searchBookmarksProvider.notifier).markAsReadUnread,
|
||||
onDelete: (bookmark) => showDialog(
|
||||
context: context,
|
||||
builder: (context) => DeleteBookmarkModal(
|
||||
bookmark: bookmark,
|
||||
onDelete: ref.read(searchBookmarksProvider.notifier).deleteBookmark,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user