From bac42bc65344ed131975df61d2d959c4fc7552cc Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Wed, 21 Oct 2026 14:14:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(player):=20=E9=94=AE=E7=9B=98=E6=94=B6?= =?UTF-8?q?=E8=B5=B7=E5=90=8E=E4=BF=9D=E6=8C=81=E8=AF=84=E8=AE=BA=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=BC=B9=E7=AA=97=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../player/widgets/comment_composer_sheet.dart | 6 ++++-- test/comment/drama_comments_sheet_test.dart | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/pages/player/widgets/comment_composer_sheet.dart b/lib/pages/player/widgets/comment_composer_sheet.dart index 104cf5c..420891e 100644 --- a/lib/pages/player/widgets/comment_composer_sheet.dart +++ b/lib/pages/player/widgets/comment_composer_sheet.dart @@ -39,6 +39,7 @@ class _CommentComposerSheetState extends State { final _input = TextEditingController(); final _inputFocus = FocusNode(); final _keyboardInset = KeyboardInsetNotifier.instance; + double _pinnedKeyboardInset = 0; bool _closing = false; @override @@ -114,7 +115,8 @@ class _CommentComposerSheetState extends State { @override Widget build(BuildContext context) { - final keyboardHeight = _keyboardHeight(context); + final currentKeyboardInset = _keyboardHeight(context); + _pinnedKeyboardInset = math.max(_pinnedKeyboardInset, currentKeyboardInset); final l10n = AppLocalizations.of(context)!; final signedIn = context.watch().isSignedIn; final hasContent = _input.text.trim().isNotEmpty; @@ -139,7 +141,7 @@ class _CommentComposerSheetState extends State { child: AnimatedPadding( duration: const Duration(milliseconds: 200), curve: Curves.easeOut, - padding: EdgeInsets.only(bottom: keyboardHeight), + padding: EdgeInsets.only(bottom: _pinnedKeyboardInset), child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () {}, diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart index b6a715a..758888e 100644 --- a/test/comment/drama_comments_sheet_test.dart +++ b/test/comment/drama_comments_sheet_test.dart @@ -377,8 +377,9 @@ void main() { tester.view.viewInsets = const FakeViewPadding(bottom: 180); await tester.pump(); await tester.pump(const Duration(milliseconds: 200)); + final keyboardUpBottom = tester.getBottomLeft(composer).dy; expect(tester.getSize(composer).height, closeTo(compactHeight, 0.1)); - expect(tester.getBottomLeft(composer).dy, closeTo(844 - 180, 0.1)); + expect(keyboardUpBottom, closeTo(844 - 180, 0.1)); expect( tester.getBottomLeft(composerInput).dy, lessThanOrEqualTo(844 - 180), @@ -388,12 +389,21 @@ void main() { tester.view.viewInsets = const FakeViewPadding(); await tester.pumpAndSettle(); expect(composer, findsOneWidget); - expect(tester.getBottomLeft(composer).dy, closeTo(844, 0.1)); + expect(tester.getBottomLeft(composer).dy, closeTo(keyboardUpBottom, 0.1)); expect(commentsSheet, findsOneWidget); expect(list, findsOneWidget); expect(placeholder, findsOneWidget); expect(tester.getRect(commentsSheet), sheetRect); expect(tester.getSize(commentsSheet).height, closeTo(sheetHeight, 0.1)); + + await tester.tapAt(const Offset(20, 20)); + await tester.pumpAndSettle(); + expect(composer, findsNothing); + + await tester.tap(placeholder); + await tester.pumpAndSettle(); + expect(composer, findsOneWidget); + expect(tester.getBottomLeft(composer).dy, closeTo(844, 0.1)); }); testWidgets('should_keep_composer_open_after_input_loses_focus', (