|
|
|
@ -60,6 +60,12 @@ class SliderDrawer extends StatefulWidget {
|
|
|
|
|
///
|
|
|
|
|
final bool isDraggable;
|
|
|
|
|
|
|
|
|
|
///[bool] whether show cover on child when slider is opened
|
|
|
|
|
final bool showCover;
|
|
|
|
|
|
|
|
|
|
///[Color] whether show cover on child when slider is opened
|
|
|
|
|
final Color coverColor;
|
|
|
|
|
|
|
|
|
|
///[appBar] if you set [null] then it will not display app bar
|
|
|
|
|
///
|
|
|
|
|
final Widget? appBar;
|
|
|
|
@ -104,7 +110,9 @@ class SliderDrawer extends StatefulWidget {
|
|
|
|
|
this.slideDirection = SlideDirection.LEFT_TO_RIGHT,
|
|
|
|
|
this.sliderBoxShadow,
|
|
|
|
|
this.appBar = const SliderAppBar(),
|
|
|
|
|
this.isCupertino = false})
|
|
|
|
|
this.isCupertino = false,
|
|
|
|
|
this.showCover = false,
|
|
|
|
|
this.coverColor = const Color.fromRGBO(0, 0, 0, 0.3)})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@ -119,7 +127,7 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
double _percent = 0.0;
|
|
|
|
|
|
|
|
|
|
late AnimationController _animationDrawerController;
|
|
|
|
|
late Animation _animation;
|
|
|
|
|
late Animation<double> _animation;
|
|
|
|
|
|
|
|
|
|
bool _isDragging = false;
|
|
|
|
|
|
|
|
|
@ -149,9 +157,7 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
vsync: this,
|
|
|
|
|
duration: Duration(milliseconds: widget.animationDuration));
|
|
|
|
|
|
|
|
|
|
_animation =
|
|
|
|
|
Tween<double>(begin: widget.sliderCloseSize, end: widget.sliderOpenSize)
|
|
|
|
|
.animate(CurvedAnimation(
|
|
|
|
|
_animation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
|
|
|
|
|
parent: _animationDrawerController,
|
|
|
|
|
curve: Curves.decelerate,
|
|
|
|
|
reverseCurve: Curves.decelerate));
|
|
|
|
@ -163,6 +169,9 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return LayoutBuilder(builder: (context, constrain) {
|
|
|
|
|
void onHorizontalDragUpdate(DragUpdateDetails detail) =>
|
|
|
|
|
_onHorizontalDragUpdate(detail, constrain);
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
child: Stack(children: [
|
|
|
|
|
///Menu
|
|
|
|
@ -189,15 +198,31 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
builder: (_, child) {
|
|
|
|
|
return Transform.translate(
|
|
|
|
|
offset: Utils.getOffsetValues(
|
|
|
|
|
widget.slideDirection, _animation.value),
|
|
|
|
|
child: child,
|
|
|
|
|
);
|
|
|
|
|
widget.slideDirection,
|
|
|
|
|
_animation.value,
|
|
|
|
|
widget.sliderCloseSize,
|
|
|
|
|
widget.sliderOpenSize),
|
|
|
|
|
child: Stack(children: [
|
|
|
|
|
child ?? const SizedBox(),
|
|
|
|
|
!widget.showCover || _animation.isDismissed
|
|
|
|
|
? const SizedBox()
|
|
|
|
|
: GestureDetector(
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: _onCoverTap,
|
|
|
|
|
onHorizontalDragStart: _onHorizontalDragStart,
|
|
|
|
|
onHorizontalDragEnd: _onHorizontalDragEnd,
|
|
|
|
|
onHorizontalDragUpdate: onHorizontalDragUpdate,
|
|
|
|
|
child: Container(
|
|
|
|
|
color: widget.coverColor.withAlpha(
|
|
|
|
|
(_animation.value * widget.coverColor.alpha)
|
|
|
|
|
.round())),
|
|
|
|
|
),
|
|
|
|
|
]));
|
|
|
|
|
},
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onHorizontalDragStart: _onHorizontalDragStart,
|
|
|
|
|
onHorizontalDragEnd: _onHorizontalDragEnd,
|
|
|
|
|
onHorizontalDragUpdate: (detail) =>
|
|
|
|
|
_onHorizontalDragUpdate(detail, constrain),
|
|
|
|
|
onHorizontalDragUpdate: onHorizontalDragUpdate,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
@ -303,6 +328,12 @@ class SliderDrawerState extends State<SliderDrawer>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onCoverTap() {
|
|
|
|
|
if (_animation.isCompleted) {
|
|
|
|
|
closeSlider();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move(double percent) {
|
|
|
|
|
_percent = percent;
|
|
|
|
|
_animationDrawerController.value = percent;
|
|
|
|
|