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
14 changes: 13 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 @@ -332,6 +338,7 @@ class BackdropScaffold extends StatefulWidget {
this.endDrawerEnableOpenDragGesture = true,
this.restorationId,
}) : frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(),
assert(frontLayerBoxShadow == null || frontLayerBoxShadow!.isNotEmpty),
lastmeta marked this conversation as resolved.
Show resolved Hide resolved
super(key: key);

@override
Expand Down Expand Up @@ -542,7 +549,7 @@ class BackdropScaffoldState extends State<BackdropScaffold>
}

Widget _buildFrontPanel(BuildContext context) {
return Material(
final frontPanel = Material(
color: widget.frontLayerBackgroundColor,
elevation: widget.frontLayerElevation,
borderRadius: widget.frontLayerBorderRadius,
Expand Down Expand Up @@ -572,6 +579,11 @@ class BackdropScaffoldState extends State<BackdropScaffold>
),
),
);
if (widget.frontLayerBoxShadow == null) return frontPanel;
return Container(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just warp this around the Material without any checks

decoration: BoxDecoration(boxShadow: widget.frontLayerBoxShadow),
child: frontPanel,
);
}

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