fix(player): 修复评论输入聚焦时面板消失

This commit is contained in:
Zhou Weidong committed 2026-10-21 12:40:12 +08:00
1 parent 226ac5920c
commit c7b230263a
4 files changed
+399 -280

No files matched your search

+36 -36
View File
@@ -246,7 +246,7 @@ void main() {
expect(tester.widget<TextField>(input).controller?.text, isEmpty);
expect(tester.widget<TextField>(input).focusNode?.hasFocus, isTrue);
expect(find.byKey(const Key('comment-expanded-composer')), findsOneWidget);
expect(tester.widget<TextField>(input).maxLines, 4);
expect(find.byKey(const Key('comment-list')), findsNothing);
expect(
tester
@@ -275,14 +275,27 @@ void main() {
await _pumpSheet(tester, repository: repository);
expect(find.byKey(const Key('comment-list')), findsOneWidget);
final editableBefore = tester.state<EditableTextState>(
find.descendant(
of: find.byKey(const Key('comment-input')),
matching: find.byType(EditableText),
),
);
await tester.tap(find.byKey(const Key('comment-input')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('comment-list')), findsNothing);
expect(find.byKey(const Key('comment-count-label')), findsNothing);
expect(find.byKey(const Key('comment-composer')), findsNothing);
expect(find.byKey(const Key('comment-expanded-composer')), findsOneWidget);
expect(find.byKey(const Key('comment-composer')), findsOneWidget);
expect(find.byKey(const Key('comment-input-surface')), findsOneWidget);
final editableAfter = tester.state<EditableTextState>(
find.descendant(
of: find.byKey(const Key('comment-input')),
matching: find.byType(EditableText),
),
);
expect(identical(editableBefore, editableAfter), isTrue);
final field = tester.widget<TextField>(
find.byKey(const Key('comment-input')),
);
@@ -313,17 +326,35 @@ void main() {
tester.view.viewInsets = const FakeViewPadding(bottom: 180);
await tester.pump();
await tester.pump(const Duration(milliseconds: 160));
expect(find.byKey(const Key('player-comments-sheet')), findsOneWidget);
expect(find.byKey(const Key('comment-list')), findsNothing);
expect(
tester.getBottomLeft(find.byKey(const Key('player-comments-sheet'))).dy,
closeTo(844 - 180, 0.1),
);
expect(
tester.getBottomLeft(find.byKey(const Key('comment-input'))).dy,
lessThanOrEqualTo(844 - 180),
);
tester.view.viewInsets = const FakeViewPadding();
FocusManager.instance.primaryFocus?.unfocus();
await tester.pumpAndSettle();
expect(find.byKey(const Key('comment-expanded-composer')), findsNothing);
expect(find.byKey(const Key('comment-list')), findsOneWidget);
expect(find.byKey(const Key('comment-composer')), findsOneWidget);
expect(
tester
.widget<TextField>(find.byKey(const Key('comment-input')))
.controller
?.text,
'Nice',
);
expect(
tester
.widget<TextField>(find.byKey(const Key('comment-input')))
.focusNode
?.hasFocus,
isFalse,
);
});
testWidgets('should_use_polished_comment_sizes', (tester) async {
@@ -482,37 +513,6 @@ void main() {
);
});
testWidgets('should_keep_sheet_fixed_and_move_only_composer_for_keyboard', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.view.resetViewInsets);
final repository = FakeCommentRepository(
pages: [CommentPage(comments: _comments(30))],
);
await _pumpSheet(tester, repository: repository);
final sheet = find.byKey(const Key('player-comments-sheet'));
final input = find.byKey(const Key('comment-composer'));
final first = find.byKey(const Key('comment-item-10'));
final sheetTop = tester.getTopLeft(sheet).dy;
final inputTop = tester.getTopLeft(input).dy;
final inputBottom = tester.getBottomLeft(input).dy;
final firstTop = tester.getTopLeft(first).dy;
tester.view.viewInsets = const FakeViewPadding(bottom: 180);
await tester.pump();
await tester.pump(const Duration(milliseconds: 160));
expect(tester.getTopLeft(sheet).dy, closeTo(sheetTop, 0.1));
expect(tester.getTopLeft(first).dy, closeTo(firstTop, 0.1));
expect(tester.getTopLeft(input).dy, lessThan(inputTop - 100));
expect(tester.getBottomLeft(input).dy, closeTo(inputBottom - 180, 0.1));
});
testWidgets('should_hide_comment_like_controls', (tester) async {
final repository = FakeCommentRepository(
pages: [