android-compose-foundations
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAndroid Compose Foundations
Android Compose 基础
When To Use
适用场景
- Use this skill when the request is about: jetpack compose screen, compose layout in android, modifier cleanup compose.
- Primary outcome: Build Android UI with Jetpack Compose foundations, layouts, modifiers, theming, and stable component structure.
- Handoff skills when the scope expands:
android-compose-state-effectsandroid-material3-design-system
- 当请求涉及以下内容时使用本技能:jetpack compose 页面、Android中的compose布局、compose modifier清理。
- 核心目标:基于Jetpack Compose基础能力、布局、修饰符、主题体系和稳定的组件结构构建Android UI。
- 当需求范围扩大时,移交至以下技能:
android-compose-state-effectsandroid-material3-design-system
Workflow
工作流程
- Identify whether the target surface is Compose, View system, or a mixed interoperability screen.
- Select the lowest-friction UI pattern that satisfies responsiveness, accessibility, and performance needs.
- Build the UI around stable state, explicit side effects, and reusable design tokens.
- Exercise edge cases such as long text, font scaling, RTL, and narrow devices in the fixture apps.
- Validate with unit, UI, and screenshot-friendly checks before handing off.
- 确定目标界面是Compose、View系统还是混合互操作页面。
- 选择满足响应式、无障碍性和性能需求的最低成本UI模式。
- 围绕稳定状态、显式副作用和可复用设计令牌构建UI。
- 在测试应用中验证长文本、字体缩放、RTL、窄屏设备等边缘场景。
- 移交前通过单元测试、UI测试和截图兼容性检查进行验证。
Guardrails
规范约束
- Optimize for stable state and predictable rendering before adding animation or abstraction.
- Respect accessibility semantics, contrast, focus order, and touch target guidance by default.
- Do not mix Compose and View system ownership without an explicit interoperability boundary.
- Prefer measured performance work over premature micro-optimizations.
- 在添加动画或抽象层之前,优先优化稳定状态和可预测渲染。
- 默认遵循无障碍语义、对比度、焦点顺序和点击区域规范。
- 若无明确的互操作边界,不得混合Compose和View系统的所有权。
- 优先开展可量化的性能优化,避免过早进行微优化。
Anti-Patterns
反模式
- Embedding navigation or business logic directly in leaf UI components.
- Using fixed dimensions that break on localization or dynamic text.
- Ignoring semantics and announcing only visual changes.
- Porting XML patterns directly into Compose without adapting the mental model.
- 在叶子UI组件中直接嵌入导航或业务逻辑。
- 使用固定尺寸,导致在本地化或动态文本场景下布局崩坏。
- 忽略语义属性,仅通知视觉变更。
- 不调整思维模式,直接将XML模式迁移到Compose中。
Examples
示例
Happy path
正常场景
- Scenario: Refine the Compose OrbitTasks board with stable slots and theme tokens.
- Command:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
- 场景:使用稳定插槽和主题令牌优化Compose OrbitTasks看板。
- 命令:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
Edge case
边缘场景
- Scenario: Keep previews and layout behavior stable under narrow widths and long text.
- Command:
cd examples/orbittasks-compose && ./gradlew :app:assembleDebug
- 场景:在窄屏宽度和长文本场景下保持预览和布局行为稳定。
- 命令:
cd examples/orbittasks-compose && ./gradlew :app:assembleDebug
Failure recovery
故障恢复
- Scenario: Keep general Compose requests from drifting into state/effects or performance work.
- Command:
python3 scripts/eval_triggers.py --skill android-compose-foundations
- 场景:避免普通Compose请求偏离到状态/副作用或性能优化工作范畴。
- 命令:
python3 scripts/eval_triggers.py --skill android-compose-foundations
Done Checklist
完成检查清单
- The implementation path is explicit, minimal, and tied to the right Android surface.
- Relevant example commands and benchmark prompts have been exercised or updated.
- Handoffs to adjacent skills are documented when the request crosses boundaries.
- Official references cover the chosen pattern and the main migration or troubleshooting path.
- 实现路径清晰、最小化,且适配正确的Android界面类型。
- 已运行或更新相关示例命令和基准提示。
- 当请求跨领域时,已记录移交至相邻技能的说明。
- 官方参考资料覆盖所选模式及主要迁移或故障排查路径。