{
  "category": "mobile",
  "title": "SwiftUI Development",
  "description": "Modern SwiftUI development practices with clean architecture and MVVM pattern",
  "recommended_globs": ["**/*.swift", "**/Package.swift", "**/*.xcodeproj/**/*"],
  "content": [
    "# SwiftUI Development",
    "",
    "// Description: Modern SwiftUI development practices with clean architecture and MVVM pattern",
    "// Recommended Globs: **/*.swift, **/Package.swift, **/*.xcodeproj/**/*",
    "",
    "## Project Structure",
    "```",
    "ProjectName/",
    "├── Sources/",
    "│   ├── App/",
    "│   │   ├── AppDelegate.swift",
    "│   │   └── SceneDelegate.swift",
    "│   ├── Views/",
    "│   │   ├── Home/",
    "│   │   │   ├── HomeView.swift",
    "│   │   │   └── HomeViewModel.swift",
    "│   │   └── Profile/",
    "│   │       ├── ProfileView.swift",
    "│   │       └── ProfileViewModel.swift",
    "│   ├── Shared/",
    "│   │   ├── Components/",
    "│   │   │   └── CustomButton.swift",
    "│   │   └── Modifiers/",
    "│   │       └── CardModifier.swift",
    "│   ├── Models/",
    "│   │   └── User.swift",
    "│   ├── Services/",
    "│   │   ├── Network/",
    "│   │   │   └── APIClient.swift",
    "│   │   └── Persistence/",
    "│   │       └── DataStore.swift",
    "│   └── Utilities/",
    "│       ├── Extensions/",
    "│       └── Constants.swift",
    "├── Resources/",
    "│   ├── Assets.xcassets/",
    "│   ├── Localization/",
    "│   └── Fonts/",
    "└── Tests/",
    "    ├── UnitTests/",
    "    └── UITests/",
    "```",
    "",
    "## View Structure",
    "```swift",
    "struct ContentView: View {",
    "    @StateObject private var viewModel = ContentViewModel()",
    "    @Environment(\\.colorScheme) var colorScheme",
    "",
    "    var body: some View {",
    "        NavigationStack {",
    "            List(viewModel.items) { item in",
    "                ItemRow(item: item)",
    "                    .swipeActions {",
    "                        Button(role: .destructive) {",
    "                            viewModel.delete(item)",
    "                        } label: {",
    "                            Label(\"Delete\", systemImage: \"trash\")",
    "                        }",
    "                    }",
    "            }",
    "            .navigationTitle(\"Items\")",
    "            .toolbar {",
    "                ToolbarItem(placement: .topBarTrailing) {",
    "                    Button(action: viewModel.addItem) {",
    "                        Image(systemName: \"plus\")",
    "                    }",
    "                }",
    "            }",
    "        }",
    "    }",
    "}",
    "",
    "struct ItemRow: View {",
    "    let item: Item",
    "",
    "    var body: some View {",
    "        HStack {",
    "            Text(item.title)",
    "                .font(.headline)",
    "            Spacer()",
    "            Image(systemName: \"chevron.right\")",
    "                .foregroundStyle(.secondary)",
    "        }",
    "        .padding(.vertical, 8)",
    "    }",
    "}",
    "```",
    "",
    "## ViewModel Pattern",
    "```swift",
    "@MainActor",
    "final class ContentViewModel: ObservableObject {",
    "    @Published private(set) var items: [Item] = []",
    "    @Published private(set) var isLoading = false",
    "    private let service: ItemService",
    "",
    "    init(service: ItemService = ItemService()) {",
    "        self.service = service",
    "    }",
    "",
    "    func loadItems() async {",
    "        isLoading = true",
    "        defer { isLoading = false }",
    "",
    "        do {",
    "            items = try await service.fetchItems()",
    "        } catch {",
    "            print(\"Error: \\(error)\")",
    "        }",
    "    }",
    "}",
    "```",
    "",
    "## Modern Layout",
    "```swift",
    "struct GridLayout: View {",
    "    let items: [GridItem]",
    "",
    "    private let columns = [",
    "        GridItem(.adaptive(minimum: 150), spacing: 16)",
    "    ]",
    "",
    "    var body: some View {",
    "        ScrollView {",
    "            LazyVGrid(columns: columns, spacing: 16) {",
    "                ForEach(items) { item in",
    "                    CardView(item: item)",
    "                        .aspectRatio(1, contentMode: .fit)",
    "                }",
    "            }",
    "            .padding()",
    "        }",
    "    }",
    "}",
    "",
    "struct CardView: View {",
    "    let item: GridItem",
    "",
    "    var body: some View {",
    "        VStack {",
    "            AsyncImage(url: item.imageURL) { image in",
    "                image",
    "                    .resizable()",
    "                    .aspectRatio(contentMode: .fill)",
    "            } placeholder: {",
    "                ProgressView()",
    "            }",
    "            .frame(height: 120)",
    "            .clipShape(RoundedRectangle(cornerRadius: 8))",
    "",
    "            Text(item.title)",
    "                .font(.headline)",
    "                .lineLimit(2)",
    "        }",
    "        .padding(8)",
    "        .background(.background)",
    "        .clipShape(RoundedRectangle(cornerRadius: 12))",
    "        .shadow(radius: 2)",
    "    }",
    "}",
    "```",
    "",
    "## Navigation and Routing",
    "```swift",
    "@Observable",
    "final class Router {",
    "    var path = NavigationPath()",
    "    ",
    "    func navigate(to destination: Destination) {",
    "        path.append(destination)",
    "    }",
    "    ",
    "    func navigateBack() {",
    "        path.removeLast()",
    "    }",
    "    ",
    "    func navigateToRoot() {",
    "        path.removeLast(path.count)",
    "    }",
    "}",
    "",
    "struct RootView: View {",
    "    @State private var router = Router()",
    "    ",
    "    var body: some View {",
    "        NavigationStack(path: $router.path) {",
    "            HomeView()",
    "                .navigationDestination(for: Destination.self) { destination in",
    "                    switch destination {",
    "                    case .detail(let item):",
    "                        DetailView(item: item)",
    "                    case .settings:",
    "                        SettingsView()",
    "                    }",
    "                }",
    "        }",
    "        .environment(\\.router, router)",
    "    }",
    "}",
    "```",
    "",
    "## Animations and Transitions",
    "```swift",
    "struct AnimatedButton: View {",
    "    @State private var isPressed = false",
    "",
    "    var body: some View {",
    "        Button {",
    "            withAnimation(.spring) {",
    "                isPressed.toggle()",
    "            }",
    "        } label: {",
    "            Image(systemName: \"heart.fill\")",
    "                .font(.title)",
    "                .foregroundStyle(isPressed ? .red : .gray)",
    "                .scaleEffect(isPressed ? 1.3 : 1.0)",
    "        }",
    "        .buttonStyle(.plain)",
    "    }",
    "}",
    "",
    "struct TransitionView: View {",
    "    @State private var show = false",
    "",
    "    var body: some View {",
    "        VStack {",
    "            if show {",
    "                Text(\"Welcome!\")",
    "                    .transition(.move(edge: .top).combined(with: .opacity))",
    "            }",
    "        }",
    "        .animation(.spring, value: show)",
    "    }",
    "}",
    "```",
    "",
    "## Best Practices",
    "",
    "### View Organization",
    "- Keep views small and focused",
    "- Extract reusable components",
    "- Use ViewBuilder for complex layouts",
    "- Implement proper view modifiers",
    "",
    "### State Management",
    "- Use @State for local view state",
    "- Use @StateObject for view model instances",
    "- Use @Observable for shared state",
    "- Implement proper data flow",
    "",
    "### Performance",
    "- Use LazyVStack/LazyHGrid for large lists",
    "- Implement proper image caching",
    "- Optimize view updates",
    "- Use background tasks for heavy operations",
    "",
    "### Accessibility",
    "- Add proper VoiceOver labels",
    "- Support Dynamic Type",
    "- Implement proper color contrast",
    "- Add proper accessibility traits",
    "",
    "## Resources",
    "- [SwiftUI Documentation](https://developer.apple.com/documentation/swiftui)",
    "- [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines)",
    "- [Swift Package Manager](https://www.swift.org/package-manager)",
    "- [Swift Concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency)"
  ]
}
