feat: search, filter and act on items from the library pages
This commit is contained in:
parent
1b426ccd8b
commit
5cd053c8a9
11 changed files with 401 additions and 43 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import '../../database/database.dart';
|
||||
import '../../l10n/strings.dart';
|
||||
import '../../mews/document.dart';
|
||||
import 'mews_urls.dart';
|
||||
import 'page_blocks.dart';
|
||||
|
||||
Future<MewsPage> buildBookmarksPage(
|
||||
|
|
@ -8,7 +9,8 @@ Future<MewsPage> buildBookmarksPage(
|
|||
required MewsDatabase db,
|
||||
required Strings strings,
|
||||
}) async {
|
||||
final bookmarks = await db.bookmarksByDate();
|
||||
final query = url.queryParameters['q'] ?? '';
|
||||
final bookmarks = await db.bookmarksByDate(query: query);
|
||||
final title = strings.t('bookmarks-title');
|
||||
|
||||
return internalPage(
|
||||
|
|
@ -16,8 +18,22 @@ Future<MewsPage> buildBookmarksPage(
|
|||
title: title,
|
||||
body: [
|
||||
...chrome(title: title, current: url, strings: strings),
|
||||
searchForm(
|
||||
action: MewsUrls.bookmarks,
|
||||
label: strings.t('bookmarks-search-label'),
|
||||
submitLabel: strings.t('action-search'),
|
||||
query: query,
|
||||
),
|
||||
if (query.isNotEmpty)
|
||||
ParagraphBlock([
|
||||
MewsLink(MewsUrls.page(url, {'q': null}),
|
||||
[MewsText(strings.t('action-clear-search'))]),
|
||||
]),
|
||||
if (bookmarks.isEmpty)
|
||||
ParagraphBlock([MewsText(strings.t('bookmarks-empty'))])
|
||||
ParagraphBlock([
|
||||
MewsText(strings.t(
|
||||
query.isEmpty ? 'bookmarks-empty' : 'bookmarks-no-matches')),
|
||||
])
|
||||
else
|
||||
itemList([
|
||||
for (final bookmark in bookmarks)
|
||||
|
|
@ -25,6 +41,11 @@ Future<MewsPage> buildBookmarksPage(
|
|||
href: bookmark.url,
|
||||
label: bookmark.title ?? bookmark.url,
|
||||
date: dayText(bookmark.createdAt),
|
||||
actions: [
|
||||
action(
|
||||
MewsUrls.action('remove-bookmark', {'url': bookmark.url}),
|
||||
strings.t('action-remove-bookmark')),
|
||||
],
|
||||
),
|
||||
]),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue