Unverified Commit d8bfb3a9 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Apply media padding to Gallery Material Design demos (#13593)

Applies media padding (e.g. iPhone X safe area insets) to the Material Design demos in the Gallery.

Covers the following demos:
* Buttons (via the TabbedComponentDemoScaffold change)
* Cards
* Expansion panels
* Grid list
* Icons
* Images (via the TabbedComponentDemoScaffold change)
* Page Selector
* Progress Indicator
* Scrollable tabs
* Selection controls (via the TabbedComponentDemoScaffold change)
* Snack bar
* Tabs
* Text fields
* Tooltips

Fixes #13594
parent d9edab84
...@@ -60,7 +60,10 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -60,7 +60,10 @@ class TravelDestinationItem extends StatelessWidget {
final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white); final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white);
final TextStyle descriptionStyle = theme.textTheme.subhead; final TextStyle descriptionStyle = theme.textTheme.subhead;
return new Container( return new SafeArea(
top: false,
bottom: false,
child: new Container(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
height: height, height: height,
child: new Card( child: new Card(
...@@ -141,6 +144,7 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -141,6 +144,7 @@ class TravelDestinationItem extends StatelessWidget {
], ],
), ),
), ),
),
); );
} }
} }
......
...@@ -131,6 +131,9 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -131,6 +131,9 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: const Text('Date and time pickers')), appBar: new AppBar(title: const Text('Date and time pickers')),
body: new DropdownButtonHideUnderline( body: new DropdownButtonHideUnderline(
child: new SafeArea(
top: false,
bottom: false,
child: new ListView( child: new ListView(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
children: <Widget>[ children: <Widget>[
...@@ -201,6 +204,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -201,6 +204,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
], ],
), ),
), ),
),
); );
} }
} }
...@@ -336,6 +336,9 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> { ...@@ -336,6 +336,9 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: const Text('Expansion panels')), appBar: new AppBar(title: const Text('Expansion panels')),
body: new SingleChildScrollView( body: new SingleChildScrollView(
child: new SafeArea(
top: false,
bottom: false,
child: new Container( child: new Container(
margin: const EdgeInsets.all(24.0), margin: const EdgeInsets.all(24.0),
child: new ExpansionPanelList( child: new ExpansionPanelList(
...@@ -351,9 +354,10 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> { ...@@ -351,9 +354,10 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
body: item.builder(item) body: item.builder(item)
); );
}).toList() }).toList()
) ),
) ),
) ),
),
); );
} }
} }
...@@ -363,6 +363,9 @@ class GridListDemoState extends State<GridListDemo> { ...@@ -363,6 +363,9 @@ class GridListDemoState extends State<GridListDemo> {
body: new Column( body: new Column(
children: <Widget>[ children: <Widget>[
new Expanded( new Expanded(
child: new SafeArea(
top: false,
bottom: false,
child: new GridView.count( child: new GridView.count(
crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3, crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3,
mainAxisSpacing: 4.0, mainAxisSpacing: 4.0,
...@@ -380,10 +383,11 @@ class GridListDemoState extends State<GridListDemo> { ...@@ -380,10 +383,11 @@ class GridListDemoState extends State<GridListDemo> {
} }
); );
}).toList(), }).toList(),
) ),
) ),
] ),
) ],
),
); );
} }
} }
...@@ -54,6 +54,9 @@ class IconsDemoState extends State<IconsDemo> { ...@@ -54,6 +54,9 @@ class IconsDemoState extends State<IconsDemo> {
data: new IconThemeData(color: iconColor), data: new IconThemeData(color: iconColor),
child: new Padding( child: new Padding(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
child: new SafeArea(
top: false,
bottom: false,
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new _IconsDemoCard(handleIconButtonPress), new _IconsDemoCard(handleIconButtonPress),
...@@ -61,6 +64,7 @@ class IconsDemoState extends State<IconsDemo> { ...@@ -61,6 +64,7 @@ class IconsDemoState extends State<IconsDemo> {
), ),
), ),
), ),
),
); );
} }
} }
......
...@@ -19,7 +19,10 @@ class _PageSelector extends StatelessWidget { ...@@ -19,7 +19,10 @@ class _PageSelector extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TabController controller = DefaultTabController.of(context); final TabController controller = DefaultTabController.of(context);
final Color color = Theme.of(context).accentColor; final Color color = Theme.of(context).accentColor;
return new Column( return new SafeArea(
top: false,
bottom: false,
child: new Column(
children: <Widget>[ children: <Widget>[
new Container( new Container(
margin: const EdgeInsets.only(top: 16.0), margin: const EdgeInsets.only(top: 16.0),
...@@ -58,6 +61,7 @@ class _PageSelector extends StatelessWidget { ...@@ -58,6 +61,7 @@ class _PageSelector extends StatelessWidget {
), ),
), ),
], ],
),
); );
} }
} }
......
...@@ -107,17 +107,21 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing ...@@ -107,17 +107,21 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
child: new GestureDetector( child: new GestureDetector(
onTap: _handleTap, onTap: _handleTap,
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: new SafeArea(
top: false,
bottom: false,
child: new Container( child: new Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
child: new AnimatedBuilder( child: new AnimatedBuilder(
animation: _animation, animation: _animation,
builder: _buildIndicators builder: _buildIndicators
) ),
) ),
) ),
) ),
) ),
) ),
),
); );
} }
} }
...@@ -105,7 +105,10 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -105,7 +105,10 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
body: new TabBarView( body: new TabBarView(
controller: _controller, controller: _controller,
children: _allPages.map((_Page page) { children: _allPages.map((_Page page) {
return new Container( return new SafeArea(
top: false,
bottom: false,
child: new Container(
key: new ObjectKey(page.icon), key: new ObjectKey(page.icon),
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child:new Card( child:new Card(
...@@ -117,6 +120,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -117,6 +120,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
), ),
), ),
), ),
),
); );
}).toList() }).toList()
), ),
......
...@@ -29,7 +29,10 @@ class _SnackBarDemoState extends State<SnackBarDemo> { ...@@ -29,7 +29,10 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
int _snackBarIndex = 1; int _snackBarIndex = 1;
Widget buildBody(BuildContext context) { Widget buildBody(BuildContext context) {
return new ListView( return new SafeArea(
top: false,
bottom: false,
child: new ListView(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
children: <Widget>[ children: <Widget>[
const Text(_text1), const Text(_text1),
...@@ -48,10 +51,10 @@ class _SnackBarDemoState extends State<SnackBarDemo> { ...@@ -48,10 +51,10 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.') content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.')
)); ));
} }
) ),
)); ));
} }
) ),
), ),
const Text(_text3), const Text(_text3),
] ]
...@@ -62,6 +65,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> { ...@@ -62,6 +65,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
); );
}) })
.toList() .toList()
),
); );
} }
......
...@@ -154,7 +154,10 @@ class TabsDemo extends StatelessWidget { ...@@ -154,7 +154,10 @@ class TabsDemo extends StatelessWidget {
}, },
body: new TabBarView( body: new TabBarView(
children: _allPages.keys.map((_Page page) { children: _allPages.keys.map((_Page page) {
return new ListView( return new SafeArea(
top: false,
bottom: false,
child: new ListView(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
itemExtent: _CardDataItem.height, itemExtent: _CardDataItem.height,
children: _allPages[page].map((_CardData data) { children: _allPages[page].map((_CardData data) {
...@@ -163,6 +166,7 @@ class TabsDemo extends StatelessWidget { ...@@ -163,6 +166,7 @@ class TabsDemo extends StatelessWidget {
child: new _CardDataItem(page: page, data: data), child: new _CardDataItem(page: page, data: data),
); );
}).toList(), }).toList(),
),
); );
}).toList(), }).toList(),
), ),
......
...@@ -108,7 +108,10 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -108,7 +108,10 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
appBar: new AppBar( appBar: new AppBar(
title: const Text('Text fields'), title: const Text('Text fields'),
), ),
body: new Form( body: new SafeArea(
top: false,
bottom: false,
child: new Form(
key: _formKey, key: _formKey,
autovalidate: _autovalidate, autovalidate: _autovalidate,
onWillPop: _warnUserAboutInvalidData, onWillPop: _warnUserAboutInvalidData,
...@@ -199,7 +202,8 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -199,7 +202,8 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
child: new Text('* indicates required field', style: Theme.of(context).textTheme.caption), child: new Text('* indicates required field', style: Theme.of(context).textTheme.caption),
), ),
], ],
) ),
),
), ),
); );
} }
......
...@@ -22,7 +22,10 @@ class TooltipDemo extends StatelessWidget { ...@@ -22,7 +22,10 @@ class TooltipDemo extends StatelessWidget {
), ),
body: new Builder( body: new Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return new ListView( return new SafeArea(
top: false,
bottom: false,
child: new ListView(
children: <Widget>[ children: <Widget>[
new Text(_introText, style: theme.textTheme.subhead), new Text(_introText, style: theme.textTheme.subhead),
new Row( new Row(
...@@ -60,6 +63,7 @@ class TooltipDemo extends StatelessWidget { ...@@ -60,6 +63,7 @@ class TooltipDemo extends StatelessWidget {
); );
}) })
.toList() .toList()
),
); );
} }
) )
......
...@@ -77,7 +77,10 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -77,7 +77,10 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
), ),
body: new TabBarView( body: new TabBarView(
children: demos.map((ComponentDemoTabData demo) { children: demos.map((ComponentDemoTabData demo) {
return new Column( return new SafeArea(
top: false,
bottom: false,
child: new Column(
children: <Widget>[ children: <Widget>[
new Padding( new Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
...@@ -87,6 +90,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -87,6 +90,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
), ),
new Expanded(child: demo.demoWidget) new Expanded(child: demo.demoWidget)
], ],
),
); );
}).toList(), }).toList(),
), ),
......
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