diff --git a/lib/pages/player/widgets/comment_composer_sheet.dart b/lib/pages/player/widgets/comment_composer_sheet.dart index ff2f41e..1b32703 100644 --- a/lib/pages/player/widgets/comment_composer_sheet.dart +++ b/lib/pages/player/widgets/comment_composer_sheet.dart @@ -224,6 +224,7 @@ class _CommentComposerSheetState extends State { ), child: SafeArea( top: false, + bottom: false, child: Padding( padding: EdgeInsets.only(bottom: _pinnedKeyboardInset), child: Padding( diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart index 6ac6907..b65cb5d 100644 --- a/test/comment/drama_comments_sheet_test.dart +++ b/test/comment/drama_comments_sheet_test.dart @@ -469,6 +469,54 @@ void main() { expect(tester.getBottomLeft(composer).dy, closeTo(844, 0.1)); }); + testWidgets( + 'should_keep_composer_input_position_when_safe_area_padding_changes', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + tester.view.padding = const FakeViewPadding(); + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + addTearDown(tester.view.resetViewInsets); + addTearDown(tester.view.resetPadding); + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '10', content: 'A comment')], + ), + ], + ); + + await _pumpSheet(tester, repository: repository); + await tester.tap(find.byKey(const Key('comment-input-placeholder'))); + await tester.pumpAndSettle(); + + final input = find.byKey(const Key('comment-composer-input')); + tester.view.viewInsets = const FakeViewPadding(bottom: 180); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 90)); + final keyboardUpInputRect = tester.getRect(input); + + tester.view.viewInsets = const FakeViewPadding(); + tester.view.padding = const FakeViewPadding(bottom: 48); + await tester.pumpAndSettle(); + + final keyboardClosedInputRect = tester.getRect(input); + expect( + keyboardClosedInputRect.top, + closeTo(keyboardUpInputRect.top, 0.1), + ); + expect( + keyboardClosedInputRect.bottom, + closeTo(keyboardUpInputRect.bottom, 0.1), + ); + expect( + keyboardClosedInputRect.height, + closeTo(keyboardUpInputRect.height, 0.1), + ); + }, + ); + testWidgets( 'should_keep_composer_position_when_keyboard_insets_change_after_settling', (tester) async {