FB-01: ambient GPS position drives the shared background map while idle
Adds ambientPositionProvider (never calls LocationSource.stop(), only the idempotent start()) and wires it into ShellScaffold whenever no trip is active, so the persistent background map centers and follows the device's live GPS position at street-level zoom instead of sitting at (0,0)/zoom 2 until a recording starts. RideMap gains an ambientPosition param that the existing chase-camera/pan-cancel/location-marker logic falls back to whenever there are no recorded points, with recorded points always taking priority. Also brings in the docs/feedback ticket set (FB-01..FB-05, README, FEEDBACK.md) that this worktree's branch point predated. Adds 10 tests (374 -> 384): RideMap-level ambient centering/chase/pan-cancel/ marker coverage in test/ride_map_test.dart, plus shell-wiring and provider-level (never-calls-stop, mapEnabledProvider-off) coverage in test/widget_test.dart. flutter analyze remains clean.
This commit is contained in:
@@ -14,6 +14,7 @@ library;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:latlong2/latlong.dart' as ll;
|
||||
|
||||
import '../app/providers.dart';
|
||||
import '../domain/models.dart';
|
||||
@@ -70,6 +71,13 @@ class ShellScaffold extends ConsumerWidget {
|
||||
final segments = trip == null
|
||||
? const <Segment>[]
|
||||
: ref.watch(liveSegmentsProvider(trip.id)).valueOrNull ?? const <Segment>[];
|
||||
// FB-01: only watched while idle, so there's never a duplicate GPS consumer during
|
||||
// an active recording -- the moment a trip starts, this stops being watched at all.
|
||||
final ambientFix =
|
||||
trip == null ? ref.watch(ambientPositionProvider).valueOrNull : null;
|
||||
final ambientPosition = ambientFix == null
|
||||
? null
|
||||
: ll.LatLng(ambientFix.latitude, ambientFix.longitude);
|
||||
|
||||
return Scaffold(
|
||||
// Falls back to the ordinary theme background when the map is disabled -- the
|
||||
@@ -90,6 +98,7 @@ class ShellScaffold extends ConsumerWidget {
|
||||
key: const Key('shell-background-map'),
|
||||
points: points,
|
||||
segments: segments,
|
||||
ambientPosition: ambientPosition,
|
||||
follow: isMapTab,
|
||||
fill: true,
|
||||
showEmptyLabel: false,
|
||||
|
||||
Reference in New Issue
Block a user