From e478a5472d719644c1050a47a9edf75cb4232301 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 19 Dec 2017 09:15:26 -0800 Subject: [PATCH] Apply media padding in Gallery Pesto demo (#13668) Applies horizontal safe area insets to the Pesto demo in the Gallery. This is to support the iPhone X sensor housing notch and other similarly creative display features when in landscape orientation. --- .../flutter_gallery/lib/demo/pesto_demo.dart | 138 ++++++++++-------- 1 file changed, 74 insertions(+), 64 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index b850ec87e6..1cad222af5 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -137,7 +137,13 @@ class _RecipeGridPageState extends State { } Widget _buildBody(BuildContext context, double statusBarHeight) { - final EdgeInsets padding = const EdgeInsets.all(8.0); + final EdgeInsets mediaPadding = MediaQuery.of(context).padding; + final EdgeInsets padding = new EdgeInsets.only( + top: 8.0, + left: 8.0 + mediaPadding.left, + right: 8.0 + mediaPadding.right, + bottom: 8.0 + ); return new SliverPadding( padding: padding, sliver: new SliverGrid( @@ -432,69 +438,73 @@ class RecipeSheet extends StatelessWidget { @override Widget build(BuildContext context) { return new Material( - child: new Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 40.0), - child: new Table( - columnWidths: { - 0: const FixedColumnWidth(64.0) - }, - children: [ - new TableRow( - children: [ - new TableCell( - verticalAlignment: TableCellVerticalAlignment.middle, - child: new Image.asset( - recipe.ingredientsImagePath, - package: recipe.ingredientsImagePackage, - width: 32.0, - height: 32.0, - alignment: Alignment.centerLeft, - fit: BoxFit.scaleDown - ) - ), - new TableCell( - verticalAlignment: TableCellVerticalAlignment.middle, - child: new Text(recipe.name, style: titleStyle) - ), - ] - ), - new TableRow( - children: [ - const SizedBox(), - new Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 4.0), - child: new Text(recipe.description, style: descriptionStyle) - ), - ] - ), - new TableRow( - children: [ - const SizedBox(), - new Padding( - padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), - child: new Text('Ingredients', style: headingStyle) - ), - ] - ), - ]..addAll(recipe.ingredients.map( - (RecipeIngredient ingredient) { - return _buildItemRow(ingredient.amount, ingredient.description); - } - ))..add( - new TableRow( - children: [ - const SizedBox(), - new Padding( - padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), - child: new Text('Steps', style: headingStyle) - ), - ] - ) - )..addAll(recipe.steps.map( - (RecipeStep step) { - return _buildItemRow(step.duration ?? '', step.description); - } - )), + child: new SafeArea( + top: false, + bottom: false, + child: new Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 40.0), + child: new Table( + columnWidths: { + 0: const FixedColumnWidth(64.0) + }, + children: [ + new TableRow( + children: [ + new TableCell( + verticalAlignment: TableCellVerticalAlignment.middle, + child: new Image.asset( + recipe.ingredientsImagePath, + package: recipe.ingredientsImagePackage, + width: 32.0, + height: 32.0, + alignment: Alignment.centerLeft, + fit: BoxFit.scaleDown + ) + ), + new TableCell( + verticalAlignment: TableCellVerticalAlignment.middle, + child: new Text(recipe.name, style: titleStyle) + ), + ] + ), + new TableRow( + children: [ + const SizedBox(), + new Padding( + padding: const EdgeInsets.only(top: 8.0, bottom: 4.0), + child: new Text(recipe.description, style: descriptionStyle) + ), + ] + ), + new TableRow( + children: [ + const SizedBox(), + new Padding( + padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), + child: new Text('Ingredients', style: headingStyle) + ), + ] + ), + ]..addAll(recipe.ingredients.map( + (RecipeIngredient ingredient) { + return _buildItemRow(ingredient.amount, ingredient.description); + } + ))..add( + new TableRow( + children: [ + const SizedBox(), + new Padding( + padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), + child: new Text('Steps', style: headingStyle) + ), + ] + ) + )..addAll(recipe.steps.map( + (RecipeStep step) { + return _buildItemRow(step.duration ?? '', step.description); + } + )), + ), ), ), );