fix(search): 避免键盘顶起搜索页

This commit is contained in:
Zhou Weidong committed 2026-10-23 03:18:24 +08:00
1 parent f8500bbaca
commit ab6800aba2
1 file changed
+7 -3
+7 -3
View File
@@ -35,9 +35,6 @@ class _SearchPageState extends State<SearchPage> {
super.initState(); super.initState();
_logic = DiscoverBinding().create(search: context.read<SearchRepository>()); _logic = DiscoverBinding().create(search: context.read<SearchRepository>());
_logic.addListener(_rebuild); _logic.addListener(_rebuild);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _logic.searchFocus.requestFocus();
});
} }
void _rebuild() { void _rebuild() {
@@ -59,10 +56,15 @@ class _SearchPageState extends State<SearchPage> {
value: SystemUiOverlayStyle.light, value: SystemUiOverlayStyle.light,
child: Theme( child: Theme(
data: AppTheme.dark(), data: AppTheme.dark(),
child: MediaQuery.removeViewInsets(
context: context,
removeBottom: true,
child: Scaffold( child: Scaffold(
key: const Key('search-page'), key: const Key('search-page'),
backgroundColor: AppColors.appBackground, backgroundColor: AppColors.appBackground,
resizeToAvoidBottomInset: false,
body: SafeArea( body: SafeArea(
bottom: false,
child: Column( child: Column(
children: [ children: [
_header(l10n), _header(l10n),
@@ -78,6 +80,7 @@ class _SearchPageState extends State<SearchPage> {
), ),
), ),
), ),
),
); );
} }
@@ -157,6 +160,7 @@ class _SearchPageState extends State<SearchPage> {
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
), ),
scrollPadding: EdgeInsets.zero,
), ),
), ),
if (_logic.searchLoading) if (_logic.searchLoading)