Cotton code
97 lines · 3.9 KB · SwiftRaw
import CottonKitimport SwiftUIstruct AboutInfo {    struct Link: Identifiable {        let id: String        let label: String        let route: Route    }    let build: BuildFacts    /// Tools' foot opens About and names no build: the build is said in one    /// form only, on the Databases foot (`BuildLine.own`, architect, 16 Oct 2026).    var footer: String { ShellLines.line("legal", "about.footer") }    /// The Build line: the build number, and — on a build that is not the    /// release — the commit it was built from (`BuildFacts.buildShown`).    var buildLine: String { build.buildShown }    static var links: [Link] { [        Link(id: "whats-new", label: ShellLines.line("legal", "about.whats_new"), route: .aboutWhatsNew),        Link(id: "help", label: ShellLines.line("legal", "about.help"), route: .aboutHelp),        Link(id: "privacy", label: ShellLines.line("legal", "privacy_title"), route: .legalPrivacy),        Link(id: "terms", label: ShellLines.line("legal", "terms_title"), route: .legalTerms),        Link(id: "report", label: ShellLines.line("legal", "about.report"), route: .tableList(table: "project_feedback", filter: nil, title: nil, query: nil)),    ] }    static func hasFooter(_ definition: TableDefinition) -> Bool {        definition.role == .tools    }}struct ToolsAboutFooter: View {    @Environment(Navigator.self) private var navigator    private let info = AboutInfo(build: .fromBundle())    var body: some View {        Button { navigator.push(.about) } label: {            Text(info.footer).paperMeta(13)                .frame(maxWidth: .infinity, minHeight: 44, alignment: .leading)                .contentShape(Rectangle())        }        .buttonStyle(OpacityButtonStyle())        .accessibilityIdentifier("tools-about")    }}struct AboutScreen: View {    @Environment(Navigator.self) private var navigator    private let info = AboutInfo(build: .fromBundle())    var body: some View {        PaperScreen(title: ShellLines.line("legal", "about.title")) {            VStack(alignment: .leading, spacing: 18) {                HStack {                    Text(ShellLines.line("legal", "about.version")).paperBody(16, ink: .pencil)                    Spacer()                    Text(info.build.version).paperBody(16)                }                HStack {                    Text(ShellLines.line("legal", "about.build")).paperBody(16, ink: .pencil)                    Spacer()                    Text(info.buildLine).paperBody(16)                }                if let attribution = BundledLicence.contents(of: "GeoNames") {                    Text(attribution).paperBody(14, ink: .pencil)                }                ForEach(AboutInfo.links) { link in                    Button { navigator.push(link.route) } label: {                        HStack {                            Text(link.label).paperBody(16)                            Spacer()                            Text("›").paperBody(16, ink: .pencil)                        }                        .frame(minHeight: 44)                        .contentShape(Rectangle())                    }                    .buttonStyle(OpacityButtonStyle())                    .accessibilityIdentifier("about-\(link.id)")                }            }        }        .accessibilityIdentifier("about-page")    }}struct AboutWhatsNewScreen: View {    var body: some View {        PaperScreen(title: ShellLines.line("legal", "about.whats_new")) {            VStack(alignment: .leading, spacing: 18) {                Text(ShellLines.line("legal", "about.new.storage")).paperBody(16)            }        }        .accessibilityIdentifier("about-whats-new")    }}struct AboutHelpScreen: View {    var body: some View {        PaperScreen(title: ShellLines.line("legal", "about.help")) { EmptyView() }            .accessibilityIdentifier("about-help")    }}