Fly mode previously showed just a black placeholder. It now renders the same MissionMap (route + waypoint markers) and footer (warnings banner, altitude profile, BottomStatsBar) as the Plan screen, minus the reticle/wheels since flying observes the route rather than replanning it. Waypoints can still be edited via the details list for spontaneous in-flight changes. Live drone position comes from a new telemetryProvider/ flightControllerLinkProvider pair (autoDispose), the first place FlightControllerLink/TelemetryFrame get wired into the UI - currently backed by MockFlightControllerLink until a real MSP transport exists (Doku 4.19). A drone marker renders on the map once a telemetry frame arrives. The Fly-mode header keeps the fit-to-area button but replaces "zoom to home" with "zoom to drone" (FlyMapControls) - the first waypoint isn't a meaningful reference point anymore once airborne. Extracted computeMissionStats and MissionFooterBar out of PlanScreen so Plan/Fly share the exact same stats/footer logic instead of duplicating it, and extracted NavIconButton out of MapSearchControls so both Plan's and Fly's map controls use the same button widget. Widget tests that now mount FlyScreen switch from the ProviderScope-based _wrap() helper to a manual ProviderContainer with an explicit FlightControllerLink.disconnect() call before test end - the mock's Timer.periodic doesn't get cancelled by container disposal alone, and flutter_test's pending-timer check runs before addTearDown callbacks. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
29 lines
973 B
Dart
29 lines
973 B
Dart
import 'package:latlong2/latlong.dart';
|
|
|
|
import '../waypoint/flat_waypoint_list.dart';
|
|
|
|
const _distance = Distance(roundResult: false);
|
|
|
|
/// Gesamtdistanz/-dauer einer Mission (HTML-Demonstrator: computeStats()).
|
|
class MissionStats {
|
|
const MissionStats({required this.distanceM, required this.durationSec});
|
|
|
|
final double distanceM;
|
|
final double durationSec;
|
|
}
|
|
|
|
/// Geteilt zwischen Plan- und Fly-Modus sowie der Warnungsberechnung (Doku
|
|
/// 3.9/3.10), die dieselben Werte fuer Zeit-/Reichweiten-Warnungen braucht.
|
|
MissionStats computeMissionStats(List<Waypoint> waypoints) {
|
|
var totalDist = 0.0;
|
|
var totalDur = 0.0;
|
|
for (var i = 0; i < waypoints.length - 1; i++) {
|
|
final a = LatLng(waypoints[i].lat, waypoints[i].lon);
|
|
final b = LatLng(waypoints[i + 1].lat, waypoints[i + 1].lon);
|
|
final d = _distance(a, b);
|
|
totalDist += d;
|
|
totalDur += d / waypoints[i + 1].speedMs;
|
|
}
|
|
return MissionStats(distanceM: totalDist, durationSec: totalDur);
|
|
}
|