import SwiftUI

struct SettingsView: View {
    @EnvironmentObject var state: AppState

    var body: some View {
        TabView {
            GeneralSettings()
                .tabItem {
                    Label("通用", systemImage: "gear")
                }
            AboutView()
                .tabItem {
                    Label("关于", systemImage: "info.circle")
                }
        }
        .frame(width: 400, height: 200)
    }
}

struct GeneralSettings: View {
    var body: some View {
        Form {
            Section("API 地址") {
                LabeledContent("记忆中心") {
                    Text("localhost:3202").foregroundStyle(.secondary)
                }
                LabeledContent("端口注册") {
                    Text("localhost:3201").foregroundStyle(.secondary)
                }
                LabeledContent("ASR 状态") {
                    Text("localhost:4125").foregroundStyle(.secondary)
                }
            }
            Section("刷新") {
                LabeledContent("自动刷新") {
                    Text("每 30 秒").foregroundStyle(.secondary)
                }
            }
        }
        .padding()
    }
}

struct AboutView: View {
    var body: some View {
        VStack(spacing: 12) {
            Image(systemName: "tray.full.fill")
                .font(.system(size: 48))
                .foregroundStyle(.blue)
            Text("项目管家")
                .font(.title2.bold())
            Text("macOS 菜单栏应用\n统管项目记忆 / 端口 / ASR 进度")
                .font(.caption)
                .foregroundStyle(.secondary)
                .multilineTextAlignment(.center)
            Text("v1.0 · 2026")
                .font(.caption2)
                .foregroundStyle(.tertiary)
        }
        .padding()
    }
}
