home / skills / maccesar / titanium-sdk-skills / ti-ui

ti-ui skill

/skills/ti-ui

This skill guides you through Titanium SDK UI patterns, performance, and platform-specific components to optimize layouts and interactions.

npx playbooks add skill maccesar/titanium-sdk-skills --skill ti-ui

Review the files below or copy the command above to add this skill to your agents.

Files (15)
SKILL.md
9.0 KB
---
name: ti-ui
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)."
argument-hint: "[component]"
allowed-tools: Read, Grep, Glob, Edit, Write, Bash(node *)
---

# Titanium SDK UI Expert

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.

## Project Detection

:::info AUTO-DETECTS TITANIUM PROJECTS
This skill automatically detects Titanium projects when invoked and provides UI/UX component guidance.

**Detection occurs automatically** - no manual command needed.

**Titanium project indicator:**
- `tiapp.xml` file (required for all Titanium projects)

**Applicable to BOTH:**
- **Alloy projects** (app/ folder structure)
- **Classic projects** (Resources/ folder)

**Behavior based on detection:**
- **Titanium detected** → Provides UI component guidance for both Alloy and Classic, ListView/TableView patterns, platform-specific UI differences
- **Not detected** → Indicates this is for Titanium projects only, does NOT provide Titanium UI guidance
:::

## Table of Contents

- [Titanium SDK UI Expert](#titanium-sdk-ui-expert)
  - [Project Detection](#project-detection)
  - [Table of Contents](#table-of-contents)
  - [Quick Reference](#quick-reference)
  - [Critical Rules (Low Freedom)](#critical-rules-low-freedom)
    - [Performance](#performance)
    - [iOS Accessibility](#ios-accessibility)
    - [Layout](#layout)
    - [Platform-Specific Properties](#platform-specific-properties)
    - [Event Management](#event-management)
    - [App Architecture](#app-architecture)
  - [Platform Differences Summary](#platform-differences-summary)
  - [UI Design Workflow](#ui-design-workflow)
  - [Searching References](#searching-references)
  - [Related Skills](#related-skills)

---

## Quick Reference

| Topic                            | Reference                                                               |
| -------------------------------- | ----------------------------------------------------------------------- |
| **App Structures**               | [application-structures.md](references/application-structures.md)       |
| Layouts, positioning, units      | [layouts-and-positioning.md](references/layouts-and-positioning.md)     |
| Events, bubbling, lifecycle      | [event-handling.md](references/event-handling.md)                       |
| ScrollView vs ScrollableView     | [scrolling-views.md](references/scrolling-views.md)                     |
| **TableView**                    | [tableviews.md](references/tableviews.md)                               |
| ListView templates & performance | [listviews-and-performance.md](references/listviews-and-performance.md) |
| Touch, swipe, pinch, gestures    | [gestures.md](references/gestures.md)                                   |
| Orientation handling             | [orientation.md](references/orientation.md)                             |
| Custom fonts, attributed strings | [custom-fonts-styling.md](references/custom-fonts-styling.md)           |
| Animations, 2D/3D matrices       | [animation-and-matrices.md](references/animation-and-matrices.md)       |
| Icons, splash screens, densities | [icons-and-splash-screens.md](references/icons-and-splash-screens.md)   |
| Android Action Bar, themes       | [platform-ui-android.md](references/platform-ui-android.md)             |
| iOS Navigation, 3D Touch         | [platform-ui-ios.md](references/platform-ui-ios.md)                     |
| VoiceOver, TalkBack, a11y        | [accessibility-deep-dive.md](references/accessibility-deep-dive.md)     |

## Critical Rules (Low Freedom)

### Performance
- **NO `Ti.UI.SIZE` in ListViews**: Causes jerky scrolling. Use fixed heights.
- **Prefer ListView over TableView** for new apps with large datasets.
- **Batch updates**: Use `applyProperties` to reduce bridge crossing overhead.
- **WebView in TableView**: Anti-pattern causing severe scrolling issues.

### iOS Accessibility
- **NO accessibility properties on container views**: Blocks children interaction.
- **NO accessibilityLabel on text controls** (Android): Overrides visible text.

### Layout
- **Use `dp` units** for cross-platform consistency.
- **Android ScrollView**: Vertical OR horizontal, not both. Set `scrollType`.

### Platform-Specific Properties

:::danger CRITICAL: Platform-Specific Properties Require Modifiers
Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties WITHOUT platform modifiers causes cross-platform compilation failures.

**Example of the damage:**
```javascript
// ❌ WRONG - Adds Ti.UI.iOS to Android project
const win = Ti.UI.createWindow({
  statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT  // FAILS on Android!
})
```

**CORRECT approaches:**

**Option 1 - TSS modifier (Alloy projects):**
```tss
"#mainWindow[platform=ios]": {
  statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
}
```

**Option 2 - Conditional code:**
```javascript
if (OS_IOS) {
  $.mainWindow.statusBarStyle = Ti.UI.iOS.StatusBar.LIGHT_CONTENT
}
```

**Properties that ALWAYS require platform modifiers:**
- iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
- Android: `actionBar` config, any `Ti.UI.Android.*` constant

**For complete platform-specific UI patterns, see** [Platform UI - iOS](references/platform-ui-ios.md) and [Platform UI - Android](references/platform-ui-android.md).
:::

### Event Management
- **Remove global listeners** (`Ti.App`, `Ti.Gesture`, `Ti.Accelerometer`) on pause to save battery.
- **Event bubbling**: Input events bubble up; system events do not.

### App Architecture
- **Limit tabs to 4 or less** for better UX across platforms.
- **Use NavigationWindow for iOS** hierarchical navigation.
- **Handle androidback** to prevent unexpected app exits.

## Platform Differences Summary

| Feature                | iOS                          | Android                 |
| ---------------------- | ---------------------------- | ----------------------- |
| 3D Matrix              | ✅ Full support               | ❌ No                    |
| Pinch gesture          | ✅ Full support               | ⚠️ Limited               |
| ScrollView             | Bidirectional                | Unidirectional          |
| TableView              | ✅ Full support               | ✅ Full support          |
| ListView               | ✅ Full support               | ✅ Full support          |
| Default template image | Left side                    | Right side              |
| ListView action items  | ✅ Swipe actions              | ❌ No                    |
| Modal windows          | Fills screen, covers tab bar | No effect (always full) |
| Navigation pattern     | NavigationWindow             | Back button + Menu      |

## UI Design Workflow

1. **Choose App Structure**: Tab-based (most common) or Window-based
2. **Layout Selection**: Choose mode (composite/vertical/horizontal) based on structure
3. **Sizing Strategy**: Assign `SIZE` or `FILL` based on component defaults
4. **Event Architecture**: Plan bubbling, app-level events, lifecycle
5. **Performance**: Use ListView/TableView templates, batch updates
6. **Accessibility**: Apply a11y properties per platform requirements
7. **Motion**: Add animations, 2D/3D transforms, transitions

## Searching References

When looking for specific patterns, grep these terms in reference files:
- **App Structure**: `TabGroup`, `NavigationWindow`, `modal`, `execution context`, `androidback`
- **Layouts**: `dp`, `Ti.UI.SIZE`, `Ti.UI.FILL`, `composite`, `vertical`, `horizontal`
- **Events**: `addEventListener`, `cancelBubble`, `bubbling`, `Ti.App.fireEvent`
- **TableView**: `TableView`, `TableViewRow`, `setData`, `appendRow`, `className`
- **ListView**: `ItemTemplate`, `bindId`, `setItems`, `updateItemAt`, `marker`
- **Gestures**: `swipe`, `pinch`, `longpress`, `shake`, `accelerometer`
- **Animation**: `animate`, `create2DMatrix`, `create3DMatrix`, `autoreverse`
- **Fonts**: `fontFamily`, `PostScript`, `createAttributedString`, `ATTRIBUTE_`
- **Icons/Splash**: `DefaultIcon`, `appicon`, `nine-patch`, `drawable`, `splash`, `iTunesArtwork`, `adaptive`
- **Android**: `Action Bar`, `onCreateOptionsMenu`, `theme`, `Material3`, `talkback`
- **iOS**: `3D Touch`, `Popover`, `SplitWindow`, `badge`, `NavigationWindow`
- **Accessibility**: `accessibilityLabel`, `VoiceOver`, `TalkBack`, `accessibilityHidden`

## Related Skills

For tasks beyond UI components, use these complementary skills:

| Task                                            | Use This Skill |
| ----------------------------------------------- | -------------- |
| Project architecture, services, memory cleanup  | `alloy-expert` |
| Native features (camera, location, push, media) | `ti-howtos`    |
| Alloy MVC, data binding, widgets                | `alloy-guides` |

Overview

This skill is a Titanium SDK UI/UX patterns and components expert for reviewing, designing, and optimizing app interfaces across Alloy and Classic projects. It auto-detects Titanium projects and provides concrete guidance for layouts, ListView/TableView performance, gestures, animations, accessibility, and platform-specific UI. Use it to enforce best practices and resolve common cross-platform pitfalls quickly.

How this skill works

When invoked inside a project containing tiapp.xml, the skill switches into Titanium mode and targets either Alloy (app/ structure) or Classic (Resources/ structure). It inspects layout choices, ListView/TableView templates and usage patterns, event handling and bubbling, gesture handlers, animation code, accessibility properties, and platform-specific APIs, then returns practical advice and fixes. If no Titanium project is detected, it reports that the guidance applies only to Titanium projects.

When to use it

  • Review or optimize ListView/TableView performance and scrolling behavior
  • Debug event handling, bubbling, or global listener leaks
  • Design or review gestures (swipe, pinch) and touch handling
  • Implement animations, transforms, and transitions for UI motion
  • Audit accessibility (VoiceOver/TalkBack) and platform-specific a11y rules
  • Adapt layouts, status bar, action/navigation bars, and orientation handling for iOS and Android

Best practices

  • Prefer ListView over TableView for large data sets; use fixed heights (avoid Ti.UI.SIZE) in item templates
  • Batch UI updates and use applyProperties to reduce bridge crossings
  • Never attach accessibility properties to container views that should forward interaction to children
  • Scope platform-specific Ti.UI.iOS* or Ti.UI.Android* properties behind platform modifiers or conditional code
  • Remove global listeners (Ti.App, Ti.Gesture, Ti.Accelerometer) on pause to save battery
  • Use dp units for cross-platform sizing and avoid mixing vertical+horizontal scroll in Android ScrollView

Example use cases

  • Identify and fix jerky ListView scrolling by replacing Ti.UI.SIZE with fixed item heights
  • Convert TableView implementations to ListView templates and bindId patterns for performance
  • Detect accidental use of Ti.UI.iOS.* properties on Android and suggest platform-conditional fixes
  • Recommend accessibility fixes: adding accessibilityLabel to controls (not containers) and ensuring VoiceOver/TalkBack focus order
  • Propose animation optimizations using 2D/3D matrices and avoiding heavy WebView content inside scrolling containers

FAQ

How does the skill detect a Titanium project?

It looks for a tiapp.xml file at the project root and inspects common Alloy (app/) or Classic (Resources/) folders.

What causes jerky ListView scrolling?

Common causes are Ti.UI.SIZE in item templates, heavy WebView content inside list rows, or frequent crossing of the JS-native bridge without batching updates.