Skip to content

Commit

Permalink
new feautures and documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dn-a committed May 13, 2020
1 parent cf45073 commit 92b8084
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 57 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [0.5.6] - 2020-05-13.

* Update Documentation.
* Added `velocity` field. Allows you to set the opening and closing velocity when using the open/close methods.
* `colorTransition` field renamed to `colorTransitionChild`.
* Added `colorTransitionScaffold` field.

## [0.5.5+3] - 2020-04-29.

* Rollback issue #33.
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flutter_inner_drawer
[![pub package](https://img.shields.io/badge/pub-0.5.5+3-orange.svg)](https://pub.dartlang.org/packages/flutter_inner_drawer)
[![pub package](https://img.shields.io/badge/pub-0.5.6-orange.svg)](https://pub.dartlang.org/packages/flutter_inner_drawer)
[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://github.com/Solido/awesome-flutter#drawers)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/dnag88)

Expand All @@ -10,7 +10,7 @@ Inner Drawer is an easy way to create an internal side section (left/right) wher
Add this to your package's pubspec.yaml file:
```dart
dependencies:
flutter_inner_drawer: "^0.5.5+3"
flutter_inner_drawer: "^0.5.6"
```
## Demo
<div align="center">
Expand Down Expand Up @@ -39,7 +39,8 @@ import 'package:flutter_inner_drawer/inner_drawer.dart';
key: _innerDrawerKey,
onTapClose: true, // default false
swipe: true, // default true
colorTransition: Color.red, // default Color.black54
colorTransitionChild: Color.red, // default Color.black54
colorTransitionScaffold: Color.black54, // default Color.black54
// DEPRECATED: use offset
leftOffset: 0.6, // Will be removed in 0.6.0 version
Expand Down Expand Up @@ -140,7 +141,7 @@ import 'package:flutter_inner_drawer/inner_drawer.dart';
|`_innerDrawerKey.currentState.toggle`|*Current State of GlobalKey<InnerDrawerState>(check example) - OPEN or CLOSE*||

## Donate
If you found this project helpful or you learned something from the source code and want to thank me:
It takes time to carry on this project. If you found it useful or learned something from the source code please consider the idea of donating 5, 20, 50 € or whatever you can to support the project.
- [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/dnag88)

## Issues
Expand Down
Binary file not shown.
Binary file modified example/android/.gradle/5.6.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified example/android/.gradle/5.6.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified example/android/.gradle/5.6.2/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified example/android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import androidx.annotation.Keep;
import androidx.annotation.NonNull;

import io.flutter.embedding.engine.FlutterEngine;

/**
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export "FLUTTER_APPLICATION_PATH=D:\Android\Flutter\Package\flutter_inner_drawer
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
4 changes: 3 additions & 1 deletion example/lib/example_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ class _ExampleOneState extends State<ExampleOne>
onTapClose: _onTapToClose,
tapScaffoldEnabled: _tapScaffold,
//leftOffset: _offset,rightOffset: _offset,
velocity: 20,
offset: IDOffset.horizontal(_offset),
swipe: _swipe,
boxShadow: _direction == InnerDrawerDirection.start &&
_animationType == InnerDrawerAnimation.linear
? []
: null,
colorTransition: currentColor,
colorTransitionChild: currentColor,
colorTransitionScaffold: currentColor,
leftAnimationType: _animationType,
rightAnimationType: InnerDrawerAnimation.linear,

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _ExampleTwoState extends State<ExampleTwo> {
swipe: _swipe,
proportionalChildArea: _proportionalChildArea,
//backgroundColor: Colors.red,
colorTransition: currentColor,
colorTransitionChild: currentColor,
leftAnimationType: _animationType,
rightAnimationType: _animationType,
leftChild: Material(
Expand Down
8 changes: 7 additions & 1 deletion example/lib/example_3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ class _ExampleThreeState extends State<ExampleThree> {
),
TextField(
focusNode: myFocusNode2,
)
),
/*ListView.builder(
itemCount: 5,
itemBuilder:(BuildContext context, int index){
return ListTile(title: Text('test $index'),);
},
)*/
],
)),
)),
Expand Down
75 changes: 46 additions & 29 deletions lib/inner_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ class InnerDrawer extends StatefulWidget {
this.tapScaffoldEnabled = false,
this.swipe = true,
this.duration,
this.velocity = 1,
this.boxShadow,
this.colorTransition,
this.colorTransitionChild,
this.colorTransitionScaffold,
this.leftAnimationType = InnerDrawerAnimation.static,
this.rightAnimationType = InnerDrawerAnimation.static,
this.backgroundColor,
Expand Down Expand Up @@ -127,11 +129,17 @@ class InnerDrawer extends StatefulWidget {
/// duration animation controller
final Duration duration;

/// possibility to set the opening and closing velocity
final double velocity;

/// BoxShadow of scaffold open
final List<BoxShadow> boxShadow;

///Color of gradient
final Color colorTransition;
///Color of gradient background
final Color colorTransitionChild;

///Color of gradient background
final Color colorTransitionScaffold;

/// Static or Linear or Quadratic
final InnerDrawerAnimation leftAnimationType;
Expand All @@ -154,8 +162,10 @@ class InnerDrawer extends StatefulWidget {

class InnerDrawerState extends State<InnerDrawer>
with SingleTickerProviderStateMixin {
ColorTween _color =
ColorTween _colorTransitionChild =
ColorTween(begin: Colors.transparent, end: Colors.black54);
ColorTween _colorTransitionScaffold =
ColorTween(begin: Colors.black54, end: Colors.transparent);

double _initWidth = _kWidth;
Orientation _orientation = Orientation.portrait;
Expand Down Expand Up @@ -189,12 +199,15 @@ class InnerDrawerState extends State<InnerDrawer>
// The animation controller's state is our build state, and it changed already.
});

if (widget.colorTransition != null)
_color = ColorTween(
begin: widget.colorTransition.withOpacity(0.0),
end: widget.colorTransition);
else
_color = ColorTween(begin: Colors.transparent, end: Colors.black54);
if (widget.colorTransitionChild != null)
_colorTransitionChild = ColorTween(
begin: widget.colorTransitionChild.withOpacity(0.0),
end: widget.colorTransitionChild);

if (widget.colorTransitionScaffold != null)
_colorTransitionScaffold = ColorTween(
begin: widget.colorTransitionScaffold,
end: widget.colorTransitionScaffold.withOpacity(0.0));

if (widget.onDragUpdate != null && _controller.value < 1) {
widget.onDragUpdate((1 - _controller.value), _position);
Expand Down Expand Up @@ -260,6 +273,10 @@ class InnerDrawerState extends State<InnerDrawer>
return _initWidth;
}

double get _velocity {
return widget.velocity;
}

/// get width of screen after initState
void _updateWidth() {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down Expand Up @@ -326,7 +343,8 @@ class InnerDrawerState extends State<InnerDrawer>
void _settle(DragEndDetails details) {
if (_controller.isDismissed) return;
if (details.velocity.pixelsPerSecond.dx.abs() >= _kMinFlingVelocity) {
double visualVelocity = details.velocity.pixelsPerSecond.dx / _width;
double visualVelocity =
(details.velocity.pixelsPerSecond.dx + _velocity) / _width;

switch (_position) {
case InnerDrawerDirection.end:
Expand All @@ -352,21 +370,20 @@ class InnerDrawerState extends State<InnerDrawer>

void open({InnerDrawerDirection direction}) {
if (direction != null) _position = direction;
_controller.fling(velocity: -1);
_controller.fling(velocity: -_velocity);
}

void close({InnerDrawerDirection direction}) {
if (direction != null) _position = direction;
_controller.fling(velocity: 1);
_controller.fling(velocity: _velocity);
}

/// Open or Close InnerDrawer
void toggle({InnerDrawerDirection direction}) {
if (direction != null) _position = direction;
if (_previouslyOpened)
_controller.fling(velocity: 1);
close();
else
_controller.fling(velocity: -1);
open();
}

final GlobalKey _gestureDetectorKey = GlobalKey();
Expand Down Expand Up @@ -487,10 +504,9 @@ class InnerDrawerState extends State<InnerDrawer>
///Disable the scaffolding tap when the drawer is open
Widget _invisibleCover() {
final Container container = Container(
color: Colors.transparent,
color: _colorTransitionScaffold.evaluate(_controller),
);
if (_controller.status == AnimationStatus.dismissed &&
!widget.tapScaffoldEnabled)
if (_controller.value != 1.0 && !widget.tapScaffoldEnabled)
return BlockSemantics(
child: GestureDetector(
// On Android, the back button is used to dismiss a modal.
Expand All @@ -509,6 +525,14 @@ class InnerDrawerState extends State<InnerDrawer>
Widget _scaffold() {
assert(widget.borderRadius >= 0);

final Widget invC = _invisibleCover();
Widget scaffoldChild = widget.scaffold;

if (invC != null)
scaffoldChild = Stack(
children: <Widget>[widget.scaffold, invC],
);

Widget container = Container(
key: _drawerKey,
decoration: BoxDecoration(
Expand All @@ -525,15 +549,8 @@ class InnerDrawerState extends State<InnerDrawer>
? ClipRRect(
borderRadius: BorderRadius.circular(
(1 - _controller.value) * widget.borderRadius),
child: widget.scaffold,
)
: widget.scaffold);

final Widget invC = _invisibleCover();
if (invC != null)
container = Stack(
children: <Widget>[container, invC],
);
child: scaffoldChild)
: scaffoldChild);

if (_scaleFactor < 1)
container = Transform.scale(
Expand Down Expand Up @@ -594,7 +611,7 @@ class InnerDrawerState extends State<InnerDrawer>
_animationType == InnerDrawerAnimation.linear
? 0
: null,
color: _color.evaluate(_controller),
color: _colorTransitionChild.evaluate(_controller),
),
Align(
alignment: _drawerOuterAlignment,
Expand Down
33 changes: 13 additions & 20 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
Expand All @@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,7 +73,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
matcher:
dependency: transitive
description:
Expand All @@ -95,13 +95,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
Expand All @@ -115,7 +108,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -127,7 +120,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -162,7 +155,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
Expand All @@ -183,6 +176,6 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.4.0 <3.0.0"
dart: ">=2.6.0 <3.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_inner_drawer
description: Inner Drawer is an easy way to create an internal side section (left/right) where you can insert a list menu or other.
version: 0.5.5+3
version: 0.5.6
author: Antonino Di Natale <[email protected]>
homepage: https://github.com/Dn-a/flutter_inner_drawer

Expand Down

0 comments on commit 92b8084

Please sign in to comment.