Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

[iOS/Win] Label will not unnecessarily expand #827

Merged
merged 3 commits into from
Mar 22, 2017
Merged

Conversation

samhouts
Copy link
Member

@samhouts samhouts commented Mar 20, 2017

Description of Change

Labels will no longer expand to the width constraint unless required to do so. Regression caused by #529. Jason tried to warn me. What could go wrong, I said. It's just a small fix, I said.

Bugs Fixed

API Changes

None.

Behavioral Changes

This shouldn't break anything, I said.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

@@ -72,15 +72,31 @@ public override SizeRequest GetDesiredSize(double widthConstraint, double height
_perfectSizeValid = true;
}

if (widthConstraint >= _perfectSize.Request.Width && heightConstraint >= _perfectSize.Request.Height)
var widthFits = widthConstraint >= _perfectSize.Request.Width;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug did not affect Windows, but the logic here was copied from iOS, so I copied the fix over for housekeeping purposes.

var widthFits = widthConstraint >= _perfectSize.Request.Width;
var heightFits = heightConstraint >= _perfectSize.Request.Height;

if (widthFits && heightFits)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored, but the logic is the same.

result.Minimum = new Size(Math.Min(10, result.Request.Width), result.Request.Height);
if (Element.LineBreakMode != LineBreakMode.NoWrap)
var tinyWidth = Math.Min(10, result.Request.Width);
result.Minimum = new Size(tinyWidth, result.Request.Height);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More refactoring, no change here.

var tinyWidth = Math.Min(10, result.Request.Width);
result.Minimum = new Size(tinyWidth, result.Request.Height);

if (widthFits || Element.LineBreakMode == LineBreakMode.NoWrap)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change that fixes this bug. Don't continue on to the "expand" logic if the text already fits the container.

{
var expandedWidth = Math.Max(tinyWidth, widthConstraint);
result.Request = new Size(expandedWidth, result.Request.Height);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of these changes are all refactoring for readability.

if (widthFits || Element.LineBreakMode == LineBreakMode.NoWrap)
return result;

bool containerIsNotInfinitelyWide = !double.IsInfinity(widthConstraint);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification of if (!double.IsInfinity(result.Request.Width) && !double.IsInfinity(widthConstraint)).

@rmarinho rmarinho requested a review from jassmith March 21, 2017 11:28
Copy link

@jassmith jassmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I remain super skeptical I can't find anything wrong.

@rmarinho rmarinho merged commit c65a9a8 into master Mar 22, 2017
rmarinho pushed a commit that referenced this pull request Mar 22, 2017
* Add repro for 53362

* [iOS] Label will not unnecessarily expand

* [Win] Label will not unnecessarily expand
@samhouts samhouts deleted the fix-bugzilla52263 branch April 19, 2017 23:06
@samhouts samhouts modified the milestone: 3.1.0 Jun 1, 2018
@samhouts samhouts modified the milestones: 2.3.0, 2.3.4 Jun 27, 2018
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
* GH-23: Added Tizen backend (#555)

* Adding the initial work to get Tizen started. #23

* Adding the initial work to get Tizen started. #23

* Use the overloads properly.

* Use the overloads properly.

* Tizen needs to have a background explicitly set

* Added the Vibration API

* Added the Vibration API

* Refactoring a little bit

* Refactoring a little bit

* Added the Browser API and some basic permissions checking

* Added the Browser API and some basic permissions checking

* Added the Battery API

* Added the Battery API

* Added the Acceleromerter API

* Added the Acceleromerter API

* Added the Filesystem API

* Added the Filesystem API

* Update Accelerometer Initialize using GetDefaultSensor

* Update Accelerometer Initialize using GetDefaultSensor

* Added the Gyroscope API

* Added the Gyroscope API

* Added the Magnetometer API

* Added the Magnetometer API

* Added the Compass API

* Added the Compass API

* Added the Connectivity API

* Added the Connectivity API

* Added the Flashlight API

* Added the Flashlight API

* Added the SecureStorage API

* Added the SecureStorage API

* Added the Vibration API

* Added the Vibration API

* Fixed build break

* Fixed build break

* Added the OrientationSensor API

* Fixed build break

* Initialized Maps/Launcher for Tizen

* Added the Permissions API

* Added the Geolocation API

* Added the Geocoding API

* Fixed build break

* Initialize Barometer API

* Added the Barometer API

* Added the TextToSpeech API

* Added the Launcher APIs

* Fixed bugs

* Update Location property name

* Update several modules

- Update AppInfo, Browser, Clipboard, Compass, Connectivity,
  DisplayInfo, DeviceInfo, Geocoding, TextToSpeech modules
- Change module name DataTrasfer to Share, Maps to Map
- Integrated module Power to Battery, ScreenLock to DeviceDisplay

* Throw PlatformNotSupportedException for Tizen

* Change the exception for the power saver feature

* Add tizen privileges

* Add FileBase

* Add ShareFileRequest

* Change enum for Browser

* Change parameter for Permissions

* Add SensorSpeedExtensions

* Add Launcher for OpenFileRequest

* Fix .csproj for VS2019

* Fix sample for watch

* Fix Geolocation speed

* Fix TextToSpeech ptich

* Fixed missing using System;

This was needed for the Math calls

* Add Support for  ⌚OS and 📺OS  (#827)

* Add Support for watchOS and tvOS

* Fix up exception from shared netstandard code to figure out what to send.

* Update Battery.ios.watchos.cs

* Integrate Tizen into the netstandard not supported area.

* [Tizen] Fix reference for avoid duplication (#850)

* Fix reference to avoid version collision

* Remove Vector3 reference on Tizen

* Fix iPad not show share sheet (#873)

Need to specify bottom center of the screen.

* Added the Main Thread helpers from Xamarin.Forms (#849)

* Added Invoke methods from Xamarin.Forms

* Updated to use Essentials approach to calling the MainThread

* Updated the docs with the new MainThread methods

* Make overload more readable

The old code was I think incorrect in that the `funcTask()` was never awaited or returned as a task.  This is the same code as the overload with the generic type parameter, but without the type param.

* Updated to use UrlEncode in GetMailToUrl (#848)

* Updated to use UrlEncode in GetMailToUrl

Fixes #843

* Added missing using

* Fixed Using order and spacings

* Use WebUtility.UrlEncode on placemark extensions

* Added volatile to MainThread.Android (#877)

Fixes #838

* Add Launcher.TryOpenAsync (#839)

* Add Launcher.TryOpenAsync

* Added ConfigureAwait(false)

* Removed unnecessary async

* Updated launcher docs

* Updated the docs

* Added Launch Tests

* Add aka.ms for release notes (#883)

* Remove experimental flags & fix launcher teasts (#887)
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
* GH-23: Added Tizen backend (#555)

* Adding the initial work to get Tizen started. #23

* Adding the initial work to get Tizen started. #23

* Use the overloads properly.

* Use the overloads properly.

* Tizen needs to have a background explicitly set

* Added the Vibration API

* Added the Vibration API

* Refactoring a little bit

* Refactoring a little bit

* Added the Browser API and some basic permissions checking

* Added the Browser API and some basic permissions checking

* Added the Battery API

* Added the Battery API

* Added the Acceleromerter API

* Added the Acceleromerter API

* Added the Filesystem API

* Added the Filesystem API

* Update Accelerometer Initialize using GetDefaultSensor

* Update Accelerometer Initialize using GetDefaultSensor

* Added the Gyroscope API

* Added the Gyroscope API

* Added the Magnetometer API

* Added the Magnetometer API

* Added the Compass API

* Added the Compass API

* Added the Connectivity API

* Added the Connectivity API

* Added the Flashlight API

* Added the Flashlight API

* Added the SecureStorage API

* Added the SecureStorage API

* Added the Vibration API

* Added the Vibration API

* Fixed build break

* Fixed build break

* Added the OrientationSensor API

* Fixed build break

* Initialized Maps/Launcher for Tizen

* Added the Permissions API

* Added the Geolocation API

* Added the Geocoding API

* Fixed build break

* Initialize Barometer API

* Added the Barometer API

* Added the TextToSpeech API

* Added the Launcher APIs

* Fixed bugs

* Update Location property name

* Update several modules

- Update AppInfo, Browser, Clipboard, Compass, Connectivity,
  DisplayInfo, DeviceInfo, Geocoding, TextToSpeech modules
- Change module name DataTrasfer to Share, Maps to Map
- Integrated module Power to Battery, ScreenLock to DeviceDisplay

* Throw PlatformNotSupportedException for Tizen

* Change the exception for the power saver feature

* Add tizen privileges

* Add FileBase

* Add ShareFileRequest

* Change enum for Browser

* Change parameter for Permissions

* Add SensorSpeedExtensions

* Add Launcher for OpenFileRequest

* Fix .csproj for VS2019

* Fix sample for watch

* Fix Geolocation speed

* Fix TextToSpeech ptich

* Fixed missing using System;

This was needed for the Math calls

* Add Support for  ⌚OS and 📺OS  (#827)

* Add Support for watchOS and tvOS

* Fix up exception from shared netstandard code to figure out what to send.

* Update Battery.ios.watchos.cs

* Integrate Tizen into the netstandard not supported area.

* [Tizen] Fix reference for avoid duplication (#850)

* Fix reference to avoid version collision

* Remove Vector3 reference on Tizen

* Fix iPad not show share sheet (#873)

Need to specify bottom center of the screen.

* Added the Main Thread helpers from Xamarin.Forms (#849)

* Added Invoke methods from Xamarin.Forms

* Updated to use Essentials approach to calling the MainThread

* Updated the docs with the new MainThread methods

* Make overload more readable

The old code was I think incorrect in that the `funcTask()` was never awaited or returned as a task.  This is the same code as the overload with the generic type parameter, but without the type param.

* Updated to use UrlEncode in GetMailToUrl (#848)

* Updated to use UrlEncode in GetMailToUrl

Fixes #843

* Added missing using

* Fixed Using order and spacings

* Use WebUtility.UrlEncode on placemark extensions

* Added volatile to MainThread.Android (#877)

Fixes #838

* Add Launcher.TryOpenAsync (#839)

* Add Launcher.TryOpenAsync

* Added ConfigureAwait(false)

* Removed unnecessary async

* Updated launcher docs

* Updated the docs

* Added Launch Tests

* Add aka.ms for release notes (#883)

* Remove experimental flags & fix launcher teasts (#887)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants