46 lines
1.6 KiB
Dart
46 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
|
|
import '../app_mode/app_mode_cubit.dart';
|
|
import 'screens/fly/fly_screen.dart';
|
|
import 'screens/plan/plan_screen.dart';
|
|
import 'widgets/top_mode_bar.dart';
|
|
|
|
/// Haelt die persistente Kopfleiste (Plan/Fly-Umschalter) und schaltet
|
|
/// darunter zwischen Plan- und Fly-Screen um, gesteuert von der App-Mode
|
|
/// State Machine (Architektur-Doku 2.2). Connect/Upload sind
|
|
/// Uebergangszustaende innerhalb des Plan-Screens (Handover-Prozess).
|
|
class AppShell extends StatelessWidget {
|
|
const AppShell({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final mode = context.select((AppModeCubit c) => c.state.mode);
|
|
final screen = mode == AppMode.fly ? const FlyScreen() : const PlanScreen();
|
|
|
|
return BlocListener<AppModeCubit, AppModeState>(
|
|
listenWhen: (previous, current) => previous.mode != current.mode,
|
|
listener: (context, state) {
|
|
// Nur FLAG_KEEP_SCREEN_ON, kein PowerManager.WakeLock (Doku 4.20
|
|
// deckt den Foreground-Service fuer Hintergrund-Telemetrie separat
|
|
// ab). Android-Empfehlung: an die Activity-Sichtbarkeit gebunden,
|
|
// keine Permission, kein manuelles Leak-Risiko.
|
|
if (state.mode == AppMode.fly) {
|
|
WakelockPlus.enable();
|
|
} else {
|
|
WakelockPlus.disable();
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
Positioned.fill(child: screen),
|
|
const Align(alignment: Alignment.topCenter, child: TopModeBar()),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|