@@ -13,6 +13,7 @@ import 'package:youtipie/core/extensions.dart';
13
13
import 'package:namida/class/track.dart' ;
14
14
import 'package:namida/class/video.dart' ;
15
15
import 'package:namida/controller/current_color.dart' ;
16
+ import 'package:namida/controller/miniplayer_controller.dart' ;
16
17
import 'package:namida/controller/namida_channel.dart' ;
17
18
import 'package:namida/controller/navigator_controller.dart' ;
18
19
import 'package:namida/controller/player_controller.dart' ;
@@ -211,6 +212,22 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
211
212
await controller.animateTo (target);
212
213
}
213
214
215
+ /// disables controls entirely when specified. for example when minplayer is minimized & controls should't be there.
216
+ void _disableControlsListener () {
217
+ if (! mounted) return ;
218
+ final value = MiniPlayerController .inst.animation.value;
219
+ final hideUnder = widget.disableControlsUnderPercentage! ;
220
+ if (value < hideUnder && _isControlsEnabled) {
221
+ setState (() {
222
+ _isControlsEnabled = false ;
223
+ });
224
+ } else if (value >= hideUnder && ! _isControlsEnabled) {
225
+ setState (() {
226
+ _isControlsEnabled = true ;
227
+ });
228
+ }
229
+ }
230
+
214
231
@override
215
232
void initState () {
216
233
super .initState ();
@@ -252,6 +269,10 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
252
269
},
253
270
);
254
271
}
272
+
273
+ if (widget.disableControlsUnderPercentage != null ) {
274
+ MiniPlayerController .inst.animation.addListener (_disableControlsListener);
275
+ }
255
276
}
256
277
257
278
final _volumeListenerKey = 'video_widget' ;
@@ -265,6 +286,7 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
265
286
_currentDeviceVolume.close ();
266
287
_canShowBrightnessSlider.close ();
267
288
Player .inst.onVolumeChangeRemoveListener (_volumeListenerKey);
289
+ MiniPlayerController .inst.animation.removeListener (_disableControlsListener);
268
290
super .dispose ();
269
291
}
270
292
@@ -530,7 +552,8 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
530
552
_doubleTapTimer = null ;
531
553
}
532
554
533
- bool get _canShowControls => widget.showControls && ! NamidaChannel .inst.isInPip.value;
555
+ late bool _isControlsEnabled = widget.showControls;
556
+ bool get _canShowControls => _isControlsEnabled && ! NamidaChannel .inst.isInPip.value;
534
557
535
558
EdgeInsets _deviceInsets = EdgeInsets .zero;
536
559
0 commit comments