From 1f3eb5034ff2372956620b2a9eb88683eee9495e Mon Sep 17 00:00:00 2001 From: amirh Date: Fri, 23 Feb 2018 18:35:40 -0800 Subject: [PATCH] Add a hasNotch flag to BottomAppBar (#14856) --- .../lib/src/material/bottom_app_bar.dart | 17 ++++++++++++++++- .../test/material/bottom_app_bar_test.dart | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index 41b7334968..3c1898e878 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -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), @@ -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(); } @@ -83,8 +95,11 @@ class _BottomAppBarState extends State { @override Widget build(BuildContext context) { + final CustomClipper 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, diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 31cdba2883..0ffa265707 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -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.