feat: check every subscription in the background and add the posts page
This commit is contained in:
parent
953ae798eb
commit
1b426ccd8b
15 changed files with 688 additions and 58 deletions
|
|
@ -11,9 +11,14 @@ import 'mews_urls.dart';
|
|||
/// constant here rather than a message.
|
||||
const actionSeparator = ' ';
|
||||
|
||||
/// One choice in a group of mutually exclusive values.
|
||||
/// A link with its label: a choice in a group, or an action on a row. For an
|
||||
/// action [current] is always false.
|
||||
typedef Choice = ({String href, String label, bool current});
|
||||
|
||||
/// An action link on a row.
|
||||
Choice action(String href, String label) =>
|
||||
(href: href, label: label, current: false);
|
||||
|
||||
/// One entry in the strip of internal pages.
|
||||
typedef NavItem = ({String url, String labelId});
|
||||
|
||||
|
|
@ -21,6 +26,7 @@ typedef NavItem = ({String url, String labelId});
|
|||
/// never shifts under the reader.
|
||||
const navItems = <NavItem>[
|
||||
(url: MewsUrls.hub, labelId: 'nav-hub'),
|
||||
(url: MewsUrls.posts, labelId: 'nav-posts'),
|
||||
(url: MewsUrls.bookmarks, labelId: 'nav-bookmarks'),
|
||||
(url: MewsUrls.subscriptions, labelId: 'nav-subscriptions'),
|
||||
(url: MewsUrls.history, labelId: 'nav-history'),
|
||||
|
|
@ -61,18 +67,59 @@ MewsListItem itemRow({
|
|||
required String label,
|
||||
String? date,
|
||||
String? note,
|
||||
bool strong = false,
|
||||
List<Choice> actions = const [],
|
||||
}) {
|
||||
final text = date == null ? label : '$date $label';
|
||||
return MewsListItem([
|
||||
ParagraphBlock([
|
||||
MewsLink(href, [MewsText(date == null ? label : '$date $label')]),
|
||||
MewsLink(href, [
|
||||
if (strong)
|
||||
MewsEmphasis(EmphasisStyle.strong, [MewsText(text)])
|
||||
else
|
||||
MewsText(text),
|
||||
]),
|
||||
if (note != null) ...[
|
||||
const MewsLineBreak(),
|
||||
MewsEmphasis(EmphasisStyle.emphasis, [MewsText(note)]),
|
||||
],
|
||||
if (actions.isNotEmpty) ...[
|
||||
const MewsLineBreak(),
|
||||
..._separated(
|
||||
[for (final action in actions) MewsLink(action.href, [MewsText(action.label)])]),
|
||||
],
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/// Joins runs with the separator between them, never around them.
|
||||
List<MewsInline> _separated(List<MewsInline> runs) {
|
||||
final out = <MewsInline>[];
|
||||
for (final run in runs) {
|
||||
if (out.isNotEmpty) out.add(const MewsText(actionSeparator));
|
||||
out.add(run);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/// A group of mutually exclusive values on one line, for a short group that
|
||||
/// would waste a list. The chosen value is plain text, the rest are links.
|
||||
List<MewsBlock> choiceLine({required String label, required List<Choice> options}) {
|
||||
return [
|
||||
ParagraphBlock([
|
||||
MewsEmphasis(EmphasisStyle.emphasis, [MewsText(label)]),
|
||||
const MewsText(actionSeparator),
|
||||
..._separated([
|
||||
for (final option in options)
|
||||
if (option.current)
|
||||
MewsEmphasis(EmphasisStyle.strong, [MewsText(option.label)])
|
||||
else
|
||||
MewsLink(option.href, [MewsText(option.label)]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/// A group of mutually exclusive values: the current one plain, the rest links.
|
||||
ListBlock choiceRow(List<Choice> options) {
|
||||
return ListBlock(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue