Portiert das Wind-System des HTML-Demonstrators (Doku 3.8) vollstaendig: Open-Meteo-Winddaten, interpoliert zwischen Druckflaechen- und festen Nabenhoehen-Stuetzpunkten auf die tatsaechliche Zielhoehe. Domain (lib/domain/wind/wind_math.dart, reines Dart): Hoehen- Interpolation (linear + zirkulaer fuer Windrichtung), Peilung zwischen zwei Punkten, Kopf-/Rueckenwind-Komponente pro Flugleg - 1:1 uebernommen aus interpolateWindAtHeight()/bearingBetween()/headTailwindComponent() des Demonstrators, per Unit-Tests abgesichert. Service (lib/services/wind/wind_service.dart): zwei getrennte, fokussierte Open-Meteo-Requests statt eines kombinierten (Doku 4.10 - ein 35-Variablen-Request verursachte im Demonstrator Modellauswahl- Fehler). Drei Verbraucher: Kopfleisten-Pille (120 m AGL ueber Referenzort), gebuendelter Wegpunkt-Fetch (ein Request fuer alle Koordinaten via Open-Meteos Mehrfach-Location-Syntax) und das Validierungspanel (rohe Messwerte je Nabenhoehe/Druckflaeche). Per MockClient getestet (kein echter Netzwerkzugriff in Tests). UI: - HeaderWindPill (TopModeBar, nur ausserhalb Fly-Modus): zeigt Windrichtung/-geschwindigkeit, Antippen schaltet perspektivisch die Wind-Marker der Wegpunkte um (Zustand vorbereitet, HTML-Demonstrator: showPerWaypointWind). - WaypointListPanel: "Fetch wind"/"Validate"-Buttons im Panel-Header, neue WIND-Spalte in der Liste. - WindValidatePanel: neue Vollbild-Route (gleiches Muster wie WaypointListPanel) mit Rohdaten je Hoehenstufe inkl. Boeen (Doku 4.9: Boeen nur hier, nicht in der Wegpunktanzeige) und Interpolationsergebnis. - FullValueChart (Speed-Tab): Kopf-/Rueckenwind-Diamanten pro Leg samt gestrichelter Nulllinie sowie gestrichelte Bodengeschwindigkeits- Stufenlinie. Bug gefunden und gefixt waehrend der Emulator-Verifikation: die Y-Achsen-Autoskalierung klemmte weiterhin auf den gueltigen Drehrad- Wertebereich (13-25 m/s), wodurch nahe Null liegende Windkomponenten (bei schwachem Wind der Normalfall) ausserhalb des sichtbaren Bereichs lagen und weder Diamanten noch Nulllinie zu sehen waren. Der HTML- Demonstrator klemmt computeSpeedChartRange() bewusst nicht auf SPD_MIN/ SPD_MAX; das Klemmen in FullValueChart._range() jetzt entsprechend entfernt. Waypoint-Modell um windSpeedMs/windDirFromDeg/windElevationM erweitert (nullable, reine Planungshilfe - der Encoder liest diese Felder nie, Doku 3.2). currentMissionProvider bekommt replaceAll() fuer den gebuendelten Wind-Fetch, der alle Wegpunkte gleichzeitig aktualisiert. Verifiziert: flutter analyze (0 issues), flutter test (44/44, davon 14 neue Wind-Mathematik- und 6 neue WindService-Tests), manuell auf Pixel_10a-Emulator mit echtem Open-Meteo-Netzwerkzugriff - Kopfleisten- Pille zeigt Live-Wind, Fetch/Validate fuellen Liste bzw. oeffnen das Validierungspanel mit echten Messwerten, Speed-Plot zeigt nach dem Fix Diamanten/Nulllinie/Bodengeschwindigkeit korrekt skaliert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
133 lines
4.2 KiB
Dart
133 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '../../app_mode/app_mode_cubit.dart';
|
|
import '../dmc_colors.dart';
|
|
import 'header_wind_pill.dart';
|
|
import 'map_search_controls.dart';
|
|
|
|
/// Persistente Kopfleiste zum Umschalten zwischen Plan- und Fly-Modus
|
|
/// (HTML-Demonstrator: #topBarWrap/#editModeBtn/#flyModeBtn). Die Leiste
|
|
/// faerbt sich in der Farbe des aktiven Modus; der jeweils andere Modus wird
|
|
/// als solider Button am Rand angeboten, um in ihn zu wechseln.
|
|
///
|
|
/// Traegt ausserhalb des Fly-Modus zusaetzlich die Wind-Pille, Ortssuche und
|
|
/// die Home-/Fit-Buttons in derselben Pille (HTML-Demonstrator: #headerWindPill/
|
|
/// #searchWrap/#homeBtn/#fitBtn sitzen alle in #topBarMiddle, nicht in einer
|
|
/// separaten Leiste) - dafuer lebt der MapController im mapControllerProvider
|
|
/// statt als PlanScreen-privates Feld, siehe dort.
|
|
class TopModeBar extends StatelessWidget {
|
|
const TopModeBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isFly = context.select((AppModeCubit c) => c.state.mode == AppMode.fly);
|
|
final activeTint = isFly ? DmcColors.flyModeRed : DmcColors.editModeGreen;
|
|
|
|
return SafeArea(
|
|
bottom: false,
|
|
child: FractionallySizedBox(
|
|
widthFactor: isFly ? 0.64 : 0.86,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
decoration: BoxDecoration(
|
|
color: activeTint.withValues(alpha: 0.55),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(26),
|
|
bottomRight: Radius.circular(26),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
_ModeButton(
|
|
label: 'Plan',
|
|
isActive: !isFly,
|
|
inactiveColor: DmcColors.editModeGreen,
|
|
cornerRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(26),
|
|
),
|
|
onTap: () => context.read<AppModeCubit>().toPlan(),
|
|
),
|
|
if (isFly)
|
|
const Spacer()
|
|
else ...[
|
|
const SizedBox(width: 8),
|
|
const HeaderWindPill(),
|
|
const SizedBox(width: 8),
|
|
const Expanded(child: MapSearchControls()),
|
|
const SizedBox(width: 12),
|
|
],
|
|
_ModeButton(
|
|
label: 'Fly',
|
|
isActive: isFly,
|
|
inactiveColor: DmcColors.flyModeRed,
|
|
cornerRadius: const BorderRadius.only(
|
|
bottomRight: Radius.circular(26),
|
|
),
|
|
onTap: () => _tryEnterFly(context),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _tryEnterFly(BuildContext context) {
|
|
try {
|
|
context.read<AppModeCubit>().toFly();
|
|
} on StateError {
|
|
// Ready-to-Fly-Gate (Doku 2.2/4.5) nicht erfuellt - Upload/Verify-Flow
|
|
// ist noch nicht verdrahtet, daher aktuell immer dieser Fall.
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text(
|
|
'Mission muss zuerst hochgeladen und verifiziert werden.',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
class _ModeButton extends StatelessWidget {
|
|
const _ModeButton({
|
|
required this.label,
|
|
required this.isActive,
|
|
required this.inactiveColor,
|
|
required this.cornerRadius,
|
|
required this.onTap,
|
|
});
|
|
|
|
final String label;
|
|
final bool isActive;
|
|
final Color inactiveColor;
|
|
final BorderRadius cornerRadius;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: isActive ? null : onTap,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 24,
|
|
vertical: isActive ? 6 : 11,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: isActive ? null : inactiveColor.withValues(alpha: 0.85),
|
|
borderRadius: isActive ? null : cornerRadius,
|
|
),
|
|
child: Text(
|
|
label,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w800,
|
|
color: Color(0xFF141414),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|