Fix nested gesture issue.

张宇轩 2 years ago
parent 1faaf0e222
commit 339d58aac7

@ -5,49 +5,49 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
flutter:
@ -59,7 +59,7 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
flutter_slider_drawer:
@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.1"
version: "2.1.2"
flutter_test:
dependency: "direct dev"
description: flutter
@ -78,35 +78,35 @@ packages:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.2"
sky_engine:
@ -118,49 +118,49 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.2"
sdks:

@ -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

@ -1,62 +1,48 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.1"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
charcode:
version: "2.1.0"
characters:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
collection:
version: "1.2.1"
clock:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.12"
convert:
version: "1.1.1"
collection:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
crypto:
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.4"
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@ -67,48 +53,34 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
matcher:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.12"
matcher:
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.6"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.8"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.3"
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@ -118,64 +90,50 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.3"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.15"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.6.1"
version: "2.1.2"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"

Loading…
Cancel
Save