Routines: workout, meditation and must-do routines with timed, rep and tick steps, sets and rest. A library screen, a builder with templates and drag-to-reorder steps, and a full-screen player that auto-advances timed phases, counts backgrounding and logs broken chains as partial. Goals: a goal editor (deadline, colour, category, default class, archive), routines linked to goals, and a goal field on tasks and routines. Tasks added from inside a goal are now actually attached to it via parentId. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import '../../about/external/initial/GoalRequest.dart';
|
|
import '../../about/external/initial/IdRequest.dart';
|
|
import '../parent/ParentViewModel.dart';
|
|
import 'ConnectGoalEditor.dart';
|
|
|
|
class ViewGoalEditor extends ParentViewModel {
|
|
ConnectGoalEditor connection;
|
|
|
|
ViewGoalEditor(super.context, this.connection);
|
|
|
|
void save(GoalRequest request) async {
|
|
if (!await hasNetwork(() => save(request))) return;
|
|
|
|
showLoading("Saving goal");
|
|
|
|
try {
|
|
await getDataManager().saveGoalEntry(request);
|
|
|
|
closeLoading();
|
|
|
|
connection.onSaved();
|
|
} catch (e) {
|
|
handleError(e, () => save(request), () => dismissError(), "Retry");
|
|
}
|
|
}
|
|
|
|
/// Archiving hides the goal; its tasks and their history stay exactly as
|
|
/// they were. Debt already accrued is not forgiven by archiving.
|
|
void archive(String goalId) async {
|
|
if (!await hasNetwork(() => archive(goalId))) return;
|
|
|
|
showLoading("Archiving");
|
|
|
|
try {
|
|
await getDataManager().archiveGoalEntry(IdRequest(id: goalId));
|
|
|
|
closeLoading();
|
|
|
|
connection.onArchived();
|
|
} catch (e) {
|
|
handleError(e, () => archive(goalId), () => dismissError(), "Retry");
|
|
}
|
|
}
|
|
}
|