Skip to content

Commit

Permalink
Merge branch 'master' into feature/#26-subheader
Browse files Browse the repository at this point in the history
  • Loading branch information
daadu committed Jun 4, 2020
2 parents 7d7929f + 3e25c78 commit 9031490
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 21 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@
"doc"
]
},
{
"login": "vlytvyne",
"name": "Вадим",
"avatar_url": "https://avatars0.githubusercontent.com/u/44924680?v=4",
"profile": "https://github.com/vlytvyne",
"contributions": [
"code"
]
},
],
"contributorsPerLine": 7,
"projectName": "backdrop",
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.3.3] - 4 June 2020

* refactor `showFrontLayer` to `concealBackLayer` and `showBackLayer` to `revealBackLayer` [https://github.com/fluttercommunity/backdrop/pull/30]
* added `onBackLayerConcealed` and `onBackLayerRevealed` callbacks [https://github.com/fluttercommunity/backdrop/pull/30]

## [0.3.2] - 28 May 2020

* fix typo [https://github.com/fluttercommunity/backdrop/pull/27]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![pub.dev](https://img.shields.io/pub/v/backdrop?logo=flutter)](https://pub.dev/packages/backdrop)
[![Gitter](https://badges.gitter.im/flutter-backdrop/community.svg)](https://gitter.im/flutter-backdrop/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg)](#contributors-)
[![GitHub issues](https://img.shields.io/github/issues/fluttercommunity/backdrop?logo=github)](https://github.com/fluttercommunity/backdrop/issues)
[![GitHub milestone](https://img.shields.io/github/milestones/progress-percent/fluttercommunity/backdrop/1?logo=github)](https://github.com/fluttercommunity/backdrop/milestone/1)
[![GitHub stars](https://img.shields.io/github/stars/fluttercommunity/backdrop?logo=github)](https://github.com/fluttercommunity/backdrop/stargazers)
Expand Down Expand Up @@ -131,6 +131,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="https://github.com/felixwortmann"><img src="https://avatars0.githubusercontent.com/u/45035656?v=4" width="100px;" alt=""/><br /><sub><b>Felix Wortmann</b></sub></a><br /><a href="https://github.com/fluttercommunity/backdrop/commits?author=felixwortmann" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/pgrimaud"><img src="https://avatars0.githubusercontent.com/u/1866496?v=4" width="100px;" alt=""/><br /><sub><b>Pierre Grimaud</b></sub></a><br /><a href="https://github.com/fluttercommunity/backdrop/commits?author=pgrimaud" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/vlytvyne"><img src="https://avatars0.githubusercontent.com/u/44924680?v=4" width="100px;" alt=""/><br /><sub><b>Вадим</b></sub></a><br /><a href="https://github.com/fluttercommunity/backdrop/commits?author=vlytvyne" title="Code">💻</a></td>
</tr>
</table>

Expand Down
66 changes: 47 additions & 19 deletions lib/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
/// [_BackdropScaffoldState] to be accessed from anywhere below the widget tree.
///
/// It can be used to explicitly call backdrop functionality like fling,
/// showBackLayer, showFrontLayer, etc.
/// concealBackLayer, revealBackLayer, etc.
///
/// Example:
/// ```dart
Expand Down Expand Up @@ -157,12 +157,12 @@ class BackdropScaffold extends StatefulWidget {

/// [FloatingActionButtonLocation] for the [FloatingActionButton] in the [Scaffold]
///
/// Defaults to `null` which leads Scaffold to use the default [FloatingActionButtonLocation].
/// Defaults to `null` which leads Scaffold to use the default [FloatingActionButtonLocation]
final FloatingActionButtonLocation floatingActionButtonLocation;

/// [FloatingActionButtonAnimator] for the [FloatingActionButton] in the [Scaffold]
///
/// Defaults to `null` which leads Scaffold to use the default [FloatingActionButtonAnimator].
/// Defaults to `null` which leads Scaffold to use the default [FloatingActionButtonAnimator]
final FloatingActionButtonAnimator floatingActionButtonAnimator;

/// Defines the color for the inactive front layer.
Expand All @@ -171,6 +171,12 @@ class BackdropScaffold extends StatefulWidget {
/// Defaults to `const Color(0xFFEEEEEE)`.
final Color inactiveOverlayColor;

/// Will be called when [backLayer] have been concealed.
final VoidCallback onBackLayerConcealed;

/// Will be called when [backLayer] have been revealed.
final VoidCallback onBackLayerRevealed;

/// Creates a backdrop scaffold to be used as a material widget.
BackdropScaffold({
this.controller,
Expand Down Expand Up @@ -202,6 +208,8 @@ class BackdropScaffold extends StatefulWidget {
this.inactiveOverlayColor = const Color(0xFFEEEEEE),
this.floatingActionButtonLocation,
this.floatingActionButtonAnimator,
this.onBackLayerConcealed,
this.onBackLayerRevealed,
});

@override
Expand Down Expand Up @@ -245,31 +253,51 @@ class _BackdropScaffoldState extends State<BackdropScaffold>
if (_shouldDisposeController) _controller.dispose();
}

bool get isTopPanelVisible =>
@Deprecated("Replace by the use of `isBackLayerConcealed`."
"This feature was deprecated after v0.3.2.")
bool get isTopPanelVisible => isBackLayerConcealed;

bool get isBackLayerConcealed =>
controller.status == AnimationStatus.completed ||
controller.status == AnimationStatus.forward;

bool get isBackPanelVisible {
final AnimationStatus status = controller.status;
return status == AnimationStatus.dismissed ||
status == AnimationStatus.reverse;
}
@Deprecated("Replace by the use of `isBackLayerRevealed`."
"This feature was deprecated after v0.3.2.")
bool get isBackPanelVisible => isBackLayerRevealed;

bool get isBackLayerRevealed =>
controller.status == AnimationStatus.dismissed ||
controller.status == AnimationStatus.reverse;

void fling() {
FocusScope.of(context)?.unfocus();
if (isTopPanelVisible) {
showBackLayer();
if (isBackLayerConcealed) {
revealBackLayer();
} else {
showFrontLayer();
concealBackLayer();
}
}

void showBackLayer() {
if (isTopPanelVisible) controller.animateBack(-1.0);
@Deprecated("Replace by the use of `revealBackLayer`."
"This feature was deprecated after v0.3.2.")
void showBackLayer() => revealBackLayer();

void revealBackLayer() {
if (isBackLayerConcealed) {
controller.animateBack(-1.0);
widget.onBackLayerRevealed?.call();
}
}

void showFrontLayer() {
if (isBackPanelVisible) controller.animateTo(1.0);
@Deprecated("Replace by the use of `concealBackLayer`."
"This feature was deprecated after v0.3.2.")
void showFrontLayer() => concealBackLayer();

void concealBackLayer() {
if (isBackLayerRevealed) {
controller.animateTo(1.0);
widget.onBackLayerConcealed?.call();
}
}

double _getHeaderHeight() {
Expand Down Expand Up @@ -344,7 +372,7 @@ class _BackdropScaffoldState extends State<BackdropScaffold>

Widget _buildBackPanel() {
return FocusScope(
canRequestFocus: isBackPanelVisible,
canRequestFocus: isBackLayerRevealed,
child: Material(
color: this.widget.backLayerBackgroundColor ??
Theme.of(context).primaryColor,
Expand Down Expand Up @@ -388,8 +416,8 @@ class _BackdropScaffoldState extends State<BackdropScaffold>
}

Future<bool> _willPopCallback(BuildContext context) async {
if (isBackPanelVisible) {
showFrontLayer();
if (isBackLayerRevealed) {
concealBackLayer();
return null;
}
return true;
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: backdrop
description: Backdrop implementation in dart. (https://material.io/design/components/backdrop.html)
version: 0.3.2
version: 0.3.3
homepage: https://github.com/fluttercommunity/backdrop
documentation: https://github.com/fluttercommunity/backdrop
maintainer: Harsh Bhikadia (@daadu)
Expand Down

0 comments on commit 9031490

Please sign in to comment.