@maccesar/titools 2.0.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/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
# Layouts, Positioning, and View Hierarchy
|
|
2
|
+
|
|
3
|
+
## 🚨 CRITICAL: Platform-Specific Properties Require Modifiers
|
|
4
|
+
|
|
5
|
+
:::danger NEVER use platform-specific properties directly
|
|
6
|
+
**Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties WITHOUT modifiers will:**
|
|
7
|
+
|
|
8
|
+
1. **Add iOS code to Android builds** → compilation failures
|
|
9
|
+
2. **Add Android code to iOS builds** → compilation failures
|
|
10
|
+
3. **Create invalid cross-platform code**
|
|
11
|
+
|
|
12
|
+
**REAL EXAMPLE of the damage:**
|
|
13
|
+
```javascript
|
|
14
|
+
// ❌ WRONG - Adds Ti.UI.iOS to Android project
|
|
15
|
+
const win = Ti.UI.createWindow({
|
|
16
|
+
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT // FAILS on Android!
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**CORRECT approaches:**
|
|
21
|
+
|
|
22
|
+
**Option 1 - TSS modifier (Alloy projects):**
|
|
23
|
+
```tss
|
|
24
|
+
// ✅ CORRECT - Only adds to iOS
|
|
25
|
+
"#mainWindow[platform=ios]": {
|
|
26
|
+
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Option 2 - Conditional code:**
|
|
31
|
+
```javascript
|
|
32
|
+
if (OS_IOS) {
|
|
33
|
+
$.mainWindow.statusBarStyle = Ti.UI.iOS.StatusBar.LIGHT_CONTENT
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Common platform-specific properties that REQUIRE modifiers:**
|
|
38
|
+
- iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
|
|
39
|
+
- Android: `actionBar` config, any `Ti.Android.*` constant
|
|
40
|
+
:::
|
|
41
|
+
|
|
42
|
+
## Table of Contents
|
|
43
|
+
|
|
44
|
+
- [Layouts, Positioning, and View Hierarchy](#layouts-positioning-and-view-hierarchy)
|
|
45
|
+
- [🚨 CRITICAL: Platform-Specific Properties Require Modifiers](#-critical-platform-specific-properties-require-modifiers)
|
|
46
|
+
- [Table of Contents](#table-of-contents)
|
|
47
|
+
- [1. Units of Measurement](#1-units-of-measurement)
|
|
48
|
+
- [Available Units](#available-units)
|
|
49
|
+
- [Density-Independent Pixels (dp)](#density-independent-pixels-dp)
|
|
50
|
+
- [Best Practice](#best-practice)
|
|
51
|
+
- [2. Positioning Properties](#2-positioning-properties)
|
|
52
|
+
- [Edge-Based Positioning](#edge-based-positioning)
|
|
53
|
+
- [Center Positioning](#center-positioning)
|
|
54
|
+
- [Dynamic Sizing](#dynamic-sizing)
|
|
55
|
+
- [3. Layout Modes](#3-layout-modes)
|
|
56
|
+
- [Composite (Default)](#composite-default)
|
|
57
|
+
- [Vertical Layout](#vertical-layout)
|
|
58
|
+
- [Horizontal Layout](#horizontal-layout)
|
|
59
|
+
- [4. Auto-Size Behaviors](#4-auto-size-behaviors)
|
|
60
|
+
- [Ti.UI.SIZE](#tiuisize)
|
|
61
|
+
- [Ti.UI.FILL](#tiuifill)
|
|
62
|
+
- [Component Defaults](#component-defaults)
|
|
63
|
+
- [Auto-Size in Layout Modes](#auto-size-in-layout-modes)
|
|
64
|
+
- [5. Combining Layouts](#5-combining-layouts)
|
|
65
|
+
- [Nested Layouts](#nested-layouts)
|
|
66
|
+
- [6. View Hierarchy and Z-Index](#6-view-hierarchy-and-z-index)
|
|
67
|
+
- [Stacking Order](#stacking-order)
|
|
68
|
+
- [Explicit Z-Index](#explicit-z-index)
|
|
69
|
+
- [7. Common Layout Patterns](#7-common-layout-patterns)
|
|
70
|
+
- [Full-Screen Overlay](#full-screen-overlay)
|
|
71
|
+
- [Centered Content](#centered-content)
|
|
72
|
+
- [Bottom-Aligned Content](#bottom-aligned-content)
|
|
73
|
+
- [Percentage-Based Layout](#percentage-based-layout)
|
|
74
|
+
- [8. Platform Considerations](#8-platform-considerations)
|
|
75
|
+
- [Android Density-Specific Resources](#android-density-specific-resources)
|
|
76
|
+
- [iOS Asset Catalog](#ios-asset-catalog)
|
|
77
|
+
- [Best Practices](#best-practices)
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 1. Units of Measurement
|
|
82
|
+
|
|
83
|
+
### Available Units
|
|
84
|
+
|
|
85
|
+
| Unit | Description | Platform Notes |
|
|
86
|
+
| ------------ | -------------------------- | ------------------------------------------- |
|
|
87
|
+
| `dp` / `dip` | Density-independent pixels | **Recommended** for cross-platform |
|
|
88
|
+
| `px` | Absolute pixels | Use sparingly - varies by screen density |
|
|
89
|
+
| `%` | Percentage of parent size | Relative to parent's dimension |
|
|
90
|
+
| `system` | Platform default | iOS = dip, Android = px (unless configured) |
|
|
91
|
+
|
|
92
|
+
### Density-Independent Pixels (dp)
|
|
93
|
+
|
|
94
|
+
**Android**: `actual pixels = dip × (screen density) / 160`
|
|
95
|
+
- mdpi (160 dpi): 1dp = 1px
|
|
96
|
+
- hdpi (240 dpi): 1dp = 1.5px
|
|
97
|
+
- xhdpi (320 dpi): 1dp = 2px
|
|
98
|
+
- xxhdpi (480 dpi): 1dp = 3px
|
|
99
|
+
|
|
100
|
+
**iOS**: Effectively `1dip = 1px` on non-retina, `1dip = 2px` on retina
|
|
101
|
+
|
|
102
|
+
### Best Practice
|
|
103
|
+
|
|
104
|
+
Always use `dp` for consistent sizing across devices:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
// GOOD
|
|
108
|
+
const view = Ti.UI.createView({
|
|
109
|
+
width: '100dp',
|
|
110
|
+
height: '50dp'
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// AVOID (platform-dependent)
|
|
114
|
+
const view = Ti.UI.createView({
|
|
115
|
+
width: 100, // pixels - varies by device
|
|
116
|
+
height: 50
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 2. Positioning Properties
|
|
121
|
+
|
|
122
|
+
### Edge-Based Positioning
|
|
123
|
+
|
|
124
|
+
Relative to parent edges:
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const view = Ti.UI.createView({
|
|
128
|
+
top: 20, // 20dp from top
|
|
129
|
+
left: 30, // 30dp from left
|
|
130
|
+
bottom: 10, // 10dp from bottom (height = parent.height - 30)
|
|
131
|
+
right: 15 // 15dp from right (width = parent.width - 45)
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Center Positioning
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
const view = Ti.UI.createView({
|
|
139
|
+
center: { x: 50, y: 50 } // 50% from parent's top-left
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Dynamic Sizing
|
|
144
|
+
|
|
145
|
+
Omit a dimension to calculate dynamically:
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
const view = Ti.UI.createView({
|
|
149
|
+
top: 10,
|
|
150
|
+
bottom: 10, // Height = parent.height - 20
|
|
151
|
+
left: 0,
|
|
152
|
+
right: 0 // Width = parent.width
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 3. Layout Modes
|
|
157
|
+
|
|
158
|
+
### Composite (Default)
|
|
159
|
+
|
|
160
|
+
Views stack on top of each other:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
const container = Ti.UI.createView({
|
|
164
|
+
layout: 'composite' // default
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const view1 = Ti.UI.createView({
|
|
168
|
+
backgroundColor: 'red',
|
|
169
|
+
top: 10, left: 10, width: 100, height: 100
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const view2 = Ti.UI.createView({
|
|
173
|
+
backgroundColor: 'blue',
|
|
174
|
+
top: 20, left: 20, width: 100, height: 100
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
container.add(view1);
|
|
178
|
+
container.add(view2);
|
|
179
|
+
// view2 appears on top of view1
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Stacking order controlled by:
|
|
183
|
+
- Addition order
|
|
184
|
+
- `zIndex` property (higher = on top)
|
|
185
|
+
|
|
186
|
+
### Vertical Layout
|
|
187
|
+
|
|
188
|
+
Children stack vertically:
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
const container = Ti.UI.createView({
|
|
192
|
+
layout: 'vertical',
|
|
193
|
+
height: Ti.UI.SIZE // Grows to fit children
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const label1 = Ti.UI.createLabel({
|
|
197
|
+
text: 'First',
|
|
198
|
+
height: Ti.UI.SIZE
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const label2 = Ti.UI.createLabel({
|
|
202
|
+
text: 'Second',
|
|
203
|
+
top: 10, // Offset from previous sibling's bottom
|
|
204
|
+
height: Ti.UI.SIZE
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
container.add(label1);
|
|
208
|
+
container.add(label2);
|
|
209
|
+
// label2 appears below label1 with 10dp gap
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Vertical Layout Rules**:
|
|
213
|
+
- Children's `top` property acts as **offset** from previous sibling
|
|
214
|
+
- Children are **horizontally centered** by default
|
|
215
|
+
- Set `horizontalWrap: false` to prevent wrapping
|
|
216
|
+
|
|
217
|
+
### Horizontal Layout
|
|
218
|
+
|
|
219
|
+
Children line up left to right:
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
const container = Ti.UI.createView({
|
|
223
|
+
layout: 'horizontal',
|
|
224
|
+
width: Ti.UI.FILL,
|
|
225
|
+
height: Ti.UI.SIZE
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const view1 = Ti.UI.createView({
|
|
229
|
+
width: 100, height: 50,
|
|
230
|
+
backgroundColor: 'red'
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const view2 = Ti.UI.createView({
|
|
234
|
+
width: 100, height: 50,
|
|
235
|
+
left: 10, // Offset from previous sibling's right
|
|
236
|
+
backgroundColor: 'blue'
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
container.add(view1);
|
|
240
|
+
container.add(view2);
|
|
241
|
+
// view2 appears to right of view1 with 10dp gap
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Horizontal Layout Rules**:
|
|
245
|
+
- Children's `left` property acts as **offset** from previous sibling
|
|
246
|
+
- `horizontalWrap: true` (default) - moves to next row if insufficient space
|
|
247
|
+
- `horizontalWrap: false` - continues on same row (may overflow)
|
|
248
|
+
|
|
249
|
+
## 4. Auto-Size Behaviors
|
|
250
|
+
|
|
251
|
+
### Ti.UI.SIZE
|
|
252
|
+
|
|
253
|
+
View sizes to fit its content:
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
const label = Ti.UI.createLabel({
|
|
257
|
+
text: 'Hello World',
|
|
258
|
+
width: Ti.UI.SIZE, // Width fits text
|
|
259
|
+
height: Ti.UI.SIZE // Height fits text
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Ti.UI.FILL
|
|
264
|
+
|
|
265
|
+
View fills remaining space in parent:
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
const view = Ti.UI.createView({
|
|
269
|
+
width: Ti.UI.FILL, // Fill remaining width
|
|
270
|
+
height: Ti.UI.FILL // Fill remaining height
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Component Defaults
|
|
275
|
+
|
|
276
|
+
| SIZE Components | FILL Components | Mixed |
|
|
277
|
+
| :-------------- | :-------------- | :------------------------------------- |
|
|
278
|
+
| Button | Window | TableViewRow (FILL width, SIZE height) |
|
|
279
|
+
| Label | View | Slider (FILL width, SIZE height) |
|
|
280
|
+
| ImageView | ScrollView | Toolbar (FILL width, SIZE height) |
|
|
281
|
+
| Switch | WebView | |
|
|
282
|
+
| TextField | ScrollableView | |
|
|
283
|
+
|
|
284
|
+
### Auto-Size in Layout Modes
|
|
285
|
+
|
|
286
|
+
In `vertical`/`horizontal` layouts:
|
|
287
|
+
- `FILL` takes into account previously added siblings
|
|
288
|
+
- Example: First child `FILL`, second child `SIZE` → second gets remaining space
|
|
289
|
+
|
|
290
|
+
## 5. Combining Layouts
|
|
291
|
+
|
|
292
|
+
### Nested Layouts
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
const outerContainer = Ti.UI.createView({
|
|
296
|
+
layout: 'vertical',
|
|
297
|
+
width: Ti.UI.FILL,
|
|
298
|
+
height: Ti.UI.FILL
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// Top section
|
|
302
|
+
const header = Ti.UI.createView({
|
|
303
|
+
layout: 'horizontal',
|
|
304
|
+
height: 50,
|
|
305
|
+
backgroundColor: 'blue'
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const title = Ti.UI.createLabel({
|
|
309
|
+
text: 'Header',
|
|
310
|
+
color: 'white'
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const button = Ti.UI.createButton({
|
|
314
|
+
title: 'Menu'
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
header.add(title);
|
|
318
|
+
header.add(button);
|
|
319
|
+
|
|
320
|
+
// Content area
|
|
321
|
+
const content = Ti.UI.createView({
|
|
322
|
+
layout: 'composite',
|
|
323
|
+
backgroundColor: 'white',
|
|
324
|
+
height: Ti.UI.FILL
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
outerContainer.add(header);
|
|
328
|
+
outerContainer.add(content);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## 6. View Hierarchy and Z-Index
|
|
332
|
+
|
|
333
|
+
### Stacking Order
|
|
334
|
+
|
|
335
|
+
Views added later appear on top:
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
const view1 = Ti.UI.createView({
|
|
339
|
+
backgroundColor: 'red',
|
|
340
|
+
width: 100, height: 100
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const view2 = Ti.UI.createView({
|
|
344
|
+
backgroundColor: 'blue',
|
|
345
|
+
width: 100, height: 100,
|
|
346
|
+
top: 50, left: 50
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
win.add(view1);
|
|
350
|
+
win.add(view2); // view2 appears on top of view1
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Explicit Z-Index
|
|
354
|
+
|
|
355
|
+
```javascript
|
|
356
|
+
const view1 = Ti.UI.createView({
|
|
357
|
+
backgroundColor: 'red',
|
|
358
|
+
zIndex: 1,
|
|
359
|
+
width: 100, height: 100
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const view2 = Ti.UI.createView({
|
|
363
|
+
backgroundColor: 'blue',
|
|
364
|
+
zIndex: 2, // Higher = on top
|
|
365
|
+
width: 100, height: 100,
|
|
366
|
+
top: 50, left: 50
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
win.add(view2);
|
|
370
|
+
win.add(view1); // Still below view2 due to zIndex
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## 7. Common Layout Patterns
|
|
374
|
+
|
|
375
|
+
### Full-Screen Overlay
|
|
376
|
+
|
|
377
|
+
```javascript
|
|
378
|
+
const overlay = Ti.UI.createView({
|
|
379
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
380
|
+
width: Ti.UI.FILL,
|
|
381
|
+
height: Ti.UI.FILL,
|
|
382
|
+
zIndex: 999 // Ensure on top
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
const dialog = Ti.UI.createView({
|
|
386
|
+
backgroundColor: 'white',
|
|
387
|
+
width: 300,
|
|
388
|
+
height: 200,
|
|
389
|
+
borderRadius: 10
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
overlay.add(dialog);
|
|
393
|
+
win.add(overlay);
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Centered Content
|
|
397
|
+
|
|
398
|
+
```javascript
|
|
399
|
+
const container = Ti.UI.createView({
|
|
400
|
+
width: Ti.UI.FILL,
|
|
401
|
+
height: Ti.UI.FILL
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const centered = Ti.UI.createView({
|
|
405
|
+
width: 200,
|
|
406
|
+
height: 100,
|
|
407
|
+
backgroundColor: 'blue',
|
|
408
|
+
center: { x: '50%', y: '50%' }
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
container.add(centered);
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Bottom-Aligned Content
|
|
415
|
+
|
|
416
|
+
```javascript
|
|
417
|
+
const footer = Ti.UI.createView({
|
|
418
|
+
backgroundColor: 'gray',
|
|
419
|
+
height: 50,
|
|
420
|
+
bottom: 0 // Anchor to bottom
|
|
421
|
+
});
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Percentage-Based Layout
|
|
425
|
+
|
|
426
|
+
```javascript
|
|
427
|
+
const leftPanel = Ti.UI.createView({
|
|
428
|
+
width: '30%',
|
|
429
|
+
height: Ti.UI.FILL,
|
|
430
|
+
backgroundColor: 'lightgray'
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
const rightPanel = Ti.UI.createView({
|
|
434
|
+
width: '70%',
|
|
435
|
+
height: Ti.UI.FILL,
|
|
436
|
+
left: '30%', // Starts where left ends
|
|
437
|
+
backgroundColor: 'white'
|
|
438
|
+
});
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## 8. Platform Considerations
|
|
442
|
+
|
|
443
|
+
### Android Density-Specific Resources
|
|
444
|
+
|
|
445
|
+
Place resources in appropriate directories:
|
|
446
|
+
- `res-ldpi`, `res-mdpi`, `res-hdpi`, `res-xhdpi`, `res-xxhdpi`
|
|
447
|
+
|
|
448
|
+
### iOS Asset Catalog
|
|
449
|
+
|
|
450
|
+
PNG/JPEG images with naming convention:
|
|
451
|
+
- `foo.png` - Non-retina
|
|
452
|
+
- `foo@2x.png` - Retina
|
|
453
|
+
- `foo@3x.png` - iPhone 6 Plus
|
|
454
|
+
|
|
455
|
+
## Best Practices
|
|
456
|
+
|
|
457
|
+
1. **Use `dp` units** for cross-platform consistency
|
|
458
|
+
2. **Prefer `Ti.UI.FILL`** over percentages for containers
|
|
459
|
+
3. **Avoid `Ti.UI.SIZE` in ListViews** for performance
|
|
460
|
+
4. **Use layout modes** instead of manual positioning when possible
|
|
461
|
+
5. **Test on multiple devices** with different screen sizes
|
|
462
|
+
6. **Use `zIndex` sparingly** - rely on addition order when possible
|