fix(recommend): 固定全部短剧筛选区并统一间距

This commit is contained in:
Zhou Weidong committed 2026-10-22 20:43:15 +08:00
1 parent 099d05064e
commit e147002e00
4 files changed
+89 -9

No files matched your search

+1
View File
@@ -1212,3 +1212,4 @@ $ flutter test
- 四行筛选统一 28 高、8 行距、24 项目间距;选中 chip 改为 `#4A1E1E`、白字 13/w600、圆角 14。 - 四行筛选统一 28 高、8 行距、24 项目间距;选中 chip 改为 `#4A1E1E`、白字 13/w600、圆角 14。
- 最热/最新改为纯文字选中态,三横线筛选固定在右端;网格改为左右 12、列距 6、行距 12。 - 最热/最新改为纯文字选中态,三横线筛选固定在右端;网格改为左右 12、列距 6、行距 12。
- 第三行筛选完整展示,卡片继续复用首页组件;`flutter analyze`:No issues found。 - 第三行筛选完整展示,卡片继续复用首页组件;`flutter analyze`:No issues found。
- 筛选项字号提升到 15、圆角 15;筛选区移出滚动容器并固定吸顶,下拉刷新仅作用于网格。
+2 -2
View File
@@ -137,9 +137,9 @@ abstract final class AppDimens {
static const double recommendCardWidth = 122; static const double recommendCardWidth = 122;
/// 全部短剧筛选与追剧双列。 /// 全部短剧筛选与追剧双列。
static const double filterChipFont = 13; static const double filterChipFont = 15;
static const double filterChipHeight = 28; static const double filterChipHeight = 28;
static const double filterChipRadius = 14; static const double filterChipRadius = 15;
static const double filterChipHorizontalPadding = 12; static const double filterChipHorizontalPadding = 12;
static const double filterRowGap = 8; static const double filterRowGap = 8;
static const double filterItemGap = 24; static const double filterItemGap = 24;
@@ -55,7 +55,12 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
final itemExtent = final itemExtent =
itemWidth / AppDimens.cardCoverAspectRatio + itemWidth / AppDimens.cardCoverAspectRatio +
AppDimens.homeCardBodyExtent; AppDimens.homeCardBodyExtent;
return NotificationListener<ScrollNotification>( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_filters(l10n),
Expanded(
child: NotificationListener<ScrollNotification>(
onNotification: _onScroll, onNotification: _onScroll,
child: AppPullToRefresh( child: AppPullToRefresh(
key: const Key('all-dramas-refresh'), key: const Key('all-dramas-refresh'),
@@ -66,7 +71,6 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
key: const Key('all-dramas-scroll'), key: const Key('all-dramas-scroll'),
physics: AppPullToRefresh.physics, physics: AppPullToRefresh.physics,
slivers: [ slivers: [
SliverToBoxAdapter(child: _filters(l10n)),
if (dramas.isEmpty) if (dramas.isEmpty)
SliverFillRemaining( SliverFillRemaining(
hasScrollBody: false, hasScrollBody: false,
@@ -89,10 +93,12 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
), ),
sliver: SliverGrid( sliver: SliverGrid(
key: const Key('all-dramas-grid'), key: const Key('all-dramas-grid'),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, crossAxisCount: 3,
crossAxisSpacing: AppDimens.allDramasGridGap, crossAxisSpacing: AppDimens.allDramasGridGap,
mainAxisSpacing: AppDimens.allDramasGridRowGap, mainAxisSpacing:
AppDimens.allDramasGridRowGap,
mainAxisExtent: itemExtent, mainAxisExtent: itemExtent,
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
@@ -106,12 +112,15 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: AppDimens.spaceXl), padding: const EdgeInsets.only(
bottom: AppDimens.spaceXl,
),
child: PagedListFooter( child: PagedListFooter(
loading: widget.feedController.loadingMore, loading: widget.feedController.loadingMore,
hasMore: widget.feedController.hasMore, hasMore: widget.feedController.hasMore,
hasItems: dramas.isNotEmpty, hasItems: dramas.isNotEmpty,
errorMessage: widget.feedController.lastError == null errorMessage:
widget.feedController.lastError == null
? null ? null
: l10n.catalogError, : l10n.catalogError,
onRetry: widget.feedController.loadMore, onRetry: widget.feedController.loadMore,
@@ -121,6 +130,9 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
], ],
), ),
), ),
),
),
],
); );
}, },
); );
@@ -304,7 +316,11 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
onTap: onTap, onTap: onTap,
child: SizedBox( child: SizedBox(
height: AppDimens.filterChipHeight, height: AppDimens.filterChipHeight,
child: Center( child: Container(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.filterChipHorizontalPadding,
),
alignment: Alignment.center,
child: Text( child: Text(
label, label,
style: TextStyle( style: TextStyle(
@@ -248,6 +248,55 @@ void main() {
for (var row = 0; row < 4; row++) { for (var row = 0; row < 4; row++) {
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget); expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
} }
final filterStarts = [
for (var row = 0; row < 4; row++)
tester.getRect(find.byKey(Key('all-filter-row-$row'))).left,
];
expect(
filterStarts,
everyElement(closeTo(AppDimens.feedPageHorizontal, 0.1)),
);
for (var row = 0; row < 3; row++) {
expect(
tester.getSize(find.byKey(Key('all-filter-row-$row'))).height,
AppDimens.filterChipHeight + AppDimens.filterRowGap,
);
}
expect(
tester.getSize(find.byKey(const Key('all-filter-row-3'))).height,
AppDimens.filterChipHeight,
);
expect(
tester.getRect(find.byKey(const Key('all-dramas-scroll'))).top -
tester.getRect(find.byKey(const Key('all-dramas-filters'))).bottom,
closeTo(AppDimens.allDramasFilterToGridGap, 0.1),
);
expect(
find.descendant(
of: find.byKey(const Key('all-dramas-refresh')),
matching: find.byKey(const Key('all-dramas-filters')),
),
findsNothing,
);
expect(
find.descendant(
of: find.byKey(const Key('all-dramas-scroll')),
matching: find.byKey(const Key('all-dramas-grid')),
),
findsOneWidget,
);
final fixedFilterTop = tester
.getRect(find.byKey(const Key('all-dramas-filters')))
.top;
await tester.drag(
find.byKey(const Key('all-dramas-scroll')),
const Offset(0, -120),
);
await tester.pump();
expect(
tester.getRect(find.byKey(const Key('all-dramas-filters'))).top,
closeTo(fixedFilterTop, 0.1),
);
expect(find.byKey(const Key('all-filter-local')), findsOneWidget); expect(find.byKey(const Key('all-filter-local')), findsOneWidget);
expect(find.byKey(const Key('all-filter-subtitles')), findsOneWidget); expect(find.byKey(const Key('all-filter-subtitles')), findsOneWidget);
for (final key in [ for (final key in [
@@ -259,10 +308,24 @@ void main() {
]) { ]) {
expect(find.byKey(Key(key)), findsOneWidget); expect(find.byKey(Key(key)), findsOneWidget);
} }
final rowZero = find.byKey(const Key('all-filter-row-0'));
final rowZeroAll = find.descendant(
of: rowZero,
matching: find.byKey(const Key('all-filter-all')),
);
final rowZeroLocal = find.descendant(
of: rowZero,
matching: find.byKey(const Key('all-filter-local')),
);
expect(
tester.getTopLeft(rowZeroLocal).dx - tester.getTopRight(rowZeroAll).dx,
AppDimens.filterItemGap,
);
await tester.tap(find.byKey(const Key('all-filter-local'))); await tester.tap(find.byKey(const Key('all-filter-local')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byKey(const Key('all-dramas-empty')), findsOneWidget); expect(find.byKey(const Key('all-dramas-empty')), findsOneWidget);
expect(_textStyle(tester, 'Local').fontWeight, FontWeight.w600); expect(_textStyle(tester, 'Local').fontWeight, FontWeight.w600);
expect(_textStyle(tester, 'Local').fontSize, AppDimens.filterChipFont);
expect(_textStyle(tester, 'Local').color, AppColors.textPrimary); expect(_textStyle(tester, 'Local').color, AppColors.textPrimary);
final selectedChip = tester.widget<Container>( final selectedChip = tester.widget<Container>(
find find