Unverified Commit fd360c4a authored by Eric egramond's avatar Eric egramond Committed by GitHub

Prevent Mediaquery from losing navigationMode value when removePadding() is called (#101938)

parent 7b7206e9
...@@ -438,11 +438,7 @@ class MediaQueryData { ...@@ -438,11 +438,7 @@ class MediaQueryData {
}) { }) {
if (!(removeLeft || removeTop || removeRight || removeBottom)) if (!(removeLeft || removeTop || removeRight || removeBottom))
return this; return this;
return MediaQueryData( return copyWith(
size: size,
devicePixelRatio: devicePixelRatio,
textScaleFactor: textScaleFactor,
platformBrightness: platformBrightness,
padding: padding.copyWith( padding: padding.copyWith(
left: removeLeft ? 0.0 : null, left: removeLeft ? 0.0 : null,
top: removeTop ? 0.0 : null, top: removeTop ? 0.0 : null,
...@@ -455,15 +451,6 @@ class MediaQueryData { ...@@ -455,15 +451,6 @@ class MediaQueryData {
right: removeRight ? math.max(0.0, viewPadding.right - padding.right) : null, right: removeRight ? math.max(0.0, viewPadding.right - padding.right) : null,
bottom: removeBottom ? math.max(0.0, viewPadding.bottom - padding.bottom) : null, bottom: removeBottom ? math.max(0.0, viewPadding.bottom - padding.bottom) : null,
), ),
viewInsets: viewInsets,
alwaysUse24HourFormat: alwaysUse24HourFormat,
highContrast: highContrast,
disableAnimations: disableAnimations,
invertColors: invertColors,
accessibleNavigation: accessibleNavigation,
boldText: boldText,
gestureSettings: gestureSettings,
displayFeatures: displayFeatures,
); );
} }
...@@ -488,12 +475,7 @@ class MediaQueryData { ...@@ -488,12 +475,7 @@ class MediaQueryData {
}) { }) {
if (!(removeLeft || removeTop || removeRight || removeBottom)) if (!(removeLeft || removeTop || removeRight || removeBottom))
return this; return this;
return MediaQueryData( return copyWith(
size: size,
devicePixelRatio: devicePixelRatio,
textScaleFactor: textScaleFactor,
platformBrightness: platformBrightness,
padding: padding,
viewPadding: viewPadding.copyWith( viewPadding: viewPadding.copyWith(
left: removeLeft ? math.max(0.0, viewPadding.left - viewInsets.left) : null, left: removeLeft ? math.max(0.0, viewPadding.left - viewInsets.left) : null,
top: removeTop ? math.max(0.0, viewPadding.top - viewInsets.top) : null, top: removeTop ? math.max(0.0, viewPadding.top - viewInsets.top) : null,
...@@ -506,14 +488,6 @@ class MediaQueryData { ...@@ -506,14 +488,6 @@ class MediaQueryData {
right: removeRight ? 0.0 : null, right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null, bottom: removeBottom ? 0.0 : null,
), ),
alwaysUse24HourFormat: alwaysUse24HourFormat,
highContrast: highContrast,
disableAnimations: disableAnimations,
invertColors: invertColors,
accessibleNavigation: accessibleNavigation,
boldText: boldText,
gestureSettings: gestureSettings,
displayFeatures: displayFeatures,
); );
} }
...@@ -538,32 +512,19 @@ class MediaQueryData { ...@@ -538,32 +512,19 @@ class MediaQueryData {
}) { }) {
if (!(removeLeft || removeTop || removeRight || removeBottom)) if (!(removeLeft || removeTop || removeRight || removeBottom))
return this; return this;
return MediaQueryData( return copyWith(
size: size,
devicePixelRatio: devicePixelRatio,
textScaleFactor: textScaleFactor,
platformBrightness: platformBrightness,
padding: padding.copyWith( padding: padding.copyWith(
left: removeLeft ? 0.0 : null, left: removeLeft ? 0.0 : null,
top: removeTop ? 0.0 : null, top: removeTop ? 0.0 : null,
right: removeRight ? 0.0 : null, right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null, bottom: removeBottom ? 0.0 : null,
), ),
viewInsets: viewInsets,
viewPadding: viewPadding.copyWith( viewPadding: viewPadding.copyWith(
left: removeLeft ? 0.0 : null, left: removeLeft ? 0.0 : null,
top: removeTop ? 0.0 : null, top: removeTop ? 0.0 : null,
right: removeRight ? 0.0 : null, right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null, bottom: removeBottom ? 0.0 : null,
), ),
alwaysUse24HourFormat: alwaysUse24HourFormat,
highContrast: highContrast,
disableAnimations: disableAnimations,
invertColors: invertColors,
accessibleNavigation: accessibleNavigation,
boldText: boldText,
gestureSettings: gestureSettings,
displayFeatures: displayFeatures,
); );
} }
......
...@@ -171,6 +171,7 @@ void main() { ...@@ -171,6 +171,7 @@ void main() {
boldText: true, boldText: true,
highContrast: true, highContrast: true,
platformBrightness: Brightness.dark, platformBrightness: Brightness.dark,
navigationMode: NavigationMode.directional,
gestureSettings: gestureSettings, gestureSettings: gestureSettings,
displayFeatures: customDisplayFeatures, displayFeatures: customDisplayFeatures,
); );
...@@ -188,6 +189,7 @@ void main() { ...@@ -188,6 +189,7 @@ void main() {
expect(copied.boldText, true); expect(copied.boldText, true);
expect(copied.highContrast, true); expect(copied.highContrast, true);
expect(copied.platformBrightness, Brightness.dark); expect(copied.platformBrightness, Brightness.dark);
expect(copied.navigationMode, NavigationMode.directional);
expect(copied.gestureSettings, gestureSettings); expect(copied.gestureSettings, gestureSettings);
expect(copied.displayFeatures, customDisplayFeatures); expect(copied.displayFeatures, customDisplayFeatures);
}); });
...@@ -223,6 +225,7 @@ void main() { ...@@ -223,6 +225,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -257,6 +260,7 @@ void main() { ...@@ -257,6 +260,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -291,6 +295,7 @@ void main() { ...@@ -291,6 +295,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -322,6 +327,7 @@ void main() { ...@@ -322,6 +327,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -356,6 +362,7 @@ void main() { ...@@ -356,6 +362,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -390,6 +397,7 @@ void main() { ...@@ -390,6 +397,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -424,6 +432,7 @@ void main() { ...@@ -424,6 +432,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -455,6 +464,7 @@ void main() { ...@@ -455,6 +464,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -489,6 +499,7 @@ void main() { ...@@ -489,6 +499,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -523,6 +534,7 @@ void main() { ...@@ -523,6 +534,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -557,6 +569,7 @@ void main() { ...@@ -557,6 +569,7 @@ void main() {
disableAnimations: true, disableAnimations: true,
boldText: true, boldText: true,
highContrast: true, highContrast: true,
navigationMode: NavigationMode.directional,
displayFeatures: displayFeatures, displayFeatures: displayFeatures,
), ),
child: Builder( child: Builder(
...@@ -588,6 +601,7 @@ void main() { ...@@ -588,6 +601,7 @@ void main() {
expect(unpadded.disableAnimations, true); expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true); expect(unpadded.boldText, true);
expect(unpadded.highContrast, true); expect(unpadded.highContrast, true);
expect(unpadded.navigationMode, NavigationMode.directional);
expect(unpadded.displayFeatures, displayFeatures); expect(unpadded.displayFeatures, displayFeatures);
}); });
...@@ -900,7 +914,7 @@ void main() { ...@@ -900,7 +914,7 @@ void main() {
); );
expect( expect(
subScreenMediaQuery.viewPadding, subScreenMediaQuery.viewPadding,
const EdgeInsets.only(top: 6.0, left:4.0, right: 8.0, bottom: 12.0), const EdgeInsets.only(top: 6.0, left: 4.0, right: 8.0, bottom: 12.0),
); );
expect( expect(
subScreenMediaQuery.viewInsets, subScreenMediaQuery.viewInsets,
......
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