Added share and unshare bookmarks
This commit is contained in:
@@ -1,10 +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/ui/share_options_modal.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/favicon_loader.provider.dart';
|
||||
|
||||
import 'package:linkdy/config/options.dart';
|
||||
@@ -22,6 +22,7 @@ class BookmarkItem extends ConsumerWidget {
|
||||
final void Function(Bookmark bookmark) onReadUnread;
|
||||
final void Function(Bookmark bookmark) onArchiveUnarchive;
|
||||
final void Function(Bookmark bookmark) onEdit;
|
||||
final void Function(Bookmark bookmark) onShareInternally;
|
||||
|
||||
const BookmarkItem({
|
||||
super.key,
|
||||
@@ -30,6 +31,7 @@ class BookmarkItem extends ConsumerWidget {
|
||||
required this.onReadUnread,
|
||||
required this.onArchiveUnarchive,
|
||||
required this.onEdit,
|
||||
required this.onShareInternally,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -66,7 +68,10 @@ class BookmarkItem extends ConsumerWidget {
|
||||
padding: const EdgeInsets.all(4),
|
||||
),
|
||||
SlidableAction(
|
||||
onPressed: (ctx) => Share.shareUri(Uri.parse(bookmark.url!)),
|
||||
onPressed: (ctx) => showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => ShareOptionsModal(bookmark: bookmark, onShareInternally: onShareInternally),
|
||||
),
|
||||
backgroundColor: Colors.orange,
|
||||
label: t.bookmarks.bookmarkOptions.share,
|
||||
icon: Icons.share_rounded,
|
||||
@@ -214,7 +219,7 @@ class BookmarkItem extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (bookmark.unread == true) ...[
|
||||
if (bookmark.shared == true) ...[
|
||||
if (bookmark.tagNames?.isNotEmpty == true)
|
||||
Container(
|
||||
width: 1,
|
||||
@@ -222,6 +227,43 @@ class BookmarkItem extends ConsumerWidget {
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
color: Theme.of(context).colorScheme.tertiary.withOpacity(0.3),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.share_rounded,
|
||||
size: 12,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
t.bookmarks.bookmarkOptions.shared,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
if (bookmark.unread == true) ...[
|
||||
if (bookmark.tagNames?.isNotEmpty == true || bookmark.shared == true)
|
||||
Container(
|
||||
width: 1,
|
||||
height: 12,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
color: Theme.of(context).colorScheme.tertiary.withOpacity(0.3),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
@@ -252,7 +294,7 @@ class BookmarkItem extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
if (bookmark.dateModified != null) ...[
|
||||
if (bookmark.unread == true)
|
||||
if (bookmark.unread == true || bookmark.shared == true || bookmark.tagNames?.isNotEmpty == true)
|
||||
Container(
|
||||
width: 1,
|
||||
height: 12,
|
||||
|
||||
@@ -132,6 +132,7 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
onArchiveUnarchive: ref.read(bookmarksProvider.notifier).archiveUnarchive,
|
||||
onShareInternally: ref.read(bookmarksProvider.notifier).shareUnshare,
|
||||
onEdit: (b) => openBookmarkFormModal(context: context, width: width, bookmark: b),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -140,6 +140,7 @@ class SearchBookmarksModal extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
onArchiveUnarchive: ref.read(searchBookmarksProvider.notifier).archiveUnarchive,
|
||||
onShareInternally: ref.read(searchBookmarksProvider.notifier).shareUnshare,
|
||||
onEdit: (b) => openBookmarkFormModal(context: context, width: width, bookmark: b),
|
||||
);
|
||||
},
|
||||
|
||||
76
lib/screens/bookmarks/ui/share_options_modal.dart
Normal file
76
lib/screens/bookmarks/ui/share_options_modal.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import 'package:linkdy/widgets/custom_list_tile.dart';
|
||||
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
|
||||
class ShareOptionsModal extends StatelessWidget {
|
||||
final Bookmark bookmark;
|
||||
final void Function(Bookmark bookmark) onShareInternally;
|
||||
|
||||
const ShareOptionsModal({
|
||||
super.key,
|
||||
required this.bookmark,
|
||||
required this.onShareInternally,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 24),
|
||||
title: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.share_rounded,
|
||||
size: 24,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(t.bookmarks.shareOptions.shareOptions),
|
||||
],
|
||||
),
|
||||
content: Column(
|
||||
children: [
|
||||
CustomListTile(
|
||||
icon: Icons.input_rounded,
|
||||
title: bookmark.shared == true
|
||||
? t.bookmarks.shareOptions.unshareInternally
|
||||
: t.bookmarks.shareOptions.shareInternally,
|
||||
subtitle: bookmark.shared == true
|
||||
? t.bookmarks.shareOptions.unshareInternallyDescription
|
||||
: t.bookmarks.shareOptions.shareInternallyDescription,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
onShareInternally(bookmark);
|
||||
},
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.output_rounded,
|
||||
title: t.bookmarks.shareOptions.shareExternally,
|
||||
subtitle: t.bookmarks.shareOptions.shareExternallyDescription,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Share.shareUri(Uri.parse(bookmark.url!));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(t.generic.close),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user