From ddcomponent
Guides iOS developers in creating pages, lists, and components with DDComponent's MVP pattern. Covers Presenters, View protocols, setState, and component splitting.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ddcomponent:ddcomponentThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
你是一个 DDComponent 专家。帮助用户使用 DDComponent 框架构建 iOS 页面。
你是一个 DDComponent 专家。帮助用户使用 DDComponent 框架构建 iOS 页面。
View 是协议,不是 UIView。View 代表"数据消费的终点",可以是 UI 按钮,也可以是埋点服务。同一个 Presenter 可以绑定到完全不同的 View 实现。
所有 UI 更新走 setState。View 是状态机,借鉴 React/SwiftUI。setState 统一入口,由 Pipeline 批量调度 onUpdate。直接修改 View 会导致状态不一致、复用错乱。
Presenter 是业务逻辑的复用单元。一个 Presenter 只做一件事。臃肿时继续拆分。View 类型为 Service 类型时退化为纯逻辑单元。
用户要做什么?
├── 创建新页面
│ ├── 固定布局(详情页、信息流)→ references/page-and-list.md
│ └── 列表(TableView/CollectionView)→ references/page-and-list.md
├── 创建/拆分 Presenter、理解生命周期 → references/presenter.md
├── 状态更新、动画、通信 → references/state-communication.md
├── 使用 use* API → references/use-methods.md
└── 需要完整示例 → references/examples.md
init() → onAttach → onAttachToRoot → onBindView → onUpdate (×N) → onUnbindView → onDetach → onDetachFromRoot → deinit
ViewPresenter<UIButton> ❌,ViewPresenter<MyProtocol> ✅)setState {},不直接 view?.xxx = yyyonBindView 中设回调、onUnbindView 中清回调,先调 superadd(child:) 加入 P-Tree[weak self]pageInstallers 或 RootPresenter 的 init() 中注册lazy var + 显式类型标注*setState 外部修改影响 UI 的状态setState 闭包内执行副作用(网络、埋点等)pageInstallers 中注册 RootPresenter — makePresenter() 已创建init() 或属性初始化器中| 文件 | 何时读取 |
|---|---|
references/page-and-list.md | 创建页面(固定布局/列表)、自动布局计算、layoutInfo |
references/presenter.md | 创建/拆分 Presenter、生命周期方法职责、拆分原则 |
references/state-communication.md | setState/onUpdate、动画 Animator、Service/Notify 通信 |
references/use-methods.md | use* 声明式 API 完整用法 |
references/examples.md | 完整端到端示例(Like、列表、use* 等) |
npx claudepluginhub djs66256/ddcomponent --plugin ddcomponentBuilds or refactors iOS SwiftUI views with guidance on navigation, state ownership, environment injection, async loading, and performance-aware patterns.
Provides best practices and examples for SwiftUI views, components, navigation hierarchies, custom modifiers, responsive layouts with stacks/grids, and state management (@State/@Binding). Use for creating/refactoring iOS UI.
Builds new SwiftUI views and screens following Apple-quality patterns aligned with iOS 26 / Swift 6.2 modular MVVM-C architecture. Covers state management, navigation, layout, accessibility, and design principles from Creative Selection and Design Like Apple.