feat(app): 客户端展示多语言并支持筛选分页

This commit is contained in:
Zhou Weidong committed 2026-10-24 17:20:24 +08:00
1 parent 8481611372
commit 8b50b5bd06
68 files changed
+2742 -1120

No files matched your search

+29 -130
View File
@@ -34,7 +34,7 @@ void main() {
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
expect(find.byKey(const Key('recommend-tab-playlist')), findsOneWidget);
expect(find.byKey(const Key('recommend-tab-all')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
expect(find.byKey(const Key('recommend-top-gradient')), findsOneWidget);
final recommendText = tester.widget<Text>(
find.descendant(
@@ -81,12 +81,12 @@ void main() {
tester
.getRect(find.byKey(const Key('recommend-top-nav')))
.overlaps(
tester.getRect(find.byKey(const Key('recommend-feed-player'))),
tester.getRect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false)),
),
isTrue,
);
final player = tester.widget<PlayerPage>(
find.byKey(const Key('recommend-feed-player')),
find.byKey(const Key('recommend-feed-player'), skipOffstage: false),
);
expect(player.homeMode, isTrue);
expect(player.embedded, isTrue);
@@ -227,15 +227,9 @@ void main() {
);
expect(viewIcon, findsOneWidget);
final badge = find.byKey(
const Key('drama-cover-badge-ribbon-hits-the-signal-demo-hot'),
const Key('drama-cover-badge-ribbon-hits-the-signal-demo-tag'),
);
expect(badge, findsOneWidget);
final badgeText = tester.widget<Text>(
find.descendant(of: badge, matching: find.byType(Text)),
);
expect(badgeText.data, 'Hit');
expect(badgeText.style?.fontSize, AppDimens.cardBadgeFont);
expect(badgeText.style?.color, AppColors.textPrimary);
expect(badge, findsNothing);
final tagsFinder = find.byKey(
const Key('recommend-tags-hits-the-signal-demo'),
);
@@ -309,7 +303,7 @@ void main() {
expect(delegate.crossAxisCount, 3);
expect(delegate.crossAxisSpacing, AppDimens.allDramasGridGap);
expect(delegate.mainAxisSpacing, AppDimens.allDramasGridRowGap);
for (var row = 0; row < 4; row++) {
for (var row = 0; row < 3; row++) {
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
final scroll = tester.widget<SingleChildScrollView>(
find.byKey(Key('all-filter-scroll-$row')),
@@ -318,7 +312,7 @@ void main() {
expect(scroll.physics, isA<BouncingScrollPhysics>());
}
final filterStarts = [
for (var row = 0; row < 4; row++)
for (var row = 0; row < 3; row++)
tester.getRect(find.byKey(Key('all-filter-row-$row'))).left,
];
expect(
@@ -326,7 +320,7 @@ void main() {
everyElement(closeTo(AppDimens.allDramasHorizontal, 0.1)),
);
final pageRect = tester.getRect(find.byKey(const Key('recommend-page')));
for (var row = 0; row < 4; row++) {
for (var row = 0; row < 3; row++) {
final rowRect = tester.getRect(find.byKey(Key('all-filter-row-$row')));
expect(
rowRect.left,
@@ -347,10 +341,6 @@ void main() {
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)
@@ -365,14 +355,14 @@ void main() {
0.1,
),
);
for (var row = 0; row < 3; row++) {
for (var row = 0; row < 2; 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,
tester.getSize(find.byKey(const Key('all-filter-row-2'))).height,
AppDimens.filterChipHeight,
);
expect(
@@ -406,112 +396,31 @@ void main() {
tester.getRect(find.byKey(const Key('all-dramas-filters'))).top,
closeTo(fixedFilterTop, 0.1),
);
expect(find.byKey(const Key('all-filter-local')), findsOneWidget);
expect(_textStyle(tester, 'Local').color, AppColors.filterChipTextInactive);
expect(find.byKey(const Key('all-filter-subtitles')), findsOneWidget);
for (final key in [
'all-filter-reversal',
'all-filter-uplifting',
'all-filter-modern',
'all-filter-sweet',
'all-filter-angst',
]) {
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(find.byKey(const Key('all-filter-classification-all')), findsOneWidget);
expect(find.byKey(const Key('all-filter-category-all')), findsOneWidget);
expect(find.byKey(const Key('all-filter-tag-all')), findsOneWidget);
expect(
tester.getTopLeft(rowZeroAll).dx,
closeTo(pageRect.left + AppDimens.allDramasHorizontal, 0.1),
);
expect(
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,
);
}
expect(
tester.getTopLeft(find.byKey(const Key('all-sort-new'))).dx -
tester.getTopRight(find.byKey(const Key('all-sort-hot'))).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);
expect(_textStyle(tester, 'Local').fontWeight, FontWeight.w600);
expect(_textStyle(tester, 'Local').fontSize, AppDimens.filterChipFont);
expect(_textStyle(tester, 'Local').color, AppColors.filterChipTextSelected);
final selectedChip = tester.widget<Container>(
find
.descendant(
of: find.byKey(const Key('all-filter-local')),
matching: find.byType(Container),
tester
.widget<Text>(
find.descendant(
of: find.byKey(const Key('all-filter-classification-all')),
matching: find.text('All'),
),
)
.first,
);
expect(
(selectedChip.decoration! as BoxDecoration).color,
AppColors.filterChipSelected,
);
expect(
tester.getSize(find.byKey(const Key('all-filter-local'))).height,
AppDimens.filterChipHeight,
);
await tester.tap(find.byKey(const Key('all-filter-all')).first);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('all-sort-new')));
await tester.pump();
expect(_textStyle(tester, 'New').fontWeight, FontWeight.w600);
expect(_textStyle(tester, 'New').fontSize, AppDimens.filterChipFont);
expect(_textStyle(tester, 'New').color, AppColors.filterChipTextSelected);
expect(
tester.getSize(find.byKey(const Key('all-sort-new'))).height,
AppDimens.filterChipHeight,
);
final chipContainer = tester.widget<Container>(
find.descendant(
of: find.byKey(const Key('all-sort-new')),
matching: find.byType(Container),
),
);
expect(
(chipContainer.decoration! as BoxDecoration).borderRadius,
BorderRadius.circular(AppDimens.filterChipRadius),
.style
?.color,
AppColors.filterChipTextSelected,
);
expect(find.byKey(const Key('all-dramas-filter-page')), findsNothing);
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
expect(find.byType(AppBottomNav), findsOneWidget);
await tester.tap(find.byKey(const Key('recommend-tab-all')));
await tester.pumpAndSettle();
expect(_textStyle(tester, 'New').fontWeight, FontWeight.w700);
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
});
@@ -527,7 +436,7 @@ void main() {
await tester.drag(pages, const Offset(-320, 0));
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
expect(
tester
.widget<Text>(
@@ -551,7 +460,7 @@ void main() {
await tester.drag(pages, const Offset(640, 0));
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
});
@@ -585,7 +494,7 @@ void main() {
await _pumpRecommend(tester);
final gesture = await tester.startGesture(
tester.getCenter(find.byKey(const Key('recommend-feed-player'))),
tester.getCenter(find.byKey(const Key('recommend-feed-player'), skipOffstage: false)),
);
await gesture.moveBy(const Offset(0, 80));
await tester.pump();
@@ -593,7 +502,7 @@ void main() {
final feedScroll = tester.state<ScrollableState>(
find
.descendant(
of: find.byKey(const Key('recommend-feed-player')),
of: find.byKey(const Key('recommend-feed-player'), skipOffstage: false),
matching: find.byType(Scrollable),
)
.first,
@@ -621,7 +530,8 @@ void main() {
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
expect(player.homeMode, isFalse);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
await tester.tap(find.byKey(const Key('recommend-search')));
await tester.pumpAndSettle();
@@ -632,17 +542,6 @@ void main() {
});
}
TextStyle _textStyle(WidgetTester tester, String text) {
return tester
.widget<Text>(
find.descendant(
of: find.byKey(const Key('all-sort-new')),
matching: find.text(text),
),
)
.style!;
}
Future<void> _pumpRecommend(WidgetTester tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;