From 9e6dd01e02d60523f141397111a2aa711a9baac9 Mon Sep 17 00:00:00 2001 From: peterscodee <8vsxdxd@gmail.com> Date: Thu, 30 Jul 2020 17:01:37 +0200 Subject: [PATCH] Fixes, elevation property --- lib/miniplayer.dart | 85 +++++++++++++++++++++++++-------------------- pubspec.yaml | 10 +++--- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/lib/miniplayer.dart b/lib/miniplayer.dart index e30023a..22ce761 100644 --- a/lib/miniplayer.dart +++ b/lib/miniplayer.dart @@ -11,14 +11,16 @@ class Miniplayer extends StatefulWidget { final double maxHeight; final MiniplayerBuilder builder; final Curve curve; + final double elevation; - const Miniplayer( - {Key key, - @required this.minHeight, - @required this.maxHeight, - @required this.builder, - this.curve = Curves.easeInQuart}) - : super(key: key); + const Miniplayer({ + Key key, + @required this.minHeight, + @required this.maxHeight, + @required this.builder, + this.curve = Curves.easeInQuart, + this.elevation = 0, + }) : super(key: key); @override _MiniplayerState createState() => _MiniplayerState(); @@ -84,41 +86,50 @@ class _MiniplayerState extends State with TickerProviderStateMixin { child: Container( color: Colors.black.withOpacity(_percentage * 0.5)), ), - SizedBox( - height: snapshot.data, - child: GestureDetector( - child: widget.builder(snapshot.data, _percentage), - onTap: () { - bool up = _height != widget.maxHeight; - animateToHeight(up ? widget.maxHeight : widget.minHeight); - }, - onPanEnd: (details) async { - if (_up) - animateToHeight(widget.maxHeight); - else - animateToHeight(widget.minHeight); - }, - onPanUpdate: (details) { - _prevHeight = _height; - var h = _height -= - details.delta.dy; //details.delta.dy < 0 -> -- = + + Align( + alignment: Alignment.bottomCenter, + child: SizedBox( + height: snapshot.data, + child: GestureDetector( + child: Material( + elevation: widget.elevation, + child: Container( + constraints: BoxConstraints.expand(), + child: widget.builder(snapshot.data, _percentage), + ), + ), + onTap: () { + bool up = _height != widget.maxHeight; + animateToHeight(up ? widget.maxHeight : widget.minHeight); + }, + onPanEnd: (details) async { + if (_up) + animateToHeight(widget.maxHeight); + else + animateToHeight(widget.minHeight); + }, + onPanUpdate: (details) { + _prevHeight = _height; + var h = _height -= + details.delta.dy; //details.delta.dy < 0 -> -- = + - //Make sure height !> maxHeight && !< minHeight - if (h > widget.maxHeight) - h = widget.maxHeight; - else if (h < widget.minHeight) h = widget.minHeight; + //Make sure height !> maxHeight && !< minHeight + if (h > widget.maxHeight) + h = widget.maxHeight; + else if (h < widget.minHeight) h = widget.minHeight; - if (_prevHeight == h && - (h == widget.minHeight || h == widget.maxHeight)) - return; + if (_prevHeight == h && + (h == widget.minHeight || h == widget.maxHeight)) + return; - //print('h: ' + h.toString()); + //print('h: ' + h.toString()); - _height = h; - _up = _prevHeight < _height; + _height = h; + _up = _prevHeight < _height; - _heightController.add(h); - }, + _heightController.add(h); + }, + ), ), ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 59f4ed4..cd74a46 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: miniplayer description: Miniplayer for Flutter -version: 0.0.1 -author: David Peters -homepage: peterscode.dev +version: 0.1.0 +homepage: https://www.peterscode.dev +repository: https://github.com/peterscodee/miniplayer environment: - sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.17.0 <2.0.0" + sdk: ">=2.3.0 <3.0.0" + flutter: ">=1.0.0 <2.0.0" dependencies: flutter: