added ToolBar.withSizeOffsets()
This commit is contained in:
@@ -268,15 +268,14 @@ class CardCollectionState extends State<CardCollection> {
|
||||
Widget buildToolBar() {
|
||||
return new ToolBar(
|
||||
left: new IconButton(icon: "navigation/menu", onPressed: _showDrawer),
|
||||
center: new Text('Swipe Away'),
|
||||
right: <Widget>[
|
||||
new Text(_dismissDirectionText(_dismissDirection))
|
||||
],
|
||||
bottom: new Padding(
|
||||
padding: const EdgeDims.only(left: 32.0),
|
||||
padding: const EdgeDims.only(left: 72.0),
|
||||
child: new Align(
|
||||
alignment: const FractionalOffset(0.0, 0.5),
|
||||
child: new Text("Remaining items: ${_cardModels.length}")
|
||||
child: new Text('Swipe Away: ${_cardModels.length}')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -218,18 +218,18 @@ class DropdownButton<T> extends StatelessComponent {
|
||||
return new GestureDetector(
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(border: _kDropdownUnderline),
|
||||
child: new IntrinsicWidth(
|
||||
child: new Row(<Widget>[
|
||||
new IndexedStack(items,
|
||||
key: indexedStackKey,
|
||||
index: selectedIndex,
|
||||
alignment: const FractionalOffset(0.5, 0.0)
|
||||
),
|
||||
new Container(
|
||||
child: new Icon(icon: 'navigation/arrow_drop_down', size: IconSize.s36),
|
||||
padding: const EdgeDims.only(top: 6.0)
|
||||
)
|
||||
])
|
||||
child: new Row(<Widget>[
|
||||
new IndexedStack(items,
|
||||
key: indexedStackKey,
|
||||
index: selectedIndex,
|
||||
alignment: const FractionalOffset(0.5, 0.0)
|
||||
),
|
||||
new Container(
|
||||
child: new Icon(icon: 'navigation/arrow_drop_down', size: IconSize.s36),
|
||||
padding: const EdgeDims.only(top: 6.0)
|
||||
)
|
||||
],
|
||||
justifyContent: FlexJustifyContent.collapse
|
||||
)
|
||||
),
|
||||
onTap: () {
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:flutter/widgets.dart';
|
||||
import 'constants.dart';
|
||||
import 'material.dart';
|
||||
|
||||
const int _kToolBarIndex = 1;
|
||||
const int _kBodyIndex = 0;
|
||||
const int _kToolBarIndex = 1;
|
||||
|
||||
// This layout has the same effect as putting the toolbar and body in a column
|
||||
// and making the body flexible. What's different is that in this case the
|
||||
@@ -22,18 +22,17 @@ class _ToolBarAndBodyLayout extends MultiChildLayoutDelegate {
|
||||
assert(childCount == 2);
|
||||
final BoxConstraints toolBarConstraints = constraints.loosen().tightenWidth(size.width);
|
||||
final Size toolBarSize = layoutChild(_kToolBarIndex, toolBarConstraints);
|
||||
final double topPadding = ui.window.padding.top;
|
||||
final double bodyHeight = size.height - toolBarSize.height - topPadding;
|
||||
final double bodyHeight = size.height - toolBarSize.height;
|
||||
final BoxConstraints bodyConstraints = toolBarConstraints.tightenHeight(bodyHeight);
|
||||
layoutChild(_kBodyIndex, bodyConstraints);
|
||||
positionChild(_kToolBarIndex, new Point(0.0, topPadding));
|
||||
positionChild(_kBodyIndex, new Point(0.0, topPadding + toolBarSize.height));
|
||||
positionChild(_kToolBarIndex, Point.origin);
|
||||
positionChild(_kBodyIndex, new Point(0.0, toolBarSize.height));
|
||||
}
|
||||
}
|
||||
|
||||
class Scaffold extends StatelessComponent {
|
||||
final _ToolBarAndBodyLayout _toolBarAndBodyLayout = new _ToolBarAndBodyLayout();
|
||||
final _ToolBarAndBodyLayout _toolBarAndBodyLayout = new _ToolBarAndBodyLayout();
|
||||
|
||||
class Scaffold extends StatelessComponent {
|
||||
Scaffold({
|
||||
Key key,
|
||||
this.body,
|
||||
@@ -48,14 +47,15 @@ class Scaffold extends StatelessComponent {
|
||||
final Widget floatingActionButton;
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
final offsetToolBar = toolBar?.withSizeOffsets(new EdgeDims.only(top: ui.window.padding.top));
|
||||
final Widget materialBody = body != null ? new Material(child: body) : null;
|
||||
Widget toolBarAndBody;
|
||||
if (toolBar != null && materialBody != null)
|
||||
toolBarAndBody = new CustomMultiChildLayout(<Widget>[materialBody, toolBar],
|
||||
if (offsetToolBar != null && materialBody != null)
|
||||
toolBarAndBody = new CustomMultiChildLayout(<Widget>[materialBody, offsetToolBar],
|
||||
delegate: _toolBarAndBodyLayout
|
||||
);
|
||||
else
|
||||
toolBarAndBody = toolBar ?? materialBody;
|
||||
toolBarAndBody = offsetToolBar ?? materialBody;
|
||||
|
||||
final List<Widget> bottomColumnChildren = <Widget>[];
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ class ToolBar extends StatelessComponent {
|
||||
this.bottom,
|
||||
this.level: 2,
|
||||
this.backgroundColor,
|
||||
this.textTheme
|
||||
this.textTheme,
|
||||
this.sizeOffsets: EdgeDims.zero
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget left;
|
||||
@@ -30,6 +31,21 @@ class ToolBar extends StatelessComponent {
|
||||
final int level;
|
||||
final Color backgroundColor;
|
||||
final TextTheme textTheme;
|
||||
final EdgeDims sizeOffsets;
|
||||
|
||||
ToolBar withSizeOffsets(EdgeDims offsets) {
|
||||
return new ToolBar(
|
||||
key: key,
|
||||
left: left,
|
||||
center: center,
|
||||
right: right,
|
||||
bottom: bottom,
|
||||
level: level,
|
||||
backgroundColor: backgroundColor,
|
||||
textTheme: textTheme,
|
||||
sizeOffsets: offsets
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
Color color = backgroundColor;
|
||||
@@ -83,7 +99,7 @@ class ToolBar extends StatelessComponent {
|
||||
),
|
||||
child: new DefaultTextStyle(
|
||||
style: sideStyle,
|
||||
child: new IntrinsicHeight(child: new Column(columnChildren))
|
||||
child: new Container(padding: sizeOffsets, child: new Column(columnChildren, justifyContent: FlexJustifyContent.collapse))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user