Skip to content

Commit

Permalink
added defaultPanelState property
Browse files Browse the repository at this point in the history
  • Loading branch information
akshathjain committed Aug 31, 2019
1 parent 3c38a55 commit eb7d049
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
## [0.3.5] - [August 31, 2019]

#### Features
- Added the `defaultPanelState` property that changes whether the panel is either open or closed by default (`PanelState.OPEN` or `PanelState.CLOSED`)

#### Documentation
- Updated the documentation to reflect new features



## [0.3.4] - [April 16, 2019]

#### Features
- Added `slideDirection` property that changes how the panel slides open (either up or down)
- Added the `slideDirection` property that changes how the panel slides open (either up or down)

#### Documentation
- Updated the documentation to reflect new features



## [0.3.3] - [April 6, 2019]

#### Features
- Added `isDraggable` property that allows/prevents dragging of the panel
- Added the `isDraggable` property that allows/prevents dragging of the panel

#### Documentation
- Updated the documentation to reflect new features



## [0.3.2] - [April 5, 2019]

#### Documentation
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
Add the following to your `pubspec.yaml` file:
```yaml
dependencies:
sliding_up_panel: ^0.3.4
sliding_up_panel: ^0.3.5
```
<br>
Expand Down Expand Up @@ -117,6 +117,7 @@ There are several options that allow for more control:
| `parallaxOffset` | Allows for specifying the extent of the parallax effect in terms of the percentage the panel has slid up/down. Recommended values are within 0.0 and 1.0 where 0.0 is no parallax and 1.0 mimics a one-to-one scrolling effect. Defaults to a 10% parallax. |
| `isDraggable` | Allows toggling of draggability of the SlidingUpPanel. Set this to false to prevent the user from being able to drag the panel up and down. Defaults to true. |
| `slideDirection` | Either `SlideDirection.UP` or `SlideDirection.DOWN`. Indicates which way the panel should slide. Defaults to `UP`. If set to `DOWN`, the panel attaches itself to the top of the screen and is fully opened when the user swipes down on the panel. |
| `defaultPanelState` | The default state of the panel; either PanelState.OPEN or `PanelState.CLOSED`. This value defaults to `PanelState.CLOSED` which indicates that the panel is in the closed position and must be opened. `PanelState.OPEN` indicates that by default the Panel is open and must be swiped closed by the user. |

<br>
<br>
Expand Down
18 changes: 17 additions & 1 deletion lib/src/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ enum SlideDirection{
DOWN,
}

enum PanelState{
OPEN,
CLOSED
}

class SlidingUpPanel extends StatefulWidget {

/// The Widget that slides into view. When the
Expand Down Expand Up @@ -120,6 +125,12 @@ class SlidingUpPanel extends StatefulWidget {
/// down on the panel.
final SlideDirection slideDirection;

/// The default state of the panel; either PanelState.OPEN or PanelState.CLOSED.
/// This value defaults to PanelState.CLOSED which indicates that the panel is
/// in the closed position and must be opened. PanelState.OPEN indicates that
/// by default the Panel is open and must be swiped closed by the user.
final PanelState defaultPanelState;

SlidingUpPanel({
Key key,
@required this.panel,
Expand Down Expand Up @@ -151,7 +162,8 @@ class SlidingUpPanel extends StatefulWidget {
this.parallaxEnabled = false,
this.parallaxOffset = 0.1,
this.isDraggable = true,
this.slideDirection = SlideDirection.UP
this.slideDirection = SlideDirection.UP,
this.defaultPanelState = PanelState.CLOSED
}) : assert(0 <= backdropOpacity && backdropOpacity <= 1.0),
super(key: key);

Expand Down Expand Up @@ -195,6 +207,10 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
_isPanelClosed,
_isPanelShown,
);

//set the default panel state
if(widget.defaultPanelState == PanelState.CLOSED) _ac.value = 0.0;
else if (widget.defaultPanelState == PanelState.OPEN) _ac.value = 1.0;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sliding_up_panel
description: A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
version: 0.3.4
version: 0.3.5
author: Akshath Jain <[email protected]>
homepage: https://github.com/akshathjain/sliding_up_panel

Expand Down

0 comments on commit eb7d049

Please sign in to comment.