diff --git a/lib/focus/input_mode_tracker.dart b/lib/focus/input_mode_tracker.dart index fe57c942..8bb4cc9e 100644 --- a/lib/focus/input_mode_tracker.dart +++ b/lib/focus/input_mode_tracker.dart @@ -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 createState() => _InputModeTrackerState(); } diff --git a/lib/screens/media_detail_screen.dart b/lib/screens/media_detail_screen.dart index 11f83a07..294f6c0d 100644 --- a/lib/screens/media_detail_screen.dart +++ b/lib/screens/media_detail_screen.dart @@ -2999,7 +2999,7 @@ class _MediaDetailScreenState extends State 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 _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 ], ); - 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.