Updated dependencies, removed split view package, removed super context menu and fix android
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:super_context_menu/super_context_menu.dart';
|
||||
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
|
||||
// Wait until the context menu close animation animation finishes
|
||||
Duration _durationTime = const Duration(milliseconds: 150);
|
||||
|
||||
class BookmarkContextMenu extends ConsumerWidget {
|
||||
final Widget child;
|
||||
final Bookmark bookmark;
|
||||
@@ -31,69 +27,119 @@ class BookmarkContextMenu extends ConsumerWidget {
|
||||
required this.onShareInternally,
|
||||
});
|
||||
|
||||
void _showBottomSheet(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isDismissible: true,
|
||||
builder: (ctx) => SafeArea(
|
||||
bottom: true,
|
||||
top: true,
|
||||
child: Wrap(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
bookmark.unread == true ? Icons.mark_email_read_rounded : Icons.mark_as_unread_rounded,
|
||||
),
|
||||
title: Text(
|
||||
bookmark.unread == true
|
||||
? t.bookmarks.bookmarkOptions.markAsRead
|
||||
: t.bookmarks.bookmarkOptions.markAsUnread,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
onReadUnread(bookmark);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
bookmark.isArchived == true ? Icons.unarchive_rounded : Icons.archive_rounded,
|
||||
),
|
||||
title: Text(
|
||||
bookmark.isArchived == true
|
||||
? t.bookmarks.bookmarkOptions.unarchive
|
||||
: t.bookmarks.bookmarkOptions.archive,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
onArchiveUnarchive(bookmark);
|
||||
},
|
||||
),
|
||||
ExpansionTile(
|
||||
leading: const Icon(Icons.share_rounded),
|
||||
title: Text(t.bookmarks.bookmarkOptions.shareOptions),
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 44),
|
||||
leading: const Icon(Icons.input_rounded),
|
||||
title: Text(
|
||||
bookmark.shared == true
|
||||
? t.bookmarks.bookmarkOptions.unshareInternally
|
||||
: t.bookmarks.bookmarkOptions.shareInternally,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
onShareInternally(bookmark);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 44),
|
||||
leading: const Icon(Icons.output_rounded),
|
||||
title: Text(t.bookmarks.bookmarkOptions.shareThirdPartyApp),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
Share.share(bookmark.url!);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit_rounded),
|
||||
title: Text(t.bookmarks.bookmarkOptions.edit),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
onEdit(bookmark);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.delete_rounded,
|
||||
color: Theme.of(ctx).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
t.bookmarks.bookmarkOptions.delete,
|
||||
style: TextStyle(color: Theme.of(ctx).colorScheme.error),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
onDelete(bookmark);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return ContextMenuWidget(
|
||||
menuProvider: (request) => Menu(
|
||||
children: [
|
||||
MenuAction(
|
||||
callback: () => Future.delayed(_durationTime).then((value) => onReadUnread(bookmark)),
|
||||
title: bookmark.unread == true
|
||||
? t.bookmarks.bookmarkOptions.markAsRead
|
||||
: t.bookmarks.bookmarkOptions.markAsUnread,
|
||||
image: MenuImage.icon(
|
||||
bookmark.unread == true ? Icons.mark_email_read_rounded : Icons.mark_as_unread_rounded,
|
||||
),
|
||||
),
|
||||
MenuAction(
|
||||
callback: () => Future.delayed(_durationTime).then((value) => onArchiveUnarchive(bookmark)),
|
||||
title: bookmark.isArchived == true
|
||||
? t.bookmarks.bookmarkOptions.unarchive
|
||||
: t.bookmarks.bookmarkOptions.archive,
|
||||
image: MenuImage.icon(
|
||||
bookmark.isArchived == true ? Icons.unarchive_rounded : Icons.archive_rounded,
|
||||
),
|
||||
),
|
||||
Menu(
|
||||
title: t.bookmarks.bookmarkOptions.shareOptions,
|
||||
image: MenuImage.icon(Icons.share_rounded),
|
||||
children: [
|
||||
MenuAction(
|
||||
callback: () => Future.delayed(_durationTime).then((value) => onShareInternally(bookmark)),
|
||||
title: bookmark.shared == true
|
||||
? t.bookmarks.bookmarkOptions.unshareInternally
|
||||
: t.bookmarks.bookmarkOptions.shareInternally,
|
||||
image: MenuImage.icon(Icons.input_rounded),
|
||||
),
|
||||
MenuAction(
|
||||
callback: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Future.delayed(_durationTime).then(
|
||||
(value) => Share.share(
|
||||
bookmark.url!,
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
);
|
||||
},
|
||||
title: t.bookmarks.bookmarkOptions.shareThirdPartyApp,
|
||||
image: MenuImage.icon(Icons.output_rounded),
|
||||
),
|
||||
],
|
||||
),
|
||||
MenuSeparator(),
|
||||
MenuAction(
|
||||
callback: () => Future.delayed(_durationTime).then((value) => onEdit(bookmark)),
|
||||
title: t.bookmarks.bookmarkOptions.edit,
|
||||
image: MenuImage.icon(Icons.edit_rounded),
|
||||
),
|
||||
MenuAction(
|
||||
callback: () => Future.delayed(_durationTime).then((value) => onDelete(bookmark)),
|
||||
title: t.bookmarks.bookmarkOptions.delete,
|
||||
image: MenuImage.icon(Icons.delete_rounded),
|
||||
attributes: const MenuActionAttributes(destructive: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
return GestureDetector(
|
||||
onLongPress: () => _showBottomSheet(context),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user