MOD: renamed to SplashVideo which makes more sense
This commit is contained in:
parent
19e889617b
commit
c2fee98cd0
|
|
@ -33,7 +33,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
nextScreen: const Scaffold(),
|
||||
onVideoComplete: () {},
|
||||
|
|
@ -51,7 +51,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
nextScreen: const Scaffold(),
|
||||
|
|
@ -69,7 +69,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoComplete: () {},
|
||||
|
|
@ -87,7 +87,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/invalid/nonexistent.mp4'),
|
||||
nextScreen: const Scaffold(),
|
||||
),
|
||||
|
|
@ -108,7 +108,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/invalid/nonexistent.mp4'),
|
||||
onVideoError: (error) {
|
||||
capturedError = error;
|
||||
|
|
@ -130,7 +130,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: NetworkFileSource('https://invalid.example.com/video.mp4'),
|
||||
onVideoError: (e) => error = e,
|
||||
),
|
||||
|
|
@ -148,7 +148,7 @@ void main() {
|
|||
testWidgets('renders title widget overlay', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
titleWidget: const Text('Welcome'),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -163,7 +163,7 @@ void main() {
|
|||
testWidgets('renders footer widget overlay', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
footerWidget: const Text('Loading...'),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -179,7 +179,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
overlayBuilder: (context) => const Text('Custom Overlay'),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -194,7 +194,7 @@ void main() {
|
|||
testWidgets('renders all overlays together', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
titleWidget: const Text('Title'),
|
||||
footerWidget: const Text('Footer'),
|
||||
|
|
@ -219,7 +219,7 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) => SplashVideoPage(
|
||||
builder: (context) => SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
footerWidget: ElevatedButton(
|
||||
|
|
@ -253,7 +253,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -282,7 +282,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
onVideoError: (_) {},
|
||||
),
|
||||
|
|
@ -291,14 +291,14 @@ void main() {
|
|||
|
||||
await tester.pump();
|
||||
// Widget should be created without exceptions
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('NetworkFileSource accepts valid URL',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: NetworkFileSource('https://example.com/video.mp4'),
|
||||
onVideoError: (_) {},
|
||||
),
|
||||
|
|
@ -306,14 +306,14 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('DeviceFileSource accepts file path',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: DeviceFileSource('/path/to/video.mp4'),
|
||||
onVideoError: (_) {},
|
||||
),
|
||||
|
|
@ -321,7 +321,7 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
videoConfig: const VideoConfig(useSafeArea: true),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -339,7 +339,7 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('supports different visibility modes',
|
||||
|
|
@ -347,7 +347,7 @@ void main() {
|
|||
for (final mode in VisibilityEnum.values) {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
videoConfig: VideoConfig(videoVisibilityEnum: mode),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -356,7 +356,7 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
|
||||
// Clean up for next iteration
|
||||
await tester.pumpWidget(Container());
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ void main() async {
|
|||
debugPrint('========================================');
|
||||
|
||||
// Initialize and run the app
|
||||
SplashVideoPage.initialize();
|
||||
SplashVideo.initialize();
|
||||
|
||||
final mediaKitWorking = await SplashVideoPage.testMediaKit();
|
||||
final mediaKitWorking = await SplashVideo.testMediaKit();
|
||||
|
||||
if (!mediaKitWorking) {
|
||||
debugPrint('');
|
||||
|
|
@ -80,7 +80,7 @@ class _DiagnosticPageState extends State<DiagnosticPage> {
|
|||
body: Stack(
|
||||
children: [
|
||||
// The splash video
|
||||
SplashVideoPage(
|
||||
SplashVideo(
|
||||
source: AssetSource('assets/splash.mp4'),
|
||||
backgroundColor: Colors.black,
|
||||
onVideoError: (error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ void main() {
|
|||
|
||||
// Initialize SplashVideo: defer first frame & setup MediaKit
|
||||
// This is safe because our first screen IS a SplashVideoPage
|
||||
SplashVideoPage.initialize();
|
||||
SplashVideo.initialize();
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class InitialSplashExample extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SplashVideoPage(
|
||||
return SplashVideo(
|
||||
source: AssetSource(ExampleSelector.kFilePath),
|
||||
backgroundColor: Colors.black,
|
||||
nextScreen: const ExampleSelector(),
|
||||
|
|
@ -289,7 +289,7 @@ class AutoNavigateExample extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SplashVideoPage(
|
||||
return SplashVideo(
|
||||
source: AssetSource(ExampleSelector.kFilePath),
|
||||
nextScreen: const HomeScreen(title: 'Auto-Navigate Example'),
|
||||
backgroundColor: Colors.black,
|
||||
|
|
@ -314,7 +314,7 @@ class ManualControlExample extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SplashVideoPage(
|
||||
return SplashVideo(
|
||||
source: AssetSource(ExampleSelector.kFilePath),
|
||||
backgroundColor: Colors.black,
|
||||
onVideoError: (error) {
|
||||
|
|
@ -374,7 +374,7 @@ class _LoopingExampleState extends State<LoopingExample> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SplashVideoPage(
|
||||
return SplashVideo(
|
||||
source: AssetSource(ExampleSelector.kFilePath),
|
||||
controller: controller,
|
||||
backgroundColor: Colors.black,
|
||||
|
|
@ -435,7 +435,7 @@ class OverlayExample extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SplashVideoPage(
|
||||
return SplashVideo(
|
||||
source: AssetSource(ExampleSelector.kFilePath),
|
||||
nextScreen: const HomeScreen(title: 'Overlay Example'),
|
||||
backgroundColor: Colors.black,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
library;
|
||||
|
||||
// Main widget
|
||||
export 'widgets/splash_video_page_w.dart';
|
||||
export 'widgets/splash_video_w.dart';
|
||||
|
||||
// Controller
|
||||
export 'splash_video_controller.dart';
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ import 'package:splash_video/widgets/splash_video_player_w.dart';
|
|||
///
|
||||
/// This widget handles video playback, overlays, navigation, and lifecycle management.
|
||||
/// It provides a smooth transition from native splash screen to video splash.
|
||||
class SplashVideoPage extends StatefulWidget {
|
||||
class SplashVideo extends StatefulWidget {
|
||||
/// Creates a SplashVideo widget
|
||||
///
|
||||
/// [source] is required and specifies the video source
|
||||
/// [controller] is required when using looping videos
|
||||
///
|
||||
/// Throws [AssertionError] if validation rules are violated
|
||||
const SplashVideoPage({
|
||||
const SplashVideo({
|
||||
super.key,
|
||||
required this.source,
|
||||
this.controller,
|
||||
|
|
@ -185,10 +185,10 @@ class SplashVideoPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
@override
|
||||
State<SplashVideoPage> createState() => _SplashVideoPageState();
|
||||
State<SplashVideo> createState() => _SplashVideoState();
|
||||
}
|
||||
|
||||
class _SplashVideoPageState extends State<SplashVideoPage> {
|
||||
class _SplashVideoState extends State<SplashVideo> {
|
||||
Timer? _completionTimer;
|
||||
StreamSubscription? _skipSubscription;
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ class _SplashVideoPageState extends State<SplashVideoPage> {
|
|||
// Validate configuration
|
||||
_validateConfiguration();
|
||||
|
||||
onSourceLoaded = widget.onSourceLoaded ?? SplashVideoPage.resume;
|
||||
onSourceLoaded = widget.onSourceLoaded ?? SplashVideo.resume;
|
||||
|
||||
// Listen for skip requests if controller provided
|
||||
if (widget.controller != null) {
|
||||
|
|
@ -32,21 +32,21 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
onVideoError: (_) {}, // Suppress errors in test
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('validates conflicting nextScreen and onVideoComplete',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
nextScreen: const Scaffold(body: Text('Next')),
|
||||
onVideoComplete: () {},
|
||||
|
|
@ -64,7 +64,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
nextScreen: const Scaffold(),
|
||||
|
|
@ -82,7 +82,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoComplete: () {},
|
||||
|
|
@ -100,7 +100,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -110,7 +110,7 @@ void main() {
|
|||
|
||||
// Should not throw
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
|
||||
controller.dispose();
|
||||
});
|
||||
|
|
@ -118,7 +118,7 @@ void main() {
|
|||
testWidgets('renders with backgroundColor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
backgroundColor: Colors.red,
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -127,13 +127,13 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders with title overlay', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
titleWidget: const Text('App Title'),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -148,7 +148,7 @@ void main() {
|
|||
testWidgets('renders with footer overlay', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
footerWidget: const CircularProgressIndicator(),
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -164,7 +164,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
overlayBuilder: (context) => const Positioned(
|
||||
top: 20,
|
||||
|
|
@ -183,7 +183,7 @@ void main() {
|
|||
testWidgets('renders all overlays together', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
titleWidget: const Text('Title'),
|
||||
footerWidget: const Text('Footer'),
|
||||
|
|
@ -204,7 +204,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/invalid.mp4'),
|
||||
onVideoError: (error) {
|
||||
errorMessage = error;
|
||||
|
|
@ -224,7 +224,7 @@ void main() {
|
|||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/invalid.mp4'),
|
||||
),
|
||||
),
|
||||
|
|
@ -241,8 +241,8 @@ void main() {
|
|||
group('SplashVideoPage Static Methods', () {
|
||||
testWidgets('initialize and resume work', (WidgetTester tester) async {
|
||||
// These methods affect WidgetsBinding, so we just verify they don't throw
|
||||
SplashVideoPage.initialize();
|
||||
SplashVideoPage.resume();
|
||||
SplashVideo.initialize();
|
||||
SplashVideo.resume();
|
||||
|
||||
// Should not throw
|
||||
expect(true, isTrue);
|
||||
|
|
@ -255,7 +255,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoError: (_) {},
|
||||
|
|
@ -263,7 +263,7 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SplashVideoPage), findsOneWidget);
|
||||
expect(find.byType(SplashVideo), findsOneWidget);
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideoPage(
|
||||
home: SplashVideo(
|
||||
source: AssetSource('assets/videos/splash.mp4'),
|
||||
controller: controller,
|
||||
onVideoError: (_) {},
|
||||
|
|
|
|||
Loading…
Reference in New Issue