@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,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ti-ui
|
|
3
|
+
description: "Titanium SDK UI/UX patterns and components expert. Use when working with, reviewing, analyzing, or examining Titanium layouts, ListView/TableView performance optimization, event handling and bubbling, gestures (swipe, pinch), animations, accessibility (VoiceOver/TalkBack), orientation changes, custom fonts/icons, app icons/splash screens, or platform-specific UI (Action Bar, Navigation Bar)."
|
|
4
|
+
argument-hint: "[component]"
|
|
5
|
+
allowed-tools: Read, Grep, Glob, Edit, Write, Bash(node *)
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Titanium SDK UI Expert
|
|
9
|
+
|
|
10
|
+
Comprehensive expert covering all official Titanium SDK UI how-to guides. Provides guidance on cross-platform UI/UX, event handling, animations, performance optimization, and platform-specific components.
|
|
11
|
+
|
|
12
|
+
## Project Detection
|
|
13
|
+
|
|
14
|
+
:::info AUTO-DETECTS TITANIUM PROJECTS
|
|
15
|
+
This skill automatically detects Titanium projects when invoked and provides UI/UX component guidance.
|
|
16
|
+
|
|
17
|
+
**Detection occurs automatically** - no manual command needed.
|
|
18
|
+
|
|
19
|
+
**Titanium project indicator:**
|
|
20
|
+
- `tiapp.xml` file (required for all Titanium projects)
|
|
21
|
+
|
|
22
|
+
**Applicable to BOTH:**
|
|
23
|
+
- **Alloy projects** (app/ folder structure)
|
|
24
|
+
- **Classic projects** (Resources/ folder)
|
|
25
|
+
|
|
26
|
+
**Behavior based on detection:**
|
|
27
|
+
- **Titanium detected** → Provides UI component guidance for both Alloy and Classic, ListView/TableView patterns, platform-specific UI differences
|
|
28
|
+
- **Not detected** → Indicates this is for Titanium projects only, does NOT provide Titanium UI guidance
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
## Table of Contents
|
|
32
|
+
|
|
33
|
+
- [Titanium SDK UI Expert](#titanium-sdk-ui-expert)
|
|
34
|
+
- [Project Detection](#project-detection)
|
|
35
|
+
- [Table of Contents](#table-of-contents)
|
|
36
|
+
- [Quick Reference](#quick-reference)
|
|
37
|
+
- [Critical Rules (Low Freedom)](#critical-rules-low-freedom)
|
|
38
|
+
- [Performance](#performance)
|
|
39
|
+
- [iOS Accessibility](#ios-accessibility)
|
|
40
|
+
- [Layout](#layout)
|
|
41
|
+
- [Platform-Specific Properties](#platform-specific-properties)
|
|
42
|
+
- [Event Management](#event-management)
|
|
43
|
+
- [App Architecture](#app-architecture)
|
|
44
|
+
- [Platform Differences Summary](#platform-differences-summary)
|
|
45
|
+
- [UI Design Workflow](#ui-design-workflow)
|
|
46
|
+
- [Searching References](#searching-references)
|
|
47
|
+
- [Related Skills](#related-skills)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Quick Reference
|
|
52
|
+
|
|
53
|
+
| Topic | Reference |
|
|
54
|
+
| -------------------------------- | ----------------------------------------------------------------------- |
|
|
55
|
+
| **App Structures** | [application-structures.md](references/application-structures.md) |
|
|
56
|
+
| Layouts, positioning, units | [layouts-and-positioning.md](references/layouts-and-positioning.md) |
|
|
57
|
+
| Events, bubbling, lifecycle | [event-handling.md](references/event-handling.md) |
|
|
58
|
+
| ScrollView vs ScrollableView | [scrolling-views.md](references/scrolling-views.md) |
|
|
59
|
+
| **TableView** | [tableviews.md](references/tableviews.md) |
|
|
60
|
+
| ListView templates & performance | [listviews-and-performance.md](references/listviews-and-performance.md) |
|
|
61
|
+
| Touch, swipe, pinch, gestures | [gestures.md](references/gestures.md) |
|
|
62
|
+
| Orientation handling | [orientation.md](references/orientation.md) |
|
|
63
|
+
| Custom fonts, attributed strings | [custom-fonts-styling.md](references/custom-fonts-styling.md) |
|
|
64
|
+
| Animations, 2D/3D matrices | [animation-and-matrices.md](references/animation-and-matrices.md) |
|
|
65
|
+
| Icons, splash screens, densities | [icons-and-splash-screens.md](references/icons-and-splash-screens.md) |
|
|
66
|
+
| Android Action Bar, themes | [platform-ui-android.md](references/platform-ui-android.md) |
|
|
67
|
+
| iOS Navigation, 3D Touch | [platform-ui-ios.md](references/platform-ui-ios.md) |
|
|
68
|
+
| VoiceOver, TalkBack, a11y | [accessibility-deep-dive.md](references/accessibility-deep-dive.md) |
|
|
69
|
+
|
|
70
|
+
## Critical Rules (Low Freedom)
|
|
71
|
+
|
|
72
|
+
### Performance
|
|
73
|
+
- **NO `Ti.UI.SIZE` in ListViews**: Causes jerky scrolling. Use fixed heights.
|
|
74
|
+
- **Prefer ListView over TableView** for new apps with large datasets.
|
|
75
|
+
- **Batch updates**: Use `applyProperties` to reduce bridge crossing overhead.
|
|
76
|
+
- **WebView in TableView**: Anti-pattern causing severe scrolling issues.
|
|
77
|
+
|
|
78
|
+
### iOS Accessibility
|
|
79
|
+
- **NO accessibility properties on container views**: Blocks children interaction.
|
|
80
|
+
- **NO accessibilityLabel on text controls** (Android): Overrides visible text.
|
|
81
|
+
|
|
82
|
+
### Layout
|
|
83
|
+
- **Use `dp` units** for cross-platform consistency.
|
|
84
|
+
- **Android ScrollView**: Vertical OR horizontal, not both. Set `scrollType`.
|
|
85
|
+
|
|
86
|
+
### Platform-Specific Properties
|
|
87
|
+
|
|
88
|
+
:::danger CRITICAL: Platform-Specific Properties Require Modifiers
|
|
89
|
+
Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties WITHOUT platform modifiers causes cross-platform compilation failures.
|
|
90
|
+
|
|
91
|
+
**Example of the damage:**
|
|
92
|
+
```javascript
|
|
93
|
+
// ❌ WRONG - Adds Ti.UI.iOS to Android project
|
|
94
|
+
const win = Ti.UI.createWindow({
|
|
95
|
+
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT // FAILS on Android!
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**CORRECT approaches:**
|
|
100
|
+
|
|
101
|
+
**Option 1 - TSS modifier (Alloy projects):**
|
|
102
|
+
```tss
|
|
103
|
+
"#mainWindow[platform=ios]": {
|
|
104
|
+
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Option 2 - Conditional code:**
|
|
109
|
+
```javascript
|
|
110
|
+
if (OS_IOS) {
|
|
111
|
+
$.mainWindow.statusBarStyle = Ti.UI.iOS.StatusBar.LIGHT_CONTENT
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Properties that ALWAYS require platform modifiers:**
|
|
116
|
+
- iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
|
|
117
|
+
- Android: `actionBar` config, any `Ti.UI.Android.*` constant
|
|
118
|
+
|
|
119
|
+
**For complete platform-specific UI patterns, see** [Platform UI - iOS](references/platform-ui-ios.md) and [Platform UI - Android](references/platform-ui-android.md).
|
|
120
|
+
:::
|
|
121
|
+
|
|
122
|
+
### Event Management
|
|
123
|
+
- **Remove global listeners** (`Ti.App`, `Ti.Gesture`, `Ti.Accelerometer`) on pause to save battery.
|
|
124
|
+
- **Event bubbling**: Input events bubble up; system events do not.
|
|
125
|
+
|
|
126
|
+
### App Architecture
|
|
127
|
+
- **Limit tabs to 4 or less** for better UX across platforms.
|
|
128
|
+
- **Use NavigationWindow for iOS** hierarchical navigation.
|
|
129
|
+
- **Handle androidback** to prevent unexpected app exits.
|
|
130
|
+
|
|
131
|
+
## Platform Differences Summary
|
|
132
|
+
|
|
133
|
+
| Feature | iOS | Android |
|
|
134
|
+
| ---------------------- | ---------------------------- | ----------------------- |
|
|
135
|
+
| 3D Matrix | ✅ Full support | ❌ No |
|
|
136
|
+
| Pinch gesture | ✅ Full support | ⚠️ Limited |
|
|
137
|
+
| ScrollView | Bidirectional | Unidirectional |
|
|
138
|
+
| TableView | ✅ Full support | ✅ Full support |
|
|
139
|
+
| ListView | ✅ Full support | ✅ Full support |
|
|
140
|
+
| Default template image | Left side | Right side |
|
|
141
|
+
| ListView action items | ✅ Swipe actions | ❌ No |
|
|
142
|
+
| Modal windows | Fills screen, covers tab bar | No effect (always full) |
|
|
143
|
+
| Navigation pattern | NavigationWindow | Back button + Menu |
|
|
144
|
+
|
|
145
|
+
## UI Design Workflow
|
|
146
|
+
|
|
147
|
+
1. **Choose App Structure**: Tab-based (most common) or Window-based
|
|
148
|
+
2. **Layout Selection**: Choose mode (composite/vertical/horizontal) based on structure
|
|
149
|
+
3. **Sizing Strategy**: Assign `SIZE` or `FILL` based on component defaults
|
|
150
|
+
4. **Event Architecture**: Plan bubbling, app-level events, lifecycle
|
|
151
|
+
5. **Performance**: Use ListView/TableView templates, batch updates
|
|
152
|
+
6. **Accessibility**: Apply a11y properties per platform requirements
|
|
153
|
+
7. **Motion**: Add animations, 2D/3D transforms, transitions
|
|
154
|
+
|
|
155
|
+
## Searching References
|
|
156
|
+
|
|
157
|
+
When looking for specific patterns, grep these terms in reference files:
|
|
158
|
+
- **App Structure**: `TabGroup`, `NavigationWindow`, `modal`, `execution context`, `androidback`
|
|
159
|
+
- **Layouts**: `dp`, `Ti.UI.SIZE`, `Ti.UI.FILL`, `composite`, `vertical`, `horizontal`
|
|
160
|
+
- **Events**: `addEventListener`, `cancelBubble`, `bubbling`, `Ti.App.fireEvent`
|
|
161
|
+
- **TableView**: `TableView`, `TableViewRow`, `setData`, `appendRow`, `className`
|
|
162
|
+
- **ListView**: `ItemTemplate`, `bindId`, `setItems`, `updateItemAt`, `marker`
|
|
163
|
+
- **Gestures**: `swipe`, `pinch`, `longpress`, `shake`, `accelerometer`
|
|
164
|
+
- **Animation**: `animate`, `create2DMatrix`, `create3DMatrix`, `autoreverse`
|
|
165
|
+
- **Fonts**: `fontFamily`, `PostScript`, `createAttributedString`, `ATTRIBUTE_`
|
|
166
|
+
- **Icons/Splash**: `DefaultIcon`, `appicon`, `nine-patch`, `drawable`, `splash`, `iTunesArtwork`, `adaptive`
|
|
167
|
+
- **Android**: `Action Bar`, `onCreateOptionsMenu`, `theme`, `Material3`, `talkback`
|
|
168
|
+
- **iOS**: `3D Touch`, `Popover`, `SplitWindow`, `badge`, `NavigationWindow`
|
|
169
|
+
- **Accessibility**: `accessibilityLabel`, `VoiceOver`, `TalkBack`, `accessibilityHidden`
|
|
170
|
+
|
|
171
|
+
## Related Skills
|
|
172
|
+
|
|
173
|
+
For tasks beyond UI components, use these complementary skills:
|
|
174
|
+
|
|
175
|
+
| Task | Use This Skill |
|
|
176
|
+
| ----------------------------------------------- | -------------- |
|
|
177
|
+
| Project architecture, services, memory cleanup | `alloy-expert` |
|
|
178
|
+
| Native features (camera, location, push, media) | `ti-howtos` |
|
|
179
|
+
| Alloy MVC, data binding, widgets | `alloy-guides` |
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Accessibility (a11y) Deep Dive
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Accessibility (a11y) Deep Dive](#accessibility-a11y-deep-dive)
|
|
6
|
+
- [Table of Contents](#table-of-contents)
|
|
7
|
+
- [1. Overview](#1-overview)
|
|
8
|
+
- [2. Core Accessibility Properties](#2-core-accessibility-properties)
|
|
9
|
+
- [Basic Usage](#basic-usage)
|
|
10
|
+
- [Android TalkBack](#android-talkback)
|
|
11
|
+
- [Star Rating Example](#star-rating-example)
|
|
12
|
+
- [Toggle Button Example](#toggle-button-example)
|
|
13
|
+
- [6. System-Level Accessibility Events](#6-system-level-accessibility-events)
|
|
14
|
+
- [Monitor Accessibility Changes](#monitor-accessibility-changes)
|
|
15
|
+
- [Code Patterns](#code-patterns)
|
|
16
|
+
- [Accessibility First Development](#accessibility-first-development)
|
|
17
|
+
- [9. External Resources](#9-external-resources)
|
|
18
|
+
- [10. Common Issues](#10-common-issues)
|
|
19
|
+
- [Issue: VoiceOver Can't Access Children](#issue-voiceover-cant-access-children)
|
|
20
|
+
- [Issue: TalkBack Doesn't Speak Text](#issue-talkback-doesnt-speak-text)
|
|
21
|
+
- [Issue: Complex Custom Controls Not Accessible](#issue-complex-custom-controls-not-accessible)
|
|
22
|
+
- [Issue: State Changes Not Announced](#issue-state-changes-not-announced)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 1. Overview
|
|
27
|
+
|
|
28
|
+
Accessibility ensures your app is usable by everyone, including users with visual, hearing, and motor disabilities. Titanium supports both Android TalkBack and iOS VoiceOver spoken feedback systems.
|
|
29
|
+
|
|
30
|
+
## 2. Core Accessibility Properties
|
|
31
|
+
|
|
32
|
+
All Titanium view elements support these accessibility properties:
|
|
33
|
+
|
|
34
|
+
| Property | Default Value | Description |
|
|
35
|
+
| --------------------- | ----------------------------- | ------------------------------------------------------------------------------- |
|
|
36
|
+
| `accessibilityHidden` | `false` | If `true`, the view is ignored by the accessibility service |
|
|
37
|
+
| `accessibilityLabel` | Title or label of the control | Succinct label identifying the view |
|
|
38
|
+
| `accessibilityHint` | - | Briefly describes what performing an action will do (e.g., "Closes the window") |
|
|
39
|
+
| `accessibilityValue` | State or value of the control | String describing current state (e.g., "Selected", "50 percent") |
|
|
40
|
+
|
|
41
|
+
### Basic Usage
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
const button = Ti.UI.createButton({
|
|
45
|
+
title: 'Save',
|
|
46
|
+
accessibilityLabel: 'Save changes',
|
|
47
|
+
accessibilityHint: 'Saves your modifications to the server'
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const slider = Ti.UI.createSlider({
|
|
51
|
+
min: 0,
|
|
52
|
+
max: 100,
|
|
53
|
+
value: 50,
|
|
54
|
+
accessibilityLabel: 'Volume control',
|
|
55
|
+
accessibilityValue: '50 percent'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Update accessibilityValue as slider changes
|
|
59
|
+
slider.addEventListener('change', (e) => {
|
|
60
|
+
slider.accessibilityValue = `${e.value.toFixed(0)} percent`;
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
...
|
|
64
|
+
### Android TalkBack
|
|
65
|
+
...
|
|
66
|
+
```javascript
|
|
67
|
+
// GOOD - Button uses default text
|
|
68
|
+
const button = Ti.UI.createButton({
|
|
69
|
+
title: 'Submit Form'
|
|
70
|
+
// accessibilityLabel NOT needed - title is spoken
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// CUSTOM - Override default
|
|
74
|
+
const button = Ti.UI.createButton({
|
|
75
|
+
title: 'Submit',
|
|
76
|
+
accessibilityLabel: 'Submit the registration form'
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
...
|
|
80
|
+
```javascript
|
|
81
|
+
// BAD - Container with accessibility properties
|
|
82
|
+
const container = Ti.UI.createView({
|
|
83
|
+
accessibilityLabel: 'Form container', // DON'T DO THIS
|
|
84
|
+
accessibilityHint: 'Contains input fields'
|
|
85
|
+
});
|
|
86
|
+
container.add(nameField);
|
|
87
|
+
container.add(emailField);
|
|
88
|
+
container.add(submitButton);
|
|
89
|
+
|
|
90
|
+
// GOOD - No accessibility on container, children accessible
|
|
91
|
+
const container = Ti.UI.createView({
|
|
92
|
+
// No accessibility properties
|
|
93
|
+
});
|
|
94
|
+
container.add(nameField);
|
|
95
|
+
container.add(emailField);
|
|
96
|
+
container.add(submitButton);
|
|
97
|
+
```
|
|
98
|
+
...
|
|
99
|
+
### Star Rating Example
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
const starView = Ti.UI.createView({
|
|
103
|
+
width: 200,
|
|
104
|
+
height: 40,
|
|
105
|
+
accessibilityLabel: 'Rating',
|
|
106
|
+
accessibilityValue: '4 out of 5 stars',
|
|
107
|
+
accessibilityHint: 'User rating for this product'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Visual representation (images or drawn stars)
|
|
111
|
+
for (let i = 0; i < 5; i++) {
|
|
112
|
+
const star = Ti.UI.createImageView({
|
|
113
|
+
image: i < 4 ? 'star-filled.png' : 'star-empty.png',
|
|
114
|
+
left: i * 35,
|
|
115
|
+
accessibilityHidden: true // Hide individual stars
|
|
116
|
+
});
|
|
117
|
+
starView.add(star);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Toggle Button Example
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
let isMuted = false;
|
|
125
|
+
const muteButton = Ti.UI.createButton({
|
|
126
|
+
title: 'Mute',
|
|
127
|
+
accessibilityLabel: 'Mute audio',
|
|
128
|
+
accessibilityValue: 'Off' // Current state
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
muteButton.addEventListener('click', () => {
|
|
132
|
+
isMuted = !isMuted;
|
|
133
|
+
muteButton.title = isMuted ? 'Unmute' : 'Mute';
|
|
134
|
+
muteButton.accessibilityValue = isMuted ? 'On' : 'Off';
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 6. System-Level Accessibility Events
|
|
139
|
+
|
|
140
|
+
### Monitor Accessibility Changes
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
Ti.App.addEventListener('accessibilitychanged', (e) => {
|
|
144
|
+
Ti.API.info(`Accessibility mode changed: ${e.enabled}`);
|
|
145
|
+
// Adjust UI behavior as needed
|
|
146
|
+
if (e.enabled) {
|
|
147
|
+
// Increase touch targets, simplify animations, etc.
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
...
|
|
152
|
+
### Code Patterns
|
|
153
|
+
|
|
154
|
+
**DO**:
|
|
155
|
+
```javascript
|
|
156
|
+
// Provide meaningful labels
|
|
157
|
+
const iconButton = Ti.UI.createButton({
|
|
158
|
+
image: 'settings.png',
|
|
159
|
+
accessibilityLabel: 'Open settings'
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Update state changes
|
|
163
|
+
checkbox.accessibilityValue = isChecked ? 'Checked' : 'Unchecked';
|
|
164
|
+
|
|
165
|
+
// Hide decorative elements
|
|
166
|
+
decorativeIcon.accessibilityHidden = true;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**DON'T**:
|
|
170
|
+
```javascript
|
|
171
|
+
// Don't set accessibilityLabel for text controls (Android)
|
|
172
|
+
const label = Ti.UI.createLabel({
|
|
173
|
+
text: 'Hello',
|
|
174
|
+
accessibilityLabel: 'Hello' // REDUNDANT on Android
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Don't set accessibility on containers (iOS)
|
|
178
|
+
const container = Ti.UI.createView({
|
|
179
|
+
accessibilityLabel: 'Container' // BLOCKS children on iOS
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Accessibility First Development
|
|
184
|
+
|
|
185
|
+
When designing complex UIs, consider accessibility from the start:
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
function createAccessibleListItem(title, subtitle, action) {
|
|
189
|
+
const item = Ti.UI.createView({
|
|
190
|
+
height: 60,
|
|
191
|
+
accessibilityLabel: title,
|
|
192
|
+
accessibilityHint: `${subtitle}. Double tap to ${action}`
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const titleLabel = Ti.UI.createLabel({
|
|
196
|
+
text: title,
|
|
197
|
+
accessibilityHidden: true // Already announced by container
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const subtitleLabel = Ti.UI.createLabel({
|
|
201
|
+
text: subtitle,
|
|
202
|
+
accessibilityHidden: true // Already announced by container
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
item.add(titleLabel);
|
|
206
|
+
item.add(subtitleLabel);
|
|
207
|
+
return item;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## 9. External Resources
|
|
212
|
+
|
|
213
|
+
- [Accessibility Programming Guide for iOS](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/iPhoneAccessibility/Introduction/Introduction.html)
|
|
214
|
+
- [Android Accessibility API Guide](http://developer.android.com/guide/topics/ui/accessibility/index.html)
|
|
215
|
+
- [Android Accessibility Design Guide](http://developer.android.com/design/patterns/accessibility.html)
|
|
216
|
+
- [W3C Web Content Accessibility Guidelines](http://www.w3.org/WAI/WCAG20/quickref/)
|
|
217
|
+
|
|
218
|
+
## 10. Common Issues
|
|
219
|
+
|
|
220
|
+
### Issue: VoiceOver Can't Access Children
|
|
221
|
+
|
|
222
|
+
**Cause**: Container view has accessibility properties set
|
|
223
|
+
|
|
224
|
+
**Solution**: Remove all accessibility properties from container views
|
|
225
|
+
|
|
226
|
+
### Issue: TalkBack Doesn't Speak Text
|
|
227
|
+
|
|
228
|
+
**Cause**: `accessibilityLabel` set on Label/Button overrides visible text
|
|
229
|
+
|
|
230
|
+
**Solution**: Don't set `accessibilityLabel` on textual controls unless intentionally overriding
|
|
231
|
+
|
|
232
|
+
### Issue: Complex Custom Controls Not Accessible
|
|
233
|
+
|
|
234
|
+
**Cause**: No accessibility properties set on custom-drawn views
|
|
235
|
+
|
|
236
|
+
**Solution**: Always provide `accessibilityLabel`, `accessibilityValue`, and `accessibilityHint` for custom controls
|
|
237
|
+
|
|
238
|
+
### Issue: State Changes Not Announced
|
|
239
|
+
|
|
240
|
+
**Cause**: `accessibilityValue` not updated when state changes
|
|
241
|
+
|
|
242
|
+
**Solution**: Always update `accessibilityValue` in change event handlers
|