feat(home): 首页改为三列探索网格
This commit is contained in:
1 parent
6dea9d479e
commit
dd96792e33
29 files changed
+1912
-256
No files matched your search
@@ -46,36 +46,18 @@ void main() {
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_start_home_on_immersive_feed', (tester) async {
|
||||
testWidgets('should_start_home_on_explorer_grid', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-black-background')), findsOneWidget);
|
||||
expect(find.byType(PageView), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-browse-page')), findsNothing);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-like-count'))).data,
|
||||
'41.9万',
|
||||
);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-save-count'))).data,
|
||||
'1006',
|
||||
);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-comments-count'))).data,
|
||||
'3.2万',
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-refresh')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-danmaku')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-fullscreen')), findsNothing);
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(find.byType(PageView), findsNothing);
|
||||
expect(
|
||||
tester.widget<Scaffold>(find.byType(Scaffold).first).backgroundColor,
|
||||
Colors.transparent,
|
||||
);
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).homeMode, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_home_feed_size_when_keyboard_insets_change', (
|
||||
@@ -83,7 +65,7 @@ void main() {
|
||||
) async {
|
||||
addTearDown(tester.view.resetViewInsets);
|
||||
await _pumpApp(tester);
|
||||
final feed = find.byKey(const Key('home-feed-black-background'));
|
||||
final feed = find.byKey(const Key('home-grid'));
|
||||
final before = tester.getRect(feed);
|
||||
|
||||
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
|
||||
@@ -99,7 +81,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_open_full_player_from_full_series_bar', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -109,7 +91,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_switch_to_anime_channel', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -126,7 +108,7 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final catalog = _PendingAnimeCatalog();
|
||||
await _pumpApp(tester, catalog: catalog);
|
||||
await _pumpApp(tester, catalog: catalog, recommend: true);
|
||||
for (var attempt = 0; attempt < 5 && catalog.animeCalls == 0; attempt++) {
|
||||
await tester.pump();
|
||||
}
|
||||
@@ -151,7 +133,7 @@ void main() {
|
||||
testWidgets('should_show_empty_state_when_anime_has_no_dramas', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, catalog: _EmptyAnimeCatalog());
|
||||
await _pumpApp(tester, catalog: _EmptyAnimeCatalog(), recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -161,7 +143,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_refresh_feed_without_blank_loading', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-refresh')));
|
||||
await tester.pump();
|
||||
@@ -173,7 +155,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_keep_feed_rail_above_bottom_panels', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final railTop = tester.getCenter(find.byKey(const Key('rail-save'))).dy;
|
||||
final railBottom = tester
|
||||
.getRect(find.byKey(const Key('rail-share')))
|
||||
@@ -194,7 +176,7 @@ void main() {
|
||||
testWidgets('should_keep_feed_header_and_progress_after_clear', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final gesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
@@ -223,7 +205,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_boost_feed_on_side_long_press', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(60, 300));
|
||||
@@ -245,7 +227,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_hide_exit_clear_button_while_boosting', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final moreGesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
@@ -282,7 +264,7 @@ void main() {
|
||||
testWidgets('should_resume_playback_when_boosting_while_paused', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
@@ -302,7 +284,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_open_more_sheet_on_center_long_press', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
@@ -316,7 +298,7 @@ void main() {
|
||||
expect(find.byKey(const Key('home-feed-pip')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_light_status_bar_after_leaving_feed_tab', (
|
||||
testWidgets('should_keep_light_status_bar_in_grid_and_recommend', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
@@ -325,12 +307,13 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_feed_drama_when_swiped_up', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final before = tester
|
||||
.widget<Text>(find.byKey(const Key('home-feed-title')))
|
||||
.data;
|
||||
@@ -345,7 +328,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_keep_feed_header_fixed_when_swiping', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final before = tester.getRect(find.byKey(const Key('home-feed-search')));
|
||||
|
||||
await tester.drag(find.byType(PageView).first, const Offset(0, -600));
|
||||
@@ -360,7 +343,7 @@ void main() {
|
||||
testWidgets('should_resume_feed_after_returning_from_full_player', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await _pumpApp(tester, recommend: true);
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
@@ -379,23 +362,21 @@ void main() {
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_hide_feed_when_switching_to_theater', (tester) async {
|
||||
testWidgets('should_switch_from_grid_to_recommend_player', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(find.byKey(const Key('discover-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_theater_search_when_feed_search_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_open_discover_search_from_home_search', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-search')));
|
||||
await tester.tap(find.byKey(const Key('home-search-entry')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final field = tester.widget<TextField>(
|
||||
@@ -404,41 +385,12 @@ void main() {
|
||||
expect(field.focusNode?.hasFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_not_render_theater_language_filters', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('theater-language-chips')), findsNothing);
|
||||
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-refresh')), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('home-drama-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_open_fullscreen_player_when_theater_card_is_tapped', (
|
||||
testWidgets('should_open_player_when_home_grid_card_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final card = find.byKey(const Key('home-drama-card-the-signal-demo'));
|
||||
await tester.scrollUntilVisible(
|
||||
card,
|
||||
220,
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('discover-refresh')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final card = find.byKey(const Key('home-feed-card-the-signal-demo'));
|
||||
await tester.ensureVisible(card);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(card);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -446,16 +398,17 @@ void main() {
|
||||
expect(player.homeMode, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_home_feed_and_theater_on_320_width', (tester) async {
|
||||
testWidgets('should_fit_home_grid_and_recommend_on_320_width', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, size: const Size(320, 568));
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-language-chips')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -477,6 +430,7 @@ Future<void> _pumpApp(
|
||||
WidgetTester tester, {
|
||||
Size size = const Size(390, 844),
|
||||
FakeCatalogRepository? catalog,
|
||||
bool recommend = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -497,6 +451,10 @@ Future<void> _pumpApp(
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
if (recommend) {
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
}
|
||||
|
||||
class _PendingAnimeCatalog extends FakeCatalogRepository {
|
||||
|
||||
Reference in new issue
Block a user