Skip to content

Commit fbcfacc

Browse files
committed
added proportionalChildArea - Cleaning code
1 parent b7a2908 commit fbcfacc

File tree

5 files changed

+70
-45
lines changed

5 files changed

+70
-45
lines changed

CHANGELOG.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
## [0.5.0] - 2019-10-16.
1+
## [0.5.1] 2019-11-09.
2+
3+
* **General improvement of the code**
4+
*
5+
* Added `proportionalChildArea`. if == true dynamically sets the width based on the selected offset, otherwise it leaves the width at 100% of the screen.
6+
* Possibility to set `boxShadow` also for linear animation.
7+
* When `borderSide` > 0, `boxShadow` did not work, fixed.
8+
* Cleaning code.
9+
* Update Readme.
10+
11+
## [0.5.0] 2019-10-16.
212

313
* **new Features and Documentation Updates**
414
*
515
* Added `borderRadius` field for scaffold border - (double value).
616
* Added `leftScale` and `RightScale` fields for scaffold scaling - (double value).
717
* Added `onDragUpdate(double value, InnerDraweDirection direction)` callback function.
818

9-
## [0.4.0] - 2019-08-07.
19+
## [0.4.0] 2019-08-07.
1020

1121
* **new Features and Documentation Updates**
1222
*
@@ -15,78 +25,78 @@
1525
* Parameter `animationType` replaced with `leftAnimationType` and `rightAnimationType`.
1626
* Possibility to tap the scaffold even when open with `tapScaffoldEnabled`.
1727

18-
## [0.3.0] - 2019-07-07.
28+
## [0.3.0] 2019-07-07.
1929

2030
* General improvement of the code.
2131

22-
## [0.2.9] - 2019-06-20.
32+
## [0.2.9] 2019-06-20.
2333

2434
* Updated dependencies.
2535
* Added toggle method.
2636

27-
## [0.2.8] - 2019-06-14.
37+
## [0.2.8] 2019-06-14.
2838

2939
* fix history.
3040

31-
## [0.2.7] - 2019-06-14.
41+
## [0.2.7] 2019-06-14.
3242

3343
* Cleaning code.
3444
* Update Readme.
3545

36-
## [0.2.6] - 2019-05-13.
46+
## [0.2.6] 2019-05-13.
3747

3848
* Fixed InnerDrawerCallback.
3949

40-
## [0.2.5] - 2019-04-19.
50+
## [0.2.5] 2019-04-19.
4151

4252
* General improvement of the code.
4353

44-
## [0.2.4] - 2019-04-16.
54+
## [0.2.4] 2019-04-16.
4555

4656
* Fix swipe precision.
4757

48-
## [0.2.3] - 2019-04-06.
58+
## [0.2.3] 2019-04-06.
4959

5060
* fix some problem.
5161
* General improvement of the code.
5262

53-
## [0.2.2] - 2019-02-26.
63+
## [0.2.2] 2019-02-26.
5464

5565
* fix some artifacts with linear animation.
5666

57-
## [0.2.1] - 2019-02-25.
67+
## [0.2.1] 2019-02-25.
5868

5969
* solved the problem of CupertinoThemeData that launched an assert.
6070

61-
## [0.2.0] - 2019-02-16.
71+
## [0.2.0] 2019-02-16.
6272

6373
* 3 types of animation (static - linear - quadratic)
6474
* Improved documentation.
6575

66-
## [0.1.5] - 2019-02-13.
76+
## [0.1.5] 2019-02-13.
6777

6878
* Improved documentation.
6979

70-
## [0.1.4] - 2019-02-13.
80+
## [0.1.4] 2019-02-13.
7181

7282
* Improved documentation.
7383

74-
## [0.1.3] - 2019-02-13.
84+
## [0.1.3] 2019-02-13.
7585

7686
* fixed swipe.
7787

78-
## [0.1.2] - 2019-02-13.
88+
## [0.1.2] 2019-02-13.
7989

8090
* Added side trigger - Possibility to activate/deactivate the swipe.
8191

82-
## [0.1.1] - 2019-02-12.
92+
## [0.1.1] 2019-02-12.
8393

8494
* Improved documentation.
8595

86-
## [0.1.0] - 2019-02-12.
96+
## [0.1.0] 2019-02-12.
8797

8898
* Improved documentation - General improvement of the code.
8999

90-
## [0.0.1] - 2019-02-12.
100+
## [0.0.1] 2019-02-12.
91101

92102
* Created Inner Drawer.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# flutter_inner_drawer
2-
[![pub package](https://img.shields.io/badge/pub-0.5.0-orange.svg)](https://pub.dartlang.org/packages/flutter_inner_drawer)
2+
[![pub package](https://img.shields.io/badge/pub-0.5.1-orange.svg)](https://pub.dartlang.org/packages/flutter_inner_drawer)
33
[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://github.com/Solido/awesome-flutter#drawers)
44
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/dnag88)
55

@@ -10,7 +10,7 @@ Inner Drawer is an easy way to create an internal side section (left/right) wher
1010
Add this to your package's pubspec.yaml file:
1111
```dart
1212
dependencies:
13-
flutter_inner_drawer: "^0.5.0"
13+
flutter_inner_drawer: "^0.5.1"
1414
```
1515
## Demo
1616
<div align="center">
@@ -45,9 +45,10 @@ import 'package:flutter_inner_drawer/inner_drawer.dart';
4545
colorTransition: Color.red, // default Color.black54
4646
innerDrawerCallback: (a) => print(a ),// return bool
4747
leftOffset: 0.6, // default 0.4
48-
rightOffset: 0.6,// default 0.4
48+
rightOffset: 0.6,// default 0.4
4949
leftScale: 0.9,// default 1
5050
rightScale: 0.9,// default 1
51+
proportionalChildArea : true, // default true
5152
borderRadius: 50, // default 0
5253
leftAnimationType: InnerDrawerAnimation.static, // default static
5354
rightAnimationType: InnerDrawerAnimation.quadratic,
@@ -104,6 +105,7 @@ import 'package:flutter_inner_drawer/inner_drawer.dart';
104105
|`rightOffset`|*Offset drawer width*|0.4|
105106
|`leftScale`|*Left scaffold scaling*|1|
106107
|`rightScale`|*Right scaffold scaling*|1|
108+
|`proportionalChildArea`|*If true, dynamically sets the width based on the selected offset, otherwise it leaves the width at 100% of the screen.*|true|
107109
|`borderRadius`|*For scaffold border*|0|
108110
|`onTapClose`|*Tap on the Scaffold closes it*|false|
109111
|`swipe`|*activate or deactivate the swipe*|true|

example/lib/example_1.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class _ExampleOneState extends State<ExampleOne>
3131

3232
double _dragUpdate = 0;
3333

34+
InnerDrawerDirection _direction = InnerDrawerDirection.start;
35+
3436
String _title = "One";
3537

3638
@override
@@ -60,6 +62,10 @@ class _ExampleOneState extends State<ExampleOne>
6062
leftOffset: _offset,
6163
rightOffset: _offset,
6264
swipe: _swipe,
65+
boxShadow: _direction == InnerDrawerDirection.start &&
66+
_animationType == InnerDrawerAnimation.linear
67+
? []
68+
: null,
6369
colorTransition: currentColor,
6470
leftAnimationType: _animationType,
6571
rightAnimationType: InnerDrawerAnimation.linear,
@@ -612,8 +618,10 @@ class _ExampleOneState extends State<ExampleOne>
612618
),
613619
))),
614620

615-
onDragUpdate: (double val, InnerDrawerDirection direction) =>
616-
setState(() => _dragUpdate = val),
621+
onDragUpdate: (double val, InnerDrawerDirection direction) {
622+
_direction = direction;
623+
setState(() => _dragUpdate = val);
624+
},
617625
//innerDrawerCallback: (a) => print(a),
618626
);
619627
}

lib/inner_drawer.dart

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class InnerDrawer extends StatefulWidget {
4747
this.rightOffset = 0.4,
4848
this.leftScale = 1,
4949
this.rightScale = 1,
50+
this.proportionalChildArea = true,
5051
this.borderRadius = 0,
5152
this.onTapClose = false,
5253
this.tapScaffoldEnabled = false,
@@ -84,6 +85,10 @@ class InnerDrawer extends StatefulWidget {
8485
/// values between 1 and 0
8586
final double rightScale;
8687

88+
/// The proportionalChild Area = true dynamically sets the width based on the selected offset.
89+
/// On false it leaves the width at 100% of the screen
90+
final bool proportionalChildArea;
91+
8792
/// edge radius when opening the scaffold - (defalut 0)
8893
final double borderRadius;
8994

@@ -355,7 +360,8 @@ class InnerDrawerState extends State<InnerDrawer>
355360
/// return widget with specific animation
356361
Widget _innerAnimationType(double width, InnerDrawerAnimation animationType) {
357362
final Widget container = Container(
358-
width: _width - width,
363+
//width: _width - width,
364+
width: widget.proportionalChildArea ? _width - width : _width,
359365
height: MediaQuery.of(context).size.height,
360366
child: _position == InnerDrawerDirection.start
361367
? widget.leftChild
@@ -432,24 +438,23 @@ class InnerDrawerState extends State<InnerDrawer>
432438

433439
Widget container = Container(
434440
key: _drawerKey,
435-
decoration: animationType == InnerDrawerAnimation.linear
436-
? null
437-
: BoxDecoration(
438-
boxShadow: widget.boxShadow ??
439-
[
440-
BoxShadow(
441-
color: Colors.black.withOpacity(0.5),
442-
blurRadius: 5,
443-
)
444-
]),
445-
child: widget.scaffold);
446-
447-
if (widget.borderRadius != 0)
448-
container = ClipRRect(
449-
borderRadius: BorderRadius.circular(
450-
(1 - _controller.value) * widget.borderRadius),
451-
child: container,
452-
);
441+
decoration: BoxDecoration(
442+
borderRadius: BorderRadius.circular(
443+
widget.borderRadius * (1 - _controller.value)),
444+
boxShadow: widget.boxShadow ??
445+
[
446+
BoxShadow(
447+
color: Colors.black.withOpacity(0.5),
448+
blurRadius: 5,
449+
)
450+
]),
451+
child: widget.borderRadius != 0
452+
? ClipRRect(
453+
borderRadius: BorderRadius.circular(
454+
(1 - _controller.value) * widget.borderRadius),
455+
child: widget.scaffold,
456+
)
457+
: widget.scaffold);
453458

454459
double scaleFactor = _position == InnerDrawerDirection.start
455460
? widget.leftScale

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_inner_drawer
22
description: Inner Drawer is an easy way to create an internal side section (left/right) where you can insert a list menu or other.
3-
version: 0.5.0
3+
version: 0.5.1
44
author: Antonino Di Natale <[email protected]>
55
homepage: https://github.com/Dn-a/flutter_inner_drawer
66

0 commit comments

Comments
 (0)