Commit 1d726bbe authored by Adam Barth's avatar Adam Barth Committed by GitHub

Left align AppBar title on iOS with multiple actions (#9723)

If there is more than one action, then the AppBar should align the title to the
left according to
<https://material.io/guidelines/platforms/platform-adaptation.html#platform-adaptation-platform-recommendations>
parent c256e6d5
......@@ -311,7 +311,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
case TargetPlatform.fuchsia:
return false;
case TargetPlatform.iOS:
return true;
return actions == null || actions.length < 2;
}
return null;
}
......
......@@ -90,6 +90,48 @@ void main() {
size = tester.getSize(title);
expect(center.dx, greaterThan(400 - size.width / 2.0));
expect(center.dx, lessThan(400 + size.width / 2.0));
// One action is still centered.
await tester.pumpWidget(
new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.iOS),
home: new Scaffold(
appBar: new AppBar(
title: const Text('X'),
actions: <Widget>[
const Icon(Icons.thumb_up),
],
),
),
),
);
center = tester.getCenter(title);
size = tester.getSize(title);
expect(center.dx, greaterThan(400 - size.width / 2.0));
expect(center.dx, lessThan(400 + size.width / 2.0));
// Two actions is left aligned again.
await tester.pumpWidget(
new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.iOS),
home: new Scaffold(
appBar: new AppBar(
title: const Text('X'),
actions: <Widget>[
const Icon(Icons.thumb_up),
const Icon(Icons.thumb_up),
],
),
),
),
);
center = tester.getCenter(title);
size = tester.getSize(title);
expect(center.dx, lessThan(400 - size.width / 2.0));
});
testWidgets('AppBar centerTitle:true centers on Android', (WidgetTester tester) async {
......@@ -105,7 +147,6 @@ void main() {
)
);
final Finder title = find.text('X');
final Offset center = tester.getCenter(title);
final Size size = tester.getSize(title);
......
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