@maccesar/titools 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -263,26 +263,68 @@ exports.ThemeService = {
|
|
|
263
263
|
}
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
### Semantic Colors (
|
|
266
|
+
### Semantic Colors (Cross-Platform)
|
|
267
267
|
|
|
268
|
-
Titanium
|
|
268
|
+
Titanium provides a cross-platform semantic colors API for Dark Mode support. Define colors in a `semantic.colors.json` file:
|
|
269
|
+
|
|
270
|
+
**File location:**
|
|
271
|
+
- **Classic apps**: `Resources/semantic.colors.json`
|
|
272
|
+
- **Alloy apps**: `app/assets/semantic.colors.json`
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"textColor": {
|
|
277
|
+
"dark": {
|
|
278
|
+
"color": "#ff85e2",
|
|
279
|
+
"alpha": "50"
|
|
280
|
+
},
|
|
281
|
+
"light": "#ff1f1f"
|
|
282
|
+
},
|
|
283
|
+
"backgroundColor": {
|
|
284
|
+
"dark": "#1a1a2e",
|
|
285
|
+
"light": "#ffffff"
|
|
286
|
+
},
|
|
287
|
+
"primaryColor": {
|
|
288
|
+
"dark": {
|
|
289
|
+
"color": "#4ade80",
|
|
290
|
+
"alpha": "100"
|
|
291
|
+
},
|
|
292
|
+
"light": {
|
|
293
|
+
"color": "#22c55e",
|
|
294
|
+
"alpha": "100"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Using semantic colors:**
|
|
269
301
|
|
|
270
302
|
```tss
|
|
271
|
-
/*
|
|
303
|
+
/* Reference via Ti.UI.fetchSemanticColor() */
|
|
272
304
|
"#label": {
|
|
273
|
-
color: Ti.UI.fetchSemanticColor('
|
|
305
|
+
color: Ti.UI.fetchSemanticColor('textColor')
|
|
274
306
|
}
|
|
275
307
|
|
|
276
|
-
"#
|
|
277
|
-
backgroundColor: Ti.UI.fetchSemanticColor('
|
|
308
|
+
"#container": {
|
|
309
|
+
backgroundColor: Ti.UI.fetchSemanticColor('backgroundColor')
|
|
278
310
|
}
|
|
279
311
|
```
|
|
280
312
|
|
|
281
|
-
|
|
313
|
+
```javascript
|
|
314
|
+
// Or use color names directly as property values
|
|
315
|
+
$.label.color = 'textColor';
|
|
316
|
+
$.container.backgroundColor = 'backgroundColor';
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**How it works:**
|
|
320
|
+
- On iOS 13+ it uses the native system method that checks the user's system-wide Dark Mode setting
|
|
321
|
+
- On all other platforms it checks `Ti.UI.semanticColorType` and returns the correct color variant
|
|
322
|
+
- Alpha can be set from 0.0-100.0 (integer or float)
|
|
323
|
+
- Light values can use hex with alpha via ARGB/AARRGGBB format
|
|
282
324
|
|
|
283
325
|
:::tip When to use Semantic Colors vs Alloy.Globals
|
|
284
|
-
- **Semantic Colors**:
|
|
285
|
-
- **Alloy.Globals palette**:
|
|
326
|
+
- **Semantic Colors**: Built-in Dark Mode support, automatic switching, simpler setup. Works cross-platform.
|
|
327
|
+
- **Alloy.Globals palette**: More control over when/how themes switch, easier to add custom themes beyond light/dark, runtime theme changes with UI rebuild.
|
|
286
328
|
:::
|
|
287
329
|
|
|
288
330
|
---
|