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
|
|
@ -16,10 +16,16 @@ class ReaderSettingsController {
|
|||
static const maxScale = 2.0;
|
||||
static const scaleStep = 0.125;
|
||||
|
||||
/// The accepted values, in the order the settings page offers them. A
|
||||
/// setting arrives as a link the reader can also type, so a value outside
|
||||
/// these lists is refused rather than stored.
|
||||
static const themeModes = ['light', 'dark', 'system'];
|
||||
static const variants = ['site', 'warm', 'cool', 'green', 'mono'];
|
||||
|
||||
final font = signal('Atkinson Hyperlegible');
|
||||
final fontScale = signal(1.0);
|
||||
final themeMode = signal('system'); // system | light | dark
|
||||
final variant = signal('site'); // site | warm | cool | green | mono
|
||||
final themeMode = signal('system');
|
||||
final variant = signal('site');
|
||||
|
||||
Future<void> load() async {
|
||||
final settings = await _db.readSettings();
|
||||
|
|
@ -30,28 +36,37 @@ class ReaderSettingsController {
|
|||
variant.value = settings.variant;
|
||||
}
|
||||
|
||||
Future<void> setFont(String family) async {
|
||||
Future<bool> setFont(String family) async {
|
||||
if (family.isEmpty || family == font.value) return false;
|
||||
font.value = family;
|
||||
await _persist();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> decreaseSize() => _setScale(fontScale.value - scaleStep);
|
||||
Future<void> increaseSize() => _setScale(fontScale.value + scaleStep);
|
||||
Future<bool> decreaseSize() => _setScale(fontScale.value - scaleStep);
|
||||
Future<bool> increaseSize() => _setScale(fontScale.value + scaleStep);
|
||||
|
||||
Future<void> _setScale(double value) async {
|
||||
if (value < minScale || value > maxScale) return;
|
||||
Future<bool> _setScale(double value) async {
|
||||
if (value < minScale || value > maxScale) return false;
|
||||
fontScale.value = value;
|
||||
await _persist();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> setThemeMode(String mode) async {
|
||||
Future<bool> setThemeMode(String mode) async {
|
||||
if (!themeModes.contains(mode) || mode == themeMode.value) return false;
|
||||
themeMode.value = mode;
|
||||
await _persist();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> setVariant(String variant) async {
|
||||
Future<bool> setVariant(String variant) async {
|
||||
if (!variants.contains(variant) || variant == this.variant.value) {
|
||||
return false;
|
||||
}
|
||||
this.variant.value = variant;
|
||||
await _persist();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _persist() => _db.saveSettings(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue