refactor(ui): share android keyboard-mode system-back guard
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user