Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added frontLayerBoxShadow option to BackdropScaffold #113

Closed
wants to merge 9 commits into from
22 changes: 21 additions & 1 deletion lib/src/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class BackdropScaffold extends StatefulWidget {
/// Defaults to 1.
final double frontLayerElevation;

/// Defines the shadow surrounding the front layer (cast upon the app bar).
///
/// Defaults to null.
final List<BoxShadow>? frontLayerBoxShadow;

/// Indicates the front layer should minimize to the back layer's bottom edge.
///
/// Otherwise, see [headerHeight] to specify this value.
Expand Down Expand Up @@ -296,6 +301,7 @@ class BackdropScaffold extends StatefulWidget {
topRight: Radius.circular(16),
),
this.frontLayerElevation = 1,
this.frontLayerBoxShadow,
this.stickyFrontLayer = false,
this.revealBackLayerAtStart = false,
this.animationCurve = Curves.ease,
Expand Down Expand Up @@ -542,7 +548,7 @@ class BackdropScaffoldState extends State<BackdropScaffold>
}

Widget _buildFrontPanel(BuildContext context) {
return Material(
var frontPanel = Material(
lastmeta marked this conversation as resolved.
Show resolved Hide resolved
color: widget.frontLayerBackgroundColor,
elevation: widget.frontLayerElevation,
borderRadius: widget.frontLayerBorderRadius,
Expand Down Expand Up @@ -572,6 +578,20 @@ class BackdropScaffoldState extends State<BackdropScaffold>
),
),
);
if (widget.frontLayerBoxShadow == null ||
widget.frontLayerBoxShadow!.isEmpty) {
return frontPanel;
}
return _wrapInShadow(frontPanel);
}
lastmeta marked this conversation as resolved.
Show resolved Hide resolved

Widget _wrapInShadow(Widget frontPanel) {
return Stack(children: <Widget>[
Container(
decoration: BoxDecoration(boxShadow: widget.frontLayerBoxShadow),
),
frontPanel,
]);
lastmeta marked this conversation as resolved.
Show resolved Hide resolved
}

Future<bool> _willPopCallback(BuildContext context) async {
Expand Down