refactor(ui): share android keyboard-mode system-back guard

This commit is contained in:
edde746
2026-06-12 13:48:06 +02:00
parent b2e5e02204
commit 18e47d2327
2 changed files with 12 additions and 3 deletions
+9
View File
@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -40,6 +42,13 @@ class InputModeTracker extends StatefulWidget {
return of(context) == InputMode.keyboard;
}
/// Whether system back must be blocked because the dpad key handler owns
/// back navigation: on Android in keyboard mode (TV/gamepad), letting the
/// system back through as well double-pops the route.
static bool shouldBlockSystemBack(BuildContext context) {
return Platform.isAndroid && isKeyboardMode(context);
}
@override
State<InputModeTracker> createState() => _InputModeTrackerState();
}
+3 -3
View File
@@ -2999,7 +2999,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen>
body: const Center(child: CircularProgressIndicator()),
),
);
final blockSystemBack = Platform.isAndroid && InputModeTracker.isKeyboardMode(context);
final blockSystemBack = InputModeTracker.shouldBlockSystemBack(context);
if (!blockSystemBack) {
return loading;
}
@@ -3021,7 +3021,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen>
_scheduleInitialMobileDetailFocus(metadata);
final blockSystemBack = Platform.isAndroid && InputModeTracker.isKeyboardMode(context);
final blockSystemBack = InputModeTracker.shouldBlockSystemBack(context);
final content = PrimaryScrollController(
controller: _scrollController,
child: IosStatusBarTapScrollToTop(
@@ -3322,7 +3322,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen>
],
);
final blockSystemBack = Platform.isAndroid && InputModeTracker.isKeyboardMode(context);
final blockSystemBack = InputModeTracker.shouldBlockSystemBack(context);
final content = OverlaySheetHost(
// blockSystemBack keeps the route from double-popping on Android keyboard/
// TV (the key handler owns dpad back); the host also closes an open sheet.