Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add onDragDown to Miniplayer #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 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 dragDownPercentage)? onDragDown;

///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.onDragDown,
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.onDragDown != null) {
dragDownPercentage.addListener(() {
widget.onDragDown!(dragDownPercentage.value);
});
}

_resetAnimationController();

_dragHeight = heightNotifier.value;
Expand Down Expand Up @@ -151,6 +163,8 @@ class _MiniplayerState extends State<Miniplayer> with TickerProviderStateMixin {
widget.controller!.removeListener(controllerListener);
}

dragDownPercentage.dispose();

super.dispose();
}

Expand Down