fix(home): 修复样式常量与测试类型错误

This commit is contained in:
Zhou Weidong committed 2026-10-22 18:43:02 +08:00
1 parent b3ea85df41
commit ba0ce2f8c0
5 files changed
+30 -24

No files matched your search

+1
View File
@@ -1116,4 +1116,5 @@ $ flutter test
- 标题下方恢复左对齐题材文字,使用 `|` 分隔、灰色小字,与封面状态角标保持独立。
- 首页搜索栏到一级、一级到二级、二级到网格间距为 8/8/10;非精选 tab 直接以 10 衔接网格。
- 播放量贴封面右下角(底 2、右 6),火焰图标 11 + 12/w400 纯文字,间距 4,并保留极淡底部渐变。
- 修复二级 chip 运行时颜色误用 `const TextStyle` 的编译错误,并校正相关测试 Finder 类型。
- 全部短剧的地区、字幕、配音筛选 UI 已占位;以下接口待补:地区、字幕/配音筛选数据。
+1 -1
View File
@@ -366,7 +366,7 @@ class HomeGridHeader extends StatelessWidget {
final selected = selectedTag == tag.id;
final label = Text(
tag.label,
style: const TextStyle(
style: TextStyle(
color: selected ? AppColors.navSelected : AppColors.textTertiary,
fontSize: AppDimens.homeSecondaryTagFont,
fontWeight: FontWeight.w600,
+9 -6
View File
@@ -79,9 +79,11 @@ void main() {
coverClip.borderRadius,
BorderRadius.circular(AppDimens.cardCoverRadius),
);
final title = tester.widget<Text>(
find.descendant(of: card, matching: find.text('The Signal')),
final titleFinder = find.descendant(
of: card,
matching: find.text('The Signal'),
);
final title = tester.widget<Text>(titleFinder);
expect(title.style?.fontSize, AppDimens.cardTitleFont);
expect(title.style?.fontWeight, FontWeight.w500);
expect(title.style?.height, AppDimens.cardTitleLineHeight);
@@ -105,14 +107,15 @@ void main() {
),
findsOneWidget,
);
final tags = tester.widget<Text>(
find.byKey(const Key('following-tags-the-signal-demo')),
final tagsFinder = find.byKey(
const Key('following-tags-the-signal-demo'),
);
final tags = tester.widget<Text>(tagsFinder);
expect(tags.data, 'Suspense | Mystery');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
expect(tester.getTopLeft(title).dx, tester.getTopLeft(coverFinder).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(titleFinder).dx, tester.getTopLeft(coverFinder).dx);
expect(tester.getTopLeft(tagsFinder).dx, tester.getTopLeft(coverFinder).dx);
await tester.tap(find.byKey(const Key('following-edit')));
await tester.pumpAndSettle();
+8 -11
View File
@@ -80,10 +80,7 @@ void main() {
expect(viewsText.style?.fontSize, AppDimens.cardPlayCountFont);
expect(viewsText.style?.fontWeight, FontWeight.w400);
expect(viewsText.style?.color, AppColors.navSelected);
expect(
find.descendant(of: cover, matching: find.byKey(views)),
findsOneWidget,
);
expect(find.descendant(of: cover, matching: views), findsOneWidget);
expect(
tester.getTopRight(cover).dx - tester.getTopRight(views).dx,
AppDimens.cardPlayCountRight,
@@ -103,21 +100,21 @@ void main() {
),
findsOneWidget,
);
final title = tester.widget<Text>(
find.byKey(const Key('home-feed-title-anime-card')),
final titleFinder = find.byKey(
const Key('home-feed-title-anime-card'),
);
final title = tester.widget<Text>(titleFinder);
expect(title.maxLines, 2);
expect(title.style?.fontSize, AppDimens.cardTitleFont);
expect(title.style?.fontWeight, FontWeight.w500);
expect(title.style?.height, AppDimens.cardTitleLineHeight);
final tags = tester.widget<Text>(
find.byKey(const Key('home-feed-tags-anime-card')),
);
final tagsFinder = find.byKey(const Key('home-feed-tags-anime-card'));
final tags = tester.widget<Text>(tagsFinder);
expect(tags.data, 'Romance | Urban');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
expect(tester.getTopLeft(title).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(titleFinder).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(tagsFinder).dx, tester.getTopLeft(cover).dx);
await tester.tap(card);
expect(taps, 1);
+11 -6
View File
@@ -98,9 +98,10 @@ void main() {
);
final cover = tester.widget<AspectRatio>(coverFinder);
expect(cover.aspectRatio, AppDimens.cardCoverAspectRatio);
final cardTitle = tester.widget<Text>(
find.byKey(const Key('recommend-title-hits-the-signal-demo')),
final cardTitleFinder = find.byKey(
const Key('recommend-title-hits-the-signal-demo'),
);
final cardTitle = tester.widget<Text>(cardTitleFinder);
expect(cardTitle.style?.fontSize, AppDimens.cardTitleFont);
expect(cardTitle.style?.fontWeight, FontWeight.w500);
expect(cardTitle.style?.height, AppDimens.cardTitleLineHeight);
@@ -135,14 +136,18 @@ void main() {
expect(badgeText.data, 'Hit');
expect(badgeText.style?.fontSize, AppDimens.cardBadgeFont);
expect(badgeText.style?.color, AppColors.textPrimary);
final tags = tester.widget<Text>(
find.byKey(const Key('recommend-tags-hits-the-signal-demo')),
final tagsFinder = find.byKey(
const Key('recommend-tags-hits-the-signal-demo'),
);
final tags = tester.widget<Text>(tagsFinder);
expect(tags.data, 'Suspense | Mystery');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
expect(tester.getTopLeft(cardTitle).dx, tester.getTopLeft(coverFinder).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
expect(
tester.getTopLeft(cardTitleFinder).dx,
tester.getTopLeft(coverFinder).dx,
);
expect(tester.getTopLeft(tagsFinder).dx, tester.getTopLeft(coverFinder).dx);
});
testWidgets('should_switch_inner_tabs_without_losing_grid_filter_state', (