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: custom front-layer shape in BackdropScaffold #116

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions lib/src/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,27 @@ class BackdropScaffold extends StatefulWidget {
/// topRight: Radius.circular(16),
/// )
/// ```
final BorderRadius frontLayerBorderRadius;
///
/// > NOTE: This is deprecated and will be removed in future. Use
/// > [frontLayerShape] instead.
@Deprecated(
"This member is deprecated since v0.7.1 and will be removed in future. "
"Use `frontLayerShape` instead.")
final BorderRadius? frontLayerBorderRadius;

/// Defines the [ShapeBorder] applied to the front layer.
///
///
/// Defaults to
/// ```dart
/// const RoundedRectangleBorder(
/// borderRadius: BorderRadius.only(
/// topLeft: Radius.circular(16),
/// topRight: Radius.circular(16),
/// ),
/// )
/// ```
final ShapeBorder frontLayerShape;

/// Defines the elevation applied to the front layer.
///
Expand Down Expand Up @@ -291,10 +311,13 @@ class BackdropScaffold extends StatefulWidget {
this.subHeader,
this.subHeaderAlwaysActive = true,
this.headerHeight,
this.frontLayerBorderRadius = const BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
ShapeBorder frontLayerShape = const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
this.frontLayerBorderRadius,
this.frontLayerElevation = 1,
this.stickyFrontLayer = false,
this.revealBackLayerAtStart = false,
Expand Down Expand Up @@ -331,7 +354,10 @@ class BackdropScaffold extends StatefulWidget {
this.drawerEnableOpenDragGesture = true,
this.endDrawerEnableOpenDragGesture = true,
this.restorationId,
}) : frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(),
}) : frontLayerShape = frontLayerBorderRadius != null
? RoundedRectangleBorder(borderRadius: frontLayerBorderRadius)
: frontLayerShape,
frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(),
super(key: key);

@override
Expand Down Expand Up @@ -545,9 +571,9 @@ class BackdropScaffoldState extends State<BackdropScaffold>
return Material(
color: widget.frontLayerBackgroundColor,
elevation: widget.frontLayerElevation,
borderRadius: widget.frontLayerBorderRadius,
child: ClipRRect(
borderRadius: widget.frontLayerBorderRadius,
shape: widget.frontLayerShape,
child: ClipPath(
clipper: ShapeBorderClipper(shape: widget.frontLayerShape),
child: Stack(
children: <Widget>[
Column(
Expand Down