[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CS9Y7PS3B7X08CJ4DSCZM0":3,"skill-same:01M7CS9Y7PS3B7X08CJ4DSCZM0":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M7CS9Y7PS3B7X08CJ4DSCZM0","swiftui-patterns",null,"Use when building native iOS with SwiftUI - small composable views, observable state models, atomic components, Swift 6.2+ concurrency, and system styling over hardcoded values","makifbaysal\u002Ftasktrooper","makifbaysal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25031940?v=4","01M7CRG3ZCSYZSSEVDMW3DEYC8","Mehmet Akif Baysal","01M7CRG401FJ8YAXH5ER730XYV",122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: swiftui-patterns\ncategory: architecture\ndescription: Use when building native iOS with SwiftUI - small composable views, observable state models, atomic components, Swift 6.2+ concurrency, and system styling over hardcoded values\ntech_stack: Swift\nsource: twostraws\u002FSwiftUI-Agent-Skill (MIT), AvdLee\u002FSwiftUI-Agent-Skill (MIT), adapted\n---\n# SwiftUI Patterns\n\n## Overview\n\nNative iOS (SwiftUI) is chosen when a task needs deep Apple-platform integration or the app is already native (see native-vs-flutter-decision). Same discipline as Flutter: small composed views, state out of the view, reusable atomic components.\n\n**Core principle:** Views are a function of state. Data and business logic live in an observable model, not in the `View`.\n\n## Rules\n\n- **Small views, composed.** Extract subviews as their own `View` types (not `@ViewBuilder` funcs) so each has its own body and preview.\n- **State ownership is explicit:** `@State` for local ephemeral UI only (and it is always `private`); app\u002Fbusiness state in an `@MainActor @Observable` model injected via `init`\u002F`@Environment`. Views send intents to the model; the model owns the logic and the networking.\n- **Atomic components:** a shared component library (atoms → molecules → organisms) of reusable views. Reuse before building; grep before adding.\n- **System styling over hardcoded values:** colors from the asset catalog \u002F `Color` semantic roles, spacing\u002Ftypography from a tokens file (see `mobile-design-system-foundation`) — not scattered magic numbers. Support Dynamic Type and dark mode.\n- **`#Preview`** every reusable view in its key states (loading\u002Fdata\u002Ferror), and in the matrix: Dynamic Type `.accessibility3`, dark, `traits: .landscapeLeft`.\n- **Value types** (`struct`) for models and view state; reference types only where identity is needed.\n- **Never name a domain type `Task`** — it shadows `_Concurrency.Task`, which every `async`\u002F`.task {}` call site needs; a rename (`BoardItem`, `WorkItem`, …) is a five-minute fix versus a confusing compile error later.\n\n## Concurrency\n\n- Follow the target's default actor isolation: a new Xcode 26 project defaults to `@MainActor` isolation, so a view model that touches UI state should be `@MainActor @Observable` explicitly rather than relying on inference holding across Swift versions.\n- No GCD (`DispatchQueue.main.async`, etc.) in new code — `async`\u002F`await`, `Task { }`, `Task.sleep(for:)`.\n- Kick off async work from `.task { }` on the view, not `onAppear` + a detached `Task`.\n\n## Worked Example\n\n```swift\nstruct BoardItem: Identifiable, Sendable { let id: Int; let title: String }   \u002F\u002F never name a model `Task`\nenum LoadState\u003CT> { case loading, empty, data(T), failed(String) }\n\n@MainActor @Observable final class ItemListModel {\n    private(set) var state: LoadState\u003C[BoardItem]> = .loading\n    private let repo: any BoardItemRepository\n    init(repo: any BoardItemRepository) { self.repo = repo }\n    func load() async {\n        state = .loading\n        do { let items = try await repo.list(); state = items.isEmpty ? .empty : .data(items) }\n        catch { state = .failed(error.localizedDescription) }\n    }\n}\n\nstruct ItemListScreen: View {\n    @State private var model: ItemListModel\n    init(model: ItemListModel) { _model = State(initialValue: model) }\n    var body: some View {\n        Group {\n            switch model.state {\n            case .loading: AppSpinner()\n            case .empty: ContentUnavailableView(\"No items yet\", systemImage: \"tray\")\n            case .failed(let message):\n                ContentUnavailableView {\n                    Label(\"Couldn't load items\", systemImage: \"exclamationmark.triangle\")\n                } description: { Text(message) } actions: {\n                    Button(\"Try again\") { Task { await model.load() } }\n                }\n            case .data(let items): ItemList(items: items)\n            }\n        }\n        .task { await model.load() }\n    }\n}\n```\n\nTypechecks with `swiftc -swift-version 6` (verified). The original example's domain `struct Task` shadowed `_Concurrency.Task`, giving `error: missing argument for parameter 'title' in call` at every `Task { }` call site — renamed to `BoardItem` here. Note the explicit `.empty` case rendered with `ContentUnavailableView` and a retry action on `.failed`, and the `init` that seeds `State(initialValue:)` so the model can be injected.\n\nPreviews at the matrix (typechecked against the iOS 18 simulator SDK):\n\n```swift\n#Preview(\"Phone, AX3, dark\") { ItemListScreen(model: .preview).environment(\\.dynamicTypeSize, .accessibility3).preferredColorScheme(.dark) }\n#Preview(\"Landscape\", traits: .landscapeLeft) { ItemListScreen(model: .preview) }\n```\n\nFor a layout that must switch at large accessibility sizes: `typeSize.isAccessibilitySize ? AnyLayout(VStackLayout()) : AnyLayout(HStackLayout())`. For an icon-only control: `Button(\"Add to cart\", systemImage: \"cart.badge.plus\", action:)` with `.labelStyle(.iconOnly)` and `.frame(minWidth: 44, minHeight: 44)` (see `mobile-accessibility`).\n\n## Rules for testing\n\n- Unit-test the `@Observable` model with a mocked repository (no UI).\n- New tests in **Swift Testing** (`import Testing`, `@Test`, `#expect`) where the target already uses Xcode 16+; XCTest stays for existing UI tests and `app.performAccessibilityAudit()`. Test-first.\n\n## Modern API\n\n- `foregroundStyle` (not `foregroundColor`), `.clipShape(.rect(cornerRadius:))` (not `.cornerRadius`), the `Tab` API for tab bars, the two-parameter `onChange(of:) { old, new in }`, `.topBarTrailing` placement, `containerRelativeFrame` instead of `GeometryReader` when it covers the case, never `UIScreen.main.bounds`.\n- `Color.withValues` is not a thing in SwiftUI (that's the Flutter equivalent) — use asset-catalog colours or `Color(.sRGB, ...)`\u002F`.opacity()` as the repo already does.\n\n## Liquid Glass (iOS 26+)\n\n- Standard bars, tab views and sheets adopt Liquid Glass automatically when built with Xcode 26+. Don't paint an opaque custom background over a toolbar\u002Ftab bar to \"fix\" this.\n- Use `.glassEffect` only on custom floating controls, and only when the task asks for it.\n- `UIDesignRequiresCompatibility` is ignored when building with the iOS 27 SDK — don't rely on it to opt back out of the new look.\n\n## Common Mistakes\n\n- Networking or business rules inside `body` \u002F `View`.\n- `@ViewBuilder` helper funcs instead of real subviews.\n- Hardcoded colors\u002Fsizes instead of asset-catalog + tokens.\n- No previews, so every change needs a full build to see.\n- A domain model named `Task`.\n- GCD calls in new code instead of `async`\u002F`await`.\n\n## Red Flags\n\n- A `View` with a URLSession call in it.\n- Magic `Color(red:...)` and paddings sprinkled across views.\n- A 200-line `body`.\n- A type named `Task` anywhere in the diff.\n","# SwiftUI Patterns\n\n## Overview\n\nNative iOS (SwiftUI) is chosen when a task needs deep Apple-platform integration or the app is already native (see native-vs-flutter-decision). Same discipline as Flutter: small composed views, state out of the view, reusable atomic components.\n\n**Core principle:** Views are a function of state. Data and business logic live in an observable model, not in the `View`.\n\n## Rules\n\n- **Small views, composed.** Extract subviews as their own `View` types (not `@ViewBuilder` funcs) so each has its own body and preview.\n- **State ownership is explicit:** `@State` for local ephemeral UI only (and it is always `private`); app\u002Fbusiness state in an `@MainActor @Observable` model injected via `init`\u002F`@Environment`. Views send intents to the model; the model owns the logic and the networking.\n- **Atomic components:** a shared component library (atoms → molecules → organisms) of reusable views. Reuse before building; grep before adding.\n- **System styling over hardcoded values:** colors from the asset catalog \u002F `Color` semantic roles, spacing\u002Ftypography from a tokens file (see `mobile-design-system-foundation`) — not scattered magic numbers. Support Dynamic Type and dark mode.\n- **`#Preview`** every reusable view in its key states (loading\u002Fdata\u002Ferror), and in the matrix: Dynamic Type `.accessibility3`, dark, `traits: .landscapeLeft`.\n- **Value types** (`struct`) for models and view state; reference types only where identity is needed.\n- **Never name a domain type `Task`** — it shadows `_Concurrency.Task`, which every `async`\u002F`.task {}` call site needs; a rename (`BoardItem`, `WorkItem`, …) is a five-minute fix versus a confusing compile error later.\n\n## Concurrency\n\n- Follow the target's default actor isolation: a new Xcode 26 project defaults to `@MainActor` isolation, so a view model that touches UI state should be `@MainActor @Observable` explicitly rather than relying on inference holding across Swift versions.\n- No GCD (`DispatchQueue.main.async`, etc.) in new code — `async`\u002F`await`, `Task { }`, `Task.sleep(for:)`.\n- Kick off async work from `.task { }` on the view, not `onAppear` + a detached `Task`.\n\n## Worked Example\n\n```swift\nstruct BoardItem: Identifiable, Sendable { let id: Int; let title: String }   \u002F\u002F never name a model `Task`\nenum LoadState\u003CT> { case loading, empty, data(T), failed(String) }\n\n@MainActor @Observable final class ItemListModel {\n    private(set) var state: LoadState\u003C[BoardItem]> = .loading\n    private let repo: any BoardItemRepository\n    init(repo: any BoardItemRepository) { self.repo = repo }\n    func load() async {\n        state = .loading\n        do { let items = try await repo.list(); state = items.isEmpty ? .empty : .data(items) }\n        catch { state = .failed(error.localizedDescription) }\n    }\n}\n\nstruct ItemListScreen: View {\n    @State private var model: ItemListModel\n    init(model: ItemListModel) { _model = State(initialValue: model) }\n    var body: some View {\n        Group {\n            switch model.state {\n            case .loading: AppSpinner()\n            case .empty: ContentUnavailableView(\"No items yet\", systemImage: \"tray\")\n            case .failed(let message):\n                ContentUnavailableView {\n                    Label(\"Couldn't load items\", systemImage: \"exclamationmark.triangle\")\n                } description: { Text(message) } actions: {\n                    Button(\"Try again\") { Task { await model.load() } }\n                }\n            case .data(let items): ItemList(items: items)\n            }\n        }\n        .task { await model.load() }\n    }\n}\n```\n\nTypechecks with `swiftc -swift-version 6` (verified). The original example's domain `struct Task` shadowed `_Concurrency.Task`, giving `error: missing argument for parameter 'title' in call` at every `Task { }` call site — renamed to `BoardItem` here. Note the explicit `.empty` case rendered with `ContentUnavailableView` and a retry action on `.failed`, and the `init` that seeds `State(initialValue:)` so the model can be injected.\n\nPreviews at the matrix (typechecked against the iOS 18 simulator SDK):\n\n```swift\n#Preview(\"Phone, AX3, dark\") { ItemListScreen(model: .preview).environment(\\.dynamicTypeSize, .accessibility3).preferredColorScheme(.dark) }\n#Preview(\"Landscape\", traits: .landscapeLeft) { ItemListScreen(model: .preview) }\n```\n\nFor a layout that must switch at large accessibility sizes: `typeSize.isAccessibilitySize ? AnyLayout(VStackLayout()) : AnyLayout(HStackLayout())`. For an icon-only control: `Button(\"Add to cart\", systemImage: \"cart.badge.plus\", action:)` with `.labelStyle(.iconOnly)` and `.frame(minWidth: 44, minHeight: 44)` (see `mobile-accessibility`).\n\n## Rules for testing\n\n- Unit-test the `@Observable` model with a mocked repository (no UI).\n- New tests in **Swift Testing** (`import Testing`, `@Test`, `#expect`) where the target already uses Xcode 16+; XCTest stays for existing UI tests and `app.performAccessibilityAudit()`. Test-first.\n\n## Modern API\n\n- `foregroundStyle` (not `foregroundColor`), `.clipShape(.rect(cornerRadius:))` (not `.cornerRadius`), the `Tab` API for tab bars, the two-parameter `onChange(of:) { old, new in }`, `.topBarTrailing` placement, `containerRelativeFrame` instead of `GeometryReader` when it covers the case, never `UIScreen.main.bounds`.\n- `Color.withValues` is not a thing in SwiftUI (that's the Flutter equivalent) — use asset-catalog colours or `Color(.sRGB, ...)`\u002F`.opacity()` as the repo already does.\n\n## Liquid Glass (iOS 26+)\n\n- Standard bars, tab views and sheets adopt Liquid Glass automatically when built with Xcode 26+. Don't paint an opaque custom background over a toolbar\u002Ftab bar to \"fix\" this.\n- Use `.glassEffect` only on custom floating controls, and only when the task asks for it.\n- `UIDesignRequiresCompatibility` is ignored when building with the iOS 27 SDK — don't rely on it to opt back out of the new look.\n\n## Common Mistakes\n\n- Networking or business rules inside `body` \u002F `View`.\n- `@ViewBuilder` helper funcs instead of real subviews.\n- Hardcoded colors\u002Fsizes instead of asset-catalog + tokens.\n- No previews, so every change needs a full build to see.\n- A domain model named `Task`.\n- GCD calls in new code instead of `async`\u002F`await`.\n\n## Red Flags\n\n- A `View` with a URLSession call in it.\n- Magic `Color(red:...)` and paddings sprinkled across views.\n- A 200-line `body`.\n- A type named `Task` anywhere in the diff.\n",{"name":5,"source":24,"category":25,"tech_stack":26,"description":7},"twostraws\u002FSwiftUI-Agent-Skill (MIT), AvdLee\u002FSwiftUI-Agent-Skill (MIT), adapted","architecture","Swift","main","910394a0b6db9fc8c9a8f36328ec421d3ebd8b38","catalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fswiftui-patterns",18,"https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper","https:\u002F\u002Ftasktrooper.ai","https:\u002F\u002Fgithub.com\u002Fmakifbaysal","Senior Software Developer","2026-11-15 04:50:29",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add makifbaysal\u002Ftasktrooper --skill swiftui-patterns",{"tool":42,"command":43},"bunx","bunx skills add makifbaysal\u002Ftasktrooper --skill swiftui-patterns",{"tool":45,"command":46},"pnpm","pnpm dlx skills add makifbaysal\u002Ftasktrooper --skill swiftui-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",true,[],[51,57,64,71,78,85],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7CSVEPQW6J6TD6CS2T5FPNZ","visual-craft","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fvisual-craft\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7CSVAQG91ETHQ0HBNZDG5FR","ux-copy","Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fux-copy\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7CSV6H0J38659NDXHJQ8396","screen-mockup-html","Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fscreen-mockup-html\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7CSV3JFRF3BM3XK52M7YEYR","performance-awareness","How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fperformance-awareness\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CSTZDH00YRF5SCT7BRT9QD","design-variants","Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-variants\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CSTV6P3SM3PAE28DB0RF77","design-system-authoring","Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-system-authoring\u002FSKILL.md",[],[]]