@maccesar/titools 2.2.4 → 2.2.8
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/lib/commands/update.js +4 -12
- 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,20 +1,20 @@
|
|
|
1
|
-
# ListViews and
|
|
1
|
+
# ListViews and performance optimization
|
|
2
2
|
|
|
3
3
|
## 1. Overview
|
|
4
4
|
|
|
5
|
-
ListView is a data-oriented, high-performance replacement for TableView. It
|
|
5
|
+
ListView is a data-oriented, high-performance replacement for TableView. It handles large datasets by recycling native views and managing the item lifecycle for you.
|
|
6
6
|
|
|
7
|
-
### Core
|
|
7
|
+
### Core concepts
|
|
8
8
|
|
|
9
9
|
| Concept | Description |
|
|
10
10
|
| ---------------- | ------------------------------------------------------------- |
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
11
|
+
| ListView | Container for sections |
|
|
12
|
+
| ListSection | Organizes items, supports CRUD operations |
|
|
13
|
+
| ListItem | Virtual view object (not directly accessible after rendering) |
|
|
14
|
+
| ItemTemplate | Defines row structure and binding |
|
|
15
|
+
| ListDataItem | Raw data bound to templates |
|
|
16
16
|
|
|
17
|
-
## 2. Basic ListView
|
|
17
|
+
## 2. Basic ListView structure
|
|
18
18
|
|
|
19
19
|
### Declarative (Alloy XML)
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ ListView is a data-oriented, high-performance replacement for TableView. It opti
|
|
|
32
32
|
</Alloy>
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
### Programmatic
|
|
35
|
+
### Programmatic data binding
|
|
36
36
|
|
|
37
37
|
```javascript
|
|
38
38
|
const items = [
|
|
@@ -44,7 +44,7 @@ const items = [
|
|
|
44
44
|
$.myList.sections[0].setItems(items);
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### Mapping
|
|
47
|
+
### Mapping external data
|
|
48
48
|
|
|
49
49
|
```javascript
|
|
50
50
|
const externalData = [
|
|
@@ -68,11 +68,11 @@ $.myList.sections[0].setItems(items);
|
|
|
68
68
|
|
|
69
69
|
## 3. Templates
|
|
70
70
|
|
|
71
|
-
### Default
|
|
71
|
+
### Default template
|
|
72
72
|
|
|
73
73
|
Built-in template with:
|
|
74
74
|
- ImageView (left on iOS, right on Android)
|
|
75
|
-
- Title
|
|
75
|
+
- Title label (left-aligned, black)
|
|
76
76
|
- Optional accessory icon
|
|
77
77
|
|
|
78
78
|
```xml
|
|
@@ -83,7 +83,7 @@ Built-in template with:
|
|
|
83
83
|
</ListView>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
### Custom
|
|
86
|
+
### Custom templates
|
|
87
87
|
|
|
88
88
|
Create with `<Templates>` and `<ItemTemplate>`:
|
|
89
89
|
|
|
@@ -110,7 +110,7 @@ Create with `<Templates>` and `<ItemTemplate>`:
|
|
|
110
110
|
</ListView>
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
### Multiple
|
|
113
|
+
### Multiple templates
|
|
114
114
|
|
|
115
115
|
```xml
|
|
116
116
|
<ListView id="dynamicListView">
|
|
@@ -149,13 +149,13 @@ const items = [
|
|
|
149
149
|
$.dynamicListView.sections[0].setItems(items);
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
### iOS
|
|
152
|
+
### iOS built-in templates (iOS only)
|
|
153
153
|
|
|
154
|
-
iOS provides four built-in templates
|
|
154
|
+
iOS provides four built-in templates you can use without defining custom templates:
|
|
155
155
|
|
|
156
156
|
| Constant | Layout |
|
|
157
157
|
| ----------------------------------- | --------------------------------------------------------------- |
|
|
158
|
-
| `Ti.UI.LIST_ITEM_TEMPLATE_DEFAULT` | Left-justified title only (
|
|
158
|
+
| `Ti.UI.LIST_ITEM_TEMPLATE_DEFAULT` | Left-justified title only (default) |
|
|
159
159
|
| `Ti.UI.LIST_ITEM_TEMPLATE_SUBTITLE` | Title with subtitle below in smaller gray text |
|
|
160
160
|
| `Ti.UI.LIST_ITEM_TEMPLATE_SETTINGS` | Left-justified title on left, right-justified subtitle on right |
|
|
161
161
|
| `Ti.UI.LIST_ITEM_TEMPLATE_CONTACTS` | Right-justified title with left-justified subtitle |
|
|
@@ -173,18 +173,18 @@ const listView = Ti.UI.createListView({
|
|
|
173
173
|
});
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
### Supported
|
|
176
|
+
### Supported template view classes
|
|
177
177
|
|
|
178
178
|
The following views can be used as child elements in custom templates: ActivityIndicator, Button, ImageView, Label, MaskedImage, ProgressBar, Slider, Switch, TextArea, TextField.
|
|
179
179
|
|
|
180
|
-
## 4. Data
|
|
180
|
+
## 4. Data binding
|
|
181
181
|
|
|
182
|
-
### Binding
|
|
182
|
+
### Binding syntax
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
XML (Alloy): `bindId:property="value"`
|
|
185
|
+
JavaScript: `{ bindId: { property: value } }`
|
|
186
186
|
|
|
187
|
-
### Programmatic
|
|
187
|
+
### Programmatic binding with custom templates
|
|
188
188
|
|
|
189
189
|
```javascript
|
|
190
190
|
const items = [
|
|
@@ -205,9 +205,9 @@ const items = [
|
|
|
205
205
|
$.elementsList.sections[0].setItems(items);
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
## 5. Section
|
|
208
|
+
## 5. Section operations
|
|
209
209
|
|
|
210
|
-
### CRUD
|
|
210
|
+
### CRUD methods
|
|
211
211
|
|
|
212
212
|
| Method | Description |
|
|
213
213
|
| ------------------------------------- | ------------------ |
|
|
@@ -217,7 +217,7 @@ $.elementsList.sections[0].setItems(items);
|
|
|
217
217
|
| `replaceItemsAt(index, count, items)` | Replace range |
|
|
218
218
|
| `deleteItemsAt(index, count)` | Delete range |
|
|
219
219
|
|
|
220
|
-
### Example
|
|
220
|
+
### Example operations
|
|
221
221
|
|
|
222
222
|
```javascript
|
|
223
223
|
const section = $.myList.sections[0];
|
|
@@ -238,9 +238,9 @@ section.replaceItemsAt(2, 3, replacementItems);
|
|
|
238
238
|
section.deleteItemsAt(10, 2);
|
|
239
239
|
```
|
|
240
240
|
|
|
241
|
-
### Row
|
|
241
|
+
### Row animation (iOS)
|
|
242
242
|
|
|
243
|
-
You can pass animation styles to append
|
|
243
|
+
You can pass animation styles to append, delete, insert, replace, and update methods:
|
|
244
244
|
|
|
245
245
|
```javascript
|
|
246
246
|
section.deleteItemsAt(0, 1, {
|
|
@@ -256,7 +256,7 @@ Available styles: `Ti.UI.iOS.RowAnimationStyle.BOTTOM`, `FADE`, `LEFT`, `NONE`,
|
|
|
256
256
|
|
|
257
257
|
## 6. Events
|
|
258
258
|
|
|
259
|
-
### Item
|
|
259
|
+
### Item click
|
|
260
260
|
|
|
261
261
|
```xml
|
|
262
262
|
<ListView id="list" onItemclick="handleClick">
|
|
@@ -279,9 +279,9 @@ function handleClick(e) {
|
|
|
279
279
|
}
|
|
280
280
|
```
|
|
281
281
|
|
|
282
|
-
### Marker
|
|
282
|
+
### Marker events (infinite scroll)
|
|
283
283
|
|
|
284
|
-
Markers act as
|
|
284
|
+
Markers act as tripwires for loading more data:
|
|
285
285
|
|
|
286
286
|
```javascript
|
|
287
287
|
// Set initial marker at item 100
|
|
@@ -309,9 +309,9 @@ Since SDK 4.1.0, use `addMarker()` to add additional markers after the initial `
|
|
|
309
309
|
$.myList.addMarker({ sectionIndex: 0, itemIndex: 149 });
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
-
### Scroll
|
|
312
|
+
### Scroll events
|
|
313
313
|
|
|
314
|
-
Since SDK 4.1.0, use `scrollstart` and `scrollend`
|
|
314
|
+
Since SDK 4.1.0, use `scrollstart` and `scrollend` to monitor scrolling:
|
|
315
315
|
|
|
316
316
|
```javascript
|
|
317
317
|
$.myList.addEventListener('scrollstart', (e) => {
|
|
@@ -326,7 +326,7 @@ $.myList.addEventListener('scrollend', (e) => {
|
|
|
326
326
|
|
|
327
327
|
Event properties: `firstVisibleSectionIndex`, `firstVisibleItemIndex`, `visibleItemCount`.
|
|
328
328
|
|
|
329
|
-
### Template
|
|
329
|
+
### Template element events
|
|
330
330
|
|
|
331
331
|
```xml
|
|
332
332
|
<ListView id="likeList" onItemclick="handleItemClick">
|
|
@@ -348,7 +348,7 @@ function handleItemClick(e) {
|
|
|
348
348
|
if (e.bindId === "icon") {
|
|
349
349
|
const item = e.section.getItemAt(e.itemIndex);
|
|
350
350
|
|
|
351
|
-
// Toggle image (update data,
|
|
351
|
+
// Toggle image (update data, not e.source)
|
|
352
352
|
if (item.icon.image === "star_grey.png") {
|
|
353
353
|
item.icon.image = "star_gold.png";
|
|
354
354
|
} else {
|
|
@@ -360,11 +360,11 @@ function handleItemClick(e) {
|
|
|
360
360
|
}
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
## 7. Critical
|
|
363
|
+
## 7. Critical performance rules
|
|
364
364
|
|
|
365
|
-
### Rule 1: Avoid Ti.UI.SIZE in
|
|
365
|
+
### Rule 1: Avoid Ti.UI.SIZE in templates
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
Bad (jerky scrolling):
|
|
368
368
|
|
|
369
369
|
```xml
|
|
370
370
|
<ItemTemplate name="bad">
|
|
@@ -372,7 +372,7 @@ function handleItemClick(e) {
|
|
|
372
372
|
</ItemTemplate>
|
|
373
373
|
```
|
|
374
374
|
|
|
375
|
-
|
|
375
|
+
Good (fixed height or FILL):
|
|
376
376
|
|
|
377
377
|
```xml
|
|
378
378
|
<ItemTemplate name="good">
|
|
@@ -380,11 +380,11 @@ function handleItemClick(e) {
|
|
|
380
380
|
</ItemTemplate>
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
### Rule 2: Cannot
|
|
383
|
+
### Rule 2: Cannot access children directly
|
|
384
384
|
|
|
385
|
-
Views are recycled. Always update via data
|
|
385
|
+
Views are recycled. Always update via data.
|
|
386
386
|
|
|
387
|
-
|
|
387
|
+
Bad:
|
|
388
388
|
|
|
389
389
|
```javascript
|
|
390
390
|
// DON'T - Will be lost when recycled
|
|
@@ -393,7 +393,7 @@ function handleClick(e) {
|
|
|
393
393
|
}
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
Good:
|
|
397
397
|
|
|
398
398
|
```javascript
|
|
399
399
|
// DO - Update the data item
|
|
@@ -404,11 +404,11 @@ function handleClick(e) {
|
|
|
404
404
|
}
|
|
405
405
|
```
|
|
406
406
|
|
|
407
|
-
### Rule 3: Minimize
|
|
407
|
+
### Rule 3: Minimize template count
|
|
408
408
|
|
|
409
|
-
Fewer templates
|
|
409
|
+
Fewer templates means better native cell reuse.
|
|
410
410
|
|
|
411
|
-
|
|
411
|
+
Good: one template with conditional visibility
|
|
412
412
|
|
|
413
413
|
```xml
|
|
414
414
|
<ItemTemplate name="flexible">
|
|
@@ -418,7 +418,7 @@ Fewer templates = better native cell reuse:
|
|
|
418
418
|
</ItemTemplate>
|
|
419
419
|
```
|
|
420
420
|
|
|
421
|
-
|
|
421
|
+
Bad: multiple similar templates
|
|
422
422
|
|
|
423
423
|
```xml
|
|
424
424
|
<ItemTemplate name="withIcon">...</ItemTemplate>
|
|
@@ -426,7 +426,7 @@ Fewer templates = better native cell reuse:
|
|
|
426
426
|
<ItemTemplate name="withSubtitle">...</ItemTemplate>
|
|
427
427
|
```
|
|
428
428
|
|
|
429
|
-
### Rule 4: Use updateItemAt for
|
|
429
|
+
### Rule 4: Use updateItemAt for changes
|
|
430
430
|
|
|
431
431
|
```javascript
|
|
432
432
|
// Get item data
|
|
@@ -440,11 +440,11 @@ item.customField.text = 'Updated';
|
|
|
440
440
|
section.updateItemAt(index, item);
|
|
441
441
|
```
|
|
442
442
|
|
|
443
|
-
### Rule 5: Animations are
|
|
443
|
+
### Rule 5: Animations are limited
|
|
444
444
|
|
|
445
445
|
ListView items have limited animation support. For complex animations, consider TableView.
|
|
446
446
|
|
|
447
|
-
## 8. iOS
|
|
447
|
+
## 8. iOS action items (swipe actions)
|
|
448
448
|
|
|
449
449
|
```javascript
|
|
450
450
|
const section = $.myList.sections[0];
|
|
@@ -463,7 +463,7 @@ section.editActions = [
|
|
|
463
463
|
];
|
|
464
464
|
section.canEdit = true;
|
|
465
465
|
|
|
466
|
-
// Handle actions
|
|
466
|
+
// Handle actions - e.action is the title string of the tapped action
|
|
467
467
|
$.myList.addEventListener('editaction', (e) => {
|
|
468
468
|
if (e.action === 'Delete') {
|
|
469
469
|
e.section.deleteItemsAt(e.itemIndex, 1);
|
|
@@ -474,16 +474,16 @@ $.myList.addEventListener('editaction', (e) => {
|
|
|
474
474
|
});
|
|
475
475
|
```
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
- `Ti.UI.iOS.ROW_ACTION_STYLE_DEFAULT`
|
|
479
|
-
- `Ti.UI.iOS.ROW_ACTION_STYLE_DESTRUCTIVE`
|
|
480
|
-
- `Ti.UI.iOS.ROW_ACTION_STYLE_NORMAL`
|
|
477
|
+
Available action styles:
|
|
478
|
+
- `Ti.UI.iOS.ROW_ACTION_STYLE_DEFAULT` - gray background
|
|
479
|
+
- `Ti.UI.iOS.ROW_ACTION_STYLE_DESTRUCTIVE` - red background (default)
|
|
480
|
+
- `Ti.UI.iOS.ROW_ACTION_STYLE_NORMAL` - custom color background
|
|
481
481
|
|
|
482
|
-
|
|
482
|
+
Event properties: `action` (string, the title), `itemId`, `itemIndex`, `section`, `sectionIndex`.
|
|
483
483
|
|
|
484
|
-
## 9. Editing
|
|
484
|
+
## 9. Editing mode (iOS)
|
|
485
485
|
|
|
486
|
-
Set
|
|
486
|
+
Set `editing` to toggle edit mode and let users delete or reorder items:
|
|
487
487
|
|
|
488
488
|
```javascript
|
|
489
489
|
// Toggle edit mode
|
|
@@ -493,7 +493,7 @@ $.myList.editing = true;
|
|
|
493
493
|
$.myList.pruneSectionsOnEdit = true;
|
|
494
494
|
```
|
|
495
495
|
|
|
496
|
-
### Delete
|
|
496
|
+
### Delete event
|
|
497
497
|
|
|
498
498
|
Fires when a user deletes an item in edit mode:
|
|
499
499
|
|
|
@@ -503,7 +503,7 @@ $.myList.addEventListener('delete', (e) => {
|
|
|
503
503
|
});
|
|
504
504
|
```
|
|
505
505
|
|
|
506
|
-
### Move
|
|
506
|
+
### Move event
|
|
507
507
|
|
|
508
508
|
Fires when a user reorders an item in edit mode:
|
|
509
509
|
|
|
@@ -533,10 +533,10 @@ const items = [
|
|
|
533
533
|
];
|
|
534
534
|
```
|
|
535
535
|
|
|
536
|
-
### Search
|
|
536
|
+
### Search properties
|
|
537
537
|
|
|
538
|
-
- `keepSectionsInSearch: true`
|
|
539
|
-
- `caseInsensitiveSearch: true`
|
|
538
|
+
- `keepSectionsInSearch: true` preserves section headers while filtering results.
|
|
539
|
+
- `caseInsensitiveSearch: true` enables case-insensitive filtering.
|
|
540
540
|
|
|
541
541
|
```javascript
|
|
542
542
|
const listView = Ti.UI.createListView({
|
|
@@ -546,9 +546,9 @@ const listView = Ti.UI.createListView({
|
|
|
546
546
|
});
|
|
547
547
|
```
|
|
548
548
|
|
|
549
|
-
### No
|
|
549
|
+
### No results event
|
|
550
550
|
|
|
551
|
-
Since SDK 3.3.0, when items are filtered using `searchView` or `searchText`, the `noresults` event fires when
|
|
551
|
+
Since SDK 3.3.0, when items are filtered using `searchView` or `searchText`, the `noresults` event fires when there are no matches:
|
|
552
552
|
|
|
553
553
|
```javascript
|
|
554
554
|
$.myList.addEventListener('noresults', (e) => {
|
|
@@ -556,26 +556,26 @@ $.myList.addEventListener('noresults', (e) => {
|
|
|
556
556
|
});
|
|
557
557
|
```
|
|
558
558
|
|
|
559
|
-
## 11. Performance
|
|
559
|
+
## 11. Performance best practices
|
|
560
560
|
|
|
561
|
-
|
|
562
|
-
- Use fixed heights in templates
|
|
563
|
-
- Minimize number of templates
|
|
564
|
-
- Use `updateItemAt()` for changes
|
|
565
|
-
- Cache `sections[0]` reference
|
|
566
|
-
- Use markers for infinite scroll
|
|
567
|
-
- Test with real device data volumes
|
|
561
|
+
Do:
|
|
562
|
+
- Use fixed heights in templates.
|
|
563
|
+
- Minimize number of templates.
|
|
564
|
+
- Use `updateItemAt()` for changes.
|
|
565
|
+
- Cache `sections[0]` reference.
|
|
566
|
+
- Use markers for infinite scroll.
|
|
567
|
+
- Test with real device data volumes.
|
|
568
568
|
|
|
569
|
-
|
|
570
|
-
- Use `Ti.UI.SIZE` for row dimensions
|
|
571
|
-
- Access `e.source` in itemclick events
|
|
572
|
-
- Create too many similar templates
|
|
573
|
-
- Add complex animations to list items
|
|
574
|
-
- Ignore the
|
|
569
|
+
Don't:
|
|
570
|
+
- Use `Ti.UI.SIZE` for row dimensions.
|
|
571
|
+
- Access `e.source` in itemclick events.
|
|
572
|
+
- Create too many similar templates.
|
|
573
|
+
- Add complex animations to list items.
|
|
574
|
+
- Ignore the recycled nature of views.
|
|
575
575
|
|
|
576
576
|
## 12. Transitioning from TableView
|
|
577
577
|
|
|
578
|
-
### Core
|
|
578
|
+
### Core logic differences
|
|
579
579
|
|
|
580
580
|
| TableView | ListView |
|
|
581
581
|
| -------------------- | ---------------------------- |
|
|
@@ -587,23 +587,23 @@ $.myList.addEventListener('noresults', (e) => {
|
|
|
587
587
|
| `updateRow()` | `updateItemAt()` |
|
|
588
588
|
| `deleteRow()` | `deleteItemsAt()` |
|
|
589
589
|
|
|
590
|
-
### API
|
|
590
|
+
### API differences
|
|
591
591
|
|
|
592
|
-
|
|
592
|
+
Properties not available for ListItem:
|
|
593
593
|
- `accessibilityLabel`, `className`, `editable`, `hasCheck`, `hasChild`, `hasDetail`, `leftImage`, `moveable`, `rightImage`.
|
|
594
|
-
-
|
|
594
|
+
- Alternatives: use `accessoryType` for indicators, and `image` or custom templates for images.
|
|
595
595
|
|
|
596
|
-
|
|
596
|
+
TableViewSection methods not supported by ListSection:
|
|
597
597
|
- `add`, `remove`, `rowAtIndex`.
|
|
598
|
-
-
|
|
598
|
+
- Alternatives: use `getItemAt` and `appendItems` or `deleteItemsAt`.
|
|
599
599
|
|
|
600
|
-
|
|
600
|
+
TableView methods not available to ListView:
|
|
601
601
|
- `appendRow`, `deleteRow`, `deselectRow`, `insertRowAfter`, `insertRowBefore`, `selectRow`, `updateRow`, `scrollToIndex`.
|
|
602
|
-
-
|
|
602
|
+
- Alternatives: use `scrollToItem` and `selectItem` (iOS). For row manipulation, use the containing ListSection.
|
|
603
603
|
|
|
604
|
-
## 13. Common
|
|
604
|
+
## 13. Common patterns
|
|
605
605
|
|
|
606
|
-
### Infinite
|
|
606
|
+
### Infinite scroll with markers
|
|
607
607
|
|
|
608
608
|
```javascript
|
|
609
609
|
const PAGE_SIZE = 25;
|
|
@@ -633,7 +633,7 @@ $.myList.addEventListener('marker', (e) => {
|
|
|
633
633
|
});
|
|
634
634
|
```
|
|
635
635
|
|
|
636
|
-
### Multiple
|
|
636
|
+
### Multiple selection
|
|
637
637
|
|
|
638
638
|
```javascript
|
|
639
639
|
const selectedItems = {};
|
|
@@ -656,13 +656,13 @@ $.myList.addEventListener('itemclick', (e) => {
|
|
|
656
656
|
});
|
|
657
657
|
```
|
|
658
658
|
|
|
659
|
-
### Section
|
|
659
|
+
### Section index (A-Z)
|
|
660
660
|
|
|
661
661
|
```javascript
|
|
662
662
|
$.myList.sectionIndexTitles = ["A", "B", "C", ...];
|
|
663
663
|
```
|
|
664
664
|
|
|
665
|
-
## 14. Platform
|
|
665
|
+
## 14. Platform differences
|
|
666
666
|
|
|
667
667
|
### iOS vs Android
|
|
668
668
|
|
|
@@ -674,7 +674,7 @@ $.myList.sectionIndexTitles = ["A", "B", "C", ...];
|
|
|
674
674
|
| Default template image | Left side | Right side |
|
|
675
675
|
| cacheSize property | Supported | Not supported |
|
|
676
676
|
|
|
677
|
-
### Grouped
|
|
677
|
+
### Grouped style (iOS)
|
|
678
678
|
|
|
679
679
|
Set `style: Ti.UI.iOS.ListViewStyle.GROUPED` to display sections as separate visual groups with rounded corners and inset spacing:
|
|
680
680
|
|
|
@@ -685,9 +685,9 @@ const listView = Ti.UI.createListView({
|
|
|
685
685
|
});
|
|
686
686
|
```
|
|
687
687
|
|
|
688
|
-
### Pull-to-
|
|
688
|
+
### Pull-to-refresh (iOS)
|
|
689
689
|
|
|
690
|
-
The `pull` event fires when the user pulls past the top of the list, and `pullend` fires when
|
|
690
|
+
The `pull` event fires when the user pulls past the top of the list, and `pullend` fires when they release. Use `pullView` to set a custom view:
|
|
691
691
|
|
|
692
692
|
```javascript
|
|
693
693
|
const pullView = Ti.UI.createView({
|
|
@@ -699,12 +699,12 @@ pullView.add(Ti.UI.createLabel({ text: 'Pull to refresh...' }));
|
|
|
699
699
|
$.myList.pullView = pullView;
|
|
700
700
|
|
|
701
701
|
$.myList.addEventListener('pull', (e) => {
|
|
702
|
-
// User is pulling
|
|
702
|
+
// User is pulling - update UI as needed
|
|
703
703
|
pullView.children[0].text = e.active ? 'Release to refresh...' : 'Pull to refresh...';
|
|
704
704
|
});
|
|
705
705
|
|
|
706
706
|
$.myList.addEventListener('pullend', (e) => {
|
|
707
|
-
// User released
|
|
707
|
+
// User released - trigger data refresh
|
|
708
708
|
refreshData();
|
|
709
709
|
});
|
|
710
710
|
```
|
|
@@ -718,16 +718,16 @@ $.myList.cacheSize = 3; // Default
|
|
|
718
718
|
|
|
719
719
|
## 15. Debugging
|
|
720
720
|
|
|
721
|
-
### Common
|
|
721
|
+
### Common issues
|
|
722
722
|
|
|
723
|
-
|
|
724
|
-
|
|
723
|
+
Problem: Jerky scrolling
|
|
724
|
+
Solution: Remove `Ti.UI.SIZE` from templates
|
|
725
725
|
|
|
726
|
-
|
|
727
|
-
|
|
726
|
+
Problem: Data changes not visible
|
|
727
|
+
Solution: Use `updateItemAt()` instead of modifying views
|
|
728
728
|
|
|
729
|
-
|
|
730
|
-
|
|
729
|
+
Problem: Event not firing on template element
|
|
730
|
+
Solution: Check `bindId` in event handler
|
|
731
731
|
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
Problem: Wrong item updated
|
|
733
|
+
Solution: Use `e.section.getItemAt(e.itemIndex)` not a global reference
|