Skip to content

Commit

Permalink
feat: Add onDragDownPercentageChange to Miniplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Blank committed May 18, 2024
1 parent 30f0d4d commit cd6c049
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/miniplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Miniplayer extends StatefulWidget {
///This can be used to hide the BottomNavigationBar.
final ValueNotifier<double>? valueNotifier;

///Gets called with the current percentage of the drag down.
///This can be used to control the volume of the media player.
final void Function(double percentage)? onDragDownPercentageChange;

///Deprecated
@Deprecated(
"Migrate onDismiss to onDismissed as onDismiss will be used differently in a future version.")
Expand All @@ -62,6 +66,7 @@ class Miniplayer extends StatefulWidget {
this.elevation = 0,
this.backgroundColor,
this.valueNotifier,
this.onDragDownPercentageChange,
this.duration = const Duration(milliseconds: 300),
this.onDismiss,
this.onDismissed,
Expand Down Expand Up @@ -121,6 +126,13 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
heightNotifier = widget.valueNotifier!;
}

// add listener to dragDownPercentage
if (widget.onDragDownPercentageChange != null) {
dragDownPercentage.addListener(() {
widget.onDragDownPercentageChange!(dragDownPercentage.value);
});
}

_resetAnimationController();

_dragHeight = heightNotifier.value;
Expand Down

0 comments on commit cd6c049

Please sign in to comment.