From af4d9189382d67c63da903f8e2cb88802b7e2913 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Thu, 22 Oct 2026 20:46:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(recommend):=20=E5=AF=B9=E9=BD=90=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E7=9F=AD=E5=89=A7=E7=AD=9B=E9=80=89=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/plans/PROGRESS.md | 1 + lib/core/theme/app_dimens.dart | 6 +- .../widgets/all_dramas_filter_grid.dart | 3 + test/recommend/recommend_sections_test.dart | 55 +++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/docs/plans/PROGRESS.md b/docs/plans/PROGRESS.md index f109384..0fd1f8e 100644 --- a/docs/plans/PROGRESS.md +++ b/docs/plans/PROGRESS.md @@ -1213,3 +1213,4 @@ $ flutter test - 最热/最新改为纯文字选中态,三横线筛选固定在右端;网格改为左右 12、列距 6、行距 12。 - 第三行筛选完整展示,卡片继续复用首页组件;`flutter analyze`:No issues found。 - 筛选项字号提升到 15、圆角 15;筛选区移出滚动容器并固定吸顶,下拉刷新仅作用于网格。 +- 四行首项文字统一到同一 x;行高 30、行距 6、项目距 12,第 4 行保持弹性空白后固定筛选图标。 diff --git a/lib/core/theme/app_dimens.dart b/lib/core/theme/app_dimens.dart index f767148..cf402ff 100644 --- a/lib/core/theme/app_dimens.dart +++ b/lib/core/theme/app_dimens.dart @@ -138,11 +138,11 @@ abstract final class AppDimens { /// 全部短剧筛选与追剧双列。 static const double filterChipFont = 15; - static const double filterChipHeight = 28; + static const double filterChipHeight = 30; static const double filterChipRadius = 15; static const double filterChipHorizontalPadding = 12; - static const double filterRowGap = 8; - static const double filterItemGap = 24; + static const double filterRowGap = 6; + static const double filterItemGap = 12; static const double allDramasHorizontal = 12; static const double allDramasGridGap = 6; static const double allDramasGridRowGap = 12; diff --git a/lib/pages/recommend/widgets/all_dramas_filter_grid.dart b/lib/pages/recommend/widgets/all_dramas_filter_grid.dart index e1317f6..1aa04d6 100644 --- a/lib/pages/recommend/widgets/all_dramas_filter_grid.dart +++ b/lib/pages/recommend/widgets/all_dramas_filter_grid.dart @@ -193,6 +193,7 @@ class _AllDramasFilterGridState extends State { scrollDirection: Axis.horizontal, child: Row( mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ for (var index = 0; index < options.length; index++) ...[ _chip( @@ -268,6 +269,8 @@ class _AllDramasFilterGridState extends State { key: const Key('all-filter-row-3'), height: AppDimens.filterChipHeight, child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ _sortOption( key: const Key('all-sort-hot'), diff --git a/test/recommend/recommend_sections_test.dart b/test/recommend/recommend_sections_test.dart index 5851add..25775ad 100644 --- a/test/recommend/recommend_sections_test.dart +++ b/test/recommend/recommend_sections_test.dart @@ -256,6 +256,43 @@ void main() { filterStarts, everyElement(closeTo(AppDimens.feedPageHorizontal, 0.1)), ); + final pageRect = tester.getRect(find.byKey(const Key('recommend-page'))); + for (var row = 0; row < 4; row++) { + final rowRect = tester.getRect(find.byKey(Key('all-filter-row-$row'))); + expect(rowRect.left, closeTo(pageRect.left + 14, 0.1)); + expect(rowRect.right, closeTo(pageRect.right - 14, 0.1)); + } + final firstTexts = [ + find.descendant( + of: find.byKey(const Key('all-filter-row-0')), + matching: find.byType(Text), + ), + find.descendant( + of: find.byKey(const Key('all-filter-row-1')), + matching: find.byType(Text), + ), + find.descendant( + of: find.byKey(const Key('all-filter-row-2')), + matching: find.byType(Text), + ), + find.descendant( + of: find.byKey(const Key('all-filter-row-3')), + matching: find.byType(Text), + ), + ]; + final firstTextX = firstTexts + .map((finder) => tester.getTopLeft(finder.first).dx) + .toList(); + expect(firstTextX, everyElement(closeTo(firstTextX.first, 0.1))); + expect( + firstTextX.first, + closeTo( + pageRect.left + + AppDimens.feedPageHorizontal + + AppDimens.filterChipHorizontalPadding, + 0.1, + ), + ); for (var row = 0; row < 3; row++) { expect( tester.getSize(find.byKey(Key('all-filter-row-$row'))).height, @@ -321,6 +358,24 @@ void main() { tester.getTopLeft(rowZeroLocal).dx - tester.getTopRight(rowZeroAll).dx, AppDimens.filterItemGap, ); + final rowOne = find.byKey(const Key('all-filter-row-1')); + final rowTwo = find.byKey(const Key('all-filter-row-2')); + for (final row in [rowOne, rowTwo]) { + final all = find.descendant( + of: row, + matching: find.byKey(const Key('all-filter-all')), + ); + final next = find.descendant( + of: row, + matching: row == rowOne + ? find.byKey(const Key('all-filter-subtitles')) + : find.byKey(const Key('all-filter-reversal')), + ); + expect( + tester.getTopLeft(next).dx - tester.getTopRight(all).dx, + AppDimens.filterItemGap, + ); + } await tester.tap(find.byKey(const Key('all-filter-local'))); await tester.pumpAndSettle(); expect(find.byKey(const Key('all-dramas-empty')), findsOneWidget);