fix(home): 调整首页分类与卡片标签样式

This commit is contained in:
Zhou Weidong committed 2026-10-22 18:22:05 +08:00
1 parent 7446431511
commit 4f6116896f
14 files changed
+251 -117

No files matched your search

+7
View File
@@ -10,6 +10,13 @@ void main() {
expect(formatInteractionCount(9999), '9999');
});
test('should_format_play_count_with_w_and_trim_integer_decimals', () {
expect(formatPlayCount(8500), '8500');
expect(formatPlayCount(10000), '1w');
expect(formatPlayCount(500000), '50w');
expect(formatPlayCount(444500), '44.5w');
});
test('should_use_one_decimal_wan_from_ten_thousand', () {
expect(formatInteractionCount(10000), '1.0万');
expect(formatInteractionCount(12400), '1.2万');
+26 -6
View File
@@ -68,6 +68,16 @@ void main() {
find.byKey(const Key('following-cover-the-signal-demo')),
);
expect(cover.aspectRatio, AppDimens.cardCoverAspectRatio);
final coverClip = tester.widget<ClipRRect>(
find.descendant(
of: find.byKey(const Key('following-cover-the-signal-demo')),
matching: find.byType(ClipRRect),
),
);
expect(
coverClip.borderRadius,
BorderRadius.circular(AppDimens.cardCoverRadius),
);
final title = tester.widget<Text>(
find.descendant(of: card, matching: find.text('The Signal')),
);
@@ -79,14 +89,24 @@ void main() {
);
expect(views.style?.fontSize, AppDimens.cardViewsFont);
expect(views.style?.color, AppColors.textPrimary);
final tags = tester.widget<Text>(
find.byKey(const Key('following-tags-the-signal-demo')),
expect(
find.descendant(
of: find.byKey(const Key('following-views-the-signal-demo')),
matching: find.byIcon(Icons.auto_awesome_rounded),
),
findsOneWidget,
);
expect(tags.data, 'Suspense | Mystery');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
final ribbon = find.byKey(
const Key('drama-genre-ribbon-the-signal-demo-0'),
);
expect(ribbon, findsOneWidget);
final ribbonText = tester.widget<Text>(
find.descendant(of: ribbon, matching: find.byType(Text)),
);
expect(ribbonText.data, 'Suspense');
expect(ribbonText.style?.fontSize, AppDimens.cardBadgeFont);
expect(ribbonText.style?.color, AppColors.textPrimary);
expect(tester.getTopLeft(title).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
await tester.tap(find.byKey(const Key('following-edit')));
await tester.pumpAndSettle();
+22 -7
View File
@@ -41,6 +41,13 @@ void main() {
final cover = find.byKey(const Key('home-feed-cover-anime-card'));
final coverSize = tester.getSize(cover);
expect(coverSize.height / coverSize.width, closeTo(6 / 5, 0.02));
final coverClip = tester.widget<ClipRRect>(
find.byKey(const Key('home-feed-cover-clip-anime-card')),
);
expect(
coverClip.borderRadius,
BorderRadius.circular(AppDimens.cardCoverRadius),
);
final badge = find.byKey(const Key('home-feed-badge-anime-anime-card'));
expect(badge, findsOneWidget);
final badgeContainer = tester.widget<Container>(badge);
@@ -61,9 +68,16 @@ void main() {
final viewsText = tester.widget<Text>(
find.descendant(of: views, matching: find.byType(Text)),
);
expect(viewsText.data, startsWith('44.'));
expect(viewsText.data, '44.5w');
expect(viewsText.style?.fontSize, AppDimens.cardViewsFont);
expect(viewsText.style?.color, AppColors.navSelected);
expect(
find.descendant(
of: views,
matching: find.byIcon(Icons.auto_awesome_rounded),
),
findsOneWidget,
);
final title = tester.widget<Text>(
find.byKey(const Key('home-feed-title-anime-card')),
);
@@ -71,14 +85,15 @@ void main() {
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 ribbon = find.byKey(const Key('drama-genre-ribbon-anime-card-0'));
expect(ribbon, findsOneWidget);
final ribbonText = tester.widget<Text>(
find.descendant(of: ribbon, matching: find.byType(Text)),
);
expect(tags.data, 'Romance | Urban');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
expect(ribbonText.data, 'Romance');
expect(ribbonText.style?.fontSize, AppDimens.cardBadgeFont);
expect(ribbonText.style?.color, AppColors.textPrimary);
expect(tester.getTopLeft(title).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
await tester.tap(card);
expect(taps, 1);
+3
View File
@@ -108,6 +108,7 @@ void main() {
await tester.tap(find.byKey(const Key('home-section-new')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-releases-page')), findsNothing);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
expect(firstDramaId(), 'page1-9');
await tester.tap(find.byKey(const Key('home-section-ranking')));
@@ -118,6 +119,7 @@ void main() {
await tester.tap(find.byKey(const Key('home-section-categories')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('filter-page')), findsNothing);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
await tester.tap(find.byKey(const Key('home-section-category-古装')));
@@ -154,6 +156,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('home-section-featured')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
final afterScrollable = find
.descendant(
+21 -6
View File
@@ -85,6 +85,13 @@ void main() {
expect(moreText.style?.fontSize, AppDimens.recommendSectionMore);
expect(moreText.style?.color, AppColors.textSecondary);
final card = find.byKey(const Key('recommend-card-hits-the-signal-demo'));
final coverClip = tester.widget<ClipRRect>(
find.descendant(of: card, matching: find.byType(ClipRRect)),
);
expect(
coverClip.borderRadius,
BorderRadius.circular(AppDimens.cardCoverRadius),
);
final cover = tester.widget<AspectRatio>(
find.descendant(of: card, matching: find.byType(AspectRatio)),
);
@@ -103,14 +110,22 @@ void main() {
);
expect(views.style?.fontSize, AppDimens.cardViewsFont);
expect(views.style?.color, AppColors.textPrimary);
final tags = tester.widget<Text>(
find.byKey(const Key('recommend-tags-hits-the-signal-demo')),
final viewIcon = find.descendant(
of: find.byKey(const Key('recommend-views-hits-the-signal-demo')),
matching: find.byIcon(Icons.auto_awesome_rounded),
);
expect(tags.data, 'Suspense | Mystery');
expect(tags.style?.fontSize, AppDimens.cardTagFont);
expect(tags.style?.color, AppColors.textTertiary);
expect(viewIcon, findsOneWidget);
final ribbon = find.byKey(
const Key('drama-genre-ribbon-hits-the-signal-demo-0'),
);
expect(ribbon, findsOneWidget);
final ribbonText = tester.widget<Text>(
find.descendant(of: ribbon, matching: find.byType(Text)),
);
expect(ribbonText.data, 'Suspense');
expect(ribbonText.style?.fontSize, AppDimens.cardBadgeFont);
expect(ribbonText.style?.color, AppColors.textPrimary);
expect(tester.getTopLeft(cardTitle).dx, tester.getTopLeft(cover).dx);
expect(tester.getTopLeft(tags).dx, tester.getTopLeft(cover).dx);
});
testWidgets('should_switch_inner_tabs_without_losing_grid_filter_state', (