import '../../database/database.dart'; import '../../l10n/strings.dart'; import '../../mews/document.dart'; import '../controllers/subscriptions_controller.dart'; import 'mews_urls.dart'; import 'page_blocks.dart'; /// The hub names every page the client provides and says what each one holds, /// so the reader has somewhere to start. Its menu is the navigation, so it /// carries no strip of its own. Future buildHubPage( Uri url, { required MewsDatabase db, required SubscriptionsController subscriptions, required Strings strings, }) async { final bookmarks = await db.countBookmarks(); final sites = await db.countSubscriptions(); final visits = await db.countHistory(); final unread = await db.unreadCount(); return internalPage( url: url, title: strings.t('hub-title'), body: [ HeadingBlock(1, [MewsText(strings.t('hub-title'))]), itemList([ itemRow( href: MewsUrls.posts, label: strings.t('nav-posts'), note: countText(strings, unread, none: 'count-unread-none', one: 'count-unread-one', many: 'count-unread-many'), ), itemRow( href: MewsUrls.bookmarks, label: strings.t('nav-bookmarks'), note: countText(strings, bookmarks, none: 'count-bookmarks-none', one: 'count-bookmarks-one', many: 'count-bookmarks-many'), ), itemRow( href: MewsUrls.subscriptions, label: strings.t('nav-subscriptions'), note: countText(strings, sites, none: 'count-sites-none', one: 'count-sites-one', many: 'count-sites-many'), ), itemRow( href: MewsUrls.history, label: strings.t('nav-history'), note: countText(strings, visits, none: 'count-pages-none', one: 'count-pages-one', many: 'count-pages-many'), ), itemRow(href: MewsUrls.settings, label: strings.t('nav-settings')), ]), ParagraphBlock([ if (subscriptions.refreshing.value) MewsEmphasis(EmphasisStyle.emphasis, [MewsText(strings.t('posts-checking'))]) else MewsLink(MewsUrls.action('refresh-subscriptions'), [MewsText(strings.t('action-refresh'))]), ]), ], ); }