Commit 10130fc5 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Spam EdgeInsetsGeometry to improve RTL support (#11849)

Most of the framework widgets should work in terms of EdgeInsetsGeometry
rather than EdgeInsets so that their clients can supply directional
insets.
parent 0783ec90
...@@ -88,7 +88,7 @@ class ButtonTheme extends InheritedWidget { ...@@ -88,7 +88,7 @@ class ButtonTheme extends InheritedWidget {
/// The amount of space to surround the child inside the bounds of the button. /// The amount of space to surround the child inside the bounds of the button.
/// ///
/// Defaults to 16.0 pixels of horizontal padding. /// Defaults to 16.0 pixels of horizontal padding.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// The closest instance of this class that encloses the given context. /// The closest instance of this class that encloses the given context.
/// ///
...@@ -231,7 +231,7 @@ class MaterialButton extends StatefulWidget { ...@@ -231,7 +231,7 @@ class MaterialButton extends StatefulWidget {
/// The amount of space to surround the child inside the bounds of the button. /// The amount of space to surround the child inside the bounds of the button.
/// ///
/// Defaults to the value from the current [ButtonTheme]. /// Defaults to the value from the current [ButtonTheme].
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// The callback that is called when the button is tapped or otherwise activated. /// The callback that is called when the button is tapped or otherwise activated.
/// ///
......
...@@ -145,7 +145,7 @@ class AlertDialog extends StatelessWidget { ...@@ -145,7 +145,7 @@ class AlertDialog extends StatelessWidget {
/// ///
/// Uses material design default if none is supplied. If there is no title, no /// Uses material design default if none is supplied. If there is no title, no
/// padding will be provided. /// padding will be provided.
final EdgeInsets titlePadding; final EdgeInsetsGeometry titlePadding;
/// The (optional) content of the dialog is displayed in the center of the /// The (optional) content of the dialog is displayed in the center of the
/// dialog in a lighter font. /// dialog in a lighter font.
...@@ -158,7 +158,7 @@ class AlertDialog extends StatelessWidget { ...@@ -158,7 +158,7 @@ class AlertDialog extends StatelessWidget {
/// Padding around the content. /// Padding around the content.
/// ///
/// Uses material design default if none is supplied. /// Uses material design default if none is supplied.
final EdgeInsets contentPadding; final EdgeInsetsGeometry contentPadding;
/// The (optional) set of actions that are displayed at the bottom of the /// The (optional) set of actions that are displayed at the bottom of the
/// dialog. /// dialog.
...@@ -174,7 +174,7 @@ class AlertDialog extends StatelessWidget { ...@@ -174,7 +174,7 @@ class AlertDialog extends StatelessWidget {
if (title != null) { if (title != null) {
children.add(new Padding( children.add(new Padding(
padding: titlePadding ?? new EdgeInsets.fromLTRB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0), padding: titlePadding ?? new EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: Theme.of(context).textTheme.title, style: Theme.of(context).textTheme.title,
child: title, child: title,
...@@ -185,7 +185,7 @@ class AlertDialog extends StatelessWidget { ...@@ -185,7 +185,7 @@ class AlertDialog extends StatelessWidget {
if (content != null) { if (content != null) {
children.add(new Flexible( children.add(new Flexible(
child: new Padding( child: new Padding(
padding: contentPadding ?? const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0), padding: contentPadding ?? const EdgeInsetsDirectional.fromSTEB(24.0, 20.0, 24.0, 24.0),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: Theme.of(context).textTheme.subhead, style: Theme.of(context).textTheme.subhead,
child: content, child: content,
...@@ -352,7 +352,7 @@ class SimpleDialog extends StatelessWidget { ...@@ -352,7 +352,7 @@ class SimpleDialog extends StatelessWidget {
/// ///
/// Uses material design default if none is supplied. If there is no title, no /// Uses material design default if none is supplied. If there is no title, no
/// padding will be provided. /// padding will be provided.
final EdgeInsets titlePadding; final EdgeInsetsGeometry titlePadding;
/// The (optional) content of the dialog is displayed in a /// The (optional) content of the dialog is displayed in a
/// [SingleChildScrollView] underneath the title. /// [SingleChildScrollView] underneath the title.
...@@ -363,7 +363,7 @@ class SimpleDialog extends StatelessWidget { ...@@ -363,7 +363,7 @@ class SimpleDialog extends StatelessWidget {
/// Padding around the content. /// Padding around the content.
/// ///
/// Uses material design default if none is supplied. /// Uses material design default if none is supplied.
final EdgeInsets contentPadding; final EdgeInsetsGeometry contentPadding;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -371,7 +371,7 @@ class SimpleDialog extends StatelessWidget { ...@@ -371,7 +371,7 @@ class SimpleDialog extends StatelessWidget {
if (title != null) { if (title != null) {
body.add(new Padding( body.add(new Padding(
padding: titlePadding ?? const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0), padding: titlePadding ?? const EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 24.0, 0.0),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: Theme.of(context).textTheme.title, style: Theme.of(context).textTheme.title,
child: title child: title
...@@ -382,7 +382,7 @@ class SimpleDialog extends StatelessWidget { ...@@ -382,7 +382,7 @@ class SimpleDialog extends StatelessWidget {
if (children != null) { if (children != null) {
body.add(new Flexible( body.add(new Flexible(
child: new SingleChildScrollView( child: new SingleChildScrollView(
padding: contentPadding ?? const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0), padding: contentPadding ?? const EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 16.0),
child: new ListBody(children: children), child: new ListBody(children: children),
) )
)); ));
......
...@@ -52,10 +52,10 @@ class DrawerHeader extends StatelessWidget { ...@@ -52,10 +52,10 @@ class DrawerHeader extends StatelessWidget {
/// system status bar. /// system status bar.
/// ///
/// If the child is null, the padding has no effect. /// If the child is null, the padding has no effect.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// The margin around the drawer header. /// The margin around the drawer header.
final EdgeInsets margin; final EdgeInsetsGeometry margin;
/// The duration for animations of the [decoration]. /// The duration for animations of the [decoration].
final Duration duration; final Duration duration;
...@@ -82,20 +82,20 @@ class DrawerHeader extends StatelessWidget { ...@@ -82,20 +82,20 @@ class DrawerHeader extends StatelessWidget {
border: new Border( border: new Border(
bottom: new BorderSide( bottom: new BorderSide(
color: theme.dividerColor, color: theme.dividerColor,
width: 0.0 width: 0.0,
) ),
) ),
), ),
child: new AnimatedContainer( child: new AnimatedContainer(
padding: padding + new EdgeInsets.only(top: statusBarHeight), padding: padding.add(new EdgeInsets.only(top: statusBarHeight)),
decoration: decoration, decoration: decoration,
duration: duration, duration: duration,
curve: curve, curve: curve,
child: child == null ? null : new DefaultTextStyle( child: child == null ? null : new DefaultTextStyle(
style: theme.textTheme.body2, style: theme.textTheme.body2,
child: child child: child,
) ),
) ),
); );
} }
} }
...@@ -52,7 +52,7 @@ class ExpandIcon extends StatefulWidget { ...@@ -52,7 +52,7 @@ class ExpandIcon extends StatefulWidget {
/// gestures. /// gestures.
/// ///
/// This property must not be null. It defaults to 8.0 padding on all sides. /// This property must not be null. It defaults to 8.0 padding on all sides.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
@override @override
_ExpandIconState createState() => new _ExpandIconState(); _ExpandIconState createState() => new _ExpandIconState();
......
...@@ -63,13 +63,13 @@ class GridTileBar extends StatelessWidget { ...@@ -63,13 +63,13 @@ class GridTileBar extends StatelessWidget {
decoration = new BoxDecoration(color: backgroundColor); decoration = new BoxDecoration(color: backgroundColor);
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
final EdgeInsets padding = new EdgeInsets.only( final EdgeInsetsDirectional padding = new EdgeInsetsDirectional.only(
left: leading != null ? 8.0 : 16.0, start: leading != null ? 8.0 : 16.0,
right: trailing != null ? 8.0 : 16.0, end: trailing != null ? 8.0 : 16.0,
); );
if (leading != null) if (leading != null)
children.add(new Padding(padding: const EdgeInsets.only(right: 8.0), child: leading)); children.add(new Padding(padding: const EdgeInsetsDirectional.only(end: 8.0), child: leading));
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final ThemeData darkTheme = new ThemeData( final ThemeData darkTheme = new ThemeData(
...@@ -114,7 +114,7 @@ class GridTileBar extends StatelessWidget { ...@@ -114,7 +114,7 @@ class GridTileBar extends StatelessWidget {
} }
if (trailing != null) if (trailing != null)
children.add(new Padding(padding: const EdgeInsets.only(left: 8.0), child: trailing)); children.add(new Padding(padding: const EdgeInsetsDirectional.only(start: 8.0), child: trailing));
return new Container( return new Container(
padding: padding, padding: padding,
......
...@@ -103,12 +103,12 @@ class IconButton extends StatelessWidget { ...@@ -103,12 +103,12 @@ class IconButton extends StatelessWidget {
/// to input gestures. /// to input gestures.
/// ///
/// This property must not be null. It defaults to 8.0 padding on all sides. /// This property must not be null. It defaults to 8.0 padding on all sides.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// Defines how the icon is positioned within the IconButton. /// Defines how the icon is positioned within the IconButton.
/// ///
/// This property must not be null. It defaults to [FractionalOffset.center]. /// This property must not be null. It defaults to [FractionalOffset.center].
final FractionalOffset alignment; final FractionalOffsetGeometry alignment;
/// The icon to display inside the button. /// The icon to display inside the button.
/// ///
......
...@@ -66,7 +66,7 @@ class Tooltip extends StatefulWidget { ...@@ -66,7 +66,7 @@ class Tooltip extends StatefulWidget {
/// The amount of space by which to inset the child. /// The amount of space by which to inset the child.
/// ///
/// Defaults to 16.0 logical pixels in each direction. /// Defaults to 16.0 logical pixels in each direction.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// The amount of vertical distance between the widget and the displayed tooltip. /// The amount of vertical distance between the widget and the displayed tooltip.
final double verticalOffset; final double verticalOffset;
...@@ -192,7 +192,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -192,7 +192,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
child: new Semantics( child: new Semantics(
label: widget.message, label: widget.message,
child: widget.child, child: widget.child,
) ),
); );
} }
} }
...@@ -261,7 +261,7 @@ class _TooltipOverlay extends StatelessWidget { ...@@ -261,7 +261,7 @@ class _TooltipOverlay extends StatelessWidget {
final String message; final String message;
final double height; final double height;
final EdgeInsets padding; final EdgeInsetsGeometry padding;
final Animation<double> animation; final Animation<double> animation;
final Offset target; final Offset target;
final double verticalOffset; final double verticalOffset;
...@@ -281,7 +281,7 @@ class _TooltipOverlay extends StatelessWidget { ...@@ -281,7 +281,7 @@ class _TooltipOverlay extends StatelessWidget {
delegate: new _TooltipPositionDelegate( delegate: new _TooltipPositionDelegate(
target: target, target: target,
verticalOffset: verticalOffset, verticalOffset: verticalOffset,
preferBelow: preferBelow preferBelow: preferBelow,
), ),
child: new FadeTransition( child: new FadeTransition(
opacity: animation, opacity: animation,
...@@ -290,19 +290,19 @@ class _TooltipOverlay extends StatelessWidget { ...@@ -290,19 +290,19 @@ class _TooltipOverlay extends StatelessWidget {
child: new Container( child: new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
color: darkTheme.backgroundColor, color: darkTheme.backgroundColor,
borderRadius: new BorderRadius.circular(2.0) borderRadius: new BorderRadius.circular(2.0),
), ),
height: height, height: height,
padding: padding, padding: padding,
child: new Center( child: new Center(
widthFactor: 1.0, widthFactor: 1.0,
child: new Text(message, style: darkTheme.textTheme.body1) child: new Text(message, style: darkTheme.textTheme.body1),
) ),
) ),
) ),
) ),
) ),
) ),
); );
} }
} }
...@@ -263,7 +263,7 @@ class TwoLevelList extends StatelessWidget { ...@@ -263,7 +263,7 @@ class TwoLevelList extends StatelessWidget {
Key key, Key key,
this.children: const <Widget>[], this.children: const <Widget>[],
this.type: MaterialListType.twoLine, this.type: MaterialListType.twoLine,
this.padding this.padding,
}) : assert(type != null), }) : assert(type != null),
super(key: key); super(key: key);
...@@ -276,7 +276,7 @@ class TwoLevelList extends StatelessWidget { ...@@ -276,7 +276,7 @@ class TwoLevelList extends StatelessWidget {
final MaterialListType type; final MaterialListType type;
/// The amount of space by which to inset the children inside the viewport. /// The amount of space by which to inset the children inside the viewport.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -153,7 +153,7 @@ class UserAccountsDrawerHeader extends StatefulWidget { ...@@ -153,7 +153,7 @@ class UserAccountsDrawerHeader extends StatefulWidget {
final Decoration decoration; final Decoration decoration;
/// The margin around the drawer header. /// The margin around the drawer header.
final EdgeInsets margin; final EdgeInsetsGeometry margin;
/// A widget placed in the upper-left corner that represents the current /// A widget placed in the upper-left corner that represents the current
/// user's account. Normally a [CircleAvatar]. /// user's account. Normally a [CircleAvatar].
......
...@@ -150,7 +150,7 @@ class AnimatedList extends StatefulWidget { ...@@ -150,7 +150,7 @@ class AnimatedList extends StatefulWidget {
final bool shrinkWrap; final bool shrinkWrap;
/// The amount of space by which to inset the children. /// The amount of space by which to inset the children.
final EdgeInsets padding; final EdgeInsetsGeometry padding;
/// The state from the closest instance of this class that encloses the given context. /// The state from the closest instance of this class that encloses the given context.
/// ///
......
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