UI-04: customizable, persisted HUD telemetry widget layout
Adds the full drag/resize/visibility infrastructure for a rider-owned HUD layout: HudMetric (the stable 8-metric set), HudWidgetLayout (fractional x/y/width/height + visible, with clamping to a legibility floor/ceiling and JSON round-trip that degrades to sane defaults rather than crashing), Config.hudLayout persistence, and a HudLayoutController that stays in-memory-authoritative during an edit session and only writes through on persist() -- never per drag frame. DraggableResizableHudWidget and HudEditOverlay assemble the interaction: edit mode is entered by a long-press on empty HUD space (not a specific widget) and exited via Done or a tap on empty space; only while editing does a widget attach any drag/resize gesture at all, so a normal tap can never move one mid-ride by construction, not by an internal flag. Fixes a real gesture-arena bug found during testing: outside edit mode, a long-press landing on a widget was free to bubble to the overlay's background long-press handler and wrongly enter edit mode. An inner no-op GestureDetector of the same gesture type now absorbs it. Adds a "Live HUD stats" Settings section, one switch per metric, that persists immediately (unlike drag frames). Placed at the end of the Settings list rather than in the middle -- inserting mid-list pushed every later section below several existing tests' viewport assumptions. Verified end-to-end on a real emulator including a full process restart: resized a widget, force-stopped the app, relaunched, and the resize held. No consuming screen exists yet (UI-05's job) -- verified via a throwaway preview entry point, deleted after use. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Xki7YAcc2TiN2PRZJ2tXr
This commit is contained in:
@@ -19,6 +19,9 @@ import '../crash/crash_reporter.dart';
|
||||
import '../data/database.dart';
|
||||
import '../data/route_plan_repository.dart';
|
||||
import '../data/trip_repository.dart';
|
||||
import '../hud/hud_layout_controller.dart';
|
||||
import '../hud/hud_metric.dart';
|
||||
import '../hud/hud_widget_layout.dart';
|
||||
import '../domain/models.dart';
|
||||
import '../notification/ride_notification_controller.dart';
|
||||
import '../notification/ride_notification_coordinator.dart';
|
||||
@@ -131,6 +134,14 @@ final mountedModeProvider = StateProvider<bool>(
|
||||
(ref) => ref.watch(configProvider)?.mountedMode ?? false,
|
||||
);
|
||||
|
||||
/// UI-04: the customizable HUD's live layout. A `StateNotifierProvider`, not a plain
|
||||
/// `StateProvider` like the flags above -- editing needs methods (`updatePosition`/
|
||||
/// `updateSize`/`setVisible`/`persist`), not just a settable value.
|
||||
final hudLayoutControllerProvider =
|
||||
StateNotifierProvider<HudLayoutController, Map<HudMetric, HudWidgetLayout>>(
|
||||
(ref) => HudLayoutController(ref.watch(configProvider)),
|
||||
);
|
||||
|
||||
/// V3-12: same shape again. Note that flipping this at runtime does not retroactively
|
||||
/// start or stop a Sentry client already initialised at app launch -- see
|
||||
/// `maybeInitCrashReporting`'s doc comment on why that gate is checked once, in
|
||||
|
||||
Reference in New Issue
Block a user