Communitygithub.com

ComeOnOliver/skillshub

用于构建 SwiftUI 视图和组件的最佳实践与示例驱动指南。适用于创建或重构 SwiftUI 界面、使用 TabView 设计标签架构、组合屏幕,或需要特定组件模式和示例时。

skillshub 是什么?

这个技能为使用 SwiftUI 进行 UI 开发的开发者提供了全面的最佳实践指南和实例驱动的方法。它专门针对 SwiftUI 视图和组件的创建与重构,支持 TabView 标签架构、NavigationStack 导航栈、Sheet 弹窗等常见模式。技能的核心是一套结构化的组件参考文档(位于 `references/components-index.md`),涵盖意图、最佳适用场景、最小化使用模式以及性能注意事项。该技能适用于现有项目和新项目脚手架搭建,强调使用现代 SwiftUI 状态管理(`@State`、`@Binding`、`@Observable`、`@Environment`),推荐异步加载(`async/await` 配合 `.task`)以及以 Item 驱动的 Sheet 模式。它为 AI 代理(如 Claude Code、Cursor)提供了一个清晰的决策流程:先从整体目标选择轨道(现有项目或新项目),然后查找邻近示例,应用本地约定,最后通过组件参考文档指导实现。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/dimillian/swiftui-ui-patterns

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

SwiftUI UI Patterns(SwiftUI 界面模式)

快速入门

根据你的目标选择一条路线:

现有项目

  • 确定功能或屏幕的主要交互模型(列表、详情、编辑器、设置、标签页)。
  • 在仓库中使用 rg "TabView\(" 或类似命令查找附近示例,然后阅读最接近的 SwiftUI 视图。
  • 应用本地约定:优先使用 SwiftUI 原生状态,尽量将状态保持在本地,并使用环境注入共享依赖。
  • 从 references/components-index.md 中选择相关的组件参考,并遵循其指导。
  • 使用小型、专注的子视图和 SwiftUI 原生数据流构建视图。

新项目脚手架搭建

  • 从 references/app-scaffolding-wiring.md 开始,连接 TabView + NavigationStack + sheets。
  • 基于提供的骨架添加一个最小的 AppTab 和 RouterPath。
  • 根据你首先需要的 UI 选择下一个组件参考(TabView、NavigationStack、Sheets)。
  • 随着添加新屏幕,扩展路由和 sheet 枚举。

应遵循的通用规则

  • 使用现代 SwiftUI 状态(@State、@Binding、@Observable、@Environment),避免不必要的视图模型。
  • 优先使用组合;保持视图小而专注。
  • 将 async/await 与 .task 结合使用,并明确处理加载/错误状态。
  • 仅当编辑遗留文件时才保持现有的遗留模式。
  • 遵循项目的格式化和风格指南。
  • Sheets:当状态表示选中的模型时,优先使用 .sheet(item:) 而非 .sheet(isPresented:)。避免在 sheet 主体中使用 if let。Sheet 应拥有自己的操作,并在内部调用 dismiss(),而不是转发 onCancel/onConfirm 闭包。

创建新 SwiftUI 视图的工作流程

  1. 定义视图的状态及其所属位置。
  2. 通过 @Environment 识别要注入的依赖。
  3. 草拟视图层次结构,并将重复部分提取到子视图中。
  4. 使用 .task 实现异步加载,如有需要则定义明确的状态枚举。
  5. 当 UI 可交互时,添加无障碍标签或标识符。
  6. 通过构建验证,并根据需要更新使用点。

组件参考

使用 references/components-index.md 作为入口点。每个组件参考应包括:

  • 意图和最佳适用场景。
  • 遵循本地约定的最小使用模式。
  • 陷阱和性能注意事项。
  • 当前仓库中现有示例的路径。

Sheet 模式

Item 驱动的 Sheet(优先)

@State private var selectedItem: Item?

.sheet(item: $selectedItem) { item in
    EditItemSheet(item: item)
}

Sheet 拥有自己的操作

struct EditItemSheet: View {
    @Environment(\.dismiss) private var dismiss
    @Environment(Store.self) private var store

    let item: Item
    @State private var isSaving = false

    var body: some View {
        VStack {
            Button(isSaving ? "Saving…" : "Save") {
                Task { await save() }
            }
        }
    }

    private func save() async {
        isSaving = true
        await store.save(item)
        dismiss()
    }
}

添加新的组件参考

  • 创建 references/<component>.md。
  • 保持简短且可操作;链接到当前仓库中的具体文件。
  • 用新条目更新 references/components-index.md。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相关技能