Commit ede5dfce authored by Adam Barth's avatar Adam Barth

[rename fixit] ToolBar -> AppBar

* left -> leading (Removes an LTR bias)
* center -> title (Widget was actually centered)
* right -> actions (Removes an LTR bias, asymmetric with leading)

Fixes #2348
parent e48c822c
...@@ -272,9 +272,9 @@ class CardCollectionState extends State<CardCollection> { ...@@ -272,9 +272,9 @@ class CardCollectionState extends State<CardCollection> {
); );
} }
Widget _buildToolBar(BuildContext context) { Widget _buildAppBar(BuildContext context) {
return new ToolBar( return new AppBar(
right: <Widget>[ actions: <Widget>[
new Text(_dismissDirectionText(_dismissDirection)) new Text(_dismissDirectionText(_dismissDirection))
], ],
flexibleSpace: (_) { flexibleSpace: (_) {
...@@ -451,7 +451,7 @@ class CardCollectionState extends State<CardCollection> { ...@@ -451,7 +451,7 @@ class CardCollectionState extends State<CardCollection> {
primarySwatch: _primaryColor primarySwatch: _primaryColor
), ),
child: new Scaffold( child: new Scaffold(
toolBar: _buildToolBar(context), appBar: _buildAppBar(context),
drawer: _buildDrawer(), drawer: _buildDrawer(),
body: body body: body
) )
......
...@@ -223,8 +223,8 @@ class DragAndDropAppState extends State<DragAndDropApp> { ...@@ -223,8 +223,8 @@ class DragAndDropAppState extends State<DragAndDropApp> {
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Drag and Drop Flutter Demo') title: new Text('Drag and Drop Flutter Demo')
), ),
body: new Column( body: new Column(
children: <Widget>[ children: <Widget>[
......
...@@ -154,7 +154,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> { ...@@ -154,7 +154,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> layers = <Widget>[ List<Widget> layers = <Widget>[
new Scaffold( new Scaffold(
toolBar: new ToolBar(center: new Text('Tap a Card')), appBar: new AppBar(title: new Text('Tap a Card')),
body: new Container( body: new Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
child: new ScrollableMixedWidgetList( child: new ScrollableMixedWidgetList(
......
...@@ -105,10 +105,10 @@ class PageableListAppState extends State<PageableListApp> { ...@@ -105,10 +105,10 @@ class PageableListAppState extends State<PageableListApp> {
); );
} }
Widget _buildToolBar() { Widget _buildAppBar() {
return new ToolBar( return new AppBar(
center: new Text('PageableList'), title: new Text('PageableList'),
right: <Widget>[ actions: <Widget>[
new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical") new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical")
] ]
); );
...@@ -126,7 +126,7 @@ class PageableListAppState extends State<PageableListApp> { ...@@ -126,7 +126,7 @@ class PageableListAppState extends State<PageableListApp> {
return new IconTheme( return new IconTheme(
data: const IconThemeData(color: Colors.white), data: const IconThemeData(color: Colors.white),
child: new Scaffold( child: new Scaffold(
toolBar: _buildToolBar(), appBar: _buildAppBar(),
drawer: _buildDrawer(), drawer: _buildDrawer(),
body: _buildBody(context) body: _buildBody(context)
) )
......
...@@ -15,8 +15,8 @@ void main() { ...@@ -15,8 +15,8 @@ void main() {
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Hardware Key Demo") title: new Text("Hardware Key Demo")
), ),
body: new Material( body: new Material(
child: new RawKeyboardDemo( child: new RawKeyboardDemo(
......
...@@ -217,8 +217,8 @@ void main() { ...@@ -217,8 +217,8 @@ void main() {
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Gestures Demo')), title: new Text('Gestures Demo')),
body: new GestureDemo() body: new GestureDemo()
); );
} }
......
...@@ -100,8 +100,8 @@ void main() { ...@@ -100,8 +100,8 @@ void main() {
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Media Query Example') title: new Text('Media Query Example')
), ),
body: new Material(child: new AdaptiveContainer(names: _kNames)) body: new Material(child: new AdaptiveContainer(names: _kNames))
); );
......
...@@ -154,8 +154,8 @@ class SectorAppState extends State<SectorApp> { ...@@ -154,8 +154,8 @@ class SectorAppState extends State<SectorApp> {
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Sector Layout in a Widget Tree') title: new Text('Sector Layout in a Widget Tree')
), ),
body: buildBody() body: buildBody()
); );
......
...@@ -121,8 +121,8 @@ void main() { ...@@ -121,8 +121,8 @@ void main() {
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Hal and Dave')), title: new Text('Hal and Dave')),
body: new Material( body: new Material(
color: Colors.grey[50], color: Colors.grey[50],
child: new StyledTextDemo() child: new StyledTextDemo()
......
...@@ -196,8 +196,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -196,8 +196,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
return new TabBarSelection<_ButtonDemo>( return new TabBarSelection<_ButtonDemo>(
values: demos, values: demos,
child: new Scaffold( child: new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Buttons"), title: new Text("Buttons"),
tabBar: new TabBar<_ButtonDemo>( tabBar: new TabBar<_ButtonDemo>(
isScrollable: true, isScrollable: true,
labels: new Map<_ButtonDemo, TabLabel>.fromIterable(demos, value: (_ButtonDemo demo) => demo.tabLabel) labels: new Map<_ButtonDemo, TabLabel>.fromIterable(demos, value: (_ButtonDemo demo) => demo.tabLabel)
......
...@@ -117,8 +117,8 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -117,8 +117,8 @@ class TravelDestinationItem extends StatelessWidget {
class CardsDemo extends StatelessWidget { class CardsDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Travel Stream") title: new Text("Travel Stream")
), ),
body: new Block( body: new Block(
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
......
...@@ -36,7 +36,7 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -36,7 +36,7 @@ class _ChipDemoState extends State<ChipDemo> {
} }
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Chips")), appBar: new AppBar(title: new Text("Chips")),
body: new Block( body: new Block(
children: chips.map((Widget widget) { children: chips.map((Widget widget) {
return new Container( return new Container(
......
...@@ -111,9 +111,9 @@ class ColorsDemo extends StatelessWidget { ...@@ -111,9 +111,9 @@ class ColorsDemo extends StatelessWidget {
return new TabBarSelection<ColorSwatch>( return new TabBarSelection<ColorSwatch>(
values: colorSwatches, values: colorSwatches,
child: new Scaffold( child: new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
elevation: 0, elevation: 0,
center: new Text("Colors"), title: new Text("Colors"),
tabBar: new TabBar<ColorSwatch>( tabBar: new TabBar<ColorSwatch>(
isScrollable: true, isScrollable: true,
labels: new Map<ColorSwatch, TabLabel>.fromIterable(colorSwatches, value: (ColorSwatch swatch) { labels: new Map<ColorSwatch, TabLabel>.fromIterable(colorSwatches, value: (ColorSwatch swatch) {
......
...@@ -31,7 +31,7 @@ class _DatePickerDemoState extends State<DatePickerDemo> { ...@@ -31,7 +31,7 @@ class _DatePickerDemoState extends State<DatePickerDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return return
new Scaffold( new Scaffold(
toolBar: new ToolBar(center: new Text("Date Picker")), appBar: new AppBar(title: new Text("Date Picker")),
body: new Column( body: new Column(
children: <Widget>[ children: <Widget>[
new Text(new DateFormat.yMMMd().format(_selectedDate)), new Text(new DateFormat.yMMMd().format(_selectedDate)),
......
...@@ -80,8 +80,8 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -80,8 +80,8 @@ class DialogDemoState extends State<DialogDemo> {
return new Scaffold( return new Scaffold(
key: scaffoldKey, key: scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Dialogs') title: new Text('Dialogs')
), ),
body: new Block( body: new Block(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0), padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
......
...@@ -20,7 +20,7 @@ class _DropDownDemoState extends State<DropDownDemo> { ...@@ -20,7 +20,7 @@ class _DropDownDemoState extends State<DropDownDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Dropdown Button")), appBar: new AppBar(title: new Text("Dropdown Button")),
body: new Center( body: new Center(
child: new DropDownButton<String>( child: new DropDownButton<String>(
items: buildItems(), items: buildItems(),
......
...@@ -18,8 +18,8 @@ class FitnessDemo extends StatelessWidget { ...@@ -18,8 +18,8 @@ class FitnessDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Fitness") title: new Text("Fitness")
), ),
body: new _FitnessDemoContents() body: new _FitnessDemoContents()
); );
......
...@@ -85,8 +85,8 @@ class FlexibleSpaceDemoState extends State<FlexibleSpaceDemo> { ...@@ -85,8 +85,8 @@ class FlexibleSpaceDemoState extends State<FlexibleSpaceDemo> {
appBarHeight: appBarHeight, appBarHeight: appBarHeight,
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
appBarBehavior: AppBarBehavior.scroll, appBarBehavior: AppBarBehavior.scroll,
toolBar: new ToolBar( appBar: new AppBar(
right: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: Icons.create, icon: Icons.create,
tooltip: 'Search' tooltip: 'Search'
......
...@@ -141,13 +141,13 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { ...@@ -141,13 +141,13 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
left: new IconButton( leading: new IconButton(
icon: Icons.clear, icon: Icons.clear,
onPressed: () { handleDismissButton(context); } onPressed: () { handleDismissButton(context); }
), ),
center: new Text('New Event'), title: new Text('New Event'),
right: <Widget> [ actions: <Widget> [
new FlatButton( new FlatButton(
child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)), child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)),
onPressed: () { onPressed: () {
......
...@@ -41,8 +41,8 @@ class GridDemoPhotoItem extends StatelessWidget { ...@@ -41,8 +41,8 @@ class GridDemoPhotoItem extends StatelessWidget {
Navigator.push(context, new MaterialPageRoute<Null>( Navigator.push(context, new MaterialPageRoute<Null>(
builder: (BuildContext context) { builder: (BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text(photo.title) title: new Text(photo.title)
), ),
body: new Material( body: new Material(
child: new AssetImage( child: new AssetImage(
...@@ -172,9 +172,9 @@ class GridListDemoState extends State<GridListDemo> { ...@@ -172,9 +172,9 @@ class GridListDemoState extends State<GridListDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Orientation orientation = MediaQuery.of(context).orientation; final Orientation orientation = MediaQuery.of(context).orientation;
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Grid List'), title: new Text('Grid List'),
right: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: Icons.more_vert, icon: Icons.more_vert,
onPressed: () { showTileStyleMenu(context); }, onPressed: () { showTileStyleMenu(context); },
......
...@@ -66,8 +66,8 @@ class IconsDemoState extends State<IconsDemo> { ...@@ -66,8 +66,8 @@ class IconsDemoState extends State<IconsDemo> {
final TextStyle textStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color); final TextStyle textStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Icons') title: new Text('Icons')
), ),
body: new IconTheme( body: new IconTheme(
data: new IconThemeData(opacity: iconOpacity), data: new IconThemeData(opacity: iconOpacity),
......
...@@ -125,9 +125,9 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> { ...@@ -125,9 +125,9 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Swipe Items to Dismiss'), title: new Text('Swipe Items to Dismiss'),
right: <Widget>[ actions: <Widget>[
new PopupMenuButton<LeaveBehindDemoAction>( new PopupMenuButton<LeaveBehindDemoAction>(
onSelected: handleDemoAction, onSelected: handleDemoAction,
items: <PopupMenuEntry<LeaveBehindDemoAction>>[ items: <PopupMenuEntry<LeaveBehindDemoAction>>[
......
...@@ -174,9 +174,9 @@ class ListDemoState extends State<ListDemo> { ...@@ -174,9 +174,9 @@ class ListDemoState extends State<ListDemo> {
return new Scaffold( return new Scaffold(
key: scaffoldKey, key: scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Scrolling List\n$itemSizeText$layoutText'), title: new Text('Scrolling List\n$itemSizeText$layoutText'),
right: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: Icons.sort_by_alpha, icon: Icons.sort_by_alpha,
tooltip: 'Sort', tooltip: 'Sort',
......
...@@ -56,15 +56,15 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -56,15 +56,15 @@ class MenuDemoState extends State<MenuDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Menus'), title: new Text('Menus'),
right: <Widget>[ actions: <Widget>[
new PopupMenuButton<String>( new PopupMenuButton<String>(
onSelected: showMenuSelection, onSelected: showMenuSelection,
items: <PopupMenuItem<String>>[ items: <PopupMenuItem<String>>[
new PopupMenuItem<String>( new PopupMenuItem<String>(
value: 'ToolBar Menu', value: 'AppBar Menu',
child: new Text('ToolBar Menu') child: new Text('AppBar Menu')
), ),
new PopupMenuItem<String>( new PopupMenuItem<String>(
value: 'Right Here', value: 'Right Here',
......
...@@ -13,7 +13,7 @@ class ModalBottomSheetDemo extends StatelessWidget { ...@@ -13,7 +13,7 @@ class ModalBottomSheetDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Modal Bottom Sheet")), appBar: new AppBar(title: new Text("Modal Bottom Sheet")),
body: new Center( body: new Center(
child: new Container( child: new Container(
width: 200.0, width: 200.0,
......
...@@ -23,7 +23,7 @@ class PageSelectorDemo extends StatelessWidget { ...@@ -23,7 +23,7 @@ class PageSelectorDemo extends StatelessWidget {
]; ];
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text('Page Selector')), appBar: new AppBar(title: new Text('Page Selector')),
body: new TabBarSelection<IconData>( body: new TabBarSelection<IconData>(
values: icons, values: icons,
child: new Builder( child: new Builder(
......
...@@ -28,7 +28,7 @@ class PersistentBottomSheetDemo extends StatelessWidget { ...@@ -28,7 +28,7 @@ class PersistentBottomSheetDemo extends StatelessWidget {
Widget build(BuildContext notUsed) { // Can't find the Scaffold from this context. Widget build(BuildContext notUsed) { // Can't find the Scaffold from this context.
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Persistent Bottom Sheet")), appBar: new AppBar(title: new Text("Persistent Bottom Sheet")),
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
child: new Icon(icon: Icons.add), child: new Icon(icon: Icons.add),
backgroundColor: Colors.redAccent[200] backgroundColor: Colors.redAccent[200]
......
...@@ -83,7 +83,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> { ...@@ -83,7 +83,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text('Progress Indicators')), appBar: new AppBar(title: new Text('Progress Indicators')),
body: new DefaultTextStyle( body: new DefaultTextStyle(
style: Theme.of(context).textTheme.title, style: Theme.of(context).textTheme.title,
child: new GestureDetector( child: new GestureDetector(
......
...@@ -48,8 +48,8 @@ class _StatusBarGraphic extends _BarGraphic { ...@@ -48,8 +48,8 @@ class _StatusBarGraphic extends _BarGraphic {
); );
} }
class _ToolBarGraphic extends _BarGraphic { class _AppBarGraphic extends _BarGraphic {
_ToolBarGraphic() : super( _AppBarGraphic() : super(
height: 48.0, height: 48.0,
color: Colors.blue[400], color: Colors.blue[400],
leftText: 'Tool Bar', leftText: 'Tool Bar',
...@@ -113,7 +113,7 @@ const String _introText = ...@@ -113,7 +113,7 @@ const String _introText =
class ScrollingTechniquesDemo extends StatelessWidget { class ScrollingTechniquesDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text('Scrolling Techniques')), appBar: new AppBar(title: new Text('Scrolling Techniques')),
body: new Padding( body: new Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: new Block( child: new Block(
...@@ -127,7 +127,7 @@ class ScrollingTechniquesDemo extends StatelessWidget { ...@@ -127,7 +127,7 @@ class ScrollingTechniquesDemo extends StatelessWidget {
titleText: 'Standard', titleText: 'Standard',
barGraphics: <Widget>[ barGraphics: <Widget>[
new _StatusBarGraphic(), new _StatusBarGraphic(),
new _ToolBarGraphic() new _AppBarGraphic()
] ]
), ),
new _TechniqueItem( new _TechniqueItem(
...@@ -135,7 +135,7 @@ class ScrollingTechniquesDemo extends StatelessWidget { ...@@ -135,7 +135,7 @@ class ScrollingTechniquesDemo extends StatelessWidget {
builder: (BuildContext context) => new FlexibleSpaceDemo(), builder: (BuildContext context) => new FlexibleSpaceDemo(),
barGraphics: <Widget>[ barGraphics: <Widget>[
new _StatusBarGraphic(), new _StatusBarGraphic(),
new _ToolBarGraphic(), new _AppBarGraphic(),
new _TabBarGraphic() new _TabBarGraphic()
] ]
), ),
...@@ -144,7 +144,7 @@ class ScrollingTechniquesDemo extends StatelessWidget { ...@@ -144,7 +144,7 @@ class ScrollingTechniquesDemo extends StatelessWidget {
builder: (BuildContext context) => new FlexibleSpaceDemo(), builder: (BuildContext context) => new FlexibleSpaceDemo(),
barGraphics: <Widget>[ barGraphics: <Widget>[
new _StatusBarGraphic(), new _StatusBarGraphic(),
new _ToolBarGraphic(), new _AppBarGraphic(),
new _FlexibleSpaceGraphic() new _FlexibleSpaceGraphic()
] ]
) )
......
...@@ -13,7 +13,7 @@ class _SliderDemoState extends State<SliderDemo> { ...@@ -13,7 +13,7 @@ class _SliderDemoState extends State<SliderDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Sliders")), appBar: new AppBar(title: new Text("Sliders")),
body: new Block(children: <Widget>[ body: new Block(children: <Widget>[
new Container( new Container(
height: 100.0, height: 100.0,
......
...@@ -58,8 +58,8 @@ class SnackBarDemo extends StatelessWidget { ...@@ -58,8 +58,8 @@ class SnackBarDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('SnackBar') title: new Text('SnackBar')
), ),
body: new Builder( body: new Builder(
// Create an inner BuildContext so that the snackBar onPressed methods // Create an inner BuildContext so that the snackBar onPressed methods
......
...@@ -28,8 +28,8 @@ class TabsDemo extends StatelessWidget { ...@@ -28,8 +28,8 @@ class TabsDemo extends StatelessWidget {
return new TabBarSelection<IconData>( return new TabBarSelection<IconData>(
values: icons, values: icons,
child: new Scaffold( child: new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Scrollable Tabs"), title: new Text("Scrollable Tabs"),
tabBar: new TabBar<IconData>( tabBar: new TabBar<IconData>(
isScrollable: true, isScrollable: true,
labels: new Map<IconData, TabLabel>.fromIterable( labels: new Map<IconData, TabLabel>.fromIterable(
......
...@@ -94,8 +94,8 @@ class _TabsFabDemoState extends State<TabsFabDemo> { ...@@ -94,8 +94,8 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
onChanged: _handleTabSelection, onChanged: _handleTabSelection,
child: new Scaffold( child: new Scaffold(
key: scaffoldKey, key: scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("FAB per Tab"), title: new Text("FAB per Tab"),
tabBar: new TabBar<_Page>( tabBar: new TabBar<_Page>(
labels: new Map<_Page, TabLabel>.fromIterable(pages, value: (_Page page) => page.tabLabel) labels: new Map<_Page, TabLabel>.fromIterable(pages, value: (_Page page) => page.tabLabel)
) )
......
...@@ -62,8 +62,8 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -62,8 +62,8 @@ class TextFieldDemoState extends State<TextFieldDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Text Fields') title: new Text('Text Fields')
), ),
body: new Block( body: new Block(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
......
...@@ -27,7 +27,7 @@ class _TimePickerDemoState extends State<TimePickerDemo> { ...@@ -27,7 +27,7 @@ class _TimePickerDemoState extends State<TimePickerDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Time Picker")), appBar: new AppBar(title: new Text("Time Picker")),
body: new Column( body: new Column(
children: <Widget>[ children: <Widget>[
new Text('$_selectedTime'), new Text('$_selectedTime'),
......
...@@ -33,7 +33,7 @@ class _ToggleControlsDemoState extends State<ToggleControlsDemo> { ...@@ -33,7 +33,7 @@ class _ToggleControlsDemoState extends State<ToggleControlsDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Selection Controls")), appBar: new AppBar(title: new Text("Selection Controls")),
body: new Column( body: new Column(
children: <Widget>[ children: <Widget>[
new Row( new Row(
......
...@@ -13,8 +13,8 @@ class TooltipDemo extends StatelessWidget { ...@@ -13,8 +13,8 @@ class TooltipDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Tooltip') title: new Text('Tooltip')
), ),
body: new Builder( body: new Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
class TwoLevelListDemo extends StatelessWidget { class TwoLevelListDemo extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text('Expand/Collapse List Control')), appBar: new AppBar(title: new Text('Expand/Collapse List Control')),
body: new Padding( body: new Padding(
padding: const EdgeInsets.all(0.0), padding: const EdgeInsets.all(0.0),
child: new TwoLevelList( child: new TwoLevelList(
......
...@@ -62,7 +62,7 @@ class TypographyDemo extends StatelessWidget { ...@@ -62,7 +62,7 @@ class TypographyDemo extends StatelessWidget {
} }
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text('Typography')), appBar: new AppBar(title: new Text('Typography')),
body: new Block(children: styleItems) body: new Block(children: styleItems)
); );
} }
......
...@@ -61,8 +61,8 @@ class _WeatherDemoState extends State<WeatherDemo> { ...@@ -61,8 +61,8 @@ class _WeatherDemoState extends State<WeatherDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!assetsLoaded) { if (!assetsLoaded) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Weather") title: new Text("Weather")
), ),
body: new Container( body: new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
...@@ -73,8 +73,8 @@ class _WeatherDemoState extends State<WeatherDemo> { ...@@ -73,8 +73,8 @@ class _WeatherDemoState extends State<WeatherDemo> {
} }
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text("Weather") title: new Text("Weather")
), ),
body: new Material( body: new Material(
child: new Stack( child: new Stack(
......
...@@ -50,7 +50,7 @@ class GalleryHomeState extends State<GalleryHome> { ...@@ -50,7 +50,7 @@ class GalleryHomeState extends State<GalleryHome> {
return new Scaffold( return new Scaffold(
appBarHeight: 128.0, appBarHeight: 128.0,
drawer: new GalleryDrawer(), drawer: new GalleryDrawer(),
toolBar: new ToolBar( appBar: new AppBar(
flexibleSpace: (BuildContext context) { flexibleSpace: (BuildContext context) {
return new Container( return new Container(
padding: const EdgeInsets.only(left: 16.0, bottom: 24.0), padding: const EdgeInsets.only(left: 16.0, bottom: 24.0),
......
...@@ -39,7 +39,7 @@ class GallerySection extends StatelessWidget { ...@@ -39,7 +39,7 @@ class GallerySection extends StatelessWidget {
appBarHeight: appBarHeight, appBarHeight: appBarHeight,
appBarBehavior: AppBarBehavior.scroll, appBarBehavior: AppBarBehavior.scroll,
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
toolBar: new ToolBar( appBar: new AppBar(
flexibleSpace: (BuildContext context) => new FlexibleSpaceBar(title: new Text(title)) flexibleSpace: (BuildContext context) => new FlexibleSpaceBar(title: new Text(title))
), ),
body: new Material( body: new Material(
......
...@@ -206,11 +206,11 @@ class StockHomeState extends State<StockHome> { ...@@ -206,11 +206,11 @@ class StockHomeState extends State<StockHome> {
Navigator.popAndPushNamed(context, '/settings'); Navigator.popAndPushNamed(context, '/settings');
} }
Widget buildToolBar() { Widget buildAppBar() {
return new ToolBar( return new AppBar(
elevation: 0, elevation: 0,
center: new Text(StockStrings.of(context).title()), title: new Text(StockStrings.of(context).title()),
right: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: Icons.search, icon: Icons.search,
onPressed: _handleSearchBegin, onPressed: _handleSearchBegin,
...@@ -303,14 +303,14 @@ class StockHomeState extends State<StockHome> { ...@@ -303,14 +303,14 @@ class StockHomeState extends State<StockHome> {
// TODO(abarth): Should we factor this into a SearchBar in the framework? // TODO(abarth): Should we factor this into a SearchBar in the framework?
Widget buildSearchBar() { Widget buildSearchBar() {
return new ToolBar( return new AppBar(
left: new IconButton( leading: new IconButton(
icon: Icons.arrow_back, icon: Icons.arrow_back,
color: Theme.of(context).accentColor, color: Theme.of(context).accentColor,
onPressed: _handleSearchEnd, onPressed: _handleSearchEnd,
tooltip: 'Back' tooltip: 'Back'
), ),
center: new Input( title: new Input(
value: _searchQuery, value: _searchQuery,
autofocus: true, autofocus: true,
hintText: 'Search stocks', hintText: 'Search stocks',
...@@ -341,7 +341,7 @@ class StockHomeState extends State<StockHome> { ...@@ -341,7 +341,7 @@ class StockHomeState extends State<StockHome> {
values: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio], values: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio],
child: new Scaffold( child: new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
toolBar: _isSearching ? buildSearchBar() : buildToolBar(), appBar: _isSearching ? buildSearchBar() : buildAppBar(),
floatingActionButton: buildFloatingActionButton(), floatingActionButton: buildFloatingActionButton(),
drawer: _buildDrawer(context), drawer: _buildDrawer(context),
body: new TabBarView<StockHomeTab>( body: new TabBarView<StockHomeTab>(
......
...@@ -94,9 +94,9 @@ class StockSettingsState extends State<StockSettings> { ...@@ -94,9 +94,9 @@ class StockSettingsState extends State<StockSettings> {
config.updater(value); config.updater(value);
} }
Widget buildToolBar(BuildContext context) { Widget buildAppBar(BuildContext context) {
return new ToolBar( return new AppBar(
center: new Text('Settings') title: new Text('Settings')
); );
} }
...@@ -247,7 +247,7 @@ class StockSettingsState extends State<StockSettings> { ...@@ -247,7 +247,7 @@ class StockSettingsState extends State<StockSettings> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: buildToolBar(context), appBar: buildAppBar(context),
body: buildSettingsPane(context) body: buildSettingsPane(context)
); );
} }
......
...@@ -73,8 +73,8 @@ class StockSymbolPage extends StatelessWidget { ...@@ -73,8 +73,8 @@ class StockSymbolPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text(stock.name) title: new Text(stock.name)
), ),
body: new Block( body: new Block(
children: <Widget>[ children: <Widget>[
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
library material; library material;
export 'src/material/app.dart'; export 'src/material/app.dart';
export 'src/material/app_bar.dart';
export 'src/material/bottom_sheet.dart'; export 'src/material/bottom_sheet.dart';
export 'src/material/button.dart'; export 'src/material/button.dart';
export 'src/material/card.dart'; export 'src/material/card.dart';
...@@ -56,7 +57,6 @@ export 'src/material/theme_data.dart'; ...@@ -56,7 +57,6 @@ export 'src/material/theme_data.dart';
export 'src/material/time_picker.dart'; export 'src/material/time_picker.dart';
export 'src/material/time_picker_dialog.dart'; export 'src/material/time_picker_dialog.dart';
export 'src/material/toggleable.dart'; export 'src/material/toggleable.dart';
export 'src/material/tool_bar.dart';
export 'src/material/tooltip.dart'; export 'src/material/tooltip.dart';
export 'src/material/two_level_list.dart'; export 'src/material/two_level_list.dart';
export 'src/material/typography.dart'; export 'src/material/typography.dart';
......
...@@ -11,12 +11,12 @@ import 'material.dart'; ...@@ -11,12 +11,12 @@ import 'material.dart';
import 'theme.dart'; import 'theme.dart';
import 'typography.dart'; import 'typography.dart';
class ToolBar extends StatelessWidget { class AppBar extends StatelessWidget {
ToolBar({ AppBar({
Key key, Key key,
this.left, this.leading,
this.center, this.title,
this.right, this.actions,
this.flexibleSpace, this.flexibleSpace,
this.foregroundOpacity: 1.0, this.foregroundOpacity: 1.0,
this.tabBar, this.tabBar,
...@@ -29,9 +29,9 @@ class ToolBar extends StatelessWidget { ...@@ -29,9 +29,9 @@ class ToolBar extends StatelessWidget {
assert((tabBar != null) ? flexibleSpace == null : true); assert((tabBar != null) ? flexibleSpace == null : true);
} }
final Widget left; final Widget leading;
final Widget center; final Widget title;
final List<Widget> right; final List<Widget> actions;
final WidgetBuilder flexibleSpace; final WidgetBuilder flexibleSpace;
final double foregroundOpacity; final double foregroundOpacity;
final Widget tabBar; final Widget tabBar;
...@@ -40,7 +40,7 @@ class ToolBar extends StatelessWidget { ...@@ -40,7 +40,7 @@ class ToolBar extends StatelessWidget {
final TextTheme textTheme; final TextTheme textTheme;
final EdgeInsets padding; final EdgeInsets padding;
ToolBar copyWith({ AppBar copyWith({
Key key, Key key,
Widget left, Widget left,
Widget center, Widget center,
...@@ -52,11 +52,11 @@ class ToolBar extends StatelessWidget { ...@@ -52,11 +52,11 @@ class ToolBar extends StatelessWidget {
TextTheme textTheme, TextTheme textTheme,
EdgeInsets padding EdgeInsets padding
}) { }) {
return new ToolBar( return new AppBar(
key: key ?? this.key, key: key ?? this.key,
left: left ?? this.left, leading: left ?? this.leading,
center: center ?? this.center, title: center ?? this.title,
right: right ?? this.right, actions: right ?? this.actions,
flexibleSpace: flexibleSpace ?? this.flexibleSpace, flexibleSpace: flexibleSpace ?? this.flexibleSpace,
foregroundOpacity: foregroundOpacity ?? this.foregroundOpacity, foregroundOpacity: foregroundOpacity ?? this.foregroundOpacity,
tabBar: tabBar ?? this.tabBar, tabBar: tabBar ?? this.tabBar,
...@@ -98,18 +98,18 @@ class ToolBar extends StatelessWidget { ...@@ -98,18 +98,18 @@ class ToolBar extends StatelessWidget {
} }
final List<Widget> toolBarRow = <Widget>[]; final List<Widget> toolBarRow = <Widget>[];
if (left != null) if (leading != null)
toolBarRow.add(left); toolBarRow.add(leading);
toolBarRow.add( toolBarRow.add(
new Flexible( new Flexible(
child: new Padding( child: new Padding(
padding: new EdgeInsets.only(left: 24.0), padding: new EdgeInsets.only(left: 24.0),
child: center != null ? new DefaultTextStyle(style: centerStyle, child: center) : null child: title != null ? new DefaultTextStyle(style: centerStyle, child: title) : null
) )
) )
); );
if (right != null) if (actions != null)
toolBarRow.addAll(right); toolBarRow.addAll(actions);
EdgeInsets combinedPadding = new EdgeInsets.symmetric(horizontal: 8.0); EdgeInsets combinedPadding = new EdgeInsets.symmetric(horizontal: 8.0);
if (padding != null) if (padding != null)
...@@ -117,7 +117,7 @@ class ToolBar extends StatelessWidget { ...@@ -117,7 +117,7 @@ class ToolBar extends StatelessWidget {
// If the toolBar's height shrinks below toolBarHeight, it will be clipped and bottom // If the toolBar's height shrinks below toolBarHeight, it will be clipped and bottom
// justified. This is so that the toolbar appears to move upwards as its height is reduced. // justified. This is so that the toolbar appears to move upwards as its height is reduced.
final double toolBarHeight = kToolBarHeight + combinedPadding.top + combinedPadding.bottom; final double toolBarHeight = kAppBarHeight + combinedPadding.top + combinedPadding.bottom;
final Widget toolBar = new ConstrainedBox( final Widget toolBar = new ConstrainedBox(
constraints: new BoxConstraints(maxHeight: toolBarHeight), constraints: new BoxConstraints(maxHeight: toolBarHeight),
child: new Padding( child: new Padding(
......
...@@ -9,8 +9,8 @@ import 'package:flutter/widgets.dart'; ...@@ -9,8 +9,8 @@ import 'package:flutter/widgets.dart';
// Mobile Landscape: 48dp // Mobile Landscape: 48dp
// Mobile Portrait: 56dp // Mobile Portrait: 56dp
// Tablet/Desktop: 64dp // Tablet/Desktop: 64dp
const double kToolBarHeight = 56.0; const double kAppBarHeight = 56.0;
const double kExtendedToolBarHeight = 128.0; const double kExtendedAppBarHeight = 128.0;
const double kTextTabBarHeight = 48.0; const double kTextTabBarHeight = 48.0;
const double kIconTabBarHeight = 48.0; const double kIconTabBarHeight = 48.0;
......
...@@ -27,7 +27,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> { ...@@ -27,7 +27,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
final double appBarHeight = Scaffold.of(context).appBarHeight; final double appBarHeight = Scaffold.of(context).appBarHeight;
final Animation<double> animation = Scaffold.of(context).appBarAnimation; final Animation<double> animation = Scaffold.of(context).appBarAnimation;
final EdgeInsets toolBarPadding = MediaQuery.of(context)?.padding ?? EdgeInsets.zero; final EdgeInsets toolBarPadding = MediaQuery.of(context)?.padding ?? EdgeInsets.zero;
final double toolBarHeight = kToolBarHeight + toolBarPadding.top; final double toolBarHeight = kAppBarHeight + toolBarPadding.top;
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
// background image // background image
...@@ -63,7 +63,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> { ...@@ -63,7 +63,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
color: titleStyle.color.withAlpha(new Tween<double>(begin: 255.0, end: 0.0).evaluate(opacityCurve).toInt()) color: titleStyle.color.withAlpha(new Tween<double>(begin: 255.0, end: 0.0).evaluate(opacityCurve).toInt())
); );
final double yAlignStart = 1.0; final double yAlignStart = 1.0;
final double yAlignEnd = (toolBarPadding.top + kToolBarHeight / 2.0) / toolBarHeight; final double yAlignEnd = (toolBarPadding.top + kAppBarHeight / 2.0) / toolBarHeight;
final double scaleAndAlignEnd = (appBarHeight - toolBarHeight) / appBarHeight; final double scaleAndAlignEnd = (appBarHeight - toolBarHeight) / appBarHeight;
final CurvedAnimation scaleAndAlignCurve = new CurvedAnimation( final CurvedAnimation scaleAndAlignCurve = new CurvedAnimation(
parent: animation, parent: animation,
......
...@@ -8,6 +8,7 @@ import 'dart:math' as math; ...@@ -8,6 +8,7 @@ import 'dart:math' as math;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'app_bar.dart';
import 'bottom_sheet.dart'; import 'bottom_sheet.dart';
import 'constants.dart'; import 'constants.dart';
import 'drawer.dart'; import 'drawer.dart';
...@@ -15,7 +16,6 @@ import 'icons.dart'; ...@@ -15,7 +16,6 @@ import 'icons.dart';
import 'icon_button.dart'; import 'icon_button.dart';
import 'material.dart'; import 'material.dart';
import 'snack_bar.dart'; import 'snack_bar.dart';
import 'tool_bar.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);
...@@ -27,7 +27,7 @@ enum AppBarBehavior { ...@@ -27,7 +27,7 @@ enum AppBarBehavior {
enum _ScaffoldSlot { enum _ScaffoldSlot {
body, body,
toolBar, appBar,
bottomSheet, bottomSheet,
snackBar, snackBar,
floatingActionButton, floatingActionButton,
...@@ -42,18 +42,18 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { ...@@ -42,18 +42,18 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
void performLayout(Size size) { void performLayout(Size size) {
BoxConstraints looseConstraints = new BoxConstraints.loose(size); BoxConstraints looseConstraints = new BoxConstraints.loose(size);
// This part of the layout has the same effect as putting the toolbar and // This part of the layout has the same effect as putting the app bar and
// body in a column and making the body flexible. What's different is that // body in a column and making the body flexible. What's different is that
// in this case the toolbar appears -after- the body in the stacking order, // in this case the app bar appears -after- the body in the stacking order,
// so the toolbar's shadow is drawn on top of the body. // so the app bar's shadow is drawn on top of the body.
final BoxConstraints fullWidthConstraints = looseConstraints.tighten(width: size.width); final BoxConstraints fullWidthConstraints = looseConstraints.tighten(width: size.width);
double contentTop = padding.top; double contentTop = padding.top;
double contentBottom = size.height - padding.bottom; double contentBottom = size.height - padding.bottom;
if (hasChild(_ScaffoldSlot.toolBar)) { if (hasChild(_ScaffoldSlot.appBar)) {
contentTop = layoutChild(_ScaffoldSlot.toolBar, fullWidthConstraints).height; contentTop = layoutChild(_ScaffoldSlot.appBar, fullWidthConstraints).height;
positionChild(_ScaffoldSlot.toolBar, Offset.zero); positionChild(_ScaffoldSlot.appBar, Offset.zero);
} }
if (hasChild(_ScaffoldSlot.body)) { if (hasChild(_ScaffoldSlot.body)) {
...@@ -183,7 +183,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -183,7 +183,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
class Scaffold extends StatefulWidget { class Scaffold extends StatefulWidget {
Scaffold({ Scaffold({
Key key, Key key,
this.toolBar, this.appBar,
this.body, this.body,
this.floatingActionButton, this.floatingActionButton,
this.drawer, this.drawer,
...@@ -192,10 +192,10 @@ class Scaffold extends StatefulWidget { ...@@ -192,10 +192,10 @@ class Scaffold extends StatefulWidget {
this.appBarHeight this.appBarHeight
}) : super(key: key) { }) : super(key: key) {
assert((appBarBehavior == AppBarBehavior.scroll) ? scrollableKey != null : true); assert((appBarBehavior == AppBarBehavior.scroll) ? scrollableKey != null : true);
assert((appBarBehavior == AppBarBehavior.scroll) ? appBarHeight != null && appBarHeight > kToolBarHeight : true); assert((appBarBehavior == AppBarBehavior.scroll) ? appBarHeight != null && appBarHeight > kAppBarHeight : true);
} }
final ToolBar toolBar; final AppBar appBar;
final Widget body; final Widget body;
final Widget floatingActionButton; final Widget floatingActionButton;
final Widget drawer; final Widget drawer;
...@@ -375,12 +375,12 @@ class ScaffoldState extends State<Scaffold> { ...@@ -375,12 +375,12 @@ class ScaffoldState extends State<Scaffold> {
bool _shouldShowBackArrow; bool _shouldShowBackArrow;
Widget _getModifiedToolBar({ EdgeInsets padding, double foregroundOpacity: 1.0, int elevation }) { Widget _getModifiedAppBar({ EdgeInsets padding, double foregroundOpacity: 1.0, int elevation }) {
ToolBar toolBar = config.toolBar; AppBar appBar = config.appBar;
if (toolBar == null) if (appBar == null)
return null; return null;
EdgeInsets toolBarPadding = new EdgeInsets.only(top: padding.top); EdgeInsets appBarPadding = new EdgeInsets.only(top: padding.top);
Widget left = toolBar.left; Widget left = appBar.leading;
if (left == null) { if (left == null) {
if (config.drawer != null) { if (config.drawer != null) {
left = new IconButton( left = new IconButton(
...@@ -399,9 +399,9 @@ class ScaffoldState extends State<Scaffold> { ...@@ -399,9 +399,9 @@ class ScaffoldState extends State<Scaffold> {
} }
} }
} }
return toolBar.copyWith( return appBar.copyWith(
elevation: elevation ?? toolBar.elevation ?? 4, elevation: elevation ?? appBar.elevation ?? 4,
padding: toolBarPadding, padding: appBarPadding,
foregroundOpacity: foregroundOpacity, foregroundOpacity: foregroundOpacity,
left: left left: left
); );
...@@ -421,9 +421,9 @@ class ScaffoldState extends State<Scaffold> { ...@@ -421,9 +421,9 @@ class ScaffoldState extends State<Scaffold> {
return false; return false;
} }
double _toolBarOpacity(double progress) { double _appBarOpacity(double progress) {
// The value of progress is 1.0 if the entire (padded) toolbar is visible, 0.0 // The value of progress is 1.0 if the entire (padded) app bar is visible, 0.0
// if the toolbar's height is zero. // if the app bar's height is zero.
return new Tween<double>(begin: 0.0, end: 1.0).evaluate(new CurvedAnimation( return new Tween<double>(begin: 0.0, end: 1.0).evaluate(new CurvedAnimation(
parent: new AnimationController()..value = progress.clamp(0.0, 1.0), parent: new AnimationController()..value = progress.clamp(0.0, 1.0),
curve: new Interval(0.50, 1.0) curve: new Interval(0.50, 1.0)
...@@ -431,35 +431,35 @@ class ScaffoldState extends State<Scaffold> { ...@@ -431,35 +431,35 @@ class ScaffoldState extends State<Scaffold> {
} }
Widget _buildScrollableAppBar(BuildContext context) { Widget _buildScrollableAppBar(BuildContext context) {
final EdgeInsets toolBarPadding = MediaQuery.of(context)?.padding ?? EdgeInsets.zero; final EdgeInsets appBarPadding = MediaQuery.of(context)?.padding ?? EdgeInsets.zero;
final double toolBarHeight = kToolBarHeight + toolBarPadding.top; final double appBarHeight = kAppBarHeight + appBarPadding.top;
Widget appBar; Widget appBar;
if (_scrollOffset <= appBarHeight && _scrollOffset >= appBarHeight - toolBarHeight) { if (_scrollOffset <= appBarHeight && _scrollOffset >= appBarHeight - appBarHeight) {
// scrolled to the top, only the toolbar is (partially) visible // scrolled to the top, only the app bar is (partially) visible
final double height = math.max(_floatingAppBarHeight, appBarHeight - _scrollOffset); final double height = math.max(_floatingAppBarHeight, appBarHeight - _scrollOffset);
final double opacity = _toolBarOpacity(1.0 - ((toolBarHeight - height) / toolBarHeight)); final double opacity = _appBarOpacity(1.0 - ((appBarHeight - height) / appBarHeight));
_appBarController.value = (appBarHeight - height) / appBarHeight; _appBarController.value = (appBarHeight - height) / appBarHeight;
appBar = new SizedBox( appBar = new SizedBox(
height: height, height: height,
child: _getModifiedToolBar(padding: toolBarPadding, foregroundOpacity: opacity) child: _getModifiedAppBar(padding: appBarPadding, foregroundOpacity: opacity)
); );
} else if (_scrollOffset > appBarHeight) { } else if (_scrollOffset > appBarHeight) {
// scrolled down, show the "floating" toolbar // scrolled down, show the "floating" app bar
_floatingAppBarHeight = (_floatingAppBarHeight + _scrollOffsetDelta).clamp(0.0, toolBarHeight); _floatingAppBarHeight = (_floatingAppBarHeight + _scrollOffsetDelta).clamp(0.0, appBarHeight);
final double toolBarOpacity = _toolBarOpacity(_floatingAppBarHeight / toolBarHeight); final double appBarOpacity = _appBarOpacity(_floatingAppBarHeight / appBarHeight);
_appBarController.value = (appBarHeight - _floatingAppBarHeight) / appBarHeight; _appBarController.value = (appBarHeight - _floatingAppBarHeight) / appBarHeight;
appBar = new SizedBox( appBar = new SizedBox(
height: _floatingAppBarHeight, height: _floatingAppBarHeight,
child: _getModifiedToolBar(padding: toolBarPadding, foregroundOpacity: toolBarOpacity) child: _getModifiedAppBar(padding: appBarPadding, foregroundOpacity: appBarOpacity)
); );
} else { } else {
// _scrollOffset < appBarHeight - toolBarHeight, scrolled to the top, flexible space is visible // _scrollOffset < appBarHeight - appBarHeight, scrolled to the top, flexible space is visible
final double height = appBarHeight - _scrollOffset.clamp(0.0, appBarHeight); final double height = appBarHeight - _scrollOffset.clamp(0.0, appBarHeight);
_appBarController.value = (appBarHeight - height) / appBarHeight; _appBarController.value = (appBarHeight - height) / appBarHeight;
appBar = new SizedBox( appBar = new SizedBox(
height: height, height: height,
child: _getModifiedToolBar(padding: toolBarPadding, elevation: 0) child: _getModifiedAppBar(padding: appBarPadding, elevation: 0)
); );
_floatingAppBarHeight = 0.0; _floatingAppBarHeight = 0.0;
} }
...@@ -484,13 +484,13 @@ class ScaffoldState extends State<Scaffold> { ...@@ -484,13 +484,13 @@ class ScaffoldState extends State<Scaffold> {
final List<LayoutId> children = new List<LayoutId>(); final List<LayoutId> children = new List<LayoutId>();
_addIfNonNull(children, config.body, _ScaffoldSlot.body); _addIfNonNull(children, config.body, _ScaffoldSlot.body);
if (config.appBarBehavior == AppBarBehavior.anchor) { if (config.appBarBehavior == AppBarBehavior.anchor) {
Widget toolBar = new ConstrainedBox( Widget appBar = new ConstrainedBox(
child: _getModifiedToolBar(padding: padding), child: _getModifiedAppBar(padding: padding),
constraints: new BoxConstraints(maxHeight: config.appBarHeight ?? kExtendedToolBarHeight + padding.top) constraints: new BoxConstraints(maxHeight: config.appBarHeight ?? kExtendedAppBarHeight + padding.top)
); );
_addIfNonNull(children, toolBar, _ScaffoldSlot.toolBar); _addIfNonNull(children, appBar, _ScaffoldSlot.appBar);
} }
// Otherwise the ToolBar will be part of a [toolbar, body] Stack. See AppBarBehavior.scroll below. // Otherwise the AppBar will be part of a [app bar, body] Stack. See AppBarBehavior.scroll below.
if (_currentBottomSheet != null || if (_currentBottomSheet != null ||
(_dismissedBottomSheets != null && _dismissedBottomSheets.isNotEmpty)) { (_dismissedBottomSheets != null && _dismissedBottomSheets.isNotEmpty)) {
......
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
title: "Markdown Demo", title: "Markdown Demo",
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new Scaffold( '/': (BuildContext context) => new Scaffold(
toolBar: new ToolBar(center: new Text("Markdown Demo")), appBar: new AppBar(title: new Text("Markdown Demo")),
body: new Markdown(data: _kMarkdownData) body: new Markdown(data: _kMarkdownData)
) )
} }
......
...@@ -34,8 +34,8 @@ class _FlutterDemoState extends State<FlutterDemo> { ...@@ -34,8 +34,8 @@ class _FlutterDemoState extends State<FlutterDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar( appBar: new AppBar(
center: new Text('Flutter Demo') title: new Text('Flutter Demo')
), ),
body: new Center( body: new Center(
child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.') child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.')
......
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