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>
This commit is contained in:
parent
c256e6d557
commit
1d726bbeb5
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user