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', (