Commit a4eca317 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Use ScrollView in examples a manual_tests (#7645)

This patch deploys ScrollView in a number of demos and manual tests.
parent 905353b4
...@@ -589,7 +589,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -589,7 +589,7 @@ class GalleryDrawer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Drawer( return new Drawer(
child: new Block( child: new ScrollView(
children: <Widget>[ children: <Widget>[
new FancyDrawerHeader(), new FancyDrawerHeader(),
new DrawerItem( new DrawerItem(
......
...@@ -123,33 +123,35 @@ class CardCollectionState extends State<CardCollection> { ...@@ -123,33 +123,35 @@ class CardCollectionState extends State<CardCollection> {
return new Drawer( return new Drawer(
child: new IconTheme( child: new IconTheme(
data: const IconThemeData(color: Colors.black), data: const IconThemeData(color: Colors.black),
child: new Block(children: <Widget>[ child: new ScrollView(
new DrawerHeader(child: new Center(child: new Text('Options'))), children: <Widget>[
buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable), new DrawerHeader(child: new Center(child: new Text('Options'))),
buildDrawerCheckbox("Snap fling scrolls to center", _snapToCenter, _toggleSnapToCenter), buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable),
buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards), buildDrawerCheckbox("Snap fling scrolls to center", _snapToCenter, _toggleSnapToCenter),
buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine), buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards),
buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable), buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine),
new Divider(), buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable),
buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor), new Divider(),
buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor), buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor), buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor), buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor),
new Divider(), buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor),
buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code), new Divider(),
buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back), buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code),
buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward), buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back),
new Divider(), buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward),
buildFontRadioItem("Left-align text", TextAlign.left, _textAlign, _changeTextAlign, icon: Icons.format_align_left, enabled: !_editable), new Divider(),
buildFontRadioItem("Center-align text", TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable), buildFontRadioItem("Left-align text", TextAlign.left, _textAlign, _changeTextAlign, icon: Icons.format_align_left, enabled: !_editable),
buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable), buildFontRadioItem("Center-align text", TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable),
new Divider(), buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
new DrawerItem( new Divider(),
icon: new Icon(Icons.dvr), new DrawerItem(
onPressed: () { debugDumpApp(); debugDumpRenderTree(); }, icon: new Icon(Icons.dvr),
child: new Text('Dump App to Console') onPressed: () { debugDumpApp(); debugDumpRenderTree(); },
), child: new Text('Dump App to Console')
]) ),
]
)
) )
); );
} }
......
...@@ -84,31 +84,33 @@ class PageableListAppState extends State<PageableListApp> { ...@@ -84,31 +84,33 @@ class PageableListAppState extends State<PageableListApp> {
Widget _buildDrawer() { Widget _buildDrawer() {
return new Drawer( return new Drawer(
child: new Block(children: <Widget>[ child: new ScrollView(
new DrawerHeader(child: new Center(child: new Text('Options'))), children: <Widget>[
new DrawerItem( new DrawerHeader(child: new Center(child: new Text('Options'))),
icon: new Icon(Icons.more_horiz), new DrawerItem(
selected: scrollDirection == Axis.horizontal, icon: new Icon(Icons.more_horiz),
child: new Text('Horizontal Layout'), selected: scrollDirection == Axis.horizontal,
onPressed: switchScrollDirection child: new Text('Horizontal Layout'),
), onPressed: switchScrollDirection
new DrawerItem( ),
icon: new Icon(Icons.more_vert), new DrawerItem(
selected: scrollDirection == Axis.vertical, icon: new Icon(Icons.more_vert),
child: new Text('Vertical Layout'), selected: scrollDirection == Axis.vertical,
onPressed: switchScrollDirection child: new Text('Vertical Layout'),
), onPressed: switchScrollDirection
new DrawerItem( ),
onPressed: toggleItemsWrap, new DrawerItem(
child: new Row( onPressed: toggleItemsWrap,
children: <Widget>[ child: new Row(
new Expanded(child: new Text('Scrolling wraps around')), children: <Widget>[
// TODO(abarth): Actually make this checkbox change this value. new Expanded(child: new Text('Scrolling wraps around')),
new Checkbox(value: itemsWrap, onChanged: null) // TODO(abarth): Actually make this checkbox change this value.
] new Checkbox(value: itemsWrap, onChanged: null)
]
)
) )
) ]
]) )
); );
} }
......
...@@ -41,7 +41,7 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -41,7 +41,7 @@ class _ChipDemoState extends State<ChipDemo> {
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: new Text('Chips')), appBar: new AppBar(title: new Text('Chips')),
body: new Block( body: new ScrollView(
children: chips.map((Widget widget) { children: chips.map((Widget widget) {
return new Container( return new Container(
height: 100.0, height: 100.0,
......
...@@ -88,7 +88,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -88,7 +88,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
title: new Text('Navigation drawer'), title: new Text('Navigation drawer'),
), ),
drawer: new Drawer( drawer: new Drawer(
child: new Block( child: new ScrollView(
children: <Widget>[ children: <Widget>[
new UserAccountsDrawerHeader( new UserAccountsDrawerHeader(
accountName: new Text('Zach Widget'), accountName: new Text('Zach Widget'),
......
...@@ -161,7 +161,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> { ...@@ -161,7 +161,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
) )
] ]
), ),
body: new Block( body: new ScrollView(
children: leaveBehindItems.map(buildItem).toList() children: leaveBehindItems.map(buildItem).toList()
) )
); );
......
...@@ -29,41 +29,39 @@ class _SnackBarDemoState extends State<SnackBarDemo> { ...@@ -29,41 +29,39 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
int _snackBarIndex = 1; int _snackBarIndex = 1;
Widget buildBody(BuildContext context) { Widget buildBody(BuildContext context) {
return new Padding( return new Block(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
child: new Block( children: <Widget>[
children: <Widget>[ new Text(_text1),
new Text(_text1), new Text(_text2),
new Text(_text2), new Center(
new Center( child: new RaisedButton(
child: new RaisedButton( child: new Text('SHOW A SNACKBAR'),
child: new Text('SHOW A SNACKBAR'), onPressed: () {
onPressed: () { final int thisSnackBarIndex = _snackBarIndex++;
final int thisSnackBarIndex = _snackBarIndex++; Scaffold.of(context).showSnackBar(new SnackBar(
Scaffold.of(context).showSnackBar(new SnackBar( content: new Text('This is snackbar #$thisSnackBarIndex.'),
content: new Text('This is snackbar #$thisSnackBarIndex.'), action: new SnackBarAction(
action: new SnackBarAction( label: 'ACTION',
label: 'ACTION', onPressed: () {
onPressed: () { Scaffold.of(context).showSnackBar(new SnackBar(
Scaffold.of(context).showSnackBar(new SnackBar( content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.')
content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.') ));
)); }
} )
) ));
)); }
} )
) ),
), new Text(_text3),
new Text(_text3), ]
] .map((Widget child) {
.map((Widget child) { return new Container(
return new Container( margin: const EdgeInsets.symmetric(vertical: 12.0),
margin: const EdgeInsets.symmetric(vertical: 12.0), child: child
child: child );
); })
}) .toList()
.toList()
)
); );
} }
......
...@@ -22,7 +22,7 @@ class TooltipDemo extends StatelessWidget { ...@@ -22,7 +22,7 @@ class TooltipDemo extends StatelessWidget {
), ),
body: new Builder( body: new Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return new Block( return new ScrollView(
children: <Widget>[ children: <Widget>[
new Text(_introText, style: theme.textTheme.subhead), new Text(_introText, style: theme.textTheme.subhead),
new Row( new Row(
......
...@@ -66,7 +66,7 @@ class TypographyDemo extends StatelessWidget { ...@@ -66,7 +66,7 @@ class TypographyDemo extends StatelessWidget {
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: new Text('Typography')), appBar: new AppBar(title: new Text('Typography')),
body: new Block(children: styleItems) body: new ScrollView(children: styleItems)
); );
} }
} }
...@@ -305,6 +305,6 @@ class GalleryDrawer extends StatelessWidget { ...@@ -305,6 +305,6 @@ class GalleryDrawer extends StatelessWidget {
)); ));
} }
return new Drawer(child: new Block(children: allDrawerItems)); return new Drawer(child: new ScrollView(children: allDrawerItems));
} }
} }
...@@ -121,63 +121,65 @@ class StockHomeState extends State<StockHome> { ...@@ -121,63 +121,65 @@ class StockHomeState extends State<StockHome> {
Widget _buildDrawer(BuildContext context) { Widget _buildDrawer(BuildContext context) {
return new Drawer( return new Drawer(
child: new Block(children: <Widget>[ child: new ScrollView(
new DrawerHeader(child: new Center(child: new Text('Stocks'))), children: <Widget>[
new DrawerItem( new DrawerHeader(child: new Center(child: new Text('Stocks'))),
icon: new Icon(Icons.assessment), new DrawerItem(
selected: true, icon: new Icon(Icons.assessment),
child: new Text('Stock List') selected: true,
), child: new Text('Stock List')
new DrawerItem( ),
icon: new Icon(Icons.account_balance), new DrawerItem(
onPressed: null, icon: new Icon(Icons.account_balance),
child: new Text('Account Balance') onPressed: null,
), child: new Text('Account Balance')
new DrawerItem( ),
icon: new Icon(Icons.dvr), new DrawerItem(
onPressed: () { icon: new Icon(Icons.dvr),
try { onPressed: () {
debugDumpApp(); try {
debugDumpRenderTree(); debugDumpApp();
debugDumpLayerTree(); debugDumpRenderTree();
debugDumpSemanticsTree(); debugDumpLayerTree();
} catch (e, stack) { debugDumpSemanticsTree();
debugPrint('Exception while dumping app:\n$e\n$stack'); } catch (e, stack) {
} debugPrint('Exception while dumping app:\n$e\n$stack');
}, }
child: new Text('Dump App to Console') },
), child: new Text('Dump App to Console')
new Divider(), ),
new DrawerItem( new Divider(),
icon: new Icon(Icons.thumb_up), new DrawerItem(
onPressed: () => _handleStockModeChange(StockMode.optimistic), icon: new Icon(Icons.thumb_up),
child: new Row( onPressed: () => _handleStockModeChange(StockMode.optimistic),
children: <Widget>[ child: new Row(
new Expanded(child: new Text('Optimistic')), children: <Widget>[
new Radio<StockMode>(value: StockMode.optimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange) new Expanded(child: new Text('Optimistic')),
] new Radio<StockMode>(value: StockMode.optimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
) ]
), )
new DrawerItem( ),
icon: new Icon(Icons.thumb_down), new DrawerItem(
onPressed: () => _handleStockModeChange(StockMode.pessimistic), icon: new Icon(Icons.thumb_down),
child: new Row( onPressed: () => _handleStockModeChange(StockMode.pessimistic),
children: <Widget>[ child: new Row(
new Expanded(child: new Text('Pessimistic')), children: <Widget>[
new Radio<StockMode>(value: StockMode.pessimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange) new Expanded(child: new Text('Pessimistic')),
] new Radio<StockMode>(value: StockMode.pessimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
) ]
), )
new Divider(), ),
new DrawerItem( new Divider(),
icon: new Icon(Icons.settings), new DrawerItem(
onPressed: _handleShowSettings, icon: new Icon(Icons.settings),
child: new Text('Settings')), onPressed: _handleShowSettings,
new DrawerItem( child: new Text('Settings')),
icon: new Icon(Icons.help), new DrawerItem(
onPressed: _handleShowAbout, icon: new Icon(Icons.help),
child: new Text('About')) onPressed: _handleShowAbout,
]) child: new Text('About'))
]
)
); );
} }
......
...@@ -241,8 +241,8 @@ class StockSettingsState extends State<StockSettings> { ...@@ -241,8 +241,8 @@ class StockSettingsState extends State<StockSettings> {
return true; return true;
}); });
return new Block( return new Block(
padding: const EdgeInsets.symmetric(vertical: 20.0),
children: rows, children: rows,
padding: const EdgeInsets.symmetric(vertical: 20.0)
); );
} }
......
...@@ -73,22 +73,20 @@ class StockSymbolPage extends StatelessWidget { ...@@ -73,22 +73,20 @@ class StockSymbolPage extends StatelessWidget {
appBar: new AppBar( appBar: new AppBar(
title: new Text(stock.name) title: new Text(stock.name)
), ),
body: new Block( body: new SingleChildScrollView(
children: <Widget>[ child: new Container(
new Container( margin: new EdgeInsets.all(20.0),
margin: new EdgeInsets.all(20.0), child: new Card(
child: new Card( child: new _StockSymbolView(
child: new _StockSymbolView( stock: stock,
stock: stock, arrow: new Hero(
arrow: new Hero( tag: stock,
tag: stock, turns: 2,
turns: 2, child: new StockArrow(percentChange: stock.percentChange)
child: new StockArrow(percentChange: stock.percentChange)
)
) )
) )
) )
] )
) )
); );
} }
......
...@@ -39,7 +39,7 @@ void main() { ...@@ -39,7 +39,7 @@ void main() {
children.add(const SizedBox(height: 18.0)); children.add(const SizedBox(height: 18.0));
children.add(new Center(child: new CircularProgressIndicator(value: progressMax > 0 ? progress / progressMax : null))); children.add(new Center(child: new CircularProgressIndicator(value: progressMax > 0 ? progress / progressMax : null)));
} }
return new Block(children: children); return new ScrollView(children: children);
}, },
), ),
), ),
...@@ -114,4 +114,4 @@ class LoaderBinding extends WidgetsFlutterBinding { ...@@ -114,4 +114,4 @@ class LoaderBinding extends WidgetsFlutterBinding {
} }
); );
} }
} }
\ No newline at end of file
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