Improved read filters

This commit is contained in:
Juan Gilsanz Polo
2024-02-28 17:10:32 +01:00
parent d461dd4840
commit c76eedf6d7
8 changed files with 142 additions and 86 deletions

View File

@@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 2
/// Strings: 348 (174 per locale)
/// Strings: 350 (175 per locale)
///
/// Built on 2024-02-28 at 14:44 UTC
/// Built on 2024-02-28 at 16:02 UTC
// coverage:ignore-file
// ignore_for_file: type=lint
@@ -234,6 +234,7 @@ class _StringsBookmarksEn {
String get all => 'All';
String get unread => 'Unread';
String get read => 'Read';
String get filterSort => 'Filter and sort';
late final _StringsBookmarksAddBookmarkEn addBookmark = _StringsBookmarksAddBookmarkEn._(_root);
late final _StringsBookmarksSearchEn search = _StringsBookmarksSearchEn._(_root);
late final _StringsBookmarksBookmarkOptionsEn bookmarkOptions = _StringsBookmarksBookmarkOptionsEn._(_root);
@@ -604,6 +605,7 @@ class _StringsBookmarksEs implements _StringsBookmarksEn {
@override String get all => 'Todos';
@override String get unread => 'No leídos';
@override String get read => 'Leídos';
@override String get filterSort => 'Filtrar y ordenar';
@override late final _StringsBookmarksAddBookmarkEs addBookmark = _StringsBookmarksAddBookmarkEs._(_root);
@override late final _StringsBookmarksSearchEs search = _StringsBookmarksSearchEs._(_root);
@override late final _StringsBookmarksBookmarkOptionsEs bookmarkOptions = _StringsBookmarksBookmarkOptionsEs._(_root);
@@ -923,6 +925,7 @@ extension on Translations {
case 'bookmarks.all': return 'All';
case 'bookmarks.unread': return 'Unread';
case 'bookmarks.read': return 'Read';
case 'bookmarks.filterSort': return 'Filter and sort';
case 'bookmarks.addBookmark.addBookmark': return 'Add new bookmark';
case 'bookmarks.addBookmark.editBookmark': return 'Edit bookmark';
case 'bookmarks.addBookmark.bookmarkUrl': return 'Bookmark URL';
@@ -1105,6 +1108,7 @@ extension on _StringsEs {
case 'bookmarks.all': return 'Todos';
case 'bookmarks.unread': return 'No leídos';
case 'bookmarks.read': return 'Leídos';
case 'bookmarks.filterSort': return 'Filtrar y ordenar';
case 'bookmarks.addBookmark.addBookmark': return 'Añadir nuevo marcador';
case 'bookmarks.addBookmark.editBookmark': return 'Editar marcador';
case 'bookmarks.addBookmark.url': return 'URL';

View File

@@ -59,6 +59,7 @@
"all": "All",
"unread": "Unread",
"read": "Read",
"filterSort": "Filter and sort",
"addBookmark": {
"addBookmark": "Add new bookmark",
"editBookmark": "Edit bookmark",

View File

@@ -59,6 +59,7 @@
"all": "Todos",
"unread": "No leídos",
"read": "Leídos",
"filterSort": "Filtrar y ordenar",
"addBookmark": {
"addBookmark": "Añadir nuevo marcador",
"editBookmark": "Editar marcador",

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:quds_popup_menu/quds_popup_menu.dart';
import 'package:linkdy/screens/bookmarks/ui/visualization_modal.dart';
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
@@ -124,76 +124,47 @@ class BookmarksScreen extends ConsumerWidget {
icon: const Icon(Icons.search_rounded),
tooltip: t.bookmarks.search.searchBookmarks,
),
const SizedBox(width: 8),
QudsPopupButton(
radius: 22,
backgroundColor: Theme.of(context).popupMenuTheme.surfaceTintColor,
items: [
QudsPopupMenuItem(
leading: const Icon(Icons.archive_rounded),
title: Text(t.bookmarks.archived),
onPressed: () => ref.read(routerProvider).push(RoutesPaths.archivedBookmarks),
PopupMenuButton(
itemBuilder: (context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () => ref.read(routerProvider).push(RoutesPaths.archivedBookmarks),
child: Row(
children: [
const Icon(Icons.archive_rounded),
const SizedBox(width: 16),
Text(t.bookmarks.archived),
],
),
),
QudsPopupMenuItem(
leading: const Icon(Icons.share_rounded),
title: Text(t.bookmarks.shared),
onPressed: () => ref.read(routerProvider).push(RoutesPaths.sharedBookmarks),
PopupMenuItem(
onTap: () => ref.read(routerProvider).push(RoutesPaths.sharedBookmarks),
child: Row(
children: [
const Icon(Icons.share_rounded),
const SizedBox(width: 16),
Text(t.bookmarks.shared),
],
),
),
QudsPopupMenuDivider(),
QudsPopupMenuSection(
leading: const Icon(Icons.list_rounded),
titleText: t.bookmarks.readStatus,
subTitle: Text(readStatus()),
subItems: [
QudsPopupMenuItem(
leading: const Icon(Icons.list_rounded),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text(t.bookmarks.showAllBookmarks)),
if (bookmarks.readStatus == ReadStatus.all) ...[
const SizedBox(width: 8),
const Icon(Icons.check_rounded),
],
],
),
onPressed: () => ref.read(bookmarksProvider.notifier).setReadStatus(ReadStatus.all),
),
QudsPopupMenuItem(
leading: const Icon(Icons.mark_as_unread_rounded),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text(t.bookmarks.showOnlyUnread)),
if (bookmarks.readStatus == ReadStatus.unread) ...[
const SizedBox(width: 8),
const Icon(Icons.check_rounded),
],
],
),
onPressed: () => ref.read(bookmarksProvider.notifier).setReadStatus(ReadStatus.unread),
),
QudsPopupMenuItem(
leading: const Icon(Icons.mark_email_read_rounded),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text(t.bookmarks.showOnlyRead)),
if (bookmarks.readStatus == ReadStatus.read) ...[
const SizedBox(width: 8),
const Icon(Icons.check_rounded),
],
],
),
onPressed: () => ref.read(bookmarksProvider.notifier).setReadStatus(ReadStatus.read),
),
],
const PopupMenuDivider(height: 1),
PopupMenuItem(
onTap: () => showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => const VisualizationModal(),
isScrollControlled: true,
),
child: Row(
children: [
const Icon(Icons.sort_rounded),
const SizedBox(width: 16),
Text(t.bookmarks.filterSort),
],
),
),
],
tooltip: t.generic.options,
child: const Icon(Icons.more_vert_rounded),
),
const SizedBox(width: 16),
const SizedBox(width: 8),
],
),
),

View File

@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:segmented_button_slide/segmented_button_slide.dart';
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
import 'package:linkdy/widgets/section_label.dart';
import 'package:linkdy/constants/enums.dart';
import 'package:linkdy/i18n/strings.g.dart';
class VisualizationModal extends ConsumerWidget {
const VisualizationModal({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28),
),
color: Theme.of(context).dialogBackgroundColor,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.sort_rounded,
color: Theme.of(context).colorScheme.secondary,
size: 24,
),
const SizedBox(height: 16),
Text(
t.bookmarks.filterSort,
style: const TextStyle(
fontSize: 24,
),
),
const SizedBox(height: 8),
SectionLabel(
label: t.bookmarks.readStatus,
padding: const EdgeInsets.symmetric(
horizontal: 0,
vertical: 16,
),
),
SegmentedButtonSlide(
entries: [
SegmentedButtonSlideEntry(label: t.bookmarks.all),
SegmentedButtonSlideEntry(label: t.bookmarks.unread),
SegmentedButtonSlideEntry(label: t.bookmarks.read),
],
selectedEntry: ref.watch(bookmarksProvider).readStatus.index,
onChange: (v) => ref.read(bookmarksProvider.notifier).setReadStatus(ReadStatus.values[v]),
colors: SegmentedButtonSlideColors(
barColor: Theme.of(context).colorScheme.primary.withOpacity(0.2),
backgroundSelectedColor: Theme.of(context).colorScheme.primary,
foregroundSelectedColor: Theme.of(context).colorScheme.onPrimary,
foregroundUnselectedColor: Theme.of(context).colorScheme.onSurface,
hoverColor: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(t.generic.close),
),
],
),
),
],
),
),
),
),
);
}
}

View File

@@ -6,7 +6,7 @@ import 'package:linkdy/screens/tags/provider/add_tag.provider.dart';
import 'package:linkdy/i18n/strings.g.dart';
class AddTagModal extends ConsumerWidget {
const AddTagModal({Key? key}) : super(key: key);
const AddTagModal({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {