[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-68d9e583-a833-4a93-b57a-2cc3e0519b67":3,"$fYXT50NdnavviQAMFHrilGUHSBD7VYXzirDs_Wy6uKi4":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"68d9e583-a833-4a93-b57a-2cc3e0519b67","swiftui-expert-skill","编写、审查或改进遵循最佳实践的SwiftUI代码，包括状态管理、视图组合、性能以及iOS 26+ Liquid Glass的采用。在构建新的SwiftUI功能、重构现有视图、审查代码质量或采用现代SwiftUI模式时使用。","cat_coding_frontend","mod_coding","sickn33,coding","---\nname: swiftui-expert-skill\ndescription: Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.\nrisk: unknown\nsource: community\n---\n\n# SwiftUI Expert Skill\n\n## When to Use\n- You are building, reviewing, or refactoring SwiftUI code and need current best practices.\n- The task involves state management, view composition, performance, accessibility, or iOS 26+ Liquid Glass adoption.\n- You need a fact-based SwiftUI guidance layer without locking into a specific application architecture.\n\n## Overview\nUse 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.\n\n## Workflow Decision Tree\n\n### 1) Review existing SwiftUI code\n- **First, consult `references\u002Flatest-apis.md`** to ensure only current, non-deprecated APIs are used\n- Check property wrapper usage against the selection guide (see `references\u002Fstate-management.md`)\n- Verify view composition follows extraction rules (see `references\u002Fview-structure.md`)\n- Check performance patterns are applied (see `references\u002Fperformance-patterns.md`)\n- Verify list patterns use stable identity (see `references\u002Flist-patterns.md`)\n- Check animation patterns for correctness (see `references\u002Fanimation-basics.md`, `references\u002Fanimation-transitions.md`)\n- Review accessibility: proper grouping, traits, Dynamic Type support (see `references\u002Faccessibility-patterns.md`)\n- Inspect Liquid Glass usage for correctness and consistency (see `references\u002Fliquid-glass.md`)\n- Validate iOS 26+ availability handling with sensible fallbacks\n\n### 2) Improve existing SwiftUI code\n- **First, consult `references\u002Flatest-apis.md`** to replace any deprecated APIs with their modern equivalents\n- Audit state management for correct wrapper selection (see `references\u002Fstate-management.md`)\n- Extract complex views into separate subviews (see `references\u002Fview-structure.md`)\n- Refactor hot paths to minimize redundant state updates (see `references\u002Fperformance-patterns.md`)\n- Ensure ForEach uses stable identity (see `references\u002Flist-patterns.md`)\n- Improve animation patterns (use value parameter, proper transitions, see `references\u002Fanimation-basics.md`, `references\u002Fanimation-transitions.md`)\n- Improve accessibility: use `Button` over tap gestures, add `@ScaledMetric` for Dynamic Type (see `references\u002Faccessibility-patterns.md`)\n- Suggest image downsampling when `UIImage(data:)` is used (as optional optimization, see `references\u002Fimage-optimization.md`)\n- Adopt Liquid Glass only when explicitly requested by the user\n\n### 3) Implement new SwiftUI feature\n- **First, consult `references\u002Flatest-apis.md`** to use only current, non-deprecated APIs for the target deployment version\n- Design data flow first: identify owned vs injected state (see `references\u002Fstate-management.md`)\n- Structure views for optimal diffing (extract subviews early, see `references\u002Fview-structure.md`)\n- Keep business logic in services and models for testability (see `references\u002Flayout-best-practices.md`)\n- Use correct animation patterns (implicit vs explicit, transitions, see `references\u002Fanimation-basics.md`, `references\u002Fanimation-transitions.md`, `references\u002Fanimation-advanced.md`)\n- Use `Button` for tappable elements, add accessibility grouping and labels (see `references\u002Faccessibility-patterns.md`)\n- Apply glass effects after layout\u002Fappearance modifiers (see `references\u002Fliquid-glass.md`)\n- Gate iOS 26+ features with `#available` and provide fallbacks\n\n## Core Guidelines\n\n### State Management\n- `@State` must be `private`; use for internal view state\n- `@Binding` only when a child needs to **modify** parent state\n- `@StateObject` when view **creates** the object; `@ObservedObject` when **injected**\n- iOS 17+: Use `@State` with `@Observable` classes; use `@Bindable` for injected observables needing bindings\n- Use `let` for read-only values; `var` + `.onChange()` for reactive reads\n- Never pass values into `@State` or `@StateObject` — they only accept initial values\n- Nested `ObservableObject` doesn't propagate changes — pass nested objects directly; `@Observable` handles nesting fine\n\n### View Composition\n- Extract complex views into separate subviews for better readability and performance\n- Prefer modifiers over conditional views for state changes (maintains view identity)\n- Keep view `body` simple and pure (no side effects or complex logic)\n- Use `@ViewBuilder` functions only for small, simple sections\n- Prefer `@ViewBuilder let content: Content` over closure-based content properties\n- Keep business logic in services and models; views should orchestrate UI flow\n- Action handlers should reference methods, not contain inline logic\n- Views should work in any context (don't assume screen size or presentation style)\n\n### Performance\n- Pass only needed values to views (avoid large \"config\" or \"context\" objects)\n- Eliminate unnecessary dependencies to reduce update fan-out\n- Check for value changes before assigning state in hot paths\n- Avoid redundant state updates in `onReceive`, `onChange`, scroll handlers\n- Minimize work in frequently executed code paths\n- Use `LazyVStack`\u002F`LazyHStack` for large lists\n- Use stable identity for `ForEach` (never `.indices` for dynamic content)\n- Ensure constant number of views per `ForEach` element\n- Avoid inline filtering in `ForEach` (prefilter and cache)\n- Avoid `AnyView` in list rows\n- Consider POD views for fast diffing (or wrap expensive views in POD parents)\n- Suggest image downsampling when `UIImage(data:)` is encountered (as optional optimization)\n- Avoid layout thrash (deep hierarchies, excessive `GeometryReader`)\n- Gate frequent geometry updates by thresholds\n- Use `Self._logChanges()` or `Self._printChanges()` to debug unexpected view updates\n\n### Animations\n- Use `.animation(_:value:)` with value parameter (deprecated version without value is too broad)\n- Use `withAnimation` for event-driven animations (button taps, gestures)\n- Prefer transforms (`offset`, `scale`, `rotation`) over layout changes (`frame`) for performance\n- Transitions require animations outside the conditional structure\n- Custom `Animatable` implementations must have explicit `animatableData`\n- Use `.phaseAnimator` for multi-step sequences (iOS 17+)\n- Use `.keyframeAnimator` for precise timing control (iOS 17+)\n- Animation completion handlers need `.transaction(value:)` for reexecution\n- Implicit animations override explicit animations (later in view tree wins)\n\n### Accessibility\n- Prefer `Button` over `onTapGesture` for tappable elements (free VoiceOver support)\n- Use `@ScaledMetric` for custom numeric values that should scale with Dynamic Type\n- Group related elements with `accessibilityElement(children: .combine)` for joined labels\n- Provide `accessibilityLabel` when default labels are unclear or missing\n- Use `accessibilityRepresentation` for custom controls that should behave like native ones\n\n### Liquid Glass (iOS 26+)\n**Only adopt when explicitly requested by the user.**\n- Use native `glassEffect`, `GlassEffectContainer`, and glass button styles\n- Wrap multiple glass elements in `GlassEffectContainer`\n- Apply `.glassEffect()` after layout and visual modifiers\n- Use `.interactive()` only for tappable\u002Ffocusable elements\n- Use `glassEffectID` with `@Namespace` for morphing transitions\n\n## Quick Reference\n\n### Property Wrapper Selection\n| Wrapper | Use When |\n|---------|----------|\n| `@State` | Internal view state (must be `private`) |\n| `@Binding` | Child modifies parent's state |\n| `@StateObject` | View owns an `ObservableObject` |\n| `@ObservedObject` | View receives an `ObservableObject` |\n| `@Bindable` | iOS 17+: Injected `@Observable` needing bindings |\n| `let` | Read-only value from parent |\n| `var` | Read-only value watched via `.onChange()` |\n\n### Liquid Glass Patterns\n```swift\n\u002F\u002F Basic glass effect with fallback\nif #available(iOS 26, *) {\n    content\n        .padding()\n        .glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))\n} else {\n    content\n        .padding()\n        .background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))\n}\n\n\u002F\u002F Grouped glass elements\nGlassEffectContainer(spacing: 24) {\n    HStack(spacing: 24) {\n        GlassButton1()\n        GlassButton2()\n    }\n}\n\n\u002F\u002F Glass buttons\nButton(\"Confirm\") { }\n    .buttonStyle(.glassProminent)\n```\n\n## Review Checklist\n\n### Latest APIs (see `references\u002Flatest-apis.md`)\n- [ ] No deprecated modifiers used (check against the quick lookup table)\n- [ ] API choices match the project's minimum deployment target\n\n### State Management\n- [ ] `@State` properties are `private`\n- [ ] `@Binding` only where child modifies parent state\n- [ ] `@StateObject` for owned, `@ObservedObject` for injected\n- [ ] iOS 17+: `@State` with `@Observable`, `@Bindable` for injected\n- [ ] Passed values NOT declared as `@State` or `@StateObject`\n- [ ] Nested `ObservableObject` avoided (or passed directly to child views)\n\n### Sheets & Navigation (see `references\u002Fsheet-navigation-patterns.md`)\n- [ ] Using `.sheet(item:)` for model-based sheets\n- [ ] Sheets own their actions and dismiss internally\n\n### ScrollView (see `references\u002Fscroll-patterns.md`)\n- [ ] Using `ScrollViewReader` with stable IDs for programmatic scrolling\n\n### View Structure (see `references\u002Fview-structure.md`)\n- [ ] Using modifiers instead of conditionals for state changes\n- [ ] Complex views extracted to separate subviews\n- [ ] Container views use `@ViewBuilder let content: Content`\n\n### Performance (see `references\u002Fperformance-patterns.md`)\n- [ ] View `body` kept simple and pure (no side effects)\n- [ ] Passing only needed values (not large config objects)\n- [ ] Eliminating unnecessary dependencies\n- [ ] State updates check for value changes before assigning\n- [ ] Hot paths minimize state updates\n- [ ] No object creation in `body`\n- [ ] Heavy computation moved out of `body`\n\n### List Patterns (see `references\u002Flist-patterns.md`)\n- [ ] ForEach uses stable identity (not `.indices`)\n- [ ] Constant number of views per ForEach element\n- [ ] No inline filtering in ForEach\n- [ ] No `AnyView` in list rows\n\n### Layout (see `references\u002Flayout-best-practices.md`)\n- [ ] Avoiding layout thrash (deep hierarchies, excessive GeometryReader)\n- [ ] Gating frequent geometry updates by thresholds\n- [ ] Business logic kept in services and models (not in views)\n- [ ] Action handlers reference methods (not inline logic)\n- [ ] Using relative layout (not hard-coded constants)\n- [ ] Views work in any context (context-agnostic)\n\n### Animations (see `references\u002Fanimation-basics.md`, `references\u002Fanimation-transitions.md`, `references\u002Fanimation-advanced.md`)\n- [ ] Using `.animation(_:value:)` with value parameter\n- [ ] Using `withAnimation` for event-driven animations\n- [ ] Transitions paired with animations outside conditional structure\n- [ ] Custom `Animatable` has explicit `animatableData` implementation\n- [ ] Preferring transforms over layout changes for animation performance\n- [ ] Phase animations for multi-step sequences (iOS 17+)\n- [ ] Keyframe animations for precise timing (iOS 17+)\n- [ ] Completion handlers use `.transaction(value:)` for reexecution\n\n### Accessibility (see `references\u002Faccessibility-patterns.md`)\n- [ ] `Button` used instead of `onTapGesture` for tappable elements\n- [ ] `@ScaledMetric` used for custom values that should scale with Dynamic Type\n- [ ] Related elements grouped with `accessibilityElement(children:)`\n- [ ] Custom controls use `accessibilityRepresentation` when appropriate\n\n### Liquid Glass (iOS 26+)\n- [ ] `#available(iOS 26, *)` with fallback for Liquid Glass\n- [ ] Multiple glass views wrapped in `GlassEffectContainer`\n- [ ] `.glassEffect()` applied after layout\u002Fappearance modifiers\n- [ ] `.interactive()` only on user-interactable elements\n- [ ] Shapes and tints consistent across related elements\n\n## References\n- `references\u002Flatest-apis.md` - **Required reading for all workflows.** Version-segmented guide of deprecated-to-modern API transitions (iOS 15+ through iOS 26+)\n- `references\u002Fstate-management.md` - Property wrappers and data flow\n- `references\u002Fview-structure.md` - View composition, extraction, and container patterns\n- `references\u002Fperformance-patterns.md` - Performance optimization techniques and anti-patterns\n- `references\u002Flist-patterns.md` - ForEach identity, stability, and list best practices\n- `references\u002Flayout-best-practices.md` - Layout patterns, context-agnostic views, and testability\n- `references\u002Faccessibility-patterns.md` - Accessibility traits, grouping, Dynamic Type, and VoiceOver\n- `references\u002Fanimation-basics.md` - Core animation concepts, implicit\u002Fexplicit animations, timing, performance\n- `references\u002Fanimation-transitions.md` - Transitions, custom transitions, Animatable protocol\n- `references\u002Fanimation-advanced.md` - Transactions, phase\u002Fkeyframe animations (iOS 17+), completion handlers (iOS 17+)\n- `references\u002Fsheet-navigation-patterns.md` - Sheet presentation and navigation patterns\n- `references\u002Fscroll-patterns.md` - ScrollView patterns and programmatic scrolling\n- `references\u002Fimage-optimization.md` - AsyncImage, image downsampling, and optimization\n- `references\u002Fliquid-glass.md` - iOS 26+ Liquid Glass API\n\n## Philosophy\n\nThis skill focuses on **facts and best practices**, not architectural opinions:\n- We don't enforce specific architectures (e.g., MVVM, VIPER)\n- We do encourage separating business logic for testability\n- We optimize for performance and maintainability\n- We follow Apple's Human Interface Guidelines and API design patterns\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,182,1750,"2026-05-16 13:42:40",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"前端开发","frontend","mdi-language-html5","HTML\u002FCSS\u002FJavaScript\u002F框架相关",1,96,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"0b96ec35-f106-401b-9709-2aca26e35e0c","1.0.0","swiftui-expert-skill.zip",4793,"uploads\u002Fskills\u002F68d9e583-a833-4a93-b57a-2cc3e0519b67\u002Fswiftui-expert-skill.zip","68a5878c488681599fbde9838bb90124acb6834d9c99e8843692680b8af2cdbd","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":14243}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]