Add mission/drone profile management with autosave and persistence
Vervollstaendigt Doku 3.5/3.6/7.1/7.3/7.5: ein Vollbild-Verwaltungsmenue fuer Missionen und Drohnenprofile (per Tabs umschaltbar, wie im HTML- Demonstrator #missionsPanel gemeinsam mit der Profilliste), Autosave der aktuell bearbeiteten Mission, Drift-Persistenz statt der bisherigen In-Memory-only currentMissionProvider, sowie Anzeige/Zugang ueber neue Chips in der Fusszeile (HTML-Demonstrator: #missionNameBtn/#droneNameBtn). Datenbank (services/database/): Missions-Tabelle um updatedAt ergaenzt, neue DroneProfiles- und AppSettingsTable-Tabellen (schemaVersion 2 mit onUpgrade-Migration). Drei Repositories kapseln Drift-Zugriff + JSON-(De-)Serialisierung der Wegpunktliste: MissionRepository, DroneProfileRepository, AppSettingsRepository - je mit Unit-Tests gegen eine In-Memory-Datenbank (NativeDatabase.memory()). Provider: CurrentMissionMetaNotifier haelt Name/id der aktuellen Mission und autosaved sie 800ms-debounced (identisch zum HTML-Demonstrator: scheduleAutosave()/flushPendingAutosave()) - inklusive Wiederherstellung des zuletzt bearbeiteten Autosave-Drafts beim App-Start (Doku 7.5). ActiveDroneProfileNotifier haelt das aktive Profil, seedet beim ersten Start automatisch T1 Ranger und merkt sich die Auswahl ueber AppSettingsTable neustart-fest. UI: MissionsDronesPanel (Missions-Tab: Liste mit Umbenennen/Loeschen/ Laden; Drones-Tab: Liste mit Bearbeiten/Loeschen/Auswaehlen, faellt beim Loeschen des aktiven Profils auf das naechste zurueck). DroneProfileEditor als Formular (bewusste Vereinfachung gegenueber den Swipe-Gesten-Chips des HTML-Demonstrators - bei elf Feldern ist ein normales Formular auf einem Mobilgeraet zugaenglicher). Rename per AlertDialog+TextField statt Browser-prompt(). Aktives Drohnenprofil ist jetzt tatsaechlich wirksam statt nur eine feste Anzeige: Speed-/Alt-Drehrad-Grenzen, Fangradius neuer Wegpunkte und die Flugpfad-Machbarkeitspruefung (Kurvenradius, Steig-/Sinkrate) in PlanScreen und WaypointListPanel lesen jetzt activeDroneProfileProvider statt der bisherigen statischen DefaultDroneProfile-Konstanten (die als T1-Ranger-Seed-Werte weiterleben). Beim Verifizieren zwei echte Bugs in BottomStatsBar gefunden und gefixt: ein Stack+Align-ohne-Factor blaehte sich auf unbegrenzte Groesse auf und verschob die Details-Pille aus ihrer sichtbaren Position (durch zwei gleich grosse Expanded-Bereiche ersetzt); zwei ConstrainedBox-Chips nebeneinander verursachten auf schmaleren Breiten einen RenderFlex- Overflow (durch Flexible ersetzt). Widget-Tests: AppShell/PlanScreen initialisieren beim Start jetzt die echte Datenbank - alle Tests, die AppShell pumpen, ueberschreiben appDatabaseProvider testweise mit einer In-Memory-Instanz. Ausserdem mussten mehrere Tests den neuen 800ms-Autosave-Timer abwarten (wie zuvor schon beim WaypointChip-Flash-Timer etabliert), damit nach Testende kein Timer mehr aussteht. Verifiziert: flutter analyze (0 issues), flutter test (59/59, davon 14 neue Repository-Tests), manuell auf Pixel_10a-Emulator - Wegpunkte werden automatisch als "New mission" gespeichert und erscheinen in der Liste, Umbenennen/Laden/Loeschen funktionieren, neues Drohnenprofil mit abweichender Max-Speed wird angelegt+aktiviert+in der Fusszeile angezeigt, Loeschen des aktiven Profils faellt auf das verbleibende zurueck. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
3dd9c38fb1
commit
aaec7f0f72
@@ -1,11 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../providers/active_drone_profile_provider.dart';
|
||||
import '../providers/mission_meta_provider.dart';
|
||||
import 'missions_drones_panel.dart';
|
||||
|
||||
/// Statuszeile am unteren Bildschirmrand (HTML-Demonstrator: #bottomBar/
|
||||
/// #statsRow). Antippen oeffnet die Wegpunktliste. Mission-/Drohnen-Name
|
||||
/// und der Send-Button sind bewusst nicht Teil dieses Schritts - die
|
||||
/// dafuer noetige Missionsverwaltung bzw. Upload-Anbindung existiert noch
|
||||
/// nicht.
|
||||
class BottomStatsBar extends StatelessWidget {
|
||||
/// #statsRow). Details-Pille (mittig) oeffnet die Wegpunktliste; die
|
||||
/// Mission-/Drohnen-Chips (links) oeffnen das Verwaltungsmenue mit dem
|
||||
/// passenden Starttab (HTML-Demonstrator: #missionNameBtn/#droneNameBtn).
|
||||
/// Der Send-Button ist bewusst nicht Teil dieses Schritts - die dafuer
|
||||
/// noetige Upload-Anbindung existiert noch nicht.
|
||||
class BottomStatsBar extends ConsumerWidget {
|
||||
const BottomStatsBar({
|
||||
super.key,
|
||||
required this.waypointCount,
|
||||
@@ -20,50 +26,97 @@ class BottomStatsBar extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final missionName = ref.watch(currentMissionMetaProvider).name;
|
||||
final droneName = ref.watch(activeDroneProfileProvider).name;
|
||||
|
||||
// Row statt Stack: ein Align/Center ohne width-/heightFactor nimmt sich
|
||||
// immer den gesamten verfuegbaren Platz seines Elternwidgets (auch wenn
|
||||
// sein Kind viel kleiner ist) - in einem Stack ohne begrenzende
|
||||
// Positioned-Kinder blaeht das dessen eigene Groesse unkontrolliert auf
|
||||
// und verschiebt die Details-Pille aus ihrer sichtbaren Position.
|
||||
// Zwei gleich grosse Expanded-Bereiche links/rechts der Pille halten sie
|
||||
// dagegen zuverlaessig zentriert.
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 9),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Details:',
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: _NameChip(
|
||||
label: 'Mission: $missionName',
|
||||
color: Colors.white.withValues(alpha: 0.12),
|
||||
textColor: Colors.white,
|
||||
onTap: () => Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => const MissionsDronesPanel.missions(),
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Icon(Icons.flag, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text('$waypointCount WP',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.straighten, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text('${totalDistanceM.round()} m',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.access_time, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text(_fmtDuration(totalDurationSec),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
],
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: _NameChip(
|
||||
label: 'Drone: $droneName',
|
||||
color: const Color(0xFF4D9DFF).withValues(alpha: 0.18),
|
||||
textColor: const Color(0xFFCFE2FF),
|
||||
onTap: () => Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => const MissionsDronesPanel.drones(),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_detailsPill(),
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _detailsPill() {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 9),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Details:',
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Icon(Icons.flag, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text('$waypointCount WP',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.straighten, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text('${totalDistanceM.round()} m',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.access_time, size: 14, color: Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
Text(_fmtDuration(totalDurationSec),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -76,3 +129,44 @@ class BottomStatsBar extends StatelessWidget {
|
||||
return '$minutes:${secs.toString().padLeft(2, '0')}';
|
||||
}
|
||||
}
|
||||
|
||||
class _NameChip extends StatelessWidget {
|
||||
const _NameChip({
|
||||
required this.label,
|
||||
required this.color,
|
||||
required this.textColor,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Color color;
|
||||
final Color textColor;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 130),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user