跳到正文
TakoAPI
返回技能列表

swiftui-ui-patterns

由 dimillian 提供

iOS & macOS Development
2.9k下载量由 clawskills.sh 提供
4星标
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

Best practices and example-driven guidance.

描述

该技能的功能

Opinionated guidance for building SwiftUI views using modern state management, composition, and navigation patterns. Covers TabView architecture, NavigationStack wiring, sheet presentation, and async data loading. Targets both new project scaffolding and incremental work on existing codebases.

Encodes SwiftUI-specific pitfalls (sheet ownership, state locality, async patterns) that generic Swift guidance omits, reducing time spent debugging avoidable mistakes.

何时使用

  • Setting up TabView with NavigationStack in a new iOS app
  • Refactoring a view model-heavy screen to use @Observable
  • Implementing a sheet driven by a selected model item
  • Adding async loading states to a SwiftUI list view
  • Structuring a multi-tab app with typed route enums

示例工作流

输入

User asks: Add an edit sheet to my SwiftUI list screen

智能体
  1. 1

    Read the existing list view to identify current state and navigation patterns

  2. 2

    Choose item-driven sheet pattern using .sheet(item:) with a @State private var selectedItem

  3. 3

    Scaffold EditItemSheet with @Environment(\.dismiss) and an internal save() async function

  4. 4

    Wire the sheet modifier to the list view and pass the selected item

  5. 5

    Validate the build and check that dismiss() is called after the async action completes

输出

A list view with a working item-driven edit sheet that owns its save action and dismisses itself on completion

安装

clawhub install dimillian/swiftui-ui-patterns

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接