Skip to content

Commit

Permalink
added onPanelSlide, onPanelOpened, and onPanelClosed callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
akshathjain committed Apr 2, 2019
1 parent 6cbf189 commit 3ee4d43
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,3 +1,6 @@
# playground app
playground/

# Miscellaneous
*.class
*.log
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Expand Up @@ -23,4 +23,19 @@ Added the backdrop feature:

Other changes:
- Removed the README from the example app (pub will display the code on the website now)
- Specified Dart as the language in the README code snippets
- Specified Dart as the language in the README code snippets

## [0.2.1]

Added methods to the `PanelController`
- `setPanelPosition`
- `animatePanelToPosition`
- `getPanelPosition`
- `isPanelAnimating`

Added callbacks to the `SlidingUpPanel`
- `onPanelSlide`
- `onPanelOpened`
- `onPanelClosed`

Updated documentation to reflect changes
16 changes: 15 additions & 1 deletion lib/src/panel.dart
Expand Up @@ -79,7 +79,15 @@ class SlidingUpPanel extends StatefulWidget {
/// is called as the panel slides around with the
/// current position of the panel. The position is a double
/// between 0.0 and 1.0 where 0.0 is fully collapsed and 1.0 is fully open.
void Function(double position) onPanelSlide;
final void Function(double position) onPanelSlide;

/// This callback is called when the
/// panel is fully opened
final VoidCallback onPanelOpened;

/// This callback is called when the panel
/// is full closed
final VoidCallback onPanelClosed;

SlidingUpPanel({
Key key,
Expand All @@ -106,6 +114,8 @@ class SlidingUpPanel extends StatefulWidget {
this.backdropColor = Colors.black,
this.backdropOpacity = 0.5,
this.onPanelSlide,
this.onPanelOpened,
this.onPanelClosed
}) : assert(0 <= backdropOpacity && backdropOpacity <= 1.0),
super(key: key);

Expand All @@ -130,6 +140,10 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
setState((){});

if(widget.onPanelSlide != null) widget.onPanelSlide(_ac.value);

if(widget.onPanelOpened != null && _ac.value == 1.0) widget.onPanelOpened();

if(widget.onPanelClosed != null && _ac.value == 0.0) widget.onPanelClosed();
});
_ac.value = 0.0;

Expand Down

0 comments on commit 3ee4d43

Please sign in to comment.