Show mission map and footer in Fly mode, add area/drone zoom buttons

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>
This commit is contained in:
Constantin Leue
2026-07-30 07:45:36 +02:00
co-authored by Claude Sonnet 5
parent d745b76403
commit 310d92f187
13 changed files with 611 additions and 104 deletions
+15
View File
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
/// Live-Positionsmarker der Drohne im Fly-Modus (Doku 3.10) - noch ohne
/// Peilungsanzeige, da TelemetryFrame aktuell keinen Kurs (heading)
/// mitliefert (nur MockFlightControllerLink, siehe Doku 4.19).
class DroneMarkerIcon extends StatelessWidget {
const DroneMarkerIcon({super.key, this.size = 22});
final double size;
@override
Widget build(BuildContext context) {
return Icon(Icons.airplanemode_active, color: const Color(0xFF4D9DFF), size: size);
}
}
+55
View File
@@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:latlong2/latlong.dart';
import '../providers/current_mission_provider.dart';
import '../providers/map_controller_provider.dart';
import '../providers/telemetry_provider.dart';
import 'nav_icon_button.dart';
/// Kartensteuerung im Fly-Modus (Doku 3.11): Ortssuche/Home entfallen hier
/// (keine Missionsbearbeitung), stattdessen zoomt der Drohnen-Button auf die
/// live Telemetrieposition - "Home" (erster Wegpunkt) ist waehrend des
/// Flugs kein sinnvoller Bezugspunkt mehr, der Fit-Button (gesamte Route)
/// bleibt dagegen unveraendert wie im Plan-Modus erhalten.
class FlyMapControls extends ConsumerWidget {
const FlyMapControls({super.key});
void _onDronePressed(BuildContext context, WidgetRef ref) {
final frame = ref.read(telemetryProvider).value;
if (frame == null) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('No telemetry yet')));
return;
}
ref.read(mapControllerProvider).move(LatLng(frame.lat, frame.lon), 16);
}
void _onFitPressed(BuildContext context, WidgetRef ref) {
final waypoints = ref.read(currentMissionProvider);
if (waypoints.isEmpty) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('No waypoints to fit')));
return;
}
fitMapToWaypoints(ref, waypoints);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
NavIconButton(
icon: Icons.my_location,
onTap: () => _onDronePressed(context, ref),
),
const SizedBox(width: 8),
NavIconButton(
icon: Icons.crop_free,
onTap: () => _onFitPressed(context, ref),
),
],
);
}
}
+3 -25
View File
@@ -7,6 +7,7 @@ import '../providers/geocoding_provider.dart';
import '../providers/map_controller_provider.dart';
import '../providers/mission_meta_provider.dart';
import '../providers/wind_provider.dart';
import 'nav_icon_button.dart';
/// Ortssuche (Nominatim) + Home-/Fit-Buttons, eingebettet als Mittelteil
/// der Plan/Fly-Kopfleiste (HTML-Demonstrator: #searchWrap/#homeBtn/
@@ -123,33 +124,10 @@ class _MapSearchControlsState extends ConsumerState<MapSearchControls> {
),
),
const SizedBox(width: 8),
_NavIconButton(icon: Icons.home, onTap: _onHomePressed),
NavIconButton(icon: Icons.home, onTap: _onHomePressed),
const SizedBox(width: 8),
_NavIconButton(icon: Icons.crop_free, onTap: _onFitPressed),
NavIconButton(icon: Icons.crop_free, onTap: _onFitPressed),
],
);
}
}
class _NavIconButton extends StatelessWidget {
const _NavIconButton({required this.icon, required this.onTap});
final IconData icon;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: 34,
height: 34,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black.withValues(alpha: 0.55),
),
child: Icon(icon, color: Colors.white, size: 16),
),
);
}
}
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
import '../../domain/mission/mission_warnings.dart';
import '../../domain/waypoint/flat_waypoint_list.dart';
import 'bottom_stats_bar.dart';
import 'mini_altitude_profile.dart';
/// Gemeinsamer Fusszeilen-Aufbau (Warnungsbanner + Hoehenprofil +
/// BottomStatsBar), geteilt zwischen Plan- und Fly-Modus (Doku 3.9/3.10) -
/// beide zeigen dieselbe Missionsuebersicht, nur Reticle/Draeder gibt es
/// ausschliesslich im Plan-Modus.
class MissionFooterBar extends StatelessWidget {
const MissionFooterBar({
super.key,
required this.waypoints,
required this.legClimbBad,
required this.vertexBad,
required this.activeIndex,
required this.totalDistanceM,
required this.totalDurationSec,
required this.warnings,
required this.onDetailsTap,
required this.onWarningsTap,
});
final List<Waypoint> waypoints;
final List<bool> legClimbBad;
final List<bool> vertexBad;
final int activeIndex;
final double totalDistanceM;
final double totalDurationSec;
final List<MissionWarning> warnings;
final VoidCallback onDetailsTap;
final VoidCallback onWarningsTap;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (warnings.isNotEmpty)
Container(
width: double.infinity,
color: const Color(0xFF7C2D12),
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
child: Text(
warnings.map((w) => w.text).join(' · '),
textAlign: TextAlign.center,
style: const TextStyle(color: Color(0xFFFDE3D0), fontSize: 12),
),
),
Container(
width: double.infinity,
color: const Color(0xFF0F0F0F).withValues(alpha: 0.72),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(8, 6, 8, 0),
child: MiniAltitudeProfile(
waypoints: waypoints,
legClimbBad: legClimbBad,
vertexBad: vertexBad,
activeIndex: activeIndex,
),
),
BottomStatsBar(
waypointCount: waypoints.length,
totalDistanceM: totalDistanceM,
totalDurationSec: totalDurationSec,
onTap: onDetailsTap,
warnings: warnings,
onWarningsTap: onWarningsTap,
),
],
),
),
],
);
}
}
+9 -1
View File
@@ -15,6 +15,7 @@ class MissionMap extends StatelessWidget {
this.windMarkers = const [],
this.routeSegments = const [],
this.rubberBandLine,
this.droneMarker,
this.onMapReady,
});
@@ -28,6 +29,10 @@ class MissionMap extends StatelessWidget {
/// geladen wurde (HTML-Demonstrator: showPerWaypointWind).
final List<Marker> windMarkers;
/// Live-Position der Drohne im Fly-Modus (Doku 3.10), null solange noch
/// keine Telemetrie eingetroffen ist.
final Marker? droneMarker;
/// Geraden + Kreisbogen-Segmente des Flugpfads (Doku 3.7/4.6); rot
/// markierte Segmente ueberschreiten Steig-/Sinkrate oder Kurvenradius.
final List<RouteSegment> routeSegments;
@@ -85,7 +90,10 @@ class MissionMap extends StatelessWidget {
],
),
CircleLayer(circles: waypointMarkers),
MarkerLayer(markers: windMarkers),
MarkerLayer(markers: [
...windMarkers,
?droneMarker,
]),
const _CompactAttribution(),
],
);
+27
View File
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
/// Runder Icon-Button ueber dunklem Kartenhintergrund, geteilt zwischen den
/// Plan- (MapSearchControls: Home/Fit) und Fly-Modus-Kartensteuerungen
/// (FlyMapControls: Drohne/Fit).
class NavIconButton extends StatelessWidget {
const NavIconButton({super.key, required this.icon, required this.onTap});
final IconData icon;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: 34,
height: 34,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black.withValues(alpha: 0.55),
),
child: Icon(icon, color: Colors.white, size: 16),
),
);
}
}
+8 -3
View File
@@ -8,6 +8,7 @@ import '../../app_mode/app_mode_cubit.dart';
import '../dmc_colors.dart';
import '../providers/flight_mode_provider.dart';
import 'flight_mode_pill.dart';
import 'fly_map_controls.dart';
import 'header_wind_pill.dart';
import 'map_search_controls.dart';
@@ -23,9 +24,11 @@ import 'map_search_controls.dart';
/// statt als PlanScreen-privates Feld, siehe dort.
///
/// Im Fly-Modus traegt sie stattdessen die Wind-Pille (Doku 7.2: "Wind-
/// Anzeige nach Hoehe interpoliert") und die Flugmodus-Auswahl (Doku 3.11,
/// HTML-Demonstrator: #flightModePill) - Ortssuche/Home/Fit sind dort
/// nicht relevant, da im Fly-Modus keine Missionsbearbeitung stattfindet.
/// Anzeige nach Hoehe interpoliert), die Flugmodus-Auswahl (Doku 3.11,
/// HTML-Demonstrator: #flightModePill) sowie Fit-/Drohnen-Zoom-Buttons
/// (FlyMapControls) - Ortssuche/Home entfallen dort, da im Fly-Modus keine
/// Missionsbearbeitung stattfindet und "Home" (erster Wegpunkt) waehrend
/// des Flugs kein sinnvoller Bezugspunkt mehr ist.
class TopModeBar extends ConsumerWidget {
const TopModeBar({super.key});
@@ -81,6 +84,8 @@ class TopModeBar extends ConsumerWidget {
const SizedBox(width: 8),
const Expanded(child: FlightModePill()),
const SizedBox(width: 8),
const FlyMapControls(),
const SizedBox(width: 8),
] else ...[
const SizedBox(width: 8),
const HeaderWindPill(),