Commit 47aee96c authored by Ian Hickson's avatar Ian Hickson

Rename _Child to _ScaffoldSlot for clarity.

parent 5fdb0749
...@@ -21,7 +21,7 @@ import 'icon_button.dart'; ...@@ -21,7 +21,7 @@ import 'icon_button.dart';
const double _kFloatingActionButtonMargin = 16.0; // TODO(hmuller): should be device dependent const double _kFloatingActionButtonMargin = 16.0; // TODO(hmuller): should be device dependent
const Duration _kFloatingActionButtonSegue = const Duration(milliseconds: 400); const Duration _kFloatingActionButtonSegue = const Duration(milliseconds: 400);
enum _Child { enum _ScaffoldSlot {
body, body,
toolBar, toolBar,
bottomSheet, bottomSheet,
...@@ -43,16 +43,16 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { ...@@ -43,16 +43,16 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
final BoxConstraints fullWidthConstraints = looseConstraints.tighten(width: size.width); final BoxConstraints fullWidthConstraints = looseConstraints.tighten(width: size.width);
Size toolBarSize = Size.zero; Size toolBarSize = Size.zero;
if (isChild(_Child.toolBar)) { if (isChild(_ScaffoldSlot.toolBar)) {
toolBarSize = layoutChild(_Child.toolBar, fullWidthConstraints); toolBarSize = layoutChild(_ScaffoldSlot.toolBar, fullWidthConstraints);
positionChild(_Child.toolBar, Offset.zero); positionChild(_ScaffoldSlot.toolBar, Offset.zero);
} }
if (isChild(_Child.body)) { if (isChild(_ScaffoldSlot.body)) {
final double bodyHeight = size.height - toolBarSize.height; final double bodyHeight = size.height - toolBarSize.height;
final BoxConstraints bodyConstraints = fullWidthConstraints.tighten(height: bodyHeight); final BoxConstraints bodyConstraints = fullWidthConstraints.tighten(height: bodyHeight);
layoutChild(_Child.body, bodyConstraints); layoutChild(_ScaffoldSlot.body, bodyConstraints);
positionChild(_Child.body, new Offset(0.0, toolBarSize.height)); positionChild(_ScaffoldSlot.body, new Offset(0.0, toolBarSize.height));
} }
// The BottomSheet and the SnackBar are anchored to the bottom of the parent, // The BottomSheet and the SnackBar are anchored to the bottom of the parent,
...@@ -67,30 +67,30 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { ...@@ -67,30 +67,30 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
Size bottomSheetSize = Size.zero; Size bottomSheetSize = Size.zero;
Size snackBarSize = Size.zero; Size snackBarSize = Size.zero;
if (isChild(_Child.bottomSheet)) { if (isChild(_ScaffoldSlot.bottomSheet)) {
bottomSheetSize = layoutChild(_Child.bottomSheet, fullWidthConstraints); bottomSheetSize = layoutChild(_ScaffoldSlot.bottomSheet, fullWidthConstraints);
positionChild(_Child.bottomSheet, new Offset((size.width - bottomSheetSize.width) / 2.0, size.height - bottomSheetSize.height)); positionChild(_ScaffoldSlot.bottomSheet, new Offset((size.width - bottomSheetSize.width) / 2.0, size.height - bottomSheetSize.height));
} }
if (isChild(_Child.snackBar)) { if (isChild(_ScaffoldSlot.snackBar)) {
snackBarSize = layoutChild(_Child.snackBar, fullWidthConstraints); snackBarSize = layoutChild(_ScaffoldSlot.snackBar, fullWidthConstraints);
positionChild(_Child.snackBar, new Offset(0.0, size.height - snackBarSize.height)); positionChild(_ScaffoldSlot.snackBar, new Offset(0.0, size.height - snackBarSize.height));
} }
if (isChild(_Child.floatingActionButton)) { if (isChild(_ScaffoldSlot.floatingActionButton)) {
final Size fabSize = layoutChild(_Child.floatingActionButton, looseConstraints); final Size fabSize = layoutChild(_ScaffoldSlot.floatingActionButton, looseConstraints);
final double fabX = size.width - fabSize.width - _kFloatingActionButtonMargin; final double fabX = size.width - fabSize.width - _kFloatingActionButtonMargin;
double fabY = size.height - fabSize.height - _kFloatingActionButtonMargin; double fabY = size.height - fabSize.height - _kFloatingActionButtonMargin;
if (snackBarSize.height > 0.0) if (snackBarSize.height > 0.0)
fabY = math.min(fabY, size.height - snackBarSize.height - fabSize.height - _kFloatingActionButtonMargin); fabY = math.min(fabY, size.height - snackBarSize.height - fabSize.height - _kFloatingActionButtonMargin);
if (bottomSheetSize.height > 0.0) if (bottomSheetSize.height > 0.0)
fabY = math.min(fabY, size.height - bottomSheetSize.height - fabSize.height / 2.0); fabY = math.min(fabY, size.height - bottomSheetSize.height - fabSize.height / 2.0);
positionChild(_Child.floatingActionButton, new Offset(fabX, fabY)); positionChild(_ScaffoldSlot.floatingActionButton, new Offset(fabX, fabY));
} }
if (isChild(_Child.drawer)) { if (isChild(_ScaffoldSlot.drawer)) {
layoutChild(_Child.drawer, new BoxConstraints.tight(size)); layoutChild(_ScaffoldSlot.drawer, new BoxConstraints.tight(size));
positionChild(_Child.drawer, Offset.zero); positionChild(_ScaffoldSlot.drawer, Offset.zero);
} }
} }
...@@ -366,8 +366,8 @@ class ScaffoldState extends State<Scaffold> { ...@@ -366,8 +366,8 @@ class ScaffoldState extends State<Scaffold> {
} }
final List<LayoutId>children = new List<LayoutId>(); final List<LayoutId>children = new List<LayoutId>();
_addIfNonNull(children, materialBody, _Child.body); _addIfNonNull(children, materialBody, _ScaffoldSlot.body);
_addIfNonNull(children, _modifiedToolBar, _Child.toolBar); _addIfNonNull(children, _modifiedToolBar, _ScaffoldSlot.toolBar);
if (_currentBottomSheet != null || if (_currentBottomSheet != null ||
(_dismissedBottomSheets != null && _dismissedBottomSheets.isNotEmpty)) { (_dismissedBottomSheets != null && _dismissedBottomSheets.isNotEmpty)) {
...@@ -380,23 +380,23 @@ class ScaffoldState extends State<Scaffold> { ...@@ -380,23 +380,23 @@ class ScaffoldState extends State<Scaffold> {
children: bottomSheets, children: bottomSheets,
alignment: const FractionalOffset(0.5, 1.0) // bottom-aligned, centered alignment: const FractionalOffset(0.5, 1.0) // bottom-aligned, centered
); );
_addIfNonNull(children, stack, _Child.bottomSheet); _addIfNonNull(children, stack, _ScaffoldSlot.bottomSheet);
} }
if (_snackBars.isNotEmpty) if (_snackBars.isNotEmpty)
_addIfNonNull(children, _snackBars.first._widget, _Child.snackBar); _addIfNonNull(children, _snackBars.first._widget, _ScaffoldSlot.snackBar);
if (config.floatingActionButton != null) { if (config.floatingActionButton != null) {
Widget fab = new _FloatingActionButtonTransition( Widget fab = new _FloatingActionButtonTransition(
key: new ValueKey<Key>(config.floatingActionButton.key), key: new ValueKey<Key>(config.floatingActionButton.key),
child: config.floatingActionButton child: config.floatingActionButton
); );
children.add(new LayoutId(child: fab, id: _Child.floatingActionButton)); children.add(new LayoutId(child: fab, id: _ScaffoldSlot.floatingActionButton));
} }
if (config.drawer != null) { if (config.drawer != null) {
children.add(new LayoutId( children.add(new LayoutId(
id: _Child.drawer, id: _ScaffoldSlot.drawer,
child: new DrawerController( child: new DrawerController(
key: _drawerKey, key: _drawerKey,
child: config.drawer child: config.drawer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment