feat: 改造追剧页双列表与三列卡片
This commit is contained in:
1 parent
cffb68809c
commit
2fac46f248
8 files changed
+435
-276
No files matched your search
@@ -40,18 +40,19 @@ void main() {
|
||||
expect(find.byKey(const Key('following-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-tab-favorites')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-tab-history')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-tab-reserve')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-tab-reserve')), findsNothing);
|
||||
expect(find.byKey(const Key('following-favorites-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-add-card')), findsOneWidget);
|
||||
expect(find.byType(CustomScrollView), findsWidgets);
|
||||
final tab = tester.widget<Text>(
|
||||
final tab = tester.widget<AnimatedDefaultTextStyle>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-tab-favorites')),
|
||||
matching: find.text('Following'),
|
||||
matching: find.byType(AnimatedDefaultTextStyle),
|
||||
),
|
||||
);
|
||||
expect(tab.style?.fontSize, AppDimens.followingTabFont);
|
||||
expect(tab.style?.fontWeight, FontWeight.w700);
|
||||
expect(tab.style?.color, AppColors.textPrimary);
|
||||
expect(tab.style.fontSize, AppDimens.followingTabFont);
|
||||
expect(tab.style.fontWeight, FontWeight.w600);
|
||||
expect(tab.style.color, AppColors.textPrimary);
|
||||
final grid = tester.widget<SliverGrid>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-favorites-grid')),
|
||||
@@ -60,9 +61,10 @@ void main() {
|
||||
);
|
||||
final delegate =
|
||||
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
||||
expect(delegate.crossAxisSpacing, AppDimens.homeGridGap);
|
||||
expect(delegate.mainAxisSpacing, AppDimens.homeGridRowGap);
|
||||
expect(delegate.childAspectRatio, AppDimens.followingGridAspectRatio);
|
||||
expect(delegate.crossAxisCount, 3);
|
||||
expect(delegate.crossAxisSpacing, AppDimens.followingGridGap);
|
||||
expect(delegate.mainAxisSpacing, AppDimens.followingGridRowGap);
|
||||
expect(delegate.mainAxisExtent, greaterThan(0));
|
||||
final card = find.byKey(const Key('following-card-the-signal-demo'));
|
||||
final coverFinder = find.byKey(
|
||||
const Key('following-cover-the-signal-demo'),
|
||||
@@ -77,7 +79,7 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
coverClip.borderRadius,
|
||||
BorderRadius.circular(AppDimens.cardCoverRadius),
|
||||
BorderRadius.circular(AppDimens.homeCardRadius),
|
||||
);
|
||||
final titleFinder = find.descendant(
|
||||
of: card,
|
||||
@@ -88,7 +90,10 @@ void main() {
|
||||
expect(title.style?.fontWeight, FontWeight.w500);
|
||||
expect(title.style?.height, AppDimens.cardTitleLineHeight);
|
||||
final views = tester.widget<Text>(
|
||||
find.byKey(const Key('following-views-the-signal-demo')),
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-views-the-signal-demo')),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
);
|
||||
expect(views.style?.fontSize, AppDimens.cardPlayCountFont);
|
||||
expect(views.style?.fontWeight, FontWeight.w400);
|
||||
@@ -107,15 +112,10 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
final tagsFinder = find.byKey(
|
||||
const Key('following-tags-the-signal-demo'),
|
||||
expect(
|
||||
tester.getTopLeft(titleFinder).dx,
|
||||
tester.getTopLeft(coverFinder).dx,
|
||||
);
|
||||
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(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();
|
||||
@@ -148,9 +148,6 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('following-tab-history')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('following-tab-reserve')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('following-reserve-empty')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_auth_gate_when_signed_out', (tester) async {
|
||||
@@ -172,7 +169,8 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('following-favorites-empty')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-add-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-favorites-empty')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('following-tab-history')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
|
||||
@@ -209,7 +207,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Server title'), findsOneWidget);
|
||||
expect(find.text('Watched to Episode 3'), findsOneWidget);
|
||||
expect(find.text('Episode 3 / 8 total'), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('following-progress-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
@@ -217,6 +215,43 @@ void main() {
|
||||
expect(catalog.detailFetches, 0);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_following_pages_horizontally', (tester) async {
|
||||
_signIn();
|
||||
await tester.pumpWidget(_app(catalog: FakeCatalogRepository()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.drag(
|
||||
find.byKey(const Key('following-tab-pages')),
|
||||
const Offset(-500, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
|
||||
final historyTab = tester.widget<AnimatedDefaultTextStyle>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-tab-history')),
|
||||
matching: find.byType(AnimatedDefaultTextStyle),
|
||||
),
|
||||
);
|
||||
expect(historyTab.style.fontWeight, FontWeight.w600);
|
||||
expect(historyTab.style.color, AppColors.textPrimary);
|
||||
});
|
||||
|
||||
testWidgets('should_open_home_from_add_card', (tester) async {
|
||||
_signIn();
|
||||
await tester.pumpWidget(_app(catalog: FakeCatalogRepository()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('following-add-card')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_reset_edit_state_when_switching_tabs', (tester) async {
|
||||
_signIn();
|
||||
final catalog = FakeCatalogRepository();
|
||||
|
||||
Reference in new issue
Block a user