@maccesar/titools 2.2.4 → 2.2.9
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 +23 -23
- package/agents/ti-pro.md +17 -17
- package/lib/commands/update.js +6 -14
- package/lib/downloader.js +17 -2
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +31 -31
- package/skills/alloy-guides/references/CONCEPTS.md +3 -3
- package/skills/alloy-guides/references/CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/MODELS.md +6 -6
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/VIEWS_XML.md +1 -1
- package/skills/alloy-guides/references/WIDGETS.md +1 -1
- package/skills/alloy-howtos/SKILL.md +27 -27
- package/skills/alloy-howtos/references/best_practices.md +9 -9
- package/skills/alloy-howtos/references/cli_reference.md +14 -14
- package/skills/alloy-howtos/references/config_files.md +16 -16
- package/skills/alloy-howtos/references/custom_tags.md +16 -16
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +11 -15
- package/skills/alloy-howtos/references/samples.md +19 -19
- package/skills/purgetss/SKILL.md +11 -1
- package/skills/purgetss/references/animation-system.md +1 -1
- package/skills/purgetss/references/cli-commands.md +3 -3
- package/skills/purgetss/references/customization-deep-dive.md +1 -1
- package/skills/purgetss/references/dynamic-component-creation.md +1 -1
- package/skills/purgetss/references/icon-fonts.md +4 -0
- package/skills/purgetss/references/installation-setup.md +8 -1
- package/skills/purgetss/references/migration-guide.md +4 -0
- package/skills/purgetss/references/tikit-components.md +193 -204
- package/skills/purgetss/references/ui-ux-design.md +1 -1
- package/skills/ti-expert/SKILL.md +78 -118
- package/skills/ti-expert/references/alloy-builtins.md +18 -18
- package/skills/ti-expert/references/alloy-structure.md +21 -21
- package/skills/ti-expert/references/anti-patterns.md +15 -15
- package/skills/ti-expert/references/cli-expert.md +15 -15
- package/skills/ti-expert/references/code-conventions.md +38 -38
- package/skills/ti-expert/references/contracts.md +8 -8
- package/skills/ti-expert/references/controller-patterns.md +14 -14
- package/skills/ti-expert/references/error-handling.md +11 -11
- package/skills/ti-expert/references/examples.md +12 -12
- package/skills/ti-expert/references/migration-patterns.md +24 -24
- package/skills/ti-expert/references/patterns.md +10 -10
- package/skills/ti-expert/references/performance-listview.md +16 -16
- package/skills/ti-expert/references/performance-optimization.md +41 -41
- package/skills/ti-expert/references/security-device.md +22 -22
- package/skills/ti-expert/references/security-fundamentals.md +19 -19
- package/skills/ti-expert/references/state-management.md +33 -33
- package/skills/ti-expert/references/testing-e2e-ci.md +25 -25
- package/skills/ti-expert/references/testing-unit.md +24 -24
- package/skills/ti-expert/references/theming.md +15 -15
- package/skills/ti-guides/SKILL.md +58 -60
- package/skills/ti-guides/references/advanced-data-and-images.md +33 -33
- package/skills/ti-guides/references/android-manifest.md +15 -15
- package/skills/ti-guides/references/app-distribution.md +70 -166
- package/skills/ti-guides/references/application-frameworks.md +96 -114
- package/skills/ti-guides/references/cli-reference.md +294 -294
- package/skills/ti-guides/references/coding-best-practices.md +42 -33
- package/skills/ti-guides/references/commonjs-advanced.md +57 -51
- package/skills/ti-guides/references/hello-world.md +36 -36
- package/skills/ti-guides/references/hyperloop-native-access.md +66 -66
- package/skills/ti-guides/references/javascript-primer.md +83 -101
- package/skills/ti-guides/references/reserved-words.md +9 -9
- package/skills/ti-guides/references/resources.md +75 -83
- package/skills/ti-guides/references/style-and-conventions.md +35 -28
- package/skills/ti-guides/references/tiapp-config.md +110 -74
- package/skills/ti-howtos/SKILL.md +88 -92
- package/skills/ti-howtos/references/android-platform-deep-dives.md +104 -104
- package/skills/ti-howtos/references/automation-fastlane-appium.md +39 -39
- package/skills/ti-howtos/references/buffer-codec-streams.md +60 -60
- package/skills/ti-howtos/references/cross-platform-development.md +115 -136
- package/skills/ti-howtos/references/debugging-profiling.md +167 -181
- package/skills/ti-howtos/references/extending-titanium.md +121 -121
- package/skills/ti-howtos/references/google-maps-v2.md +84 -82
- package/skills/ti-howtos/references/ios-map-kit.md +65 -60
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +123 -123
- package/skills/ti-howtos/references/local-data-sources.md +79 -78
- package/skills/ti-howtos/references/location-and-maps.md +116 -120
- package/skills/ti-howtos/references/media-apis.md +87 -86
- package/skills/ti-howtos/references/notification-services.md +250 -260
- package/skills/ti-howtos/references/remote-data-sources.md +98 -93
- package/skills/ti-howtos/references/tutorials.md +226 -216
- package/skills/ti-howtos/references/using-modules.md +73 -102
- package/skills/ti-howtos/references/web-content-integration.md +101 -103
- package/skills/ti-howtos/references/webpack-build-pipeline.md +52 -44
- package/skills/ti-ui/SKILL.md +85 -85
- package/skills/ti-ui/references/accessibility-deep-dive.md +57 -57
- package/skills/ti-ui/references/animation-and-matrices.md +79 -79
- package/skills/ti-ui/references/application-structures.md +96 -99
- package/skills/ti-ui/references/custom-fonts-styling.md +99 -99
- package/skills/ti-ui/references/event-handling.md +58 -58
- package/skills/ti-ui/references/gestures.md +62 -64
- package/skills/ti-ui/references/icons-and-splash-screens.md +88 -88
- package/skills/ti-ui/references/layouts-and-positioning.md +87 -97
- package/skills/ti-ui/references/listviews-and-performance.md +107 -107
- package/skills/ti-ui/references/orientation.md +87 -88
- package/skills/ti-ui/references/platform-ui-android.md +87 -81
- package/skills/ti-ui/references/platform-ui-ios.md +63 -61
- package/skills/ti-ui/references/scrolling-views.md +29 -29
- package/skills/ti-ui/references/tableviews.md +56 -56
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# iOS UI
|
|
1
|
+
# iOS UI components and conventions
|
|
2
2
|
|
|
3
3
|
## 1. Overview
|
|
4
4
|
|
|
5
|
-
iOS
|
|
5
|
+
iOS has UI components and patterns that differ from Android. This guide covers iPad-only controls, badges, Settings integration, 3D Touch, and iOS navigation patterns.
|
|
6
6
|
|
|
7
|
-
## 2. iPad-
|
|
7
|
+
## 2. iPad-only UI components
|
|
8
8
|
|
|
9
9
|
### Popover
|
|
10
10
|
|
|
11
|
-
Popovers
|
|
11
|
+
Popovers show temporary content without taking over the whole screen. Use them for menus, options, or detail views.
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
14
|
const button = Ti.UI.createButton({
|
|
@@ -32,7 +32,7 @@ const popoverContent = Ti.UI.createView({
|
|
|
32
32
|
});
|
|
33
33
|
popover.add(popoverContent);
|
|
34
34
|
|
|
35
|
-
button.addEventListener('click', (
|
|
35
|
+
button.addEventListener('click', () => {
|
|
36
36
|
popover.show({
|
|
37
37
|
view: button, // Anchor to this view
|
|
38
38
|
animated: true
|
|
@@ -41,15 +41,15 @@ button.addEventListener('click', (e) => {
|
|
|
41
41
|
|
|
42
42
|
win.add(button);
|
|
43
43
|
```
|
|
44
|
-
|
|
45
|
-
### Popover
|
|
44
|
+
|
|
45
|
+
### Popover events
|
|
46
46
|
|
|
47
47
|
```javascript
|
|
48
|
-
popover.addEventListener('hide', (
|
|
48
|
+
popover.addEventListener('hide', () => {
|
|
49
49
|
Ti.API.info('Popover hidden');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
popover.addEventListener('show', (
|
|
52
|
+
popover.addEventListener('show', () => {
|
|
53
53
|
Ti.API.info('Popover shown');
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -59,7 +59,7 @@ popover.hide();
|
|
|
59
59
|
|
|
60
60
|
### SplitWindow
|
|
61
61
|
|
|
62
|
-
SplitWindow manages master-detail
|
|
62
|
+
SplitWindow manages a master-detail layout (left list, right detail). It is iPad only.
|
|
63
63
|
|
|
64
64
|
```javascript
|
|
65
65
|
// Master (left) window
|
|
@@ -94,10 +94,10 @@ const splitwin = Ti.UI.iPad.createSplitWindow({
|
|
|
94
94
|
|
|
95
95
|
splitwin.open();
|
|
96
96
|
```
|
|
97
|
-
...
|
|
98
|
-
### SplitWindow in Portrait
|
|
99
97
|
|
|
100
|
-
|
|
98
|
+
### SplitWindow in portrait
|
|
99
|
+
|
|
100
|
+
By default, the master view is hidden in portrait. To show it:
|
|
101
101
|
|
|
102
102
|
```javascript
|
|
103
103
|
splitwin.addEventListener('visible', (e) => {
|
|
@@ -110,7 +110,7 @@ splitwin.addEventListener('visible', (e) => {
|
|
|
110
110
|
|
|
111
111
|
## 3. Badges
|
|
112
112
|
|
|
113
|
-
### App
|
|
113
|
+
### App icon badge
|
|
114
114
|
|
|
115
115
|
```javascript
|
|
116
116
|
// Set badge to number
|
|
@@ -122,7 +122,7 @@ Ti.UI.iOS.appBadge = null;
|
|
|
122
122
|
// Note: Setting to 0 still displays "0"
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
### Tab
|
|
125
|
+
### Tab badge
|
|
126
126
|
|
|
127
127
|
```javascript
|
|
128
128
|
const tabGroup = Ti.UI.createTabGroup();
|
|
@@ -144,19 +144,19 @@ tab1.badge = 5;
|
|
|
144
144
|
tab1.setBadge(null);
|
|
145
145
|
tab1.badge = null;
|
|
146
146
|
```
|
|
147
|
-
...
|
|
148
|
-
### Settings.bundle Integration
|
|
149
147
|
|
|
150
|
-
|
|
148
|
+
## 4. Settings.bundle integration
|
|
149
|
+
|
|
150
|
+
iOS apps can expose user settings in the Settings app using a Settings.bundle.
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Setup:
|
|
153
153
|
- Place the bundle at `platform/iphone/Settings.bundle/` (SDK 1.8+)
|
|
154
154
|
- The bundle contains `Root.plist`, which defines the settings UI (toggles, text fields, groups, etc.)
|
|
155
155
|
- Edit `Root.plist` using Xcode's Property List editor for a visual interface
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Key conventions: Settings keys typically use the `_preference` suffix, for example `username_preference` or `enabled_preference`.
|
|
158
158
|
|
|
159
|
-
###
|
|
159
|
+
### Access preferences in the app
|
|
160
160
|
|
|
161
161
|
```javascript
|
|
162
162
|
// Read a preference set in iOS Settings app
|
|
@@ -166,13 +166,15 @@ const username = Ti.App.Properties.getString('username_preference');
|
|
|
166
166
|
const name = Ti.App.Properties.getString('name_preference');
|
|
167
167
|
const enabled = Ti.App.Properties.getBool('enabled_preference');
|
|
168
168
|
```
|
|
169
|
-
...
|
|
170
|
-
#### Static Quick Actions (via tiapp.xml)
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
## 5. Quick Actions and 3D Touch
|
|
171
|
+
|
|
172
|
+
### Static Quick Actions (via tiapp.xml)
|
|
173
|
+
|
|
174
|
+
Static shortcuts are defined in `tiapp.xml` and available immediately after install.
|
|
173
175
|
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
+
- Required keys: `UIApplicationShortcutItemTitle`, `UIApplicationShortcutItemType`
|
|
177
|
+
- Optional keys: `UIApplicationShortcutItemSubtitle`, `UIApplicationShortcutItemIconType`, `UIApplicationShortcutItemIconFile`, `UIApplicationShortcutItemUserInfo`
|
|
176
178
|
|
|
177
179
|
```xml
|
|
178
180
|
<ios>
|
|
@@ -198,7 +200,7 @@ Quick action titles and subtitles can be localized using `i18n/LANG/app.xml` (no
|
|
|
198
200
|
|
|
199
201
|
To use custom images for quick action icons, enable app thinning in `tiapp.xml` with `<use-app-thinning>true</use-app-thinning>` inside the `<ios>` element.
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
### Dynamic Quick Actions
|
|
202
204
|
|
|
203
205
|
```javascript
|
|
204
206
|
if (Ti.UI.iOS.forceTouchSupported) {
|
|
@@ -223,13 +225,13 @@ if (Ti.UI.iOS.forceTouchSupported) {
|
|
|
223
225
|
}
|
|
224
226
|
```
|
|
225
227
|
|
|
226
|
-
|
|
228
|
+
### Handle quick actions
|
|
227
229
|
|
|
228
230
|
```javascript
|
|
229
231
|
Ti.App.iOS.addEventListener('shortcutitemclick', (e) => {
|
|
230
232
|
Ti.API.info(`Shortcut clicked: ${e.itemtype}`);
|
|
231
233
|
|
|
232
|
-
switch(e.itemtype) {
|
|
234
|
+
switch (e.itemtype) {
|
|
233
235
|
case 'com.myapp.add':
|
|
234
236
|
addNewItem();
|
|
235
237
|
break;
|
|
@@ -243,11 +245,11 @@ Ti.App.iOS.addEventListener('shortcutitemclick', (e) => {
|
|
|
243
245
|
});
|
|
244
246
|
```
|
|
245
247
|
|
|
246
|
-
### Peek and
|
|
248
|
+
### Peek and pop
|
|
247
249
|
|
|
248
|
-
Peek
|
|
250
|
+
Peek shows a preview, Pop opens the full view.
|
|
249
251
|
|
|
250
|
-
####
|
|
252
|
+
#### Enable peek and pop
|
|
251
253
|
|
|
252
254
|
```javascript
|
|
253
255
|
if (Ti.UI.iOS.forceTouchSupported) {
|
|
@@ -256,11 +258,11 @@ if (Ti.UI.iOS.forceTouchSupported) {
|
|
|
256
258
|
const detail = Alloy.createController('detail').getView();
|
|
257
259
|
|
|
258
260
|
const shareAction = Ti.UI.iOS.createPreviewAction({
|
|
259
|
-
title:
|
|
261
|
+
title: 'Share',
|
|
260
262
|
style: Ti.UI.iOS.PREVIEW_ACTION_STYLE_DEFAULT
|
|
261
263
|
});
|
|
262
264
|
|
|
263
|
-
shareAction.addEventListener('click', (
|
|
265
|
+
shareAction.addEventListener('click', () => {
|
|
264
266
|
// Handle share action
|
|
265
267
|
});
|
|
266
268
|
|
|
@@ -284,7 +286,7 @@ if (Ti.UI.iOS.forceTouchSupported) {
|
|
|
284
286
|
}
|
|
285
287
|
```
|
|
286
288
|
|
|
287
|
-
#### Preview
|
|
289
|
+
#### Preview action styles
|
|
288
290
|
|
|
289
291
|
```javascript
|
|
290
292
|
Ti.UI.iOS.PREVIEW_ACTION_STYLE_DEFAULT
|
|
@@ -292,9 +294,9 @@ Ti.UI.iOS.PREVIEW_ACTION_STYLE_SELECTED // Blue background
|
|
|
292
294
|
Ti.UI.iOS.PREVIEW_ACTION_STYLE_DESTRUCTIVE // Red background
|
|
293
295
|
```
|
|
294
296
|
|
|
295
|
-
#### Peek and
|
|
297
|
+
#### Peek and pop details
|
|
296
298
|
|
|
297
|
-
- Use
|
|
299
|
+
- Use `contentHeight` on the preview context to control preview height (for example `contentHeight: 400`).
|
|
298
300
|
- Use `Ti.UI.iOS.createPreviewActionGroup()` to group related preview actions into a submenu:
|
|
299
301
|
|
|
300
302
|
```javascript
|
|
@@ -308,9 +310,9 @@ const actionGroup = Ti.UI.iOS.createPreviewActionGroup({
|
|
|
308
310
|
});
|
|
309
311
|
```
|
|
310
312
|
|
|
311
|
-
|
|
313
|
+
Important: 3D Touch features (peek and pop, quick actions with force) can only be tested on physical devices with 3D Touch hardware. The iOS Simulator does not support force touch.
|
|
312
314
|
|
|
313
|
-
## 6. Navigation
|
|
315
|
+
## 6. Navigation bar (iOS)
|
|
314
316
|
|
|
315
317
|
### NavigationWindow
|
|
316
318
|
|
|
@@ -358,7 +360,7 @@ const toolbar = Ti.UI.createToolbar({
|
|
|
358
360
|
win.add(toolbar);
|
|
359
361
|
```
|
|
360
362
|
|
|
361
|
-
### System
|
|
363
|
+
### System buttons
|
|
362
364
|
|
|
363
365
|
```javascript
|
|
364
366
|
Ti.UI.iOS.SystemButton.DONE
|
|
@@ -371,9 +373,9 @@ Ti.UI.iOS.SystemButton.FIXED_SPACE
|
|
|
371
373
|
// ... and more
|
|
372
374
|
```
|
|
373
375
|
|
|
374
|
-
## 7. Tab
|
|
376
|
+
## 7. Tab bar
|
|
375
377
|
|
|
376
|
-
###
|
|
378
|
+
### Create a tab bar
|
|
377
379
|
|
|
378
380
|
```javascript
|
|
379
381
|
const tabGroup = Ti.UI.createTabGroup();
|
|
@@ -396,7 +398,7 @@ tabGroup.addTab(tab2);
|
|
|
396
398
|
tabGroup.open();
|
|
397
399
|
```
|
|
398
400
|
|
|
399
|
-
### Tab
|
|
401
|
+
### Tab bar customization (iOS)
|
|
400
402
|
|
|
401
403
|
```javascript
|
|
402
404
|
tabGroup.setActiveTabIconColor('blue');
|
|
@@ -409,7 +411,7 @@ win1.tabBarHidden = true;
|
|
|
409
411
|
tabGroup.tabsStyle = Ti.UI.iOS.TABS_STYLE_BOTTOM;
|
|
410
412
|
```
|
|
411
413
|
|
|
412
|
-
## 8. Activity
|
|
414
|
+
## 8. Activity indicator
|
|
413
415
|
|
|
414
416
|
```javascript
|
|
415
417
|
const activityIndicator = Ti.UI.createActivityIndicator({
|
|
@@ -425,7 +427,7 @@ activityIndicator.show();
|
|
|
425
427
|
activityIndicator.hide();
|
|
426
428
|
```
|
|
427
429
|
|
|
428
|
-
### iOS-
|
|
430
|
+
### iOS-specific location
|
|
429
431
|
|
|
430
432
|
```javascript
|
|
431
433
|
const activityIndicator = Ti.UI.createActivityIndicator({
|
|
@@ -435,7 +437,7 @@ const activityIndicator = Ti.UI.createActivityIndicator({
|
|
|
435
437
|
});
|
|
436
438
|
```
|
|
437
439
|
|
|
438
|
-
## 9. Platform
|
|
440
|
+
## 9. Platform best practices
|
|
439
441
|
|
|
440
442
|
### Follow iOS Human Interface Guidelines
|
|
441
443
|
|
|
@@ -445,7 +447,7 @@ const activityIndicator = Ti.UI.createActivityIndicator({
|
|
|
445
447
|
- Use Popovers for auxiliary content (iPad)
|
|
446
448
|
- Respect 3D Touch conventions
|
|
447
449
|
|
|
448
|
-
### iOS-
|
|
450
|
+
### iOS-specific patterns
|
|
449
451
|
|
|
450
452
|
```javascript
|
|
451
453
|
// Use system buttons for standard actions
|
|
@@ -465,30 +467,30 @@ const view = Ti.UI.createView({
|
|
|
465
467
|
});
|
|
466
468
|
```
|
|
467
469
|
|
|
468
|
-
## 10. Common
|
|
470
|
+
## 10. Common issues
|
|
469
471
|
|
|
470
|
-
### Settings
|
|
472
|
+
### Settings not appearing
|
|
471
473
|
|
|
472
|
-
|
|
474
|
+
Problem: Settings are not visible in the Settings app.
|
|
473
475
|
|
|
474
|
-
|
|
475
|
-
1. Clean and rebuild project
|
|
476
|
+
Solutions:
|
|
477
|
+
1. Clean and rebuild the project
|
|
476
478
|
2. Check plist syntax
|
|
477
|
-
3. Ensure Settings.bundle is in platform/iphone
|
|
478
|
-
4. Kill and relaunch Settings app
|
|
479
|
+
3. Ensure Settings.bundle is in `platform/iphone/`
|
|
480
|
+
4. Kill and relaunch the Settings app
|
|
479
481
|
|
|
480
|
-
### 3D Touch
|
|
482
|
+
### 3D Touch not working
|
|
481
483
|
|
|
482
|
-
|
|
484
|
+
Problem: 3D Touch features do not respond.
|
|
483
485
|
|
|
484
|
-
|
|
485
|
-
1.
|
|
486
|
+
Solutions:
|
|
487
|
+
1. Test on a physical device with 3D Touch hardware
|
|
486
488
|
2. Check `Ti.UI.iOS.forceTouchSupported` before using
|
|
487
489
|
3. Ensure iOS 9 or later
|
|
488
490
|
4. Verify `previewContext` is properly attached
|
|
489
491
|
|
|
490
|
-
### SplitWindow
|
|
492
|
+
### SplitWindow issues
|
|
491
493
|
|
|
492
|
-
|
|
494
|
+
Problem: Master view is not visible in portrait.
|
|
493
495
|
|
|
494
|
-
|
|
496
|
+
Solution: This is default behavior. Use `showMasterViewInPopover()` or handle it via NavigationWindow.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Scrolling
|
|
1
|
+
# Scrolling views
|
|
2
2
|
|
|
3
3
|
## 1. ScrollView vs ScrollableView
|
|
4
4
|
|
|
5
|
-
| Feature | ScrollView | ScrollableView
|
|
6
|
-
| ---------------- | ------------------------------ |
|
|
7
|
-
| Purpose | Scrollable area of content | Paging through multiple views
|
|
8
|
-
| Scroll
|
|
9
|
-
| Content
|
|
10
|
-
|
|
|
11
|
-
| Use
|
|
5
|
+
| Feature | ScrollView | ScrollableView |
|
|
6
|
+
| ---------------- | ------------------------------ | ----------------------------- |
|
|
7
|
+
| Purpose | Scrollable area of content | Paging through multiple views |
|
|
8
|
+
| Scroll direction | Vertical and/or horizontal | Horizontal only |
|
|
9
|
+
| Content size | `contentHeight`/`contentWidth` | Full-screen views |
|
|
10
|
+
| Interaction | Drag to scroll | Swipe to snap between pages |
|
|
11
|
+
| Use case | Long content, forms, images | Image gallery, onboarding |
|
|
12
12
|
|
|
13
13
|
## 2. ScrollView
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Create a ScrollView
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
18
|
const scrollView = Ti.UI.createScrollView({
|
|
@@ -34,20 +34,20 @@ scrollView.add(content);
|
|
|
34
34
|
win.add(scrollView);
|
|
35
35
|
```
|
|
36
36
|
...
|
|
37
|
-
### ScrollView
|
|
37
|
+
### ScrollView properties
|
|
38
38
|
|
|
39
39
|
| Property | Description | Platform |
|
|
40
40
|
| --------------------------------------------- | ------------------------------------------------------------------- | -------- |
|
|
41
41
|
| `contentWidth` / `contentHeight` | Size of the scrollable content area | All |
|
|
42
|
-
| `scrollType` | `'vertical'` or `'horizontal'` (Android only
|
|
42
|
+
| `scrollType` | `'vertical'` or `'horizontal'` (Android only - see below) | Android |
|
|
43
43
|
| `showHorizontalScrollIndicator` | Show/hide horizontal scroll indicator | All |
|
|
44
44
|
| `showVerticalScrollIndicator` | Show/hide vertical scroll indicator | All |
|
|
45
|
-
| `zoomScale` / `minZoomScale` / `maxZoomScale` | Zoom level (values 0
|
|
45
|
+
| `zoomScale` / `minZoomScale` / `maxZoomScale` | Zoom level (values 0-1) | iOS |
|
|
46
46
|
| `horizontalBounce` / `verticalBounce` | Enable/disable bounce effect at edges | iOS |
|
|
47
47
|
| `canCancelEvents` | Allow ScrollView to cancel touch events in children (default: true) | iOS |
|
|
48
48
|
| `scrollable` | Enable/disable scrolling | All |
|
|
49
49
|
|
|
50
|
-
### ScrollView
|
|
50
|
+
### ScrollView events
|
|
51
51
|
|
|
52
52
|
```javascript
|
|
53
53
|
scrollView.addEventListener('scroll', (e) => {
|
|
@@ -66,9 +66,9 @@ scrollView.addEventListener('scrollEnd', (e) => {
|
|
|
66
66
|
});
|
|
67
67
|
```
|
|
68
68
|
...
|
|
69
|
-
### Android ScrollView
|
|
69
|
+
### Android ScrollView direction
|
|
70
70
|
|
|
71
|
-
Android ScrollView can be vertical
|
|
71
|
+
Android ScrollView can be vertical or horizontal, not both. If you do not set `scrollType`, Android auto-detects: if width equals contentWidth it defaults to vertical; if height equals contentHeight it defaults to horizontal. If Titanium cannot determine the direction, it logs a warning.
|
|
72
72
|
|
|
73
73
|
```javascript
|
|
74
74
|
// Explicit horizontal scroll
|
|
@@ -83,7 +83,7 @@ const scrollView = Ti.UI.createScrollView({
|
|
|
83
83
|
...
|
|
84
84
|
## 3. ScrollableView
|
|
85
85
|
|
|
86
|
-
###
|
|
86
|
+
### Create a ScrollableView
|
|
87
87
|
|
|
88
88
|
```javascript
|
|
89
89
|
const view1 = Ti.UI.createView({ backgroundColor: '#123' });
|
|
@@ -100,7 +100,7 @@ const scrollableView = Ti.UI.createScrollableView({
|
|
|
100
100
|
win.add(scrollableView);
|
|
101
101
|
```
|
|
102
102
|
...
|
|
103
|
-
### ScrollableView
|
|
103
|
+
### ScrollableView events
|
|
104
104
|
|
|
105
105
|
```javascript
|
|
106
106
|
scrollableView.addEventListener('scroll', (e) => {
|
|
@@ -113,7 +113,7 @@ scrollableView.addEventListener('dragEnd', (e) => {
|
|
|
113
113
|
});
|
|
114
114
|
```
|
|
115
115
|
...
|
|
116
|
-
### Image
|
|
116
|
+
### Image gallery
|
|
117
117
|
|
|
118
118
|
```javascript
|
|
119
119
|
const images = [];
|
|
@@ -131,7 +131,7 @@ const gallery = Ti.UI.createScrollableView({
|
|
|
131
131
|
});
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### Onboarding
|
|
134
|
+
### Onboarding wizard
|
|
135
135
|
|
|
136
136
|
```javascript
|
|
137
137
|
const page1 = createOnboardingPage('Welcome', 'Get started with our app');
|
|
@@ -158,7 +158,7 @@ nextButton.addEventListener('click', () => {
|
|
|
158
158
|
});
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
### Long
|
|
161
|
+
### Long-form content
|
|
162
162
|
|
|
163
163
|
```javascript
|
|
164
164
|
const scrollView = Ti.UI.createScrollView({
|
|
@@ -178,7 +178,7 @@ for (let i = 0; i < 50; i++) {
|
|
|
178
178
|
}
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
### Scrollable
|
|
181
|
+
### Scrollable form
|
|
182
182
|
|
|
183
183
|
```javascript
|
|
184
184
|
const formScrollView = Ti.UI.createScrollView({
|
|
@@ -219,7 +219,7 @@ scrollableView.scrollToView(scrollableView.views.length - 1);
|
|
|
219
219
|
const current = scrollableView.currentPage;
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
## 8. Detecting
|
|
222
|
+
## 8. Detecting scroll position
|
|
223
223
|
|
|
224
224
|
```javascript
|
|
225
225
|
scrollView.addEventListener('scroll', (e) => {
|
|
@@ -233,11 +233,11 @@ scrollView.addEventListener('scroll', (e) => {
|
|
|
233
233
|
});
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
## Best
|
|
236
|
+
## Best practices
|
|
237
237
|
|
|
238
|
-
1.
|
|
239
|
-
2.
|
|
240
|
-
3.
|
|
241
|
-
4.
|
|
242
|
-
5.
|
|
243
|
-
6.
|
|
238
|
+
1. Use ScrollableView for paginated content (galleries, wizards)
|
|
239
|
+
2. Use ScrollView for continuous scrolling content (long forms, articles)
|
|
240
|
+
3. Specify dimensions explicitly on Android when possible
|
|
241
|
+
4. Consider performance with large datasets
|
|
242
|
+
5. Test on real devices; simulator behavior may differ
|
|
243
|
+
6. Use paging controls for ScrollableView to improve UX
|