fix(home): 调整榜单版式并去掉二级分类

This commit is contained in:
Zhou Weidong committed 2026-10-23 03:18:24 +08:00
1 parent 60489d6dca
commit f4cf7bc2dd
7 files changed
+90 -316

No files matched your search

+4 -2
View File
@@ -113,8 +113,10 @@ void main() {
final top3 = tester.getRect(find.byKey(const Key('ranking-cover-3')));
expect(top1.width, greaterThan(top2.width));
expect(top3.width, closeTo(top2.width, 0.5));
expect(top2.left, closeTo(14, 0.5));
expect(top3.right, closeTo(376, 0.5));
expect(top2.left, closeTo(8, 0.5));
expect(top3.right, closeTo(382, 0.5));
expect(top1.left - top2.right, lessThanOrEqualTo(10));
expect(top2.width, greaterThan(100));
expect(top2.left, lessThan(top1.left));
expect(top3.left, greaterThan(top1.right));
expect(top1.bottom, closeTo(top2.bottom - 12, 0.5));
+10 -15
View File
@@ -12,6 +12,7 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
import 'package:fruitshorts/core/theme/app_dimens.dart';
import 'package:fruitshorts/core/theme/app_theme.dart';
import 'package:fruitshorts/pages/home/widgets/home_feed_card.dart';
import 'package:fruitshorts/pages/player/player_view.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
@@ -55,18 +56,7 @@ void main() {
.map((key) => tester.getCenter(find.byKey(key)).dx)
.toList();
expect(sectionCenters, orderedEquals(sectionCenters.toList()..sort()));
final tagKeys = [
const Key('home-tag-hot'),
const Key('home-tag-uplifting'),
const Key('home-tag-sweet'),
const Key('home-tag-faceSlap'),
const Key('home-tag-angst'),
];
final tagCenters = tagKeys
.map((key) => tester.getCenter(find.byKey(key)).dx)
.toList();
expect(tagCenters, orderedEquals(tagCenters.toList()..sort()));
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
expect(find.text('Featured'), findsOneWidget);
expect(find.text('New'), findsOneWidget);
expect(find.text('Categories'), findsOneWidget);
@@ -117,6 +107,11 @@ void main() {
expect(find.byKey(const Key('ranking-page')), findsOneWidget);
expect(find.byKey(const Key('ranking-hero')), findsOneWidget);
expect(find.byKey(const Key('home-grid-cards')), findsNothing);
final home = tester.widget<DecoratedBox>(find.byKey(const Key('home-grid')));
expect(
(home.decoration as BoxDecoration).gradient,
AppTheme.pageGradient,
);
await tester.tap(find.byKey(const Key('home-section-categories')));
await tester.pumpAndSettle();
@@ -158,7 +153,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);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
final afterScrollable = find
.descendant(
@@ -176,7 +171,7 @@ void main() {
final repository = _PagedCatalogRepository();
await _pumpApp(tester, repository);
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
await tester.drag(
find.byKey(const Key('home-primary-page-view')),
const Offset(-320, 0),
@@ -195,7 +190,7 @@ void main() {
const Offset(320, 0),
);
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
});
testWidgets('should_load_next_page_without_expanding_page_size', (
+6 -101
View File
@@ -93,44 +93,8 @@ void main() {
expect(find.byKey(const Key('home-section-ranking')), findsOneWidget);
expect(find.byKey(const Key('home-section-category-古装')), findsOneWidget);
expect(find.byKey(const Key('home-section-category-社群')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
expect(find.byKey(const Key('home-grid-filter')), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('home-grid-filter'))),
const Size.square(AppDimens.homeSecondaryFilterVisualSize),
);
expect(
tester.getSize(find.byKey(const Key('home-secondary-filter-visual'))),
const Size.square(AppDimens.homeSecondaryFilterVisualSize),
);
expect(
tester.getCenter(find.byKey(const Key('home-grid-filter'))).dy,
closeTo(tester.getCenter(find.byKey(const Key('home-tag-hot'))).dy, 0.1),
);
expect(
tester.getRect(find.byKey(const Key('home-grid-filter'))).right,
closeTo(
tester.getRect(find.byKey(const Key('home-grid'))).right -
AppDimens.feedPageHorizontal,
0.1,
),
);
final filterIcon = tester.widget<CustomPaint>(
find.byKey(const Key('home-secondary-filter-icon')),
);
expect(
filterIcon.size,
const Size.square(AppDimens.homeSecondaryFilterIcon),
);
final filterMaterial = tester.widget<Material>(
find
.ancestor(
of: find.byKey(const Key('home-grid-filter')),
matching: find.byType(Material),
)
.first,
);
expect(filterMaterial.color, AppColors.transparent);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
expect(find.byKey(const Key('home-grid-filter')), findsNothing);
final searchBox = find.descendant(
of: find.byKey(const Key('home-search-entry')),
matching: find.byType(Container),
@@ -169,28 +133,6 @@ void main() {
),
findsNothing,
);
final secondaryTag = tester.widget<Text>(
find.descendant(
of: find.byKey(const Key('home-tag-hot')),
matching: find.text('Hot'),
),
);
expect(secondaryTag.style?.fontSize, AppDimens.homeSecondaryTagFont);
expect(secondaryTag.style?.fontWeight, FontWeight.w600);
expect(secondaryTag.style?.color, AppColors.textTertiary);
final unselectedTagChip = tester.widget<AnimatedContainer>(
find.byKey(const Key('home-tag-animated-hot')),
);
expect(
(unselectedTagChip.decoration! as BoxDecoration).color,
AppColors.transparent,
);
expect(
unselectedTagChip.padding,
const EdgeInsets.symmetric(
horizontal: AppDimens.homeSecondaryTagHorizontalPadding,
),
);
final primaryStart = tester.getTopLeft(find.text('Featured'));
final pageStart = tester.getTopLeft(searchBox);
expect(primaryStart.dx, pageStart.dx);
@@ -198,41 +140,6 @@ void main() {
tester.getTopLeft(find.text('New')).dx -
tester.getBottomRight(find.text('Featured')).dx;
expect(primaryGap, closeTo(AppDimens.homePrimaryCategoryGap, 0.1));
final tagStart = tester.getTopLeft(find.byKey(const Key('home-tag-hot')));
expect(tagStart.dx, pageStart.dx);
expect(
tester.getSize(find.byKey(const Key('home-tag-hot'))).height,
AppDimens.homeSecondaryTagHeight,
);
final tagGap =
tester.getTopLeft(find.byKey(const Key('home-tag-uplifting'))).dx -
tester.getBottomRight(find.byKey(const Key('home-tag-hot'))).dx;
expect(tagGap, closeTo(AppDimens.homeSecondaryTagGap, 0.1));
await tester.tap(find.byKey(const Key('home-tag-hot')));
await tester.pump();
final selectedTagChip = tester.widget<AnimatedContainer>(
find.byKey(const Key('home-tag-animated-hot')),
);
expect(
(selectedTagChip.decoration! as BoxDecoration).color,
AppColors.contentSurface,
);
expect(
(selectedTagChip.decoration! as BoxDecoration).borderRadius,
BorderRadius.circular(AppDimens.homeSecondaryTagRadius),
);
expect(
tester.getSize(find.byKey(const Key('home-tag-hot'))).height,
AppDimens.homeSecondaryTagHeight,
);
final selectedTag = tester.widget<Text>(
find.descendant(
of: find.byKey(const Key('home-tag-hot')),
matching: find.text('Hot'),
),
);
expect(selectedTag.style?.color, AppColors.navSelected);
expect(selectedTag.style?.fontWeight, FontWeight.w600);
expect(find.byType(PageView), findsNothing);
expect(tester.takeException(), isNull);
});
@@ -351,13 +258,11 @@ void main() {
);
await tester.pumpAndSettle();
expect(
tester.widget<Text>(find.byKey(const Key('home-feed-title'))).data,
'Feed Drama',
);
final seriesTitle = tester.widget<Text>(
find.byKey(const Key('home-feed-series-title')),
);
expect(seriesTitle.data, 'Feed Drama');
expect(find.text('Episode 2'), findsNothing);
expect(seriesTitle.style?.fontSize, 19);
expect(seriesTitle.style?.fontWeight, FontWeight.w600);
expect(seriesTitle.style?.color, AppColors.textPrimary);
@@ -726,7 +631,7 @@ void main() {
await gesture.moveBy(const Offset(120, 0));
await tester.pump();
expect(scrubVisibility.last, isTrue);
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-feed-series-title')), findsOneWidget);
expect(find.byKey(const Key('rail-save')), findsOneWidget);
expect(
tester
@@ -824,7 +729,7 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
expect(scrubVisibility.last, isFalse);
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-feed-series-title')), findsOneWidget);
expect(
tester
.widget<AnimatedOpacity>(
+1 -1
View File
@@ -204,7 +204,7 @@ void main() {
expect(find.byKey(const Key('home-grid')), findsOneWidget);
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
expect(find.byKey(const Key('home-search-entry')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsNothing);
expect(tester.takeException(), isNull);
});