Skip to content

Commit 3767380

Browse files
committed
Fix zoomAndPan not having an effect.
Hide controls while interacting with zoomAndPan.
1 parent 4340bc1 commit 3767380

File tree

4 files changed

+54
-39
lines changed

4 files changed

+54
-39
lines changed

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {
3131

3232
android {
3333
namespace "com.example.example"
34-
compileSdk 34
34+
compileSdk 35
3535

3636
compileOptions {
3737
sourceCompatibility JavaVersion.VERSION_17

example/lib/app/app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
110110
_chewieController = ChewieController(
111111
videoPlayerController: _videoPlayerController1,
112112
autoPlay: true,
113+
zoomAndPan: true,
113114
looping: true,
114115
progressIndicatorDelay:
115116
bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null,

lib/src/chewie_player.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ class ChewieController extends ChangeNotifier {
383383
cupertinoProgressColors ?? this.cupertinoProgressColors,
384384
materialProgressColors:
385385
materialProgressColors ?? this.materialProgressColors,
386+
zoomAndPan: zoomAndPan ?? this.zoomAndPan,
387+
maxScale: maxScale ?? this.maxScale,
388+
controlsSafeAreaMinimum:
389+
controlsSafeAreaMinimum ?? this.controlsSafeAreaMinimum,
390+
transformationController:
391+
transformationController ?? this.transformationController,
386392
materialSeekButtonFadeDuration:
387393
materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration,
388394
materialSeekButtonSize:

lib/src/player_with_controls.dart

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)