fix(flutter): 更多面板增加小窗播放入口
This commit is contained in:
1 parent
3b2bdb8e5a
commit
0af5de9641
4 files changed
+115
-1
No files matched your search
@@ -35,6 +35,9 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
},
|
},
|
||||||
onClear: _hideChrome,
|
onClear: _hideChrome,
|
||||||
onDownload: () => requestEpisodeDownload(context, episode.id),
|
onDownload: () => requestEpisodeDownload(context, episode.id),
|
||||||
|
onPip: logic.pictureInPicture.isPlatformSupported
|
||||||
|
? () => unawaited(logic.enterPip(context))
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class PlayerMoreActions {
|
|||||||
required this.onSpeedChanged,
|
required this.onSpeedChanged,
|
||||||
required this.onClear,
|
required this.onClear,
|
||||||
required this.onDownload,
|
required this.onDownload,
|
||||||
|
this.onPip,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// 倍速变化。
|
/// 倍速变化。
|
||||||
@@ -45,6 +46,9 @@ class PlayerMoreActions {
|
|||||||
|
|
||||||
/// 离线缓存当前集。
|
/// 离线缓存当前集。
|
||||||
final VoidCallback onDownload;
|
final VoidCallback onDownload;
|
||||||
|
|
||||||
|
/// 进入小窗播放;平台不支持时为 null。
|
||||||
|
final VoidCallback? onPip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// K29.6 精简版播放页更多面板。
|
/// K29.6 精简版播放页更多面板。
|
||||||
@@ -113,6 +117,13 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
|||||||
title: l10n.clearPlayback,
|
title: l10n.clearPlayback,
|
||||||
onTap: _clear,
|
onTap: _clear,
|
||||||
),
|
),
|
||||||
|
if (widget.actions.onPip != null)
|
||||||
|
_actionRow(
|
||||||
|
key: const Key('player-more-pip'),
|
||||||
|
icon: Icons.picture_in_picture_alt_rounded,
|
||||||
|
title: l10n.pictureInPicture,
|
||||||
|
onTap: () => _closeThen(widget.actions.onPip!),
|
||||||
|
),
|
||||||
_actionRow(
|
_actionRow(
|
||||||
key: const Key('player-more-offline'),
|
key: const Key('player-more-offline'),
|
||||||
icon: Icons.download_rounded,
|
icon: Icons.download_rounded,
|
||||||
|
|||||||
@@ -389,7 +389,6 @@ void main() {
|
|||||||
Key('player-more-text-size'),
|
Key('player-more-text-size'),
|
||||||
Key('player-more-cast'),
|
Key('player-more-cast'),
|
||||||
Key('player-more-timer'),
|
Key('player-more-timer'),
|
||||||
Key('player-more-pip'),
|
|
||||||
Key('player-more-report'),
|
Key('player-more-report'),
|
||||||
]) {
|
]) {
|
||||||
expect(find.byKey(removed), findsNothing);
|
expect(find.byKey(removed), findsNothing);
|
||||||
@@ -506,6 +505,30 @@ void main() {
|
|||||||
expect(find.text('720P · Unavailable'), findsOneWidget);
|
expect(find.text('720P · Unavailable'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('should_show_pip_action_when_platform_supported', (tester) async {
|
||||||
|
await _pumpApp(tester);
|
||||||
|
await _openSeriesPlayer(tester);
|
||||||
|
await tester.tap(find.byKey(const Key('player-more')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('player-more-pip')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||||
|
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
||||||
|
|
||||||
|
testWidgets('should_hide_pip_action_when_platform_unsupported', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await _pumpApp(tester);
|
||||||
|
await _openSeriesPlayer(tester);
|
||||||
|
await tester.tap(find.byKey(const Key('player-more')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('player-more-pip')), findsNothing);
|
||||||
|
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||||
|
}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));
|
||||||
|
|
||||||
testWidgets('should_enter_clear_screen_from_more_panel', (tester) async {
|
testWidgets('should_enter_clear_screen_from_more_panel', (tester) async {
|
||||||
await _pumpApp(tester);
|
await _pumpApp(tester);
|
||||||
await _openSeriesPlayer(tester);
|
await _openSeriesPlayer(tester);
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||||
|
import 'package:fruitshorts/pages/player/widgets/player_more_sheet.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('should_hide_pip_row_when_platform_unsupported', (tester) async {
|
||||||
|
await _openSheet(tester);
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('player-more-sheet')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-more-pip')), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('should_trigger_pip_and_close_sheet_when_tapped', (tester) async {
|
||||||
|
var pipCalls = 0;
|
||||||
|
await _openSheet(tester, onPip: () => pipCalls++);
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('player-more-pip')), findsOneWidget);
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(find.byKey(const Key('player-more-clear'))).dy <
|
||||||
|
tester.getTopLeft(find.byKey(const Key('player-more-pip'))).dy,
|
||||||
|
isTrue,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(find.byKey(const Key('player-more-pip'))).dy <
|
||||||
|
tester.getTopLeft(find.byKey(const Key('player-more-offline'))).dy,
|
||||||
|
isTrue,
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.tap(find.byKey(const Key('player-more-pip')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(pipCalls, 1);
|
||||||
|
expect(find.byKey(const Key('player-more-sheet')), findsNothing);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _openSheet(WidgetTester tester, {VoidCallback? onPip}) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
supportedLocales: AppLocalizations.supportedLocales,
|
||||||
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
home: Scaffold(
|
||||||
|
body: Builder(
|
||||||
|
builder: (context) => Center(
|
||||||
|
child: TextButton(
|
||||||
|
key: const Key('open-more-sheet'),
|
||||||
|
onPressed: () => showModalBottomSheet<void>(
|
||||||
|
context: context,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (_) => PlayerMoreSheet(
|
||||||
|
l10n: AppLocalizations.of(context)!,
|
||||||
|
state: const PlayerMoreState(speed: 1.0, qualities: ['AUTO']),
|
||||||
|
actions: PlayerMoreActions(
|
||||||
|
onSpeedChanged: (_) {},
|
||||||
|
onClear: () {},
|
||||||
|
onDownload: () {},
|
||||||
|
onPip: onPip,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text('open'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.tap(find.byKey(const Key('open-more-sheet')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user