Skip to content

Commit

Permalink
added header/footer properties to the panel
Browse files Browse the repository at this point in the history
  • Loading branch information
akshathjain committed Apr 13, 2020
1 parent 24c6004 commit 14705a7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [1.0.2] - [April 13, 2020]
### Features
- Addressed issue #71, #103 - Added an optional `header` widget that floats above the `panel` and attaches to the top
- Added an optional `footer` widget that floats above the `panel` and attaches to the bottom

### Documentation
- Updated documentation to reflect new features and fixes

## [1.0.1] - [April 2, 2020]
### Fixes
- Addressed issue #94: Too much widget rebuild occurring when the user slides the panel. This fix results in huge performance benefits when using the `panelChild` and `panelBuilder` properties
Expand Down
4 changes: 3 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: ^1.0.1
sliding_up_panel: ^1.0.2
```
Note that `v1.0.0` introduced some breaking changes outlined [below](#breaking-changes).

Expand Down Expand Up @@ -97,6 +97,8 @@ There are several options that allow for more control:
|`panelBuilder` [beta]| NOTE: This feature is still in beta and may have some problems. Please open an issue on [GitHub](https://github.com/akshathjain/sliding_up_panel) if you encounter something unexpected. <br><br> Provides a `ScrollController` to attach to a scrollable object in the panel that links the panel position with the scroll position. Useful for implementing an infinite scroll behavior. If `panel` and `panelBuilder` are both non-null, `panel` will be used. |
| `collapsed` | The Widget displayed overtop the `panel` when collapsed. This fades out as the `panel` is opened. |
| `body` | The Widget that lies underneath the sliding panel. This Widget automatically sizes itself to fill the screen. |
| `header` | Optional persistent widget that floats above the `panel` and attaches to the top of the `panel`. Content at the top of the panel will be covered by this widget. Add padding to the top of the `panel` to avoid coverage. |
| `footer` | Optional persistent widget that floats above the `panel` and attaches to the bottom of the `panel`. Content at the bottom of the panel will be covered by this widget. Add padding to the bottom of the `panel` to avoid coverage. |
| `minHeight` | The height of the sliding panel when fully collapsed. |
| `maxHeight` | The height of the sliding panel when fully open. |
| `snapPoint` [beta] | NOTE: This feature is still in beta and may have some problems. Please open an issue on [GitHub](https://github.com/akshathjain/sliding_up_panel) if you encounter something unexpected. <br><br> A point between `minHeight` and `maxHeight` that the panel snaps to while animating. A fast swipe on the panel will disregard this point and go directly to the open/close position. This value is represented as a percentage of the total animation distance (`maxHeight` - `minHeight`), so it must be between 0.0 and 1.0, exclusive. |
Expand Down
28 changes: 28 additions & 0 deletions lib/src/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class SlidingUpPanel extends StatefulWidget {
/// to fill the screen.
final Widget body;

/// Optional persistent widget that floats above the [panel] and attaches
/// to the top of the [panel]. Content at the top of the panel will be covered
/// by this widget. Add padding to the bottom of the `panel` to
/// avoid coverage.
final Widget header;

/// Optional persistent widget that floats above the [panel] and
/// attaches to the bottom of the [panel]. Content at the bottom of the panel
/// will be covered by this widget. Add padding to the bottom of the `panel`
/// to avoid coverage.
final Widget footer;

/// The height of the sliding panel when fully collapsed.
final double minHeight;

Expand Down Expand Up @@ -186,6 +198,8 @@ class SlidingUpPanel extends StatefulWidget {
this.isDraggable = true,
this.slideDirection = SlideDirection.UP,
this.defaultPanelState = PanelState.CLOSED,
this.header,
this.footer
}) : assert(panel != null || panelBuilder != null),
assert(0 <= backdropOpacity && backdropOpacity <= 1.0),
assert (snapPoint == null || 0 < snapPoint && snapPoint < 1.0),
Expand Down Expand Up @@ -317,6 +331,20 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
)
),

// header
widget.header != null ? Positioned(
top: widget.slideDirection == SlideDirection.UP ? 0.0 : null,
bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null,
child: widget.header,
) : Container(),

// footer
widget.footer != null ? Positioned(
top: widget.slideDirection == SlideDirection.UP ? null : 0.0,
bottom: widget.slideDirection == SlideDirection.DOWN ? null : 0.0,
child: widget.footer
) : Container(),

// collapsed panel
Positioned(
top: widget.slideDirection == SlideDirection.UP ? 0.0 : null,
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: 1.0.1
version: 1.0.2
homepage: https://github.com/akshathjain/sliding_up_panel

environment:
Expand Down

0 comments on commit 14705a7

Please sign in to comment.