スキル一覧に戻る
fusengine

swiftui-navigation

by fusengine

Redefining development through cognitive automation and collaborative agent systems.

0🍴 0📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


SwiftUI Navigation

// Type-safe routing with enum
enum AppRoute: Hashable, Codable {
    case home
    case profile(userId: String)
    case settings
    case detail(item: Item)
}

struct ContentView: View {
    @State private var path = NavigationPath()

    var body: some View {
        NavigationStack(path: $path) {
            HomeView()
                .navigationDestination(for: AppRoute.self) { route in
                    destinationView(for: route)
                }
        }
    }

    @ViewBuilder
    private func destinationView(for route: AppRoute) -> some View {
        switch route {
        case .home: HomeView()
        case .profile(let id): ProfileView(userId: id)
        case .settings: SettingsView()
        case .detail(let item): DetailView(item: item)
        }
    }

    // Programmatic navigation
    func navigateTo(_ route: AppRoute) {
        path.append(route)
    }

    func popToRoot() {
        path.removeLast(path.count)
    }
}

Deep Linking

struct ContentView: View {
    @State private var path = NavigationPath()

    var body: some View {
        NavigationStack(path: $path)
            .onOpenURL { url in
                handleDeepLink(url)
            }
    }

    private func handleDeepLink(_ url: URL) {
        guard let routes = DeepLinkParser.parse(url) else { return }
        path = NavigationPath()
        for route in routes {
            path.append(route)
        }
    }
}

struct DeepLinkParser {
    static func parse(_ url: URL) -> [AppRoute]? {
        guard url.scheme == "myapp" else { return nil }

        switch url.host {
        case "profile":
            let id = url.pathComponents.dropFirst().first ?? ""
            return [.profile(userId: id)]
        case "settings":
            return [.settings]
        default:
            return nil
        }
    }
}
struct MainView: View {
    @State private var selectedItem: Item?
    @State private var visibility = NavigationSplitViewVisibility.all

    var body: some View {
        NavigationSplitView(columnVisibility: $visibility) {
            // Sidebar
            List(items, selection: $selectedItem) { item in
                NavigationLink(value: item) {
                    Label(item.name, systemImage: item.icon)
                }
            }
            .navigationTitle("Items")
        } detail: {
            // Detail
            if let item = selectedItem {
                ItemDetailView(item: item)
            } else {
                ContentUnavailableView("Select an item",
                    systemImage: "sidebar.left")
            }
        }
    }
}

TabView

struct MainTabView: View {
    @State private var selectedTab = 0

    var body: some View {
        TabView(selection: $selectedTab) {
            HomeView()
                .tabItem { Label("Home", systemImage: "house") }
                .tag(0)

            SearchView()
                .tabItem { Label("Search", systemImage: "magnifyingglass") }
                .tag(1)

            ProfileView()
                .tabItem { Label("Profile", systemImage: "person") }
                .tag(2)
        }
    }
}

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です