swiftui-expert-skill by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill swiftui-expert-skill使用此技能来构建、审查或改进 SwiftUI 功能,确保正确的状态管理、优化的视图组合以及 iOS 26+ 的液态玻璃样式。优先使用原生 API、遵循 Apple 设计指南和注重性能的模式。此技能侧重于事实和最佳实践,不强加特定的架构模式。
references/latest-apis.md,以确保仅使用当前、未弃用的 APIreferences/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/accessibility-patterns.md)references/liquid-glass.md)references/latest-apis.md,将任何已弃用的 API 替换为其现代等效项references/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)Button 而非点击手势,为动态类型添加 @ScaledMetric(参见 references/accessibility-patterns.md)UIImage(data:) 时,建议进行图像下采样(作为可选优化,参见 references/image-optimization.md)references/latest-apis.md,为目标部署版本仅使用当前、未弃用的 APIreferences/state-management.md)references/view-structure.md)references/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md)Button,添加无障碍功能分组和标签(参见 references/accessibility-patterns.md)references/liquid-glass.md)#available 对 iOS 26+ 功能进行条件限制并提供降级方案@State 必须是 private;用于内部视图状态@Binding 仅当子视图需要修改父视图状态时使用@StateObject 用于视图创建对象时;@ObservedObject 用于注入对象时@Observable 类使用 @State;对需要绑定的注入可观察对象使用 @Bindablelet;对响应式读取使用 var + .onChange()@State 或 @StateObject —— 它们只接受初始值ObservableObject 不会传播更改 —— 直接传递嵌套对象;@Observable 能很好地处理嵌套body 简单且纯粹(无副作用或复杂逻辑)@ViewBuilder 函数@ViewBuilder let content: Content 而非基于闭包的 content 属性onReceive、onChange、滚动处理程序中进行冗余状态更新LazyVStack/LazyHStackForEach 使用稳定的标识符(对于动态内容切勿使用 .indices)ForEach 元素的视图数量恒定ForEach 中进行内联过滤(预过滤并缓存)AnyViewUIImage(data:) 时,建议进行图像下采样(作为可选优化)GeometryReader)Self._logChanges() 或 Self._printChanges() 来调试意外的视图更新.animation(_:value:)(不带 value 的已弃用版本范围太广)withAnimationoffset、scale、rotation)而非布局更改(frame)Animatable 实现必须具有显式的 animatableData.phaseAnimator(iOS 17+).keyframeAnimator(iOS 17+).transaction(value:) 来重新执行Button 而非 onTapGesture(免费获得 VoiceOver 支持)@ScaledMetricaccessibilityElement(children: .combine) 对相关元素进行分组,以获得合并的标签accessibilityLabelaccessibilityRepresentation仅在用户明确请求时采用。
glassEffect、GlassEffectContainer 和玻璃按钮样式GlassEffectContainer 中.glassEffect().interactive()@Namespace 的 glassEffectID| 包装器 | 使用时机 |
|---|---|
@State | 内部视图状态(必须是 private) |
@Binding | 子视图修改父视图状态 |
@StateObject | 视图拥有一个 ObservableObject |
@ObservedObject | 视图接收一个 ObservableObject |
@Bindable | iOS 17+:需要绑定的注入 @Observable |
let | 来自父视图的只读值 |
var | 通过 .onChange() 监视的只读值 |
// 带降级方案的基本玻璃效果
if #available(iOS 26, *) {
content
.padding()
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
} else {
content
.padding()
.background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
}
// 分组的玻璃元素
GlassEffectContainer(spacing: 24) {
HStack(spacing: 24) {
GlassButton1()
GlassButton2()
}
}
// 玻璃按钮
Button("Confirm") { }
.buttonStyle(.glassProminent)
references/latest-apis.md)@State 属性是 private@Binding 仅用于子视图修改父视图状态的地方@StateObject 用于自有对象,@ObservedObject 用于注入对象@Observable 使用 @State,对注入对象使用 @Bindable@State 或 @StateObjectObservableObject(或直接传递给子视图)references/sheet-navigation-patterns.md).sheet(item:)references/scroll-patterns.md)ScrollViewReaderreferences/view-structure.md)@ViewBuilder let content: Contentreferences/performance-patterns.md)body 保持简单纯粹(无副作用)body 中创建对象bodyreferences/list-patterns.md).indices)AnyViewreferences/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md).animation(_:value:)withAnimationAnimatable 具有显式的 animatableData 实现.transaction(value:) 来重新执行references/accessibility-patterns.md)Button 而非 onTapGesture@ScaledMetricaccessibilityElement(children:) 对相关元素进行分组accessibilityRepresentation#available(iOS 26, *) 并提供降级方案GlassEffectContainer 中.glassEffect() 在布局/外观修饰符之后应用.interactive() 仅用于用户可交互元素references/latest-apis.md - 所有工作流程的必读内容。 按版本分段的已弃用到现代 API 转换指南(iOS 15+ 至 iOS 26+)references/state-management.md - 属性包装器和数据流references/view-structure.md - 视图组合、提取和容器模式references/performance-patterns.md - 性能优化技术和反模式references/list-patterns.md - ForEach 标识符、稳定性和列表最佳实践references/layout-best-practices.md - 布局模式、上下文无关视图和可测试性references/accessibility-patterns.md - 无障碍功能特性、分组、动态类型和 VoiceOverreferences/animation-basics.md - 核心动画概念、隐式/显式动画、时序、性能references/animation-transitions.md - 过渡、自定义过渡、Animatable 协议references/animation-advanced.md - 事务、阶段/关键帧动画(iOS 17+)、完成处理程序(iOS 17+)references/sheet-navigation-patterns.md - 表单呈现和导航模式references/scroll-patterns.md - ScrollView 模式和编程式滚动references/image-optimization.md - AsyncImage、图像下采样和优化references/liquid-glass.md - iOS 26+ 液态玻璃 API此技能侧重于事实和最佳实践,而非架构观点:
每周安装量
126
代码仓库
GitHub 星标
27.4K
首次出现
2026年1月31日
安全审计
安装于
opencode124
codex122
gemini-cli122
github-copilot120
amp117
kimi-cli117
Use this skill to build, review, or improve SwiftUI features with correct state management, optimal view composition, and iOS 26+ Liquid Glass styling. Prioritize native APIs, Apple design guidance, and performance-conscious patterns. This skill focuses on facts and best practices without enforcing specific architectural patterns.
references/latest-apis.md to ensure only current, non-deprecated APIs are usedreferences/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)references/accessibility-patterns.md)references/liquid-glass.md)references/latest-apis.md to replace any deprecated APIs with their modern equivalentsreferences/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)Button over tap gestures, add for Dynamic Type (see )references/latest-apis.md to use only current, non-deprecated APIs for the target deployment versionreferences/state-management.md)references/view-structure.md)references/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md)Button for tappable elements, add accessibility grouping and labels (see )@State must be private; use for internal view state@Binding only when a child needs to modify parent state@StateObject when view creates the object; @ObservedObject when injected@State with @Observable classes; use @Bindable for injected observables needing bindingslet for read-only values; var + for reactive readsbody simple and pure (no side effects or complex logic)@ViewBuilder functions only for small, simple sections@ViewBuilder let content: Content over closure-based content propertiesonReceive, onChange, scroll handlersLazyVStack/LazyHStack for large listsForEach (never .indices for dynamic content)ForEach elementForEach (prefilter and cache)AnyView in list rows.animation(_:value:) with value parameter (deprecated version without value is too broad)withAnimation for event-driven animations (button taps, gestures)offset, scale, rotation) over layout changes (frame) for performanceAnimatable implementations must have explicit animatableData.phaseAnimator for multi-step sequences (iOS 17+).keyframeAnimator for precise timing control (iOS 17+)Button over onTapGesture for tappable elements (free VoiceOver support)@ScaledMetric for custom numeric values that should scale with Dynamic TypeaccessibilityElement(children: .combine) for joined labelsaccessibilityLabel when default labels are unclear or missingaccessibilityRepresentation for custom controls that should behave like native onesOnly adopt when explicitly requested by the user.
glassEffect, GlassEffectContainer, and glass button stylesGlassEffectContainer.glassEffect() after layout and visual modifiers.interactive() only for tappable/focusable elementsglassEffectID with @Namespace for morphing transitions| Wrapper | Use When |
|---|---|
@State | Internal view state (must be private) |
@Binding | Child modifies parent's state |
@StateObject | View owns an ObservableObject |
@ObservedObject | View receives an ObservableObject |
// Basic glass effect with fallback
if #available(iOS 26, *) {
content
.padding()
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
} else {
content
.padding()
.background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
}
// Grouped glass elements
GlassEffectContainer(spacing: 24) {
HStack(spacing: 24) {
GlassButton1()
GlassButton2()
}
}
// Glass buttons
Button("Confirm") { }
.buttonStyle(.glassProminent)
references/latest-apis.md)@State properties are private@Binding only where child modifies parent state@StateObject for owned, @ObservedObject for injected@State with @Observable, @Bindable for injected@State or @StateObjectObservableObject avoided (or passed directly to child views)references/sheet-navigation-patterns.md).sheet(item:) for model-based sheetsreferences/scroll-patterns.md)ScrollViewReader with stable IDs for programmatic scrollingreferences/view-structure.md)@ViewBuilder let content: Contentreferences/performance-patterns.md)body kept simple and pure (no side effects)bodybodyreferences/list-patterns.md).indices)AnyView in list rowsreferences/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md).animation(_:value:) with value parameterwithAnimation for event-driven animationsAnimatable has explicit animatableData implementation.transaction(value:) for reexecutionreferences/accessibility-patterns.md)Button used instead of onTapGesture for tappable elements@ScaledMetric used for custom values that should scale with Dynamic TypeaccessibilityElement(children:)accessibilityRepresentation when appropriate#available(iOS 26, *) with fallback for Liquid GlassGlassEffectContainer.glassEffect() applied after layout/appearance modifiers.interactive() only on user-interactable elementsreferences/latest-apis.md - Required reading for all workflows. Version-segmented guide of deprecated-to-modern API transitions (iOS 15+ through iOS 26+)references/state-management.md - Property wrappers and data flowreferences/view-structure.md - View composition, extraction, and container patternsreferences/performance-patterns.md - Performance optimization techniques and anti-patternsreferences/list-patterns.md - ForEach identity, stability, and list best practicesreferences/layout-best-practices.md - Layout patterns, context-agnostic views, and testabilityreferences/accessibility-patterns.md - Accessibility traits, grouping, Dynamic Type, and VoiceOverreferences/animation-basics.md - Core animation concepts, implicit/explicit animations, timing, performanceThis skill focuses on facts and best practices , not architectural opinions:
Weekly Installs
126
Repository
GitHub Stars
27.4K
First Seen
Jan 31, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode124
codex122
gemini-cli122
github-copilot120
amp117
kimi-cli117
Swift Actor 线程安全持久化:构建离线优先应用的编译器强制安全数据层
1,700 周安装
@ScaledMetricreferences/accessibility-patterns.mdUIImage(data:) is used (as optional optimization, see references/image-optimization.md)references/accessibility-patterns.mdreferences/liquid-glass.md)#available and provide fallbacks.onChange()@State or @StateObject — they only accept initial valuesObservableObject doesn't propagate changes — pass nested objects directly; @Observable handles nesting fineUIImage(data:) is encountered (as optional optimization)GeometryReader)Self._logChanges() or Self._printChanges() to debug unexpected view updates.transaction(value:) for reexecution@BindableiOS 17+: Injected @Observable needing bindings |
let | Read-only value from parent |
var | Read-only value watched via .onChange() |
references/animation-transitions.md - Transitions, custom transitions, Animatable protocolreferences/animation-advanced.md - Transactions, phase/keyframe animations (iOS 17+), completion handlers (iOS 17+)references/sheet-navigation-patterns.md - Sheet presentation and navigation patternsreferences/scroll-patterns.md - ScrollView patterns and programmatic scrollingreferences/image-optimization.md - AsyncImage, image downsampling, and optimizationreferences/liquid-glass.md - iOS 26+ Liquid Glass API