screen-locker/stronglift_replacement/workout_app/lib/services/position_source.dart
Krzysztof kuhy Rudnicki c2544c4a9c Add GPS run foundation: TCX codec, DB, deps
Pure-Dart TCX codec pinned to the PC's RunnerUp parser by a shared
golden fixture (Dart byte-compare + pytest through the real verifier),
GPS filters and moving-time maths mirroring the PC walk rule, runs /
run_points tables (schema v9), PositionSource seam over geolocator,
location permissions and foreground service type, map/cache deps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWZ9CKZsNxtD5Jr9bYD
2026-11-10 15:37:41 +01:00

39 lines
1.3 KiB
Dart

/// The seam between the recorder and the platform's location provider.
///
/// Everything above this interface (recorder, map, sandbox replay) is pure
/// Dart and runs on the Linux test host and the desktop target; only
/// `GeolocatorPositionSource` touches the geolocator plugin.
library;
import 'package:workout_app/services/gps_filter.dart';
/// Whether the app may read the location right now.
enum LocationAccess {
/// Permission granted and the location service is on.
granted,
/// Permission refused this time; asking again may work.
denied,
/// Permission refused for good; only the system settings can change it.
deniedForever,
/// Permission is fine but the device's location switch is off.
serviceOff;
/// Whether fixes can be read right now.
bool get isGranted => this == LocationAccess.granted;
}
/// A stream of GPS fixes plus the permission handshake that guards it.
abstract class PositionSource {
/// Asks for (or re-checks) location permission; never throws for a refusal.
Future<LocationAccess> requestAccess();
/// Fixes roughly every [interval], best accuracy, until cancelled.
///
/// [interval] must stay well under the PC's 30 s credit gap
/// (`kMaxCreditGapSeconds`): a quieter stream earns nothing.
Stream<GpsFix> fixes({Duration interval = const Duration(seconds: 2)});
}