Skip to content

Commit

Permalink
Add a hasNotch flag to BottomAppBar (flutter#14856)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirh committed Feb 24, 2018
1 parent c6e7ad1 commit 1f3eb50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/flutter/lib/src/material/bottom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class BottomAppBar extends StatefulWidget {
Key key,
this.color,
this.elevation: 8.0,
this.hasNotch: true,
this.child,
}) : assert(elevation != null),
assert(elevation >= 0.0),
Expand All @@ -68,6 +69,17 @@ class BottomAppBar extends StatefulWidget {
/// Defaults to 8, the appropriate elevation for bottom app bars.
final double elevation;

/// Whether to make a notch in the bottom app bar's shape for the floating
/// action button.
///
/// When true, the bottom app bar uses
/// [ScaffoldGeometry.floatingActionButtonNotch] to make a notch along its
/// top edge, where it is overlapped by the
/// [ScaffoldGeometry.floatingActionButtonArea].
///
/// When false, the shape of the bottom app bar is a rectangle.
final bool hasNotch;

@override
State createState() => new _BottomAppBarState();
}
Expand All @@ -83,8 +95,11 @@ class _BottomAppBarState extends State<BottomAppBar> {

@override
Widget build(BuildContext context) {
final CustomClipper<Path> clipper = widget.hasNotch
? new _BottomAppBarClipper(geometry: geometryListenable)
: const ShapeBorderClipper(shape: const RoundedRectangleBorder());
return new PhysicalShape(
clipper: new _BottomAppBarClipper(geometry: geometryListenable),
clipper: clipper,
elevation: widget.elevation,
// TODO(amirh): use a default color from the theme.
color: widget.color ?? Colors.white,
Expand Down
6 changes: 6 additions & 0 deletions packages/flutter/test/material/bottom_app_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ void main() {
)
);
});

// TODO(amirh): test a BottomAppBar with hasNotch=false and an overlapping
// FAB.
//
// Cannot test this before https://github.com/flutter/flutter/pull/14368
// as there is no way to make the FAB and BAB overlap.
}

// The bottom app bar clip path computation is only available at paint time.
Expand Down

0 comments on commit 1f3eb50

Please sign in to comment.