搜索

PythonReactSEOPDF
GitHub Skill

swiftui-components

SwiftUI component expert for building reusable views, custom modifiers, and view compositions. Use when creating new SwiftUI views, refactoring UI code, or building watchOS-specific interfaces.

fotescodev☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

SwiftUI Components Expert

Instructions

When building SwiftUI components:

  1. Analyze the required component functionality
  2. Check existing components for reuse opportunities
  3. Follow watchOS design guidelines
  4. Ensure accessibility support
  5. Add appropriate previews

watchOS SwiftUI Patterns

Screen Size Considerations
  • Apple Watch screens are small (40-49mm)
  • Use vertical scrolling sparingly
  • Prefer single-tap interactions
  • Keep text concise
Common Patterns
Action Button
struct ActionButton: View {
    let title: String
    let action: () -> Void

    var body: some View {
        Button(action: action) {
            Text(title)
                .frame(maxWidth: .infinity)
        }
        .buttonStyle(.borderedProminent)
    }
}
Status Card
struct StatusCard: View {
    let icon: String
    let title: String
    let value: String

    var body: some View {
        HStack {
            Image(systemName: icon)
                .foregroundStyle(.secondary)
            VStack(alignment: .leading) {
                Text(title)
                    .font(.caption2)
                    .foregroundStyle(.secondary)
                Text(value)
                    .font(.headline)
            }
            Spacer()
        }
        .padding(.vertical, 4)
    }
}
State Management
// Use @Observable for view models (watchOS 10+)
@Observable
final class FeatureViewModel {
    var items: [Item] = []
    var isLoading = false

    func loadItems() async {
        isLoading = true
        defer { isLoading = false }
        // Load items...
    }
}
Haptic Feedback
// Add haptics for important interactions
WKInterfaceDevice.current().play(.success)
WKInterfaceDevice.current().play(.failure)
WKInterfaceDevice.current().play(.notification)

Best Practices

  • Extract reusable components when used 2+ times
  • Use SF Symbols for icons
  • Support Dynamic Type
  • Test on multiple watch sizes
  • Keep view body under 100 lines

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!