Fix CupertinoAlertDialog TextStyle (#64468)
This commit is contained in:
@@ -18,22 +18,28 @@ import 'scrollbar.dart';
|
||||
|
||||
// TODO(abarth): These constants probably belong somewhere more general.
|
||||
|
||||
// Used XD to flutter plugin(https://github.com/AdobeXD/xd-to-flutter-plugin/)
|
||||
// to derive values of TextStyle(height and letterSpacing) from
|
||||
// Adobe XD template for iOS 13, which can be found in
|
||||
// Apple Design Resources(https://developer.apple.com/design/resources/).
|
||||
// However the values are not exactly the same as native, so eyeballing is needed.
|
||||
const TextStyle _kCupertinoDialogTitleStyle = TextStyle(
|
||||
fontFamily: '.SF UI Display',
|
||||
inherit: false,
|
||||
fontSize: 18.0,
|
||||
fontSize: 17.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.48,
|
||||
height: 1.3,
|
||||
letterSpacing: -0.5,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
);
|
||||
|
||||
const TextStyle _kCupertinoDialogContentStyle = TextStyle(
|
||||
fontFamily: '.SF UI Text',
|
||||
inherit: false,
|
||||
fontSize: 13.4,
|
||||
fontSize: 13.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
height: 1.036,
|
||||
letterSpacing: -0.25,
|
||||
height: 1.35,
|
||||
letterSpacing: -0.2,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
);
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ void main() {
|
||||
// Visually the "Cancel" button and "OK" button are the same height when using the
|
||||
// regular font. However, when using the test font, "Cancel" becomes 2 lines which
|
||||
// is why the height we're verifying for "Cancel" is larger than "OK".
|
||||
expect(tester.getSize(find.text('The Title')), equals(const Size(270.0, 162.0)));
|
||||
expect(tester.getSize(find.text('The Title')), equals(const Size(270.0, 132.0)));
|
||||
expect(tester.getTopLeft(find.text('The Title')), equals(const Offset(265.0, 80.0 + 24.0)));
|
||||
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Cancel')), equals(const Size(310.0, 148.0)));
|
||||
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'OK')), equals(const Size(310.0, 98.0)));
|
||||
@@ -1147,6 +1147,36 @@ void main() {
|
||||
// once animation settles the dialog is padded by the new viewInsets
|
||||
expect(tester.getRect(find.byType(Placeholder)), placeholderRectWithoutInsets.translate(10, 10));
|
||||
});
|
||||
|
||||
testWidgets('Default cupertino dialog golden', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
createAppWithButtonThatLaunchesDialog(
|
||||
dialogBuilder: (BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0),
|
||||
child: const RepaintBoundary(
|
||||
child: CupertinoAlertDialog(
|
||||
title: Text('Title'),
|
||||
content: Text('text'),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(child: Text('No')),
|
||||
CupertinoDialogAction(child: Text('OK')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await expectLater(
|
||||
find.byType(CupertinoAlertDialog),
|
||||
matchesGoldenFile('dialog_test.cupertino.default.png'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
RenderBox findActionButtonRenderBoxByTitle(WidgetTester tester, String title) {
|
||||
|
||||
Reference in New Issue
Block a user