46 lines
1.4 KiB
Dart
46 lines
1.4 KiB
Dart
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');
|
|
}
|