Settings sync between the dashboard and the app

- Dashboard (settingsync.py): the plugins' settings go into a synced
  settings.db, one row per setting (the row id is the setting's key, so the
  phone and the dashboard edit the same row; the later change wins) plus each
  field as the plugin declares it. Fields marked "local" (addresses, paths on
  one machine) and the plugins' on / off stay out. Values set on another
  device are checked as the Settings page does before they're saved; a
  refused one is written back with the dashboard's value.
- App 1.1.7: a Settings page (the gear on every tab) built from those fields,
  synced both ways. Food targets, the cycle, the work day and the body profile
  read the synced values; with a dashboard that doesn't sync settings yet,
  they still come from its Health summaries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-10-26 16:30:00 +02:00
parent 98b110dd56
commit 820aca7d92
25 changed files with 606 additions and 41 deletions

View file

@ -8,6 +8,7 @@
// "workload.entry" {node_id, start, end 'YYYY-MM-DD HH:MM' local, billable 0/1, note, created, updated}
import 'dart:convert';
import '../app/prefs.dart';
import '../sync/store.dart';
const kinds = ['client', 'project', 'task'];
@ -20,7 +21,7 @@ const palette = ['#ffb33a', '#5cc8ff', '#7fd6a3', '#ff6b7a', '#c792ea', '#ff9d5c
const epoch = '0000-01-01'; // a rate "since" this applies to all work
const tNode = 'workload.node', tRate = 'workload.rate', tEntry = 'workload.entry';
/// Until settings sync: the dashboard's Settings ▸ Work defaults.
/// The dashboard's Settings ▸ Work (synced: prefs.dart); its defaults until they've come.
class WorkSettings {
const WorkSettings({
this.currency = 'EUR',
@ -34,6 +35,13 @@ class WorkSettings {
final double defaultRate;
final int dayStart, dayEnd, defaultMinutes;
final double weekTarget;
static WorkSettings of(SyncStore store) {
final p = Prefs(store);
return WorkSettings(currency: p.get<String>('workload.currency', 'EUR'), defaultRate: p.number('workload.default_rate', 0).toDouble(),
dayStart: p.number('workload.day_start', 7).round(), dayEnd: p.number('workload.day_end', 19).round(),
defaultMinutes: p.number('workload.default_minutes', 60).round(), weekTarget: p.number('workload.week_target', 40).toDouble());
}
}
class Invalid implements Exception {