@maccesar/titools 2.2.11 → 2.3.0
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/README.md +255 -713
- package/bin/titools.js +1 -1
- package/lib/commands/update.js +5 -6
- package/lib/config.js +1 -0
- package/lib/downloader.js +10 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +46 -48
- package/skills/alloy-guides/references/CONTROLLERS.md +4 -6
- package/skills/alloy-guides/references/MODELS.md +340 -184
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +3 -4
- package/skills/alloy-guides/references/VIEWS_STYLES.md +44 -46
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +4 -5
- package/skills/alloy-guides/references/VIEWS_XML.md +51 -17
- package/skills/alloy-guides/references/WIDGETS.md +1 -1
- package/skills/alloy-howtos/SKILL.md +12 -13
- package/skills/alloy-howtos/references/cli_reference.md +40 -41
- package/skills/alloy-howtos/references/samples.md +3 -4
- package/skills/purgetss/SKILL.md +369 -356
- package/skills/purgetss/references/EXAMPLES.md +24 -25
- package/skills/purgetss/references/animation-advanced.md +555 -0
- package/skills/purgetss/references/animation-system.md +395 -995
- package/skills/purgetss/references/apply-directive.md +111 -141
- package/skills/purgetss/references/arbitrary-values.md +206 -480
- package/skills/purgetss/references/class-categories.md +277 -0
- package/skills/purgetss/references/class-index.md +1 -420
- package/skills/purgetss/references/cli-commands.md +446 -556
- package/skills/purgetss/references/configurable-properties.md +163 -599
- package/skills/purgetss/references/custom-rules.md +33 -76
- package/skills/purgetss/references/customization-deep-dive.md +319 -518
- package/skills/purgetss/references/dynamic-component-creation.md +33 -37
- package/skills/purgetss/references/grid-layout.md +42 -371
- package/skills/purgetss/references/icon-fonts.md +82 -475
- package/skills/purgetss/references/installation-setup.md +159 -331
- package/skills/purgetss/references/migration-guide.md +54 -109
- package/skills/purgetss/references/opacity-modifier.md +25 -222
- package/skills/purgetss/references/performance-tips.md +2 -2
- package/skills/purgetss/references/platform-modifiers.md +21 -407
- package/skills/purgetss/references/tikit-components.md +237 -104
- package/skills/purgetss/references/titanium-resets.md +20 -21
- package/skills/purgetss/references/ui-ux-design.md +171 -1702
- package/skills/ti-api/SKILL.md +109 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-expert/SKILL.md +106 -138
- package/skills/ti-expert/references/adaptive-layouts.md +414 -0
- package/skills/ti-expert/references/alloy-builtins.md +16 -20
- package/skills/ti-expert/references/alloy-structure.md +40 -42
- package/skills/ti-expert/references/anti-patterns.md +34 -0
- package/skills/ti-expert/references/architecture-tiers.md +248 -0
- package/skills/ti-expert/references/code-conventions.md +5 -3
- package/skills/ti-expert/references/error-handling.md +14 -7
- package/skills/ti-expert/references/examples.md +4 -2
- package/skills/ti-expert/references/performance-optimization.md +26 -24
- package/skills/ti-expert/references/security-device.md +17 -14
- package/skills/ti-expert/references/security-fundamentals.md +60 -101
- package/skills/ti-expert/references/state-management.md +15 -14
- package/skills/ti-expert/references/testing-e2e-ci.md +30 -21
- package/skills/ti-expert/references/theming.md +12 -20
- package/skills/ti-guides/SKILL.md +13 -17
- package/skills/ti-guides/references/advanced-data-and-images.md +30 -10
- package/skills/ti-guides/references/application-frameworks.md +3 -3
- package/skills/ti-guides/references/coding-best-practices.md +31 -2
- package/skills/ti-guides/references/commonjs-advanced.md +46 -4
- package/skills/ti-guides/references/hello-world.md +9 -13
- package/skills/ti-guides/references/hyperloop-native-access.md +4 -1
- package/skills/ti-guides/references/javascript-primer.md +13 -5
- package/skills/ti-guides/references/resources.md +0 -2
- package/skills/ti-guides/references/style-and-conventions.md +1 -0
- package/skills/ti-guides/references/tiapp-config.md +0 -32
- package/skills/ti-howtos/SKILL.md +43 -45
- package/skills/ti-howtos/references/buffer-codec-streams.md +25 -3
- package/skills/ti-howtos/references/debugging-profiling.md +14 -25
- package/skills/ti-howtos/references/google-maps-v2.md +3 -3
- package/skills/ti-howtos/references/ios-map-kit.md +8 -1
- package/skills/ti-howtos/references/notification-services.md +0 -1
- package/skills/ti-howtos/references/webpack-build-pipeline.md +3 -0
- package/skills/ti-ui/SKILL.md +47 -49
- package/skills/ti-ui/references/application-structures.md +3 -2
- package/skills/ti-ui/references/orientation.md +17 -9
- package/skills/ti-ui/references/platform-ui-ios.md +63 -0
- package/skills/ti-ui/references/scrolling-views.md +39 -0
|
@@ -1,125 +1,37 @@
|
|
|
1
1
|
# Platform and Device Modifiers
|
|
2
2
|
|
|
3
|
-
Platform and
|
|
3
|
+
Platform and device modifiers (also called variants or prefixes) apply styles conditionally based on platform (iOS or Android) and device type (tablet or handheld):
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- Platform modifiers:
|
|
6
|
+
- `ios:`
|
|
7
|
+
- `android:`
|
|
8
|
+
- Device modifiers:
|
|
9
|
+
- `tablet:`
|
|
10
|
+
- `handheld:`
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
**Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties WITHOUT modifiers will:**
|
|
9
|
-
|
|
10
|
-
1. **Add iOS code to Android builds** → compilation failures
|
|
11
|
-
2. **Add Android code to iOS builds** → compilation failures
|
|
12
|
-
3. **Create invalid cross-platform code**
|
|
13
|
-
4. **Confuse developers** who don't understand the error
|
|
14
|
-
|
|
15
|
-
**REAL EXAMPLE of the damage:**
|
|
16
|
-
```javascript
|
|
17
|
-
// ❌ WRONG - Adds Ti.UI.iOS to Android project
|
|
18
|
-
"#mainWindow": {
|
|
19
|
-
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT // FAILS on Android!
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Error message:**
|
|
24
|
-
```
|
|
25
|
-
[ERROR] Ti.UI iOS is not defined
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**CORRECT approaches:**
|
|
29
|
-
|
|
30
|
-
**Option 1 - TSS modifier (RECOMMENDED for PurgeTSS):**
|
|
31
|
-
```tss
|
|
32
|
-
// ✅ CORRECT - Only adds to iOS
|
|
33
|
-
"#mainWindow[platform=ios]": {
|
|
34
|
-
statusBarStyle: Ti.UI.iOS.StatusBar.LIST_VIEW_EDIT_ACTION_STYLE_NORMAL
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**Option 2 - Platform modifier classes:**
|
|
39
|
-
```xml
|
|
40
|
-
<!-- ✅ CORRECT -->
|
|
41
|
-
<Window class="ios:status-bar-light android:status-bar-dark">
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Option 3 - Conditional controller logic:**
|
|
45
|
-
```javascript
|
|
46
|
-
if (OS_IOS) {
|
|
47
|
-
$.mainWindow.statusBarStyle = Ti.UI.iOS.StatusBar.LIGHT_CONTENT
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**Common platform-specific properties that REQUIRE modifiers:**
|
|
52
|
-
- iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, `systemButton`, any `Ti.UI.iOS.*`
|
|
53
|
-
- Android: `actionBar` config, any `Ti.Android.*` constant
|
|
54
|
-
|
|
55
|
-
**When suggesting platform-specific code, ALWAYS:**
|
|
56
|
-
1. Check if user's project supports that platform
|
|
57
|
-
2. Use `[platform=ios]` or `[platform=android]` TSS modifier
|
|
58
|
-
3. OR use PurgeTSS platform classes: `ios:prop-*`, `android:prop-*`
|
|
59
|
-
4. OR use conditional `OS_IOS` / `OS_ANDROID` checks in controllers
|
|
60
|
-
|
|
61
|
-
:::
|
|
62
|
-
|
|
63
|
-
## Available Modifiers
|
|
64
|
-
|
|
65
|
-
### Platform Modifiers
|
|
66
|
-
|
|
67
|
-
Target specific OS engines directly in the XML:
|
|
68
|
-
|
|
69
|
-
- **`ios:`** - Applies only to Apple devices (iPhone, iPad)
|
|
70
|
-
- **`android:`** - Applies only to Android devices
|
|
71
|
-
|
|
72
|
-
```xml
|
|
73
|
-
<View class="ios:mt-10 android:mt-5 mt-4" />
|
|
74
|
-
<Label class="ios:text-blue-600 android:text-gray-600" />
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Device (Form Factor) Modifiers
|
|
78
|
-
|
|
79
|
-
Target device categories based on screen size:
|
|
80
|
-
|
|
81
|
-
- **`tablet:`** - iPads and Android Tablets
|
|
82
|
-
- **`handheld:`** - Phones (iPhone and Android phones)
|
|
83
|
-
|
|
84
|
-
```xml
|
|
85
|
-
<View class="tablet:w-1/2 handheld:w-full w-screen" />
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Usage in XML
|
|
89
|
-
|
|
90
|
-
### Basic Platform Targeting
|
|
12
|
+
You can set different background colors and font sizes per platform and device, and combine them with arbitrary values. Examples: `ios:bg-(#53606b)`, `ios:text-(20px)`, `android:bg-(#8fb63e)`, and `android:text-(24px)`.
|
|
91
13
|
|
|
92
14
|
```xml
|
|
93
15
|
<Alloy>
|
|
94
16
|
<Window class="tablet:bg-green-500 handheld:bg-blue-500">
|
|
95
|
-
<View class="tablet:bg-green-100 handheld:bg-blue-100
|
|
96
|
-
<Label class="ios:text-blue-800 ios:text-xl android:text-green-800 android:text-2xl
|
|
97
|
-
This is a Test
|
|
98
|
-
</Label>
|
|
17
|
+
<View class="h-32 tablet:bg-green-100 handheld:bg-blue-100">
|
|
18
|
+
<Label class="w-screen h-auto text-center ios:text-blue-800 ios:text-xl android:text-green-800 android:text-2xl">This is a Test</Label>
|
|
99
19
|
</View>
|
|
100
20
|
</Window>
|
|
101
21
|
</Alloy>
|
|
102
22
|
```
|
|
103
23
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```xml
|
|
109
|
-
<Label class="ios:bg-(#53606b) ios:text-(20px) android:bg-(#8fb63e) android:text-(24px)" />
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Multiple Modifiers on Same Element
|
|
113
|
-
|
|
114
|
-
```xml
|
|
115
|
-
<View class="ios:tablet:bg-white ios:handheld:bg-gray-100 android:bg-gray-200" />
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Generated TSS Output
|
|
24
|
+
```tss
|
|
25
|
+
/* Ti Elements */
|
|
26
|
+
'View': { width: Ti.UI.SIZE, height: Ti.UI.SIZE }
|
|
27
|
+
'Window': { backgroundColor: '#FFFFFF' }
|
|
119
28
|
|
|
120
|
-
|
|
29
|
+
/* Main Styles */
|
|
30
|
+
'.h-32': { height: 128 }
|
|
31
|
+
'.h-auto': { height: Ti.UI.SIZE }
|
|
32
|
+
'.text-center': { textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER }
|
|
33
|
+
'.w-screen': { width: Ti.UI.FILL }
|
|
121
34
|
|
|
122
|
-
```tss
|
|
123
35
|
/* Platform and Device Modifiers */
|
|
124
36
|
'.android:text-2xl[platform=android]': { font: { fontSize: 24 } }
|
|
125
37
|
'.android:text-green-800[platform=android]': { color: '#166534', textColor: '#166534' }
|
|
@@ -131,303 +43,5 @@ PurgeTSS generates platform-specific selectors in `app.tss`:
|
|
|
131
43
|
'.tablet:bg-green-500[formFactor=tablet]': { backgroundColor: '#22c55e' }
|
|
132
44
|
```
|
|
133
45
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
You can create custom conditional modifiers using global variables:
|
|
137
|
-
|
|
138
|
-
### Syntax
|
|
139
|
-
|
|
140
|
-
```xml
|
|
141
|
-
<View class="[if=Alloy.Globals.isIPhoneX]:pb-24" />
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
The `[if=...]` syntax evaluates Alloy.Globals or controller arguments.
|
|
145
|
-
|
|
146
|
-
### Example with iPhone X Notch
|
|
147
|
-
|
|
148
|
-
```xml
|
|
149
|
-
<View class="[if=Alloy.Globals.iPhoneX]:bottom-(34) [if=Alloy.Globals.iPhoneX]:bg-white" />
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Setting Up Conditional Variables
|
|
153
|
-
|
|
154
|
-
In your controller or `alloy.js`:
|
|
155
|
-
|
|
156
|
-
```javascript
|
|
157
|
-
// Detect iPhone X
|
|
158
|
-
if (OS_IOS && Ti.Platform.displayCaps.platformHeight === 812 && Ti.Platform.displayCaps.platformWidth === 375) {
|
|
159
|
-
Alloy.Globals.isIPhoneX = true;
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Modifiers in config.cjs
|
|
164
|
-
|
|
165
|
-
Platform and device modifiers can also be defined within `config.cjs` for centralized theme logic.
|
|
166
|
-
|
|
167
|
-
### Custom Class with Platform Variants
|
|
168
|
-
|
|
169
|
-
```javascript
|
|
170
|
-
'.my-view': {
|
|
171
|
-
DEFAULT: {
|
|
172
|
-
apply: 'bg-white'
|
|
173
|
-
},
|
|
174
|
-
ios: {
|
|
175
|
-
apply: 'shadow-lg'
|
|
176
|
-
},
|
|
177
|
-
android: {
|
|
178
|
-
apply: 'elevation-4'
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Ti Element with Platform and Device Variants
|
|
184
|
-
|
|
185
|
-
```javascript
|
|
186
|
-
TextField: {
|
|
187
|
-
DEFAULT: {
|
|
188
|
-
top: 10,
|
|
189
|
-
left: 20,
|
|
190
|
-
right: 20,
|
|
191
|
-
bottom: 0
|
|
192
|
-
},
|
|
193
|
-
'[if=Alloy.Globals.iPhoneX]': {
|
|
194
|
-
bottom: 'Alloy.CFG.iPhoneXNotchSize'
|
|
195
|
-
},
|
|
196
|
-
android: {
|
|
197
|
-
touchFeedback: true
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Complex Example with All Variants
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
module.exports = {
|
|
206
|
-
theme: {
|
|
207
|
-
'.feature-card': {
|
|
208
|
-
DEFAULT: {
|
|
209
|
-
width: 'Ti.UI.FILL',
|
|
210
|
-
height: '100px',
|
|
211
|
-
backgroundColor: '#ffffff'
|
|
212
|
-
},
|
|
213
|
-
ios: {
|
|
214
|
-
borderRadius: 12
|
|
215
|
-
},
|
|
216
|
-
android: {
|
|
217
|
-
borderRadius: 8
|
|
218
|
-
},
|
|
219
|
-
tablet: {
|
|
220
|
-
width: '50%'
|
|
221
|
-
},
|
|
222
|
-
handheld: {
|
|
223
|
-
width: '100%'
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## Platform-Specific Properties
|
|
231
|
-
|
|
232
|
-
Some Titanium properties are platform-specific and should be used with platform modifiers:
|
|
233
|
-
|
|
234
|
-
### iOS-Specific Properties
|
|
235
|
-
|
|
236
|
-
```xml
|
|
237
|
-
<View class="ios:clip-mode-disabled" />
|
|
238
|
-
<Label class="ios:adjusts-font-size-to-fit" />
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Android-Specific Properties
|
|
242
|
-
|
|
243
|
-
```xml
|
|
244
|
-
<View class="android:touch-feedback" />
|
|
245
|
-
<TextField class="android:soft-keyboard-hide-on-focus" />
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Interaction Modifiers
|
|
249
|
-
|
|
250
|
-
### Active State Modifier
|
|
251
|
-
|
|
252
|
-
Style applied while the element is being touched/clicked:
|
|
253
|
-
|
|
254
|
-
```xml
|
|
255
|
-
<Button class="active:bg-brand-700 active:scale-95" />
|
|
256
|
-
<View class="active:opacity-80" onTouchstart="doSomething" />
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
:::info
|
|
260
|
-
The `active:` modifier works with elements that have touch event handlers. The style is applied during the touch interaction and removed when the touch ends.
|
|
261
|
-
:::
|
|
262
|
-
|
|
263
|
-
## Best Practices
|
|
264
|
-
|
|
265
|
-
### 1. Use Modifiers for Platform Differences
|
|
266
|
-
|
|
267
|
-
```xml
|
|
268
|
-
<!-- Good: Platform-specific styling -->
|
|
269
|
-
<View class="ios:shadow-lg android:elevation-4 bg-white" />
|
|
270
|
-
|
|
271
|
-
<!-- Avoid: Creating separate views -->
|
|
272
|
-
<Window>
|
|
273
|
-
<View platform="ios" class="bg-white shadow-lg" />
|
|
274
|
-
<View platform="android" class="elevation-4 bg-white" />
|
|
275
|
-
</Window>
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### 2. Combine with Default Styles
|
|
279
|
-
|
|
280
|
-
Always provide a default style, then override with modifiers:
|
|
281
|
-
|
|
282
|
-
```xml
|
|
283
|
-
<!-- Good: Default + overrides -->
|
|
284
|
-
<Label class="ios:text-xl android:text-2xl text-lg text-gray-800" />
|
|
285
|
-
|
|
286
|
-
<!-- Less clear: Only modifiers -->
|
|
287
|
-
<Label class="ios:text-xl android:text-2xl ios:text-gray-800 android:text-gray-800" />
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### 3. Use Device Modifiers for Layout Adaptation
|
|
291
|
-
|
|
292
|
-
```xml
|
|
293
|
-
<!-- Adaptive layout based on form factor -->
|
|
294
|
-
<View class="horizontal w-screen">
|
|
295
|
-
<View class="tablet:w-1/3 handheld:w-full bg-white">
|
|
296
|
-
<!-- Sidebar on tablet, full content on phone -->
|
|
297
|
-
</View>
|
|
298
|
-
<View class="tablet:w-2/3 handheld:w-full bg-gray-100">
|
|
299
|
-
<!-- Main content -->
|
|
300
|
-
</View>
|
|
301
|
-
</View>
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### 4. Leverage config.cjs for Complex Platform Logic
|
|
305
|
-
|
|
306
|
-
For complex platform-specific rules, define them in `config.cjs` rather than cluttering XML:
|
|
307
|
-
|
|
308
|
-
```javascript
|
|
309
|
-
// In config.cjs
|
|
310
|
-
'.navigation-header': {
|
|
311
|
-
DEFAULT: { height: 56 },
|
|
312
|
-
ios: { height: 44 },
|
|
313
|
-
tablet: { height: 64 }
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// In XML - clean and simple
|
|
317
|
-
<View class="navigation-header" />
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
## Common Patterns
|
|
321
|
-
|
|
322
|
-
### iOS Shadow / Android Elevation
|
|
323
|
-
|
|
324
|
-
```xml
|
|
325
|
-
<View class="ios:shadow-md android:elevation-2 rounded-lg bg-white" />
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
### Different Font Sizes per Platform
|
|
329
|
-
|
|
330
|
-
```xml
|
|
331
|
-
<Label class="ios:text-base android:text-sm font-semibold text-gray-800" />
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### Safe Area Handling for iPhone X
|
|
335
|
-
|
|
336
|
-
```xml
|
|
337
|
-
<View class="[if=Alloy.Globals.isIPhoneX]:pt-12 pt-4" />
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Adaptive Spacing
|
|
341
|
-
|
|
342
|
-
```xml
|
|
343
|
-
<View class="tablet:p-8 handheld:p-4 p-4" />
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
### Platform-Specific Colors
|
|
347
|
-
|
|
348
|
-
```xml
|
|
349
|
-
<Button class="bg-brand-500 ios:bg-blue-600 android:bg-green-600 text-white" />
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
## Troubleshooting
|
|
353
|
-
|
|
354
|
-
### Modifiers Not Applying
|
|
355
|
-
|
|
356
|
-
**Problem**: Platform modifier classes not generating in `app.tss`
|
|
357
|
-
|
|
358
|
-
**Solution**: Ensure `purge.mode` is set to `'all'` in `config.cjs`:
|
|
359
|
-
|
|
360
|
-
```javascript
|
|
361
|
-
module.exports = {
|
|
362
|
-
purge: {
|
|
363
|
-
mode: 'all' // Required to parse all class attributes
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
### Conditional Modifiers Not Working
|
|
369
|
-
|
|
370
|
-
**Problem**: `[if=Alloy.Globals...]` modifiers not applying
|
|
371
|
-
|
|
372
|
-
**Solution**: Verify the global variable exists before the view is created:
|
|
373
|
-
|
|
374
|
-
```javascript
|
|
375
|
-
// In alloy.js or controller
|
|
376
|
-
Alloy.Globals.isIPhoneX = /* detection logic */;
|
|
377
|
-
|
|
378
|
-
console.log(Alloy.Globals.isIPhoneX); // Should be true/false
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Platform Detection Issues
|
|
382
|
-
|
|
383
|
-
**Problem**: Styles applying to wrong platform
|
|
384
|
-
|
|
385
|
-
**Solution**: Check generated `app.tss` for correct selector:
|
|
386
|
-
|
|
387
|
-
```tss
|
|
388
|
-
/* Should be platform-specific selector */
|
|
389
|
-
'.ios:bg-blue-500[platform=ios]': { backgroundColor: '#3b82f6' }
|
|
390
|
-
'.android:bg-blue-500[platform=android]': { backgroundColor: '#3b82f6' }
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
## Modifier Reference Table
|
|
394
|
-
|
|
395
|
-
| Modifier | Target | Example | Generated Selector |
|
|
396
|
-
| --------------- | -------------------- | ------------------------------------ | ------------------------------ |
|
|
397
|
-
| `ios:` | iOS devices only | `ios:bg-blue-500` | `[platform=ios]` |
|
|
398
|
-
| `android:` | Android devices only | `android:bg-green-500` | `[platform=android]` |
|
|
399
|
-
| `tablet:` | Tablets only | `tablet:w-1/2` | `[formFactor=tablet]` |
|
|
400
|
-
| `handheld:` | Phones only | `handheld:w-full` | `[formFactor=handheld]` |
|
|
401
|
-
| `[if=varName]:` | Custom conditional | `[if=Alloy.Globals.isIPhoneX]:pt-12` | `[if=Alloy.Globals.isIPhoneX]` |
|
|
402
|
-
| `active:` | Touch interaction | `active:opacity-80` | `active` state |
|
|
403
|
-
|
|
404
|
-
## Complete Example
|
|
405
|
-
|
|
406
|
-
```xml
|
|
407
|
-
<Alloy>
|
|
408
|
-
<Window class="bg-white">
|
|
409
|
-
<!-- Header with platform-specific styling -->
|
|
410
|
-
<View class="ios:shadow-sm android:elevation-2 h-16 bg-white">
|
|
411
|
-
<Label class="ios:text-xl android:text-lg h-auto w-screen text-center font-bold text-gray-800">
|
|
412
|
-
Platform Demo
|
|
413
|
-
</Label>
|
|
414
|
-
</View>
|
|
415
|
-
|
|
416
|
-
<!-- Adaptive content layout -->
|
|
417
|
-
<View class="tablet:p-8 p-4">
|
|
418
|
-
<View class="horizontal w-screen">
|
|
419
|
-
<!-- Tablet: sidebar, Phone: full width cards -->
|
|
420
|
-
<View class="tablet:w-1/3 handheld:w-full rounded-lg bg-gray-100 p-4">
|
|
421
|
-
<Label text="Sidebar" class="text-center" />
|
|
422
|
-
</View>
|
|
423
|
-
<View class="tablet:w-2/3 handheld:w-full ml-4 rounded-lg bg-white p-4">
|
|
424
|
-
<Label text="Main Content" class="text-center" />
|
|
425
|
-
</View>
|
|
426
|
-
</View>
|
|
427
|
-
</View>
|
|
428
|
-
|
|
429
|
-
<!-- iPhone X safe area handling -->
|
|
430
|
-
<View class="[if=Alloy.Globals.isIPhoneX]:h-8 bg-transparent" />
|
|
431
|
-
</Window>
|
|
432
|
-
</Alloy>
|
|
433
|
-
```
|
|
46
|
+
> **Platform-Specific Properties**
|
|
47
|
+
> If a style relies on `Ti.UI.iOS.*` or `Ti.UI.Android.*` constants, scope it with the matching `ios:` or `android:` modifier, or with the equivalent platform block in `config.cjs`.
|