fix(player): 键盘收起后保持评论输入弹窗位置

This commit is contained in:
Zhou Weidong committed 2026-10-21 14:14:58 +08:00
1 parent bc971c17d5
commit bac42bc653
2 files changed
+16 -4

No files matched your search

@@ -39,6 +39,7 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
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<CommentComposerSheet> {
@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<AuthController>().isSignedIn;
final hasContent = _input.text.trim().isNotEmpty;
@@ -139,7 +141,7 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
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: () {},
+12 -2
View File
@@ -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', (