fenilsonani / menu-browser / Sources/ HelpView.swift

import SwiftUI

struct HelpView: View {
    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 24) {
                helpSection(
                    icon: "rocket",
                    title: "Getting Started",
                    items: [
                        "MenuBrowser lives in your menu bar \u{2014} click the icon or press \u{2318}\u{21E7}B",
                        "Click any browser to make it your default (where URLs go when no rule matches)",
                        "Set MenuBrowser as your system default browser so URLs flow through it"
                    ]
                )

                helpSection(
                    icon: "link",
                    title: "URL Rules",
                    items: [
                        "Add rules in Preferences to route specific domains to a browser",
                        "Domain rules: \"github.com\" matches github.com and all subdomains",
                        "Path rules: \"github.com/work\" only matches that path prefix",
                        "More specific rules (longer patterns) take priority",
                        "Toggle rules on/off with the green dot without deleting them"
                    ]
                )

                helpSection(
                    icon: "keyboard",
                    title: "Keyboard Shortcuts",
                    items: [
                        "\u{2318}\u{21E7}B \u{2014} Open browser menu (customizable in Preferences)",
                        "\u{2318}1 through \u{2318}9 \u{2014} Set the default browser by position",
                        "Type in the search field to filter browsers instantly"
                    ]
                )

                helpSection(
                    icon: "person.2",
                    title: "Browser Profiles",
                    items: [
                        "Chrome, Edge, and Brave profiles are auto-detected",
                        "When adding a URL rule, pick a specific profile to target",
                        "URLs matching that rule open directly in the right profile"
                    ]
                )

                helpSection(
                    icon: "eye.slash",
                    title: "Private Browsing",
                    items: [
                        "Copy a URL to your clipboard, then open the menu",
                        "Choose \"Open Private in...\" to open in an incognito window",
                        "Supports Chrome (--incognito) and Firefox (--private-window)"
                    ]
                )

                helpSection(
                    icon: "wrench",
                    title: "Troubleshooting",
                    items: [
                        "URLs not routing? Make sure MenuBrowser is set as your default browser",
                        "If browsers aren't detected, try quitting and reopening MenuBrowser"
                    ]
                )

                Divider()

                HStack(spacing: 16) {
                    Button("View on GitHub") {
                        NSWorkspace.shared.open(URL(string: "https://github.com/fenilsonani/menu-browser")!)
                    }
                    Button("Report an Issue") {
                        NSWorkspace.shared.open(URL(string: "https://github.com/fenilsonani/menu-browser/issues/new")!)
                    }
                }
                .font(.system(size: 12))

                let v = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0"
                Text("MenuBrowser v\(v) \u{2014} Made by Fenil Sonani")
                    .font(.system(size: 11))
                    .foregroundStyle(.tertiary)
            }
            .padding(28)
        }
        .frame(width: 480, height: 500)
    }

    private func helpSection(icon: String, title: String, items: [String]) -> some View {
        VStack(alignment: .leading, spacing: 8) {
            HStack(spacing: 8) {
                Image(systemName: icon)
                    .font(.system(size: 14, weight: .semibold))
                    .foregroundColor(.accentColor)
                    .frame(width: 20)
                Text(title)
                    .font(.system(size: 15, weight: .semibold))
            }

            VStack(alignment: .leading, spacing: 5) {
                ForEach(items, id: \.self) { item in
                    HStack(alignment: .top, spacing: 8) {
                        Text("\u{2022}")
                            .foregroundStyle(.tertiary)
                        Text(item)
                            .font(.system(size: 12.5))
                            .foregroundStyle(.secondary)
                            .fixedSize(horizontal: false, vertical: true)
                    }
                }
            }
            .padding(.leading, 28)
        }
    }
}