fix(flutter): 精修首页 feed 交互与底色

This commit is contained in:
Zhou Weidong committed 2026-10-20 13:56:51 +08:00
1 parent 435fbbbbb1
commit 321c62664c
17 files changed
+427 -448

No files matched your search

+81 -1
View File
@@ -14,6 +14,7 @@ import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart
import 'package:fruitshorts/core/theme/app_theme.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/player/widgets/home_feed_overlay.dart';
import 'package:video_player/video_player.dart';
import '../support/fake_catalog.dart';
import '../support/fake_category.dart';
@@ -112,7 +113,8 @@ void main() {
onShare: () {},
onEpisodes: () {},
onDetail: () {},
onFullscreen: () {},
onOpenFullPlayer: () {},
onRefreshFeed: () {},
onDownload: () {},
onClear: () {},
onSearch: () {},
@@ -145,4 +147,82 @@ void main() {
'12',
);
});
testWidgets('should_refresh_seek_and_open_player_from_feed_actions', (
tester,
) async {
var refreshed = 0;
var opened = 0;
Duration? seeked;
final controller = ValueNotifier<VideoPlayerValue>(
VideoPlayerValue(
duration: const Duration(seconds: 100),
position: const Duration(seconds: 10),
isInitialized: true,
),
);
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
locale: const Locale('en'),
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: Builder(
builder: (context) => Scaffold(
body: HomeFeedOverlay(
l10n: AppLocalizations.of(context)!,
drama: const Drama(
id: 'action-drama',
title: 'Action Drama',
synopsis: 'synopsis',
posterUrl: '',
totalEpisodes: 8,
viewCount: 1200,
),
episode: const Episode(
id: 'action-episode',
number: 1,
title: 'Episode 1',
isFree: true,
),
controller: controller,
liked: false,
saved: false,
onLike: () {},
onSave: () {},
onComments: () {},
onShare: () {},
onEpisodes: () {},
onDetail: () {},
onOpenFullPlayer: () => opened++,
onRefreshFeed: () => refreshed++,
onDownload: () {},
onClear: () {},
onSearch: () {},
onScrubStart: () {},
onSeek: (value) => seeked = value,
),
),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('home-feed-refresh')));
await tester.pump();
expect(refreshed, 1);
await tester.drag(
find.byKey(const Key('home-feed-progress')),
const Offset(120, 0),
);
await tester.pumpAndSettle();
expect(seeked, isNotNull);
expect(seeked!.inSeconds, greaterThan(0));
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pump();
expect(opened, 1);
});
}
+11 -9
View File
@@ -65,27 +65,29 @@ void main() {
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(
tester.widget<Scaffold>(find.byType(Scaffold).first).backgroundColor,
Colors.black,
);
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).homeMode, isTrue);
});
testWidgets('should_open_episode_sheet_from_full_series_bar', (tester) async {
testWidgets('should_open_full_player_from_full_series_bar', (tester) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-episodes-sheet')), findsOneWidget);
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
expect(player.homeMode, isFalse);
});
testWidgets('should_show_coming_soon_for_danmaku_and_anime_tab', (
tester,
) async {
testWidgets('should_show_coming_soon_for_anime_tab', (tester) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('home-feed-danmaku')));
await tester.pump();
expect(find.text('Coming soon'), findsOneWidget);
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
await tester.pump();
expect(find.text('Coming soon'), findsOneWidget);