fix(iOS): Ti.UI.convertUnits does not consult ti.ui.defaultunit property #10462
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JIRA: https://jira.appcelerator.org/browse/TIMOB-26113
Description:
When attempting to convert units, the
Ti.UI.convertUnits
method should assume the units specified in the ti.ui.defaultunit Ti.App.Property value when the first value passed in does not explicitly state the input units.This PR fixes this on iOS. Under the hood is didn't consult it at all and instead assumed
'dpi'
. I also made that method allow for number values to be passed in for the first argument (and not just strings).Note that the first commit is simply to fix the formatting on the files to match our standards, you should look at the second commit for review purposes.
Test case:
In your tiapp.xml file, change the
ti.ui.defaultunit
value to'px'
or'in'
for the tests below. Our automated suite uses whatever unit is filled into the trap.xml by default, which is'dp'
- so I can't easily write an automated test for this fix (as'dp'
and 'dpi'
are just alternate ways of specifying the same unit type, and so our default apps fill in the same unit type for default as the iOS was hard-coded to assume).