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
100
app/lib/application/pages/settings_page.dart
Normal file
100
app/lib/application/pages/settings_page.dart
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import '../../l10n/strings.dart';
|
||||
import '../../mews/document.dart';
|
||||
import '../controllers/reader_settings_controller.dart'
|
||||
show ReaderSettingsController;
|
||||
import 'mews_urls.dart';
|
||||
import 'page_blocks.dart';
|
||||
|
||||
/// The bundled typefaces the reader can pick. Adding a font is one TTF in
|
||||
/// assets/fonts, one entry in pubspec.yaml, one entry here and one label in
|
||||
/// the locale file.
|
||||
const _fonts = <({String family, String labelId})>[
|
||||
(family: 'Atkinson Hyperlegible', labelId: 'settings-font-atkinson'),
|
||||
];
|
||||
|
||||
/// Message ids for the values the controller accepts. Kept literal so every
|
||||
/// id in the locale file can be found by searching for it.
|
||||
const _themeLabels = {
|
||||
'light': 'settings-theme-light',
|
||||
'dark': 'settings-theme-dark',
|
||||
'system': 'settings-theme-system',
|
||||
};
|
||||
|
||||
const _variantLabels = {
|
||||
'site': 'settings-variant-site',
|
||||
'warm': 'settings-variant-warm',
|
||||
'cool': 'settings-variant-cool',
|
||||
'green': 'settings-variant-green',
|
||||
'mono': 'settings-variant-mono',
|
||||
};
|
||||
|
||||
Future<MewsPage> buildSettingsPage(
|
||||
Uri url, {
|
||||
required ReaderSettingsController settings,
|
||||
required Strings strings,
|
||||
}) async {
|
||||
final title = strings.t('settings-page-title');
|
||||
final scale = settings.fontScale.value;
|
||||
|
||||
return internalPage(
|
||||
url: url,
|
||||
title: title,
|
||||
body: [
|
||||
...chrome(title: title, current: url, strings: strings),
|
||||
HeadingBlock(2, [MewsText(strings.t('settings-font-heading'))]),
|
||||
choiceRow([
|
||||
for (final font in _fonts)
|
||||
(
|
||||
href: MewsUrls.action('set-font', {'value': font.family}),
|
||||
label: strings.t(font.labelId),
|
||||
current: font.family == settings.font.value,
|
||||
),
|
||||
]),
|
||||
// Text size steps between the controller's bounds, with the current
|
||||
// value between the two steps.
|
||||
HeadingBlock(2, [MewsText(strings.t('settings-size-heading'))]),
|
||||
itemList([
|
||||
if (scale > ReaderSettingsController.minScale)
|
||||
MewsListItem([
|
||||
ParagraphBlock([
|
||||
MewsLink(MewsUrls.action('set-size', {'step': 'down'}),
|
||||
[MewsText(strings.t('settings-size-decrease'))]),
|
||||
]),
|
||||
]),
|
||||
MewsListItem([
|
||||
ParagraphBlock([
|
||||
MewsEmphasis(EmphasisStyle.strong, [
|
||||
MewsText(strings.t('settings-size-value',
|
||||
{'percent': (scale * 100).round()})),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
if (scale < ReaderSettingsController.maxScale)
|
||||
MewsListItem([
|
||||
ParagraphBlock([
|
||||
MewsLink(MewsUrls.action('set-size', {'step': 'up'}),
|
||||
[MewsText(strings.t('settings-size-increase'))]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
HeadingBlock(2, [MewsText(strings.t('settings-theme-heading'))]),
|
||||
choiceRow([
|
||||
for (final mode in ReaderSettingsController.themeModes)
|
||||
(
|
||||
href: MewsUrls.action('set-theme', {'value': mode}),
|
||||
label: strings.t(_themeLabels[mode]!),
|
||||
current: mode == settings.themeMode.value,
|
||||
),
|
||||
]),
|
||||
HeadingBlock(2, [MewsText(strings.t('settings-variant-heading'))]),
|
||||
choiceRow([
|
||||
for (final variant in ReaderSettingsController.variants)
|
||||
(
|
||||
href: MewsUrls.action('set-colors', {'value': variant}),
|
||||
label: strings.t(_variantLabels[variant]!),
|
||||
current: variant == settings.variant.value,
|
||||
),
|
||||
]),
|
||||
],
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue