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

Add axis to update and end event #10

Open
wants to merge 1 commit 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
20 changes: 18 additions & 2 deletions lib/slide_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum SlideDirection {
}

enum ButtonState { NOTCONFIRMED, CONFIRMED }
enum UpdateAxis { HORIZONTAL, VERTICAL }

class SlideButton extends StatefulWidget {
/// A child, allowing for any widget to
Expand Down Expand Up @@ -66,6 +67,9 @@ class SlideButton extends StatefulWidget {
/// itself to the right of the screen and is confirmed .
final SlideDirection slideDirection;

/// Either UpdateAxis.HORIZONTAL or UpdateAxis.VERTICAL. Indicates which gesture event is used.
final UpdateAxis updateAxis;

const SlideButton({
Key key,
this.slidingChild,
Expand All @@ -74,6 +78,7 @@ class SlideButton extends StatefulWidget {
this.confirmPercentage = 0.9,
this.initialSliderPercentage = 0.2,
this.slideDirection = SlideDirection.RIGHT,
this.updateAxis = UpdateAxis.HORIZONTAL,
this.isDraggable = true,
this.onButtonSlide,
this.onButtonOpened,
Expand Down Expand Up @@ -148,8 +153,19 @@ class _SlideButtonState extends State<SlideButton>
Align(
alignment: Alignment(-1.0, 0.0),
child: GestureDetector(
onVerticalDragUpdate: widget.isDraggable ? _onDrag : null,
onVerticalDragEnd: widget.isDraggable ? _onDragEnd : null,
onVerticalDragUpdate: (widget.updateAxis == UpdateAxis.VERTICAL)
? (widget.isDraggable ? _onDrag : null)
: null,
onVerticalDragEnd: (widget.updateAxis == UpdateAxis.VERTICAL)
? (widget.isDraggable ? _onDragEnd : null)
: null,
onHorizontalDragUpdate:
(widget.updateAxis == UpdateAxis.HORIZONTAL)
? (widget.isDraggable ? _onDrag : null)
: null,
onHorizontalDragEnd: (widget.updateAxis == UpdateAxis.HORIZONTAL)
? (widget.isDraggable ? _onDragEnd : null)
: null,
child: Container(
height: widget.height,
child: Align(
Expand Down