@@ -33,53 +33,61 @@ class PlayerWithControls extends StatelessWidget {
3333 ChewieController chewieController,
3434 BuildContext context,
3535 ) {
36- return Stack (
37- children: < Widget > [
38- if (chewieController.placeholder != null )
39- chewieController.placeholder! ,
40- InteractiveViewer (
41- transformationController: chewieController.transformationController,
42- maxScale: chewieController.maxScale,
43- panEnabled: chewieController.zoomAndPan,
44- scaleEnabled: chewieController.zoomAndPan,
45- child: Center (
36+ final playerNotifier =
37+ Provider .of <PlayerNotifier >(context, listen: false );
38+ return InteractiveViewer (
39+ transformationController: chewieController.transformationController,
40+ maxScale: chewieController.maxScale,
41+ panEnabled: chewieController.zoomAndPan,
42+ scaleEnabled: chewieController.zoomAndPan,
43+ onInteractionUpdate: chewieController.zoomAndPan
44+ ? (_) => playerNotifier.hideStuff = true
45+ : null ,
46+ onInteractionEnd: chewieController.zoomAndPan
47+ ? (_) => playerNotifier.hideStuff = false
48+ : null ,
49+ child: Stack (
50+ children: [
51+ if (chewieController.placeholder != null )
52+ chewieController.placeholder! ,
53+ Center (
4654 child: AspectRatio (
4755 aspectRatio: chewieController.aspectRatio ??
4856 chewieController.videoPlayerController.value.aspectRatio,
4957 child: VideoPlayer (chewieController.videoPlayerController),
5058 ),
5159 ),
52- ) ,
53- if (chewieController.overlay != null ) chewieController.overlay ! ,
54- if ( Theme . of (context).platform != TargetPlatform .iOS)
55- Consumer < PlayerNotifier > (
56- builder : (
57- BuildContext context ,
58- PlayerNotifier notifier ,
59- Widget ? widget,
60- ) =>
61- Visibility (
62- visible : ! notifier.hideStuff,
63- child : AnimatedOpacity (
64- opacity : notifier.hideStuff ? 0.0 : 0.8 ,
65- duration : const Duration (
66- milliseconds : 250 ,
67- ),
68- child : const DecoratedBox (
69- decoration : BoxDecoration (color : Colors .black54 ),
70- child : SizedBox . expand ( ),
60+ if (chewieController.overlay != null ) chewieController.overlay ! ,
61+ if (Theme . of (context).platform != TargetPlatform .iOS)
62+ Consumer < PlayerNotifier >(
63+ builder : (
64+ BuildContext context,
65+ PlayerNotifier notifier ,
66+ Widget ? widget ,
67+ ) =>
68+ Visibility (
69+ visible : ! notifier.hideStuff,
70+ child : AnimatedOpacity (
71+ opacity : notifier.hideStuff ? 0.0 : 0.8 ,
72+ duration : const Duration (
73+ milliseconds : 250 ,
74+ ) ,
75+ child : const DecoratedBox (
76+ decoration : BoxDecoration (color : Colors .black54),
77+ child : SizedBox . expand ( ),
78+ ),
7179 ),
7280 ),
7381 ),
74- ),
75- if ( ! chewieController.isFullScreen )
76- buildControls (context, chewieController)
77- else
78- SafeArea (
79- bottom : false ,
80- child : buildControls (context, chewieController ),
81- ) ,
82- ] ,
82+ if ( ! chewieController.isFullScreen)
83+ buildControls (context, chewieController)
84+ else
85+ SafeArea (
86+ bottom : false ,
87+ child : buildControls (context, chewieController) ,
88+ ),
89+ ] ,
90+ ) ,
8391 );
8492 }
8593
0 commit comments