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:
parent
98b110dd56
commit
820aca7d92
25 changed files with 606 additions and 41 deletions
|
|
@ -17,9 +17,9 @@ IconData kindIcon(Node n) => n.kind == 'task'
|
|||
: Icons.business;
|
||||
|
||||
class CustomersPage extends StatefulWidget {
|
||||
const CustomersPage({super.key, required this.sync, this.s = const WorkSettings()});
|
||||
const CustomersPage({super.key, required this.sync});
|
||||
final SyncService sync;
|
||||
final WorkSettings s;
|
||||
WorkSettings get s => WorkSettings.of(sync.store); // the dashboard's, synced
|
||||
@override
|
||||
State<CustomersPage> createState() => _CustomersPageState();
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ class _CustomersPageState extends State<CustomersPage> {
|
|||
void _edit({String? id, String kind = 'client', String? parent}) => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => NodeEditor(sync: widget.sync, s: widget.s, nodeId: id, kind: kind, parent: parent),
|
||||
builder: (_) => NodeEditor(sync: widget.sync, nodeId: id, kind: kind, parent: parent),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -112,9 +112,9 @@ class _CustomersPageState extends State<CustomersPage> {
|
|||
|
||||
/// One node's editor (new when [nodeId] is null: a [kind] under [parent]).
|
||||
class NodeEditor extends StatefulWidget {
|
||||
const NodeEditor({super.key, required this.sync, this.s = const WorkSettings(), this.nodeId, this.kind = 'client', this.parent});
|
||||
const NodeEditor({super.key, required this.sync, this.nodeId, this.kind = 'client', this.parent});
|
||||
final SyncService sync;
|
||||
final WorkSettings s;
|
||||
WorkSettings get s => WorkSettings.of(sync.store); // the dashboard's, synced
|
||||
final String? nodeId, kind, parent;
|
||||
@override
|
||||
State<NodeEditor> createState() => _NodeEditorState();
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ Future<void> openEntry(
|
|||
int? endMin,
|
||||
String? node,
|
||||
String note = '',
|
||||
WorkSettings s = const WorkSettings(),
|
||||
WorkSettings? s,
|
||||
}) => showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: card,
|
||||
builder: (_) => EntrySheet(sync: sync, entry: entry, day: day, startMin: startMin, endMin: endMin, node: node, note: note, s: s),
|
||||
builder: (_) => EntrySheet(sync: sync, entry: entry, day: day, startMin: startMin, endMin: endMin, node: node, note: note, s: s ?? WorkSettings.of(sync.store)),
|
||||
);
|
||||
|
||||
class EntrySheet extends StatefulWidget {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import 'entry_sheet.dart';
|
|||
import 'work_model.dart';
|
||||
|
||||
class ReportPage extends StatefulWidget {
|
||||
const ReportPage({super.key, required this.sync, this.s = const WorkSettings()});
|
||||
const ReportPage({super.key, required this.sync});
|
||||
final SyncService sync;
|
||||
final WorkSettings s;
|
||||
WorkSettings get s => WorkSettings.of(sync.store); // the dashboard's, synced
|
||||
@override
|
||||
State<ReportPage> createState() => _ReportPageState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ Widget _hold({
|
|||
);
|
||||
|
||||
class WorkPage extends StatefulWidget {
|
||||
const WorkPage({super.key, required this.sync, this.s = const WorkSettings(), this.actions = const []});
|
||||
const WorkPage({super.key, required this.sync, this.actions = const []});
|
||||
final SyncService sync;
|
||||
final WorkSettings s;
|
||||
WorkSettings get s => WorkSettings.of(sync.store); // the dashboard's, synced
|
||||
final List<Widget> actions; // the shell's (sync icon, ⋮) — Work has its own bar: in landscape the week's ‹ CW › sits in it
|
||||
@override
|
||||
State<WorkPage> createState() => _WorkPageState();
|
||||
|
|
@ -202,7 +202,7 @@ class _WorkPageState extends State<WorkPage> {
|
|||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => NodeEditor(sync: widget.sync, s: widget.s, nodeId: c.node.id),
|
||||
builder: (_) => NodeEditor(sync: widget.sync, nodeId: c.node.id),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -299,7 +299,7 @@ class _WorkPageState extends State<WorkPage> {
|
|||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CustomersPage(sync: widget.sync, s: widget.s),
|
||||
builder: (_) => CustomersPage(sync: widget.sync),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.add),
|
||||
|
|
@ -407,7 +407,7 @@ class _WorkPageState extends State<WorkPage> {
|
|||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => NodeEditor(sync: widget.sync, s: widget.s, nodeId: c.node.id),
|
||||
builder: (_) => NodeEditor(sync: widget.sync, nodeId: c.node.id),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue