From 90333e61bb92b42f8e598e26009d93bf7e9100e6 Mon Sep 17 00:00:00 2001 From: Vadym Date: Wed, 3 Jun 2020 12:54:00 +0300 Subject: [PATCH 01/11] added onExpand onCollapse callbacks --- lib/backdrop.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 9dc9a89..486e326 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -164,6 +164,12 @@ class BackdropScaffold extends StatefulWidget { /// Defaults to `const Color(0xFFEEEEEE)`. final Color inactiveOverlayColor; + /// Will be called when front layer expands + final VoidCallback onExpand; + + /// Will be called when front layer collapses + final VoidCallback onCollapse; + /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ this.controller, @@ -192,7 +198,9 @@ class BackdropScaffold extends StatefulWidget { this.floatingActionButton, this.inactiveOverlayColor = const Color(0xFFEEEEEE), this.floatingActionButtonLocation, - this.floatingActionButtonAnimator + this.floatingActionButtonAnimator, + this.onExpand, + this.onCollapse }); @override @@ -254,10 +262,12 @@ class _BackdropScaffoldState extends State void showBackLayer() { if (isTopPanelVisible) controller.animateBack(-1.0); + widget.onCollapse?.call(); } void showFrontLayer() { if (isBackPanelVisible) controller.animateTo(1.0); + widget.onExpand?.call(); } double _getBackPanelHeight() => From d32a333020a0ce0471e7d3a8a62a33bc69e2d54f Mon Sep 17 00:00:00 2001 From: Vadym Date: Wed, 3 Jun 2020 13:15:02 +0300 Subject: [PATCH 02/11] fix --- lib/backdrop.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 486e326..bdf86ee 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -261,13 +261,17 @@ class _BackdropScaffoldState extends State } void showBackLayer() { - if (isTopPanelVisible) controller.animateBack(-1.0); - widget.onCollapse?.call(); + if (isTopPanelVisible) { + controller.animateBack(-1.0); + widget.onCollapse?.call(); + } } void showFrontLayer() { - if (isBackPanelVisible) controller.animateTo(1.0); - widget.onExpand?.call(); + if (isBackPanelVisible) { + controller.animateTo(1.0); + widget.onExpand?.call(); + } } double _getBackPanelHeight() => From 5a81873f9265b44d6554f986928f864a9dc7c9fc Mon Sep 17 00:00:00 2001 From: Vadym Date: Wed, 3 Jun 2020 13:20:40 +0300 Subject: [PATCH 03/11] converted tabs to whitspaces for consistency --- lib/backdrop.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index bdf86ee..a4c125b 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -199,8 +199,8 @@ class BackdropScaffold extends StatefulWidget { this.inactiveOverlayColor = const Color(0xFFEEEEEE), this.floatingActionButtonLocation, this.floatingActionButtonAnimator, - this.onExpand, - this.onCollapse + this.onExpand, + this.onCollapse }); @override @@ -262,15 +262,15 @@ class _BackdropScaffoldState extends State void showBackLayer() { if (isTopPanelVisible) { - controller.animateBack(-1.0); - widget.onCollapse?.call(); + controller.animateBack(-1.0); + widget.onCollapse?.call(); } } void showFrontLayer() { if (isBackPanelVisible) { - controller.animateTo(1.0); - widget.onExpand?.call(); + controller.animateTo(1.0); + widget.onExpand?.call(); } } From 402f92a116d6e1a83ad290e18c6b56b9398b5d5d Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 15:52:56 +0530 Subject: [PATCH 04/11] minor --- lib/backdrop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index a4c125b..801bcc8 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -200,7 +200,7 @@ class BackdropScaffold extends StatefulWidget { this.floatingActionButtonLocation, this.floatingActionButtonAnimator, this.onExpand, - this.onCollapse + this.onCollapse, }); @override From 61802e95b3c24845fc983f25ac28c838abd1d0b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D0=B4=D0=B8=D0=BC?= <44924680+vlytvyne@users.noreply.github.com> Date: Wed, 3 Jun 2020 13:29:31 +0300 Subject: [PATCH 05/11] rename callbacks Co-authored-by: Harsh Bhikadia --- lib/backdrop.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 801bcc8..947b6b7 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -165,10 +165,10 @@ class BackdropScaffold extends StatefulWidget { final Color inactiveOverlayColor; /// Will be called when front layer expands - final VoidCallback onExpand; + final VoidCallback onFrontLayerVisible; /// Will be called when front layer collapses - final VoidCallback onCollapse; + final VoidCallback onBackLayerVisible; /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ From f9077b60073bbb4e84af988afc3e2697628c83b0 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 16:06:51 +0530 Subject: [PATCH 06/11] Update lib/backdrop.dart --- lib/backdrop.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 947b6b7..46ad841 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -199,8 +199,8 @@ class BackdropScaffold extends StatefulWidget { this.inactiveOverlayColor = const Color(0xFFEEEEEE), this.floatingActionButtonLocation, this.floatingActionButtonAnimator, - this.onExpand, - this.onCollapse, + this.onFrontLayerVisible, + this.onBackLayerVisible, }); @override From 3804aa93b7bb56ae7674370b550b84fe27cd7264 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 16:07:08 +0530 Subject: [PATCH 07/11] Update lib/backdrop.dart --- lib/backdrop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 46ad841..fc343a5 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -263,7 +263,7 @@ class _BackdropScaffoldState extends State void showBackLayer() { if (isTopPanelVisible) { controller.animateBack(-1.0); - widget.onCollapse?.call(); + widget.onBackLayerVisible?.call(); } } From 927212b0aef69e827ddc2438f4c90b89fad58b05 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 16:07:17 +0530 Subject: [PATCH 08/11] Update lib/backdrop.dart --- lib/backdrop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index fc343a5..2272cb6 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -270,7 +270,7 @@ class _BackdropScaffoldState extends State void showFrontLayer() { if (isBackPanelVisible) { controller.animateTo(1.0); - widget.onExpand?.call(); + widget.onFrontLayerVisible?.call(); } } From 48408e14070ab3fff0005b024702699fe4eed007 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 16:09:00 +0530 Subject: [PATCH 09/11] Update lib/backdrop.dart --- lib/backdrop.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 2272cb6..f40fd32 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -164,10 +164,10 @@ class BackdropScaffold extends StatefulWidget { /// Defaults to `const Color(0xFFEEEEEE)`. final Color inactiveOverlayColor; - /// Will be called when front layer expands + /// Will be called when front layer is visible final VoidCallback onFrontLayerVisible; - /// Will be called when front layer collapses + /// Will be called when back layer is visible final VoidCallback onBackLayerVisible; /// Creates a backdrop scaffold to be used as a material widget. From a5d4e7f9540cef5dac7ed9b678d1e28380ff855e Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 3 Jun 2020 16:50:46 +0530 Subject: [PATCH 10/11] refactor - `showFrontLayer` -> `concealBackLayer` - `showBackLayer` -> `revealBackLayer` - `onFrontLayerVisible` -> `onBackLayerConcealed` - `onBackLayerVisible` -> `onBackLayerRevealed` https://github.com/fluttercommunity/backdrop/pull/30 --- lib/backdrop.dart | 68 ++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index f40fd32..5a31b62 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -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 @@ -149,12 +149,12 @@ class BackdropScaffold extends StatefulWidget { final Widget floatingActionButton; /// [FloatingActionButtonLocation] for the [FloatingActionButton] in the [Scaffold] - /// + /// /// 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] final FloatingActionButtonAnimator floatingActionButtonAnimator; @@ -164,11 +164,11 @@ class BackdropScaffold extends StatefulWidget { /// Defaults to `const Color(0xFFEEEEEE)`. final Color inactiveOverlayColor; - /// Will be called when front layer is visible - final VoidCallback onFrontLayerVisible; + /// Will be called when [backLayer] have been concealed. + final VoidCallback onBackLayerConcealed; - /// Will be called when back layer is visible - final VoidCallback onBackLayerVisible; + /// Will be called when [backLayer] have been revealed. + final VoidCallback onBackLayerRevealed; /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ @@ -199,8 +199,8 @@ class BackdropScaffold extends StatefulWidget { this.inactiveOverlayColor = const Color(0xFFEEEEEE), this.floatingActionButtonLocation, this.floatingActionButtonAnimator, - this.onFrontLayerVisible, - this.onBackLayerVisible, + this.onBackLayerConcealed, + this.onBackLayerRevealed, }); @override @@ -241,36 +241,50 @@ class _BackdropScaffoldState extends State if (_shouldDisposeController) _controller.dispose(); } - bool get isTopPanelVisible => + @Deprecated("Replace by the use of `isBackLayerConcealed`." + "This feature was deprecated after v1.0.0.") + 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 v1.0.0.") + 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) { + @Deprecated("Replace by the use of `revealBackLayer`." + "This feature was deprecated after v1.0.0.") + void showBackLayer() => revealBackLayer(); + + void revealBackLayer() { + if (isBackLayerConcealed) { controller.animateBack(-1.0); - widget.onBackLayerVisible?.call(); + widget.onBackLayerRevealed?.call(); } } - void showFrontLayer() { - if (isBackPanelVisible) { + @Deprecated("Replace by the use of `concealBackLayer`." + "This feature was deprecated after v1.0.0.") + void showFrontLayer() => concealBackLayer(); + + void concealBackLayer() { + if (isBackLayerRevealed) { controller.animateTo(1.0); - widget.onFrontLayerVisible?.call(); + widget.onBackLayerConcealed?.call(); } } @@ -327,7 +341,7 @@ class _BackdropScaffoldState extends State Widget _buildBackPanel() { return FocusScope( - canRequestFocus: isBackPanelVisible, + canRequestFocus: isBackLayerRevealed, child: Material( color: this.widget.backLayerBackgroundColor ?? Theme.of(context).primaryColor, @@ -358,8 +372,8 @@ class _BackdropScaffoldState extends State } Future _willPopCallback(BuildContext context) async { - if (isBackPanelVisible) { - showFrontLayer(); + if (isBackLayerRevealed) { + concealBackLayer(); return null; } return true; From adea3d166d6f015168cca51cfa8a75c19711b957 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Thu, 4 Jun 2020 15:24:05 +0530 Subject: [PATCH 11/11] minor - change deprecation warning message --- lib/backdrop.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 5a31b62..d0451c0 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -242,7 +242,7 @@ class _BackdropScaffoldState extends State } @Deprecated("Replace by the use of `isBackLayerConcealed`." - "This feature was deprecated after v1.0.0.") + "This feature was deprecated after v0.3.3.") bool get isTopPanelVisible => isBackLayerConcealed; bool get isBackLayerConcealed => @@ -250,7 +250,7 @@ class _BackdropScaffoldState extends State controller.status == AnimationStatus.forward; @Deprecated("Replace by the use of `isBackLayerRevealed`." - "This feature was deprecated after v1.0.0.") + "This feature was deprecated after v0.3.3.") bool get isBackPanelVisible => isBackLayerRevealed; bool get isBackLayerRevealed => @@ -267,7 +267,7 @@ class _BackdropScaffoldState extends State } @Deprecated("Replace by the use of `revealBackLayer`." - "This feature was deprecated after v1.0.0.") + "This feature was deprecated after v0.3.3.") void showBackLayer() => revealBackLayer(); void revealBackLayer() { @@ -278,7 +278,7 @@ class _BackdropScaffoldState extends State } @Deprecated("Replace by the use of `concealBackLayer`." - "This feature was deprecated after v1.0.0.") + "This feature was deprecated after v0.3.3.") void showFrontLayer() => concealBackLayer(); void concealBackLayer() {