Unverified Commit aa29358c authored by Jessica Pereira's avatar Jessica Pereira Committed by GitHub

Fix license page rtl (#120497)

* fix license page rtl

* fix editor spacings, tests to lateral view

* fix defaultSize and setSurfaceSize

* add validation for packageList position

* fix spacing

* simplify align
parent c6e1a4dc
......@@ -1400,7 +1400,10 @@ class _MasterDetailScaffoldState extends State<_MasterDetailScaffold>
),
),
),
body: _masterPanel(context),
body: Align(
alignment: AlignmentDirectional.centerStart,
child: _masterPanel(context),
),
),
// Detail view stacked above main scaffold and master view.
SafeArea(
......
......@@ -1067,6 +1067,136 @@ void main() {
expect(tester.takeException().toString(), 'Exception: Injected failure');
expect(find.text('Exception: Injected failure'), findsOneWidget);
});
testWidgets('LicensePage master view layout position - ltr', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.ltr;
const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0);
const String title = 'License ABC';
LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['ABC'], 'DEF'),
]);
});
// Configure to show the default layout.
await tester.binding.setSurfaceSize(defaultSize);
await tester.pumpWidget(
const MaterialApp(
title: title,
home: Scaffold(
body: Directionality(
textDirection: textDirection,
child: LicensePage(),
),
),
),
);
// To stop loading
await tester.pumpAndSettle();
// If the layout width is less than 840.0 pixels, nested layout is
// used which positions license page title at the top center.
Offset titleOffset = tester.getCenter(find.text(title));
expect(titleOffset, Offset(defaultSize.width / 2, 92.0));
expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0));
// Configure a wide window to show the lateral UI.
await tester.binding.setSurfaceSize(wideSize);
await tester.pumpWidget(
const MaterialApp(
title: title,
home: Scaffold(
body: Directionality(
textDirection: textDirection,
child: LicensePage(),
),
),
),
);
// To finish the FakeTimer
await tester.pumpAndSettle();
// If the layout width is greater than 840.0 pixels, lateral UI layout
// is used which positions license page title and packageList
// at the top left.
titleOffset = tester.getTopRight(find.text(title));
expect(titleOffset, const Offset(292.0, 136.0));
expect(titleOffset.dx, lessThan(wideSize.width - 320)); // Default master view width is 320.0.
expect(tester.getCenter(find.byType(ListView)), const Offset(160, 356));
// Configure to show the default layout.
await tester.binding.setSurfaceSize(defaultSize);
});
testWidgets('LicensePage master view layout position - rtl', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.rtl;
const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0);
const String title = 'License ABC';
LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['ABC'], 'DEF'),
]);
});
// Configure to show the default layout.
await tester.binding.setSurfaceSize(defaultSize);
await tester.pumpWidget(
const MaterialApp(
title: title,
home: Scaffold(
body: Directionality(
textDirection: textDirection,
child: LicensePage(),
),
),
),
);
// To stop loading
await tester.pumpAndSettle();
// If the layout width is less than 840.0 pixels, nested layout is
// used which positions license page title at the top center.
Offset titleOffset = tester.getCenter(find.text(title));
expect(titleOffset, Offset(defaultSize.width / 2, 92.0));
expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0));
// Configure a wide window to show the lateral UI.
await tester.binding.setSurfaceSize(wideSize);
await tester.pumpWidget(
const MaterialApp(
title: title,
home: Scaffold(
body: Directionality(
textDirection: textDirection,
child: LicensePage(),
),
),
),
);
// To finish the FakeTimer
await tester.pumpAndSettle();
// If the layout width is greater than 840.0 pixels, lateral UI layout
// is used which positions license page title and packageList
// at the top right.
titleOffset = tester.getTopLeft(find.text(title));
expect(titleOffset, const Offset(908.0, 136.0));
expect(titleOffset.dx, greaterThan(wideSize.width - 320)); // Default master view width is 320.0.
expect(tester.getCenter(find.byType(ListView)), const Offset(1040.0, 356.0));
// Configure to show the default layout.
await tester.binding.setSurfaceSize(defaultSize);
});
}
class FakeLicenseEntry extends LicenseEntry {
......
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