import 'package:flutter/material.dart'; import '../../domain/mission/mission_warnings.dart'; /// Vollbild-Warnungsliste (Doku 3.10, HTML-Demonstrator: #warningsPanel) - /// jede Zeile verweist per [onWarningTap] auf den Screen, der die Ursache /// beheben kann (Altitude-/Speed-Tab der Wegpunktliste, oder die Karte). class WarningsPanel extends StatelessWidget { const WarningsPanel({ super.key, required this.warnings, required this.onClose, required this.onWarningTap, }); final List warnings; final VoidCallback onClose; final void Function(MissionWarning warning) onWarningTap; @override Widget build(BuildContext context) { return Material( color: const Color(0xEB080808), child: SafeArea( child: Column( children: [ Padding( padding: const EdgeInsets.fromLTRB(16, 12, 8, 12), child: Row( children: [ const Expanded( child: Text( 'Warnings', style: TextStyle( color: Colors.white, fontSize: 20, fontWeight: FontWeight.w700, ), ), ), IconButton( onPressed: onClose, icon: const Icon(Icons.close, color: Colors.white), ), ], ), ), const Divider(color: Colors.white24, height: 1), Expanded( child: warnings.isEmpty ? const Center( child: Text( 'No active warnings', style: TextStyle(color: Colors.white60, fontSize: 15), ), ) : ListView.builder( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), itemCount: warnings.length, itemBuilder: (context, index) => _row(warnings[index]), ), ), ], ), ), ); } Widget _row(MissionWarning warning) { return GestureDetector( onTap: () => onWarningTap(warning), child: Container( margin: const EdgeInsets.symmetric(vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12), decoration: BoxDecoration( color: Colors.white.withValues(alpha: 0.04), borderRadius: BorderRadius.circular(10), ), child: Row( children: [ Expanded( flex: 3, child: Text(warning.text, style: const TextStyle(color: Colors.white)), ), Text( _actionLabel(warning.action), style: const TextStyle( color: Color(0xFF4D9DFF), fontWeight: FontWeight.w600, decoration: TextDecoration.underline, ), ), ], ), ), ); } String _actionLabel(WarningAction action) => switch (action) { WarningAction.altitude => 'Open altitude view', WarningAction.speed => 'Open speed view', WarningAction.map => 'Show on map', }; }