Fix nested gesture issue.

master
落雨楓 2 years ago
parent 1faaf0e222
commit 05f9c682e4

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

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

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

Loading…
Cancel
Save