|
|
|
@ -119,9 +119,8 @@ class SliderDrawer extends StatefulWidget {
|
|
|
|
|
SliderDrawerState createState() => SliderDrawerState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
|
static const double WIDTH_GESTURE = 50.0;
|
|
|
|
|
class SliderDrawerState extends State<SliderDrawer> with TickerProviderStateMixin {
|
|
|
|
|
static const double WIDTH_GESTURE = 10.0;
|
|
|
|
|
static const double HEIGHT_GESTURE = 30.0;
|
|
|
|
|
static const double BLUR_SHADOW = 20.0;
|
|
|
|
|
double _percent = 0.0;
|
|
|
|
@ -154,8 +153,7 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
_animationDrawerController = AnimationController(
|
|
|
|
|
vsync: this,
|
|
|
|
|
duration: Duration(milliseconds: widget.animationDuration));
|
|
|
|
|
vsync: this, duration: Duration(milliseconds: widget.animationDuration));
|
|
|
|
|
|
|
|
|
|
_animation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
|
|
|
|
|
parent: _animationDrawerController,
|
|
|
|
@ -172,6 +170,12 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
void onHorizontalDragUpdate(DragUpdateDetails detail) =>
|
|
|
|
|
_onHorizontalDragUpdate(detail, constrain);
|
|
|
|
|
|
|
|
|
|
var gestureArea = GestureDetector(
|
|
|
|
|
onHorizontalDragStart: _onHorizontalDragStart,
|
|
|
|
|
onHorizontalDragEnd: _onHorizontalDragEnd,
|
|
|
|
|
onHorizontalDragUpdate: onHorizontalDragUpdate,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
child: Stack(children: [
|
|
|
|
|
///Menu
|
|
|
|
@ -197,12 +201,10 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
animation: _animationDrawerController,
|
|
|
|
|
builder: (_, child) {
|
|
|
|
|
return Transform.translate(
|
|
|
|
|
offset: Utils.getOffsetValues(
|
|
|
|
|
widget.slideDirection,
|
|
|
|
|
_animation.value,
|
|
|
|
|
widget.sliderCloseSize,
|
|
|
|
|
widget.sliderOpenSize),
|
|
|
|
|
child: Stack(children: [
|
|
|
|
|
offset: Utils.getOffsetValues(widget.slideDirection, _animation.value,
|
|
|
|
|
widget.sliderCloseSize, widget.sliderOpenSize),
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
child ?? const SizedBox(),
|
|
|
|
|
!widget.showCover || _animation.isDismissed
|
|
|
|
|
? const SizedBox()
|
|
|
|
@ -213,36 +215,49 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
onHorizontalDragEnd: _onHorizontalDragEnd,
|
|
|
|
|
onHorizontalDragUpdate: onHorizontalDragUpdate,
|
|
|
|
|
child: Container(
|
|
|
|
|
color: widget.coverColor.withAlpha(
|
|
|
|
|
(_animation.value * widget.coverColor.alpha)
|
|
|
|
|
.round())),
|
|
|
|
|
color: widget.coverColor
|
|
|
|
|
.withAlpha((_animation.value * widget.coverColor.alpha).round())),
|
|
|
|
|
),
|
|
|
|
|
]));
|
|
|
|
|
},
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onHorizontalDragStart: _onHorizontalDragStart,
|
|
|
|
|
onHorizontalDragEnd: _onHorizontalDragEnd,
|
|
|
|
|
onHorizontalDragUpdate: onHorizontalDragUpdate,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
color: _appBarColor,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
if (widget.appBar != null && widget.appBar is SliderAppBar)
|
|
|
|
|
SAppBar(
|
|
|
|
|
isCupertino: widget.isCupertino,
|
|
|
|
|
slideDirection: widget.slideDirection,
|
|
|
|
|
onTap: () => toggle(),
|
|
|
|
|
animationController: _animationDrawerController,
|
|
|
|
|
splashColor: widget.splashColor,
|
|
|
|
|
sliderAppBar: widget.appBar as SliderAppBar,
|
|
|
|
|
),
|
|
|
|
|
if (widget.appBar != null && widget.appBar is! SliderAppBar)
|
|
|
|
|
widget.appBar!,
|
|
|
|
|
Expanded(child: widget.child),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
color: _appBarColor,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
if (widget.appBar != null && widget.appBar is SliderAppBar)
|
|
|
|
|
SAppBar(
|
|
|
|
|
isCupertino: widget.isCupertino,
|
|
|
|
|
slideDirection: widget.slideDirection,
|
|
|
|
|
onTap: () => toggle(),
|
|
|
|
|
animationController: _animationDrawerController,
|
|
|
|
|
splashColor: widget.splashColor,
|
|
|
|
|
sliderAppBar: widget.appBar as SliderAppBar,
|
|
|
|
|
),
|
|
|
|
|
if (widget.appBar != null && widget.appBar is! SliderAppBar) widget.appBar!,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
widget.child,
|
|
|
|
|
widget.slideDirection == SlideDirection.TOP_TO_BOTTOM
|
|
|
|
|
? Positioned(
|
|
|
|
|
top: 0, left: 0, right: 0, height: HEIGHT_GESTURE, child: gestureArea)
|
|
|
|
|
: Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
right:
|
|
|
|
|
widget.slideDirection == SlideDirection.RIGHT_TO_LEFT ? 0 : null,
|
|
|
|
|
left:
|
|
|
|
|
widget.slideDirection == SlideDirection.LEFT_TO_RIGHT ? 0 : null,
|
|
|
|
|
bottom: 0,
|
|
|
|
|
width: WIDTH_GESTURE,
|
|
|
|
|
child: gestureArea),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -258,27 +273,10 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
|
|
|
|
|
void _onHorizontalDragStart(DragStartDetails detail) {
|
|
|
|
|
if (!widget.isDraggable) return;
|
|
|
|
|
//Check use start dragging from left edge / right edge then enable dragging
|
|
|
|
|
final rightSideWidthGesture =
|
|
|
|
|
MediaQuery.of(context).size.width - WIDTH_GESTURE;
|
|
|
|
|
if ((widget.slideDirection == SlideDirection.LEFT_TO_RIGHT &&
|
|
|
|
|
detail.localPosition.dx <= WIDTH_GESTURE) ||
|
|
|
|
|
(widget.slideDirection == SlideDirection.RIGHT_TO_LEFT &&
|
|
|
|
|
detail.localPosition.dx >=
|
|
|
|
|
rightSideWidthGesture) /*&&
|
|
|
|
|
detail.localPosition.dy <= widget.appBarHeight*/
|
|
|
|
|
) {
|
|
|
|
|
this.setState(() {
|
|
|
|
|
_isDragging = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Check use start dragging from top edge / bottom edge then enable dragging
|
|
|
|
|
if (widget.slideDirection == SlideDirection.TOP_TO_BOTTOM &&
|
|
|
|
|
detail.localPosition.dy >= HEIGHT_GESTURE) {
|
|
|
|
|
this.setState(() {
|
|
|
|
|
_isDragging = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState(() {
|
|
|
|
|
_isDragging = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onHorizontalDragEnd(DragEndDetails detail) {
|
|
|
|
@ -303,9 +301,8 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
var globalPosition = detail.globalPosition.dx;
|
|
|
|
|
globalPosition = globalPosition < 0 ? 0 : globalPosition;
|
|
|
|
|
double position = globalPosition / constraints.maxWidth;
|
|
|
|
|
var realPosition = widget.slideDirection == SlideDirection.LEFT_TO_RIGHT
|
|
|
|
|
? position
|
|
|
|
|
: (1 - position);
|
|
|
|
|
var realPosition =
|
|
|
|
|
widget.slideDirection == SlideDirection.LEFT_TO_RIGHT ? position : (1 - position);
|
|
|
|
|
move(realPosition);
|
|
|
|
|
}
|
|
|
|
|
// Open Drawer : Slider Open -> Top/Bottom
|
|
|
|
|