From de81b3102073815b10d4d13c54baf0dc6fa87cf8 Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 14:42:49 +0200 Subject: [PATCH 01/10] Implemented BackdropAppBar --- lib/backdrop.dart | 174 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 34 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 6fb33b5..15ea3ee 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -67,17 +67,14 @@ class BackdropScaffold extends StatefulWidget { /// Can be used to customize the behaviour of the backdrop animation. final AnimationController controller; - /// The widget assigned to the [Scaffold]'s [AppBar.title]. - final Widget title; - /// Content that should be displayed on the back layer. final Widget backLayer; /// The widget that is shown on the front layer . final Widget frontLayer; - /// Actions passed to [AppBar.actions]. - final List actions; + /// App bar used for [BackdropScaffold]. + final PreferredSizeWidget appBar; /// Defines the height of the front layer when it is in the opened state. /// @@ -104,11 +101,6 @@ class BackdropScaffold extends StatefulWidget { /// ``` final BorderRadius frontLayerBorderRadius; - /// The position of the icon button that toggles the backdrop functionality. - /// - /// Defaults to [BackdropIconPosition.leading]. - final BackdropIconPosition iconPosition; - /// A flag indicating whether the front layer should stick to the height of /// the back layer when being opened. /// @@ -136,16 +128,14 @@ class BackdropScaffold extends StatefulWidget { /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ this.controller, - this.title, this.backLayer, this.frontLayer, - this.actions = const [], + this.appBar, this.headerHeight = 32.0, this.frontLayerBorderRadius = const BorderRadius.only( topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0), ), - this.iconPosition = BackdropIconPosition.leading, this.stickyFrontLayer = false, this.animationCurve = Curves.easeInOut, this.resizeToAvoidBottomInset = true, @@ -309,16 +299,7 @@ class _BackdropScaffoldState extends State onWillPop: () => _willPopCallback(context), child: Scaffold( key: scaffoldKey, - appBar: AppBar( - title: widget.title, - actions: widget.iconPosition == BackdropIconPosition.action - ? [BackdropToggleButton()] + widget.actions - : widget.actions, - elevation: 0.0, - leading: widget.iconPosition == BackdropIconPosition.leading - ? BackdropToggleButton() - : null, - ), + appBar: widget.appBar, body: LayoutBuilder( builder: (context, constraints) { return Container( @@ -399,19 +380,144 @@ class BackdropToggleButton extends StatelessWidget { } } -/// This enum is used to specify where [BackdropToggleButton] should appear -/// within [AppBar]. -enum BackdropIconPosition { - /// Indicates that [BackdropToggleButton] should not appear at all. - none, +/// A material app bar that offers functionality for triggering the +/// [BackdropScaffold]'s functionality. It is internally implemented using the +/// [AppBar] class. +/// +/// What differs from the [AppBar] implementation is the behaviour of +/// [BackdropScaffold.leading] and [BackdropScaffold.automaticallyImplyLeading]. +class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { + /// Refer to [AppBar.leading]. + /// + /// If this is `null` and if [BackdropAppBar.automaticallyImplyLeading] is + /// set to `true`, [BackdropAppBar] sets the underlying [AppBar.leading] to + /// [BackdropToggleButton]. + final Widget leading; + + /// Refer to [AppBar.automaticallyImplyLeading]. + /// + /// If this is set to `true` and [BackdropAppBar.leading] is set to `null`, + /// [BackdropAppBar] automatically sets the underlying [AppBar.leading] + /// to [BackdropToggleButton]. + /// + /// Defaults to `true`. + final bool automaticallyImplyLeading; + + /// The widget that should be displayed as the [AppBar] title. + final Widget title; + + /// Refer to [AppBar.actions]. + final List actions; + + /// Refer to [AppBar.flexibleSpace]. + final Widget flexibleSpace; + + /// Refer to [AppBar.bottom]. + final PreferredSizeWidget bottom; + + /// Refer to [AppBar.elevation]. + /// + /// Defaults to 0.0. This differs from [AppBar.elevation]. + final double elevation; + + /// Refer to [AppBar.shape] + final ShapeBorder shape; - /// Indicates that [BackdropToggleButton] should appear at the start of - /// [AppBar]. - leading, + /// Refer to [AppBar.backgroundColor]. + final Color backgroundColor; - /// Indicates that [BackdropToggleButton] should appear as an action within - /// [AppBar.actions]. - action + /// Refer to [AppBar.brightness]. + final Brightness brightness; + + /// Refer to [AppBar.iconTheme]. + final IconThemeData iconTheme; + + /// Refer to [AppBar.actionsIconTheme]. + final IconThemeData actionsIconTheme; + + /// Refer to [AppBar.textTheme]. + final TextTheme textTheme; + + /// Refer to [AppBar.primary]. + final bool primary; + + /// Refer to [AppBar.centerTitle]. + final bool centerTitle; + + /// Refer to [AppBar.excludeHeaderSemantics]. + final bool excludeHeaderSemantics; + + /// Refer to [AppBar.iconTheme].titleSpacing + final double titleSpacing; + + /// Refer to [AppBar.toolbarOpacity]. + final double toolbarOpacity; + + /// Refer to [AppBar.bottomOpacity]. + final double bottomOpacity; + + /// Refer to [AppBar.preferredSize]. + @override + final Size preferredSize; + + /// Creates a backdrop app bar. + /// + /// For more information refer to [AppBar]. + BackdropAppBar({ + Key key, + this.leading, + this.automaticallyImplyLeading = true, + this.title, + this.actions, + this.flexibleSpace, + this.bottom, + this.elevation = 0.0, + this.shape, + this.backgroundColor, + this.brightness, + this.iconTheme, + this.actionsIconTheme, + this.textTheme, + this.primary = true, + this.centerTitle, + this.excludeHeaderSemantics = false, + this.titleSpacing = NavigationToolbar.kMiddleSpacing, + this.toolbarOpacity = 1.0, + this.bottomOpacity = 1.0, + }) : assert(automaticallyImplyLeading != null), + assert(elevation == null || elevation >= 0.0), + assert(primary != null), + assert(titleSpacing != null), + assert(toolbarOpacity != null), + assert(bottomOpacity != null), + preferredSize = Size.fromHeight( + kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)), + super(key: key); + + @override + Widget build(BuildContext context) { + return AppBar( + leading: leading ?? + (automaticallyImplyLeading ? BackdropToggleButton() : null), + title: title, + actions: actions, + flexibleSpace: flexibleSpace, + bottom: bottom, + elevation: elevation, + shape: shape, + backgroundColor: backgroundColor, + brightness: brightness, + iconTheme: iconTheme, + actionsIconTheme: actionsIconTheme, + textTheme: textTheme, + primary: primary, + centerTitle: centerTitle, + excludeHeaderSemantics: excludeHeaderSemantics, + titleSpacing: titleSpacing, + toolbarOpacity: toolbarOpacity, + bottomOpacity: bottomOpacity, + ); + } } /// Implements the back layer to be used for navigation. From 7e8e82d6e7be6b56c83109d83ed805cb06d23272 Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 14:43:49 +0200 Subject: [PATCH 02/10] Adapted example app to use BackdropAppBar --- example/lib/main.dart | 15 ++++++++------- example/lib/navigation.dart | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 9b31e35..2fc7068 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -9,19 +9,20 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'Backdrop Demo', home: BackdropScaffold( - title: Text("Backdrop Example"), + appBar: BackdropAppBar( + title: Text("Backdrop Example"), + actions: [ + BackdropToggleButton( + icon: AnimatedIcons.list_view, + ) + ], + ), backLayer: Center( child: Text("Back Layer"), ), frontLayer: Center( child: Text("Front Layer"), ), - iconPosition: BackdropIconPosition.leading, - actions: [ - BackdropToggleButton( - icon: AnimatedIcons.list_view, - ), - ], ), ); } diff --git a/example/lib/navigation.dart b/example/lib/navigation.dart index bd10b8a..3b064df 100644 --- a/example/lib/navigation.dart +++ b/example/lib/navigation.dart @@ -17,13 +17,14 @@ class _MyAppState extends State { return MaterialApp( title: 'Backdrop Demo', home: BackdropScaffold( - title: Text("Backdrop Navigation Example"), - iconPosition: BackdropIconPosition.leading, - actions: [ - BackdropToggleButton( - icon: AnimatedIcons.list_view, - ), - ], + appBar: BackdropAppBar( + title: Text("Navigation Example"), + actions: [ + BackdropToggleButton( + icon: AnimatedIcons.list_view, + ) + ], + ), stickyFrontLayer: true, frontLayer: _pages[_currentIndex], backLayer: BackdropNavigationBackLayer( From 6ad9b71ee9193de06327cf60c3feb2f03028320c Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 14:50:56 +0200 Subject: [PATCH 03/10] Adapted documentation examples to use new BackdropAppBar --- lib/backdrop.dart | 115 ++++++++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 15ea3ee..1a83e30 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -40,25 +40,26 @@ class Backdrop extends InheritedWidget { /// Usage example: /// ```dart /// Widget build(BuildContext context) { -/// return MaterialApp( -/// title: 'Backdrop Demo', -/// home: BackdropScaffold( -/// title: Text("Backdrop Example"), -/// backLayer: Center( -/// child: Text("Back Layer"), -/// ), -/// frontLayer: Center( -/// child: Text("Front Layer"), -/// ), -/// iconPosition: BackdropIconPosition.leading, -/// actions: [ -/// BackdropToggleButton( -/// icon: AnimatedIcons.list_view, -/// ), -/// ], -/// ), -/// ); -/// } +// return MaterialApp( +// title: 'Backdrop Demo', +// home: BackdropScaffold( +// appBar: BackdropAppBar( +// title: Text("Backdrop Example"), +// actions: [ +// BackdropToggleButton( +// icon: AnimatedIcons.list_view, +// ) +// ], +// ), +// backLayer: Center( +// child: Text("Back Layer"), +// ), +// frontLayer: Center( +// child: Text("Front Layer"), +// ), +// ), +// ); +// } /// ``` /// /// See also: @@ -386,6 +387,29 @@ class BackdropToggleButton extends StatelessWidget { /// /// What differs from the [AppBar] implementation is the behaviour of /// [BackdropScaffold.leading] and [BackdropScaffold.automaticallyImplyLeading]. +/// +/// Usage example: +/// ```dart +/// Widget build(BuildContext context) { +// return MaterialApp( +// title: 'Backdrop Demo', +// home: BackdropScaffold( +// appBar: BackdropAppBar( +// title: Text("Backdrop Example"), +// actions: [ +// BackdropToggleButton( +// icon: AnimatedIcons.list_view, +// ) +// ], +// ), +// ... +// ), +// ); +// } +/// ``` +/// +/// See also: +/// * [AppBar], which is the plain app bar used in material apps. class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { /// Refer to [AppBar.leading]. /// @@ -528,32 +552,33 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { /// Usage example: /// ```dart /// int _currentIndex = 0; -/// final List _pages = [Widget1(), Widget2()]; -/// -/// @override -/// Widget build(BuildContext context) { -/// return MaterialApp( -/// title: 'Backdrop Demo', -/// home: BackdropScaffold( -/// title: Text("Backdrop Navigation Example"), -/// iconPosition: BackdropIconPosition.leading, -/// actions: [ -/// BackdropToggleButton( -/// icon: AnimatedIcons.list_view, -/// ), -/// ], -/// stickyFrontLayer: true, -/// frontLayer: _pages[_currentIndex], -/// backLayer: BackdropNavigationBackLayer( -/// items: [ -/// ListTile(title: Text("Widget 1")), -/// ListTile(title: Text("Widget 2")), -/// ], -/// onTap: (int position) => {setState(() => _currentIndex = position)}, -/// ), -/// ), -/// ); -/// } +// final List _pages = [Widget1(), Widget2()]; +// +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// title: 'Backdrop Demo', +// home: BackdropScaffold( +// appBar: BackdropAppBar( +// title: Text("Navigation Example"), +// actions: [ +// BackdropToggleButton( +// icon: AnimatedIcons.list_view, +// ) +// ], +// ), +// stickyFrontLayer: true, +// frontLayer: _pages[_currentIndex], +// backLayer: BackdropNavigationBackLayer( +// items: [ +// ListTile(title: Text("Widget 1")), +// ListTile(title: Text("Widget 2")), +// ], +// onTap: (int position) => {setState(() => _currentIndex = position)}, +// ), +// ), +// ); +// } /// ``` class BackdropNavigationBackLayer extends StatelessWidget { /// The items to be inserted into the underlying [ListView] of the From 54281ce94f5d74733bb3e5869a4981e810c40905 Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 17:08:50 +0200 Subject: [PATCH 04/10] Updated readme examples --- README.md | 64 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index dda3cf4..0729551 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,20 @@ A `backLayer` and a `frontLayer` have to be defined for the backdrop to work. ```dart BackdropScaffold( + appBar: BackdropAppBar( title: Text("Backdrop Example"), - backLayer: Center( - child: Text("Back Layer"), - ), - frontLayer: Center( - child: Text("Front Layer"), - ), - iconPosition: BackdropIconPosition.leading, + actions: [ + BackdropToggleButton( + icon: AnimatedIcons.list_view, + ) + ], + ), + backLayer: Center( + child: Text("Back Layer"), + ), + frontLayer: Center( + child: Text("Front Layer"), + ), ) ```
@@ -54,33 +60,33 @@ To use backdrop for navigation, use the provided `BackdropNavigationBackLayer` a The `BackdropNavigationBackLayer` contains a property `items` representing the list elements shown on the back layer. The front layer has to be "manually" set depending on the current index, which can be accessed with the `onTap` callback. ```dart -class _MyAppState extends State { - int _currentIndex = 0; - final List _frontLayers = [Widget1(), Widget2()]; - - @override - Widget build(BuildContext context) { - return new MaterialApp( - title: 'Backdrop Demo', - home: BackdropScaffold( - title: Text("Backdrop Navigation Example"), - iconPosition: BackdropIconPosition.leading, +int _currentIndex = 0; +final List _pages = [Widget1(), Widget2()]; + +@override +Widget build(BuildContext context) { + return MaterialApp( + title: 'Backdrop Demo', + home: BackdropScaffold( + appBar: BackdropAppBar( + title: Text("Navigation Example"), actions: [ BackdropToggleButton( icon: AnimatedIcons.list_view, - ), + ) ], - frontLayer: _frontLayers[_currentIndex], - backLayer: BackdropNavigationBackLayer( - items: [ - ListTile(title: Text("Widget 1")), - ListTile(title: Text("Widget 2")), - ], - onTap: (int position) => {setState(() => _currentIndex = position)}, - ), ), - ); - } + stickyFrontLayer: true, + frontLayer: _pages[_currentIndex], + backLayer: BackdropNavigationBackLayer( + items: [ + ListTile(title: Text("Widget 1")), + ListTile(title: Text("Widget 2")), + ], + onTap: (int position) => {setState(() => _currentIndex = position)}, + ), + ), + ); } ``` From 09a35d800d75280e0bc05ab73873f2e03c08b9f2 Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 17:15:00 +0200 Subject: [PATCH 05/10] Changed order of properties, moved appBar up --- lib/backdrop.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 1a83e30..c7d98fd 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -68,15 +68,15 @@ class BackdropScaffold extends StatefulWidget { /// Can be used to customize the behaviour of the backdrop animation. final AnimationController controller; + /// App bar used for [BackdropScaffold]. + final PreferredSizeWidget appBar; + /// Content that should be displayed on the back layer. final Widget backLayer; /// The widget that is shown on the front layer . final Widget frontLayer; - /// App bar used for [BackdropScaffold]. - final PreferredSizeWidget appBar; - /// Defines the height of the front layer when it is in the opened state. /// /// This height value is only applied, if [stickyFrontLayer] @@ -129,9 +129,9 @@ class BackdropScaffold extends StatefulWidget { /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ this.controller, + this.appBar, this.backLayer, this.frontLayer, - this.appBar, this.headerHeight = 32.0, this.frontLayerBorderRadius = const BorderRadius.only( topLeft: Radius.circular(16.0), From e0372ddf8dc524097b2860f46f583e5dccd8d384 Mon Sep 17 00:00:00 2001 From: WieFel Date: Sat, 23 May 2020 21:00:14 +0200 Subject: [PATCH 06/10] Adapted documentation --- lib/backdrop.dart | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index c7d98fd..1bec1ae 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -411,14 +411,14 @@ class BackdropToggleButton extends StatelessWidget { /// See also: /// * [AppBar], which is the plain app bar used in material apps. class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { - /// Refer to [AppBar.leading]. + /// See [AppBar.leading]. /// /// If this is `null` and if [BackdropAppBar.automaticallyImplyLeading] is /// set to `true`, [BackdropAppBar] sets the underlying [AppBar.leading] to /// [BackdropToggleButton]. final Widget leading; - /// Refer to [AppBar.automaticallyImplyLeading]. + /// See [AppBar.automaticallyImplyLeading]. /// /// If this is set to `true` and [BackdropAppBar.leading] is set to `null`, /// [BackdropAppBar] automatically sets the underlying [AppBar.leading] @@ -430,63 +430,63 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { /// The widget that should be displayed as the [AppBar] title. final Widget title; - /// Refer to [AppBar.actions]. + /// See [AppBar.actions]. final List actions; - /// Refer to [AppBar.flexibleSpace]. + /// See [AppBar.flexibleSpace]. final Widget flexibleSpace; - /// Refer to [AppBar.bottom]. + /// See [AppBar.bottom]. final PreferredSizeWidget bottom; - /// Refer to [AppBar.elevation]. + /// See [AppBar.elevation]. /// /// Defaults to 0.0. This differs from [AppBar.elevation]. final double elevation; - /// Refer to [AppBar.shape] + /// See [AppBar.shape] final ShapeBorder shape; - /// Refer to [AppBar.backgroundColor]. + /// See [AppBar.backgroundColor]. final Color backgroundColor; - /// Refer to [AppBar.brightness]. + /// See [AppBar.brightness]. final Brightness brightness; - /// Refer to [AppBar.iconTheme]. + /// See [AppBar.iconTheme]. final IconThemeData iconTheme; - /// Refer to [AppBar.actionsIconTheme]. + /// See [AppBar.actionsIconTheme]. final IconThemeData actionsIconTheme; - /// Refer to [AppBar.textTheme]. + /// See [AppBar.textTheme]. final TextTheme textTheme; - /// Refer to [AppBar.primary]. + /// See [AppBar.primary]. final bool primary; - /// Refer to [AppBar.centerTitle]. + /// See [AppBar.centerTitle]. final bool centerTitle; - /// Refer to [AppBar.excludeHeaderSemantics]. + /// See [AppBar.excludeHeaderSemantics]. final bool excludeHeaderSemantics; - /// Refer to [AppBar.iconTheme].titleSpacing + /// See [AppBar.iconTheme].titleSpacing final double titleSpacing; - /// Refer to [AppBar.toolbarOpacity]. + /// See [AppBar.toolbarOpacity]. final double toolbarOpacity; - /// Refer to [AppBar.bottomOpacity]. + /// See [AppBar.bottomOpacity]. final double bottomOpacity; - /// Refer to [AppBar.preferredSize]. + /// See [AppBar.preferredSize]. @override final Size preferredSize; /// Creates a backdrop app bar. /// - /// For more information refer to [AppBar]. + /// For more information see [AppBar]. BackdropAppBar({ Key key, this.leading, From 14e61fe26b3acfe9ae4149f31eb17fd1ef048eeb Mon Sep 17 00:00:00 2001 From: Felix Wielander Date: Wed, 27 May 2020 10:54:25 +0200 Subject: [PATCH 07/10] Added title, actions, iconPosition again for backwards compatibility --- lib/backdrop.dart | 59 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index 1bec1ae..ca858fd 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -68,6 +68,12 @@ class BackdropScaffold extends StatefulWidget { /// Can be used to customize the behaviour of the backdrop animation. final AnimationController controller; + /// Deprecated. Use [BackdropAppBar.title]. + /// + /// The widget assigned to the [Scaffold]'s [AppBar.title]. + @Deprecated("Replace by BackdropAppBar's title property.") + final Widget title; + /// App bar used for [BackdropScaffold]. final PreferredSizeWidget appBar; @@ -77,6 +83,12 @@ class BackdropScaffold extends StatefulWidget { /// The widget that is shown on the front layer . final Widget frontLayer; + /// Deprecated. Use [BackdropAppBar.actions]. + /// + /// Actions passed to [AppBar.actions]. + @Deprecated("Replace by use of BackdropAppBar.") + final List actions; + /// Defines the height of the front layer when it is in the opened state. /// /// This height value is only applied, if [stickyFrontLayer] @@ -102,6 +114,15 @@ class BackdropScaffold extends StatefulWidget { /// ``` final BorderRadius frontLayerBorderRadius; + /// Deprecated. Use [BackdropAppBar]'s properties [BackdropAppBar.leading] and + /// [BackdropAppBar.automaticallyImplyLeading] to achieve the same behaviour. + /// + /// The position of the icon button that toggles the backdrop functionality. + /// + /// Defaults to [BackdropIconPosition.leading]. + @Deprecated("Replace by using BackdropAppBar.") + final BackdropIconPosition iconPosition; + /// A flag indicating whether the front layer should stick to the height of /// the back layer when being opened. /// @@ -129,14 +150,17 @@ class BackdropScaffold extends StatefulWidget { /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ this.controller, + this.title, this.appBar, this.backLayer, this.frontLayer, + this.actions = const [], this.headerHeight = 32.0, this.frontLayerBorderRadius = const BorderRadius.only( topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0), ), + this.iconPosition = BackdropIconPosition.leading, this.stickyFrontLayer = false, this.animationCurve = Curves.easeInOut, this.resizeToAvoidBottomInset = true, @@ -300,7 +324,17 @@ class _BackdropScaffoldState extends State onWillPop: () => _willPopCallback(context), child: Scaffold( key: scaffoldKey, - appBar: widget.appBar, + appBar: widget.appBar ?? + AppBar( + title: widget.title, + actions: widget.iconPosition == BackdropIconPosition.action + ? [BackdropToggleButton()] + widget.actions + : widget.actions, + elevation: 0.0, + leading: widget.iconPosition == BackdropIconPosition.leading + ? BackdropToggleButton() + : null, + ), body: LayoutBuilder( builder: (context, constraints) { return Container( @@ -335,9 +369,8 @@ class _BackdropScaffoldState extends State /// An animated button that can be used to trigger the backdrop functionality of /// [BackdropScaffold]. /// -/// This button is used directly within [BackdropScaffold]. Its position can be -/// specified using [BackdropIconPosition]. -/// This button can also be passed to the [AppBar.actions] of an [AppBar]. +/// This button is implicitly used within [BackdropAppBar]. +/// This button can also be passed to the [BackdropAppBar.actions]. /// /// When being pressed, [BackdropToggleButton] looks for a [Backdrop] instance /// above it in the widget tree and toggles its opening/closing. @@ -381,6 +414,24 @@ class BackdropToggleButton extends StatelessWidget { } } +/// Deprecated. Not needed anymore when [BackdropAppBar] is used. +/// +/// This enum is used to specify where [BackdropToggleButton] should appear +/// within [AppBar]. +@Deprecated("Replace by the use of BackdropAppBar.") +enum BackdropIconPosition { + /// Indicates that [BackdropToggleButton] should not appear at all. + none, + + /// Indicates that [BackdropToggleButton] should appear at the start of + /// [AppBar]. + leading, + + /// Indicates that [BackdropToggleButton] should appear as an action within + /// [AppBar.actions]. + action +} + /// A material app bar that offers functionality for triggering the /// [BackdropScaffold]'s functionality. It is internally implemented using the /// [AppBar] class. From eb1cf08e125f3fa4b1bb511c0a25d9ac5c2c152c Mon Sep 17 00:00:00 2001 From: Felix Wielander Date: Wed, 27 May 2020 11:11:00 +0200 Subject: [PATCH 08/10] Moved @Deprecated of properties inside constructor. --- lib/backdrop.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index ca858fd..b3f7592 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -71,7 +71,6 @@ class BackdropScaffold extends StatefulWidget { /// Deprecated. Use [BackdropAppBar.title]. /// /// The widget assigned to the [Scaffold]'s [AppBar.title]. - @Deprecated("Replace by BackdropAppBar's title property.") final Widget title; /// App bar used for [BackdropScaffold]. @@ -86,7 +85,6 @@ class BackdropScaffold extends StatefulWidget { /// Deprecated. Use [BackdropAppBar.actions]. /// /// Actions passed to [AppBar.actions]. - @Deprecated("Replace by use of BackdropAppBar.") final List actions; /// Defines the height of the front layer when it is in the opened state. @@ -120,7 +118,6 @@ class BackdropScaffold extends StatefulWidget { /// The position of the icon button that toggles the backdrop functionality. /// /// Defaults to [BackdropIconPosition.leading]. - @Deprecated("Replace by using BackdropAppBar.") final BackdropIconPosition iconPosition; /// A flag indicating whether the front layer should stick to the height of @@ -150,17 +147,24 @@ class BackdropScaffold extends StatefulWidget { /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ this.controller, - this.title, + @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.title." + "This feature was deprecated after v0.2.17.") + this.title, this.appBar, this.backLayer, this.frontLayer, - this.actions = const [], + @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.actions." + "This feature was deprecated after v0.2.17.") + this.actions = const [], this.headerHeight = 32.0, this.frontLayerBorderRadius = const BorderRadius.only( topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0), ), - this.iconPosition = BackdropIconPosition.leading, + @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.leading" + "and BackdropAppBar.automaticallyImplyLeading" + "This feature was deprecated after v0.2.17.") + this.iconPosition = BackdropIconPosition.leading, this.stickyFrontLayer = false, this.animationCurve = Curves.easeInOut, this.resizeToAvoidBottomInset = true, From 5c7f6c141356279d8ae0af9e50b629e10d4097c2 Mon Sep 17 00:00:00 2001 From: Felix Wielander Date: Wed, 27 May 2020 11:16:10 +0200 Subject: [PATCH 09/10] Small spelling correction --- lib/backdrop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index b3f7592..cf6874e 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -162,7 +162,7 @@ class BackdropScaffold extends StatefulWidget { topRight: Radius.circular(16.0), ), @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.leading" - "and BackdropAppBar.automaticallyImplyLeading" + "and BackdropAppBar.automaticallyImplyLeading." "This feature was deprecated after v0.2.17.") this.iconPosition = BackdropIconPosition.leading, this.stickyFrontLayer = false, From f30fa66b42b9943d8f338f12e8309bfe3a889666 Mon Sep 17 00:00:00 2001 From: Felix Wielander Date: Wed, 27 May 2020 11:17:32 +0200 Subject: [PATCH 10/10] Correction in deprecated message --- lib/backdrop.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/backdrop.dart b/lib/backdrop.dart index cf6874e..218a252 100644 --- a/lib/backdrop.dart +++ b/lib/backdrop.dart @@ -422,7 +422,8 @@ class BackdropToggleButton extends StatelessWidget { /// /// This enum is used to specify where [BackdropToggleButton] should appear /// within [AppBar]. -@Deprecated("Replace by the use of BackdropAppBar.") +@Deprecated("Replace by the use of BackdropAppBar." + "This feature was deprecated after v0.2.17.") enum BackdropIconPosition { /// Indicates that [BackdropToggleButton] should not appear at all. none,