feat: add a hub for the client's own pages and gate mews:do action links
This commit is contained in:
parent
df705d831f
commit
b311b9f7dd
21 changed files with 966 additions and 404 deletions
46
app/lib/application/pages/subscriptions_page.dart
Normal file
46
app/lib/application/pages/subscriptions_page.dart
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import '../../database/database.dart';
|
||||
import '../../l10n/strings.dart';
|
||||
import '../../mews/document.dart';
|
||||
import '../controllers/reader_settings_controller.dart' show LibraryController;
|
||||
import 'page_blocks.dart';
|
||||
|
||||
Future<MewsPage> buildSubscriptionsPage(
|
||||
Uri url, {
|
||||
required MewsDatabase db,
|
||||
required LibraryController library,
|
||||
required Strings strings,
|
||||
}) async {
|
||||
final sites = await db.allSubscriptions();
|
||||
final title = strings.t('subscriptions-title');
|
||||
|
||||
return internalPage(
|
||||
url: url,
|
||||
title: title,
|
||||
body: [
|
||||
...chrome(title: title, current: url, strings: strings),
|
||||
if (sites.isEmpty)
|
||||
ParagraphBlock([MewsText(strings.t('subscriptions-empty'))])
|
||||
else
|
||||
itemList([
|
||||
for (final site in sites)
|
||||
itemRow(
|
||||
href: site.url,
|
||||
label: site.title ?? site.url,
|
||||
date: dayText(site.createdAt),
|
||||
note: _unreadNote(library, strings, site.url),
|
||||
),
|
||||
]),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The unread count for a site, or null when it has nothing new, so the row
|
||||
/// carries no empty line.
|
||||
String? _unreadNote(LibraryController library, Strings strings, String siteUrl) {
|
||||
final count = library.newEntries.value[siteUrl]?.length ?? 0;
|
||||
if (count == 0) return null;
|
||||
return countText(strings, count,
|
||||
none: 'count-unread-none',
|
||||
one: 'count-unread-one',
|
||||
many: 'count-unread-many');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue