import SwiftUI
import IndieAbout

/// The About section (indie-about skill). Presented as a sheet from `BoardsTabView`'s gear
/// button, so it carries its own navigation stack and a Done button to dismiss itself.
struct SettingsScreen: View {
    @Environment(BoardIndexStore.self) private var index
    @Environment(\.dismiss) private var dismiss

    var body: some View {
        NavigationStack {
            Form {
                // Same voice as the Mac app's `AboutBox.configuration`; the changelog itself is
                // the phone app's own (see project.yml — separate product, separate 1.0).
                Section {
                    IndieAbout(configuration: .init(
                        copyrightText: "© 2026 rzen",
                        documents: [.license(extension: "md")],
                        changelogDocument: .changelog()
                    ))
                }
            }
            .navigationTitle("Settings")
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button("Done") { dismiss() }
                }
            }
        }
        // Idempotent (BoardIndexStore.start()), and harmless if BoardsTabView already called it —
        // defensive only, since the boards screen is always what starts the index now.
        .task { index.start() }
    }
}
