[ALOY-812] Alloy: Automatically convert string-values for number-properties like borderWidth in TSS
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-03-25T16:15:46.000+0000 |
Affected Version/s | Alloy 1.2.1 |
Fix Version/s | n/a |
Components | n/a |
Labels | alloy, android, dip, px, tss |
Reporter | Fokke Zandbergen |
Assignee | Tim Poulsen |
Created | 2013-08-29T10:39:50.000+0000 |
Updated | 2018-03-07T22:28:27.000+0000 |
Description
When doing an app for both iOS and Android, I usually set the default unit todp
. This works great, but some properties like borderWidth
and borderRadius
are always interpreted as px
on Android.
So for the right size, I need to use Alloy's builtin measurement.dpToPx
. However, TSS does not (longer) support using methods, only (global) values. This means for every different value I use, I need to pre-calculate the px-value in alloy.js
and store it in Alloy.Globals
so I can use it in the TSS. This is far from ideal.
Why not add builtin casting of non-number values to number-values for properties that require that type?
For example, in TSS I'd have:
"View": {
borderWidth: '5dp'
}
Which then would be compiled to:
borderWidth: Alloy.measurement.toNumber('5dp');
The Alloy.measurement.toNumber
method then should read the unit from the string and perform the appropriate conversion to get the number-value (px).
Attachments
File | Date | Size |
---|---|---|
S420.png | 2014-03-25T16:15:16.000+0000 | 105815 |