2026-10-11 13:05:07 +03:00
|
|
|
import '../../database/database.dart';
|
|
|
|
|
import '../../l10n/strings.dart';
|
|
|
|
|
import '../../mews/document.dart';
|
|
|
|
|
import 'page_blocks.dart';
|
|
|
|
|
|
|
|
|
|
Future<MewsPage> buildSubscriptionsPage(
|
|
|
|
|
Uri url, {
|
|
|
|
|
required MewsDatabase db,
|
|
|
|
|
required Strings strings,
|
|
|
|
|
}) async {
|
|
|
|
|
final sites = await db.allSubscriptions();
|
2026-10-11 13:12:48 +03:00
|
|
|
final unread = await db.unreadCounts();
|
2026-10-11 13:05:07 +03:00
|
|
|
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),
|
2026-10-11 13:12:48 +03:00
|
|
|
note: _unreadNote(strings, unread[site.url] ?? 0),
|
2026-10-11 13:05:07 +03:00
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-11 13:12:48 +03:00
|
|
|
/// The unread count for a site, or null when it has nothing unread, so the
|
|
|
|
|
/// row carries no second line.
|
|
|
|
|
String? _unreadNote(Strings strings, int count) {
|
2026-10-11 13:05:07 +03:00
|
|
|
if (count == 0) return null;
|
|
|
|
|
return countText(strings, count,
|
|
|
|
|
none: 'count-unread-none',
|
|
|
|
|
one: 'count-unread-one',
|
|
|
|
|
many: 'count-unread-many');
|
|
|
|
|
}
|