SPB Git

Repository Public License

SettingsView.swift 5.6 KB 86 lines swift

1// ORIX Clean — App/Sources/Features/Settings/SettingsView.swift2// Description: Settings: appearance, density, map palette, size accounting, permissions, privacy and stored history.3// Author: Simon-Pierre Boucher — contact@spboucher.ai4import ORIXCleanCore5import SwiftUI67struct SettingsView: View {8    @Environment(AppModel.self) private var model9    @AppStorage("appearance") private var appearance = "system"10    @AppStorage("density") private var density = Density.comfortable.rawValue11    @AppStorage("mapPalette") private var palette = MapPalette.orix.rawValue12    @AppStorage("sizeKind") private var sizeKind = SizeKind.allocated.rawValue13    @AppStorage("showPackageContents") private var showPackages = false14    @State private var confirmErase = false1516    var body: some View {17        TabView {18            Form {19                Picker(L("Appearance"), selection: $appearance) {20                    Text(L("Match System")).tag("system"); Text(L("Light")).tag("light"); Text(L("Dark")).tag("dark")21                }22                Picker(L("List density"), selection: $density) { ForEach(Density.allCases) { Text($0.title).tag($0.rawValue) } }23                Picker(L("Storage map colours"), selection: $palette) { ForEach(MapPalette.allCases) { Text($0.title).tag($0.rawValue) } }24                Picker(L("Sizes in the storage map"), selection: $sizeKind) {25                    Text(L("Size on disk (allocated blocks)")).tag(SizeKind.allocated.rawValue)26                    Text(L("Content size (file length)")).tag(SizeKind.logical.rawValue)27                }28                Toggle(L("Open applications and other packages in the storage map"), isOn: $showPackages)29                Text(L("The language follows macOS (English and Canadian French). Motion follows “Reduce motion” in System Settings > Accessibility."))30                    .font(.caption).foregroundStyle(ORIX.Palette.textSecondary)31            }32            .formStyle(.grouped)33            .tabItem { Label(L("General"), systemImage: "gearshape") }3435            Form {36                Section(L("Access")) {37                    LabeledContent(L("Full Disk Access")) {38                        HStack {39                            Label(model.fullDiskAccess ? L("Granted") : L("Not granted"), systemImage: model.fullDiskAccess ? "checkmark.circle.fill" : "minus.circle")40                                .foregroundStyle(model.fullDiskAccess ? ORIX.Palette.low : ORIX.Palette.textSecondary)41                            Button(L("Open Settings")) { NSWorkspace.shared.open(Permissions.fullDiskAccessSettingsURL) }42                            Button(L("Check Again")) { model.refreshEnvironment() }43                        }44                    }45                    Text(L("Optional. Without it ORIX Clean still works on everything macOS lets it read, and tells you what was not read. With it, protected folders (Mail, Safari data, the Trash, other apps' containers) are included. It never gives access to system files protected by System Integrity Protection, and ORIX Clean never asks for an administrator password."))46                        .font(.caption).foregroundStyle(ORIX.Palette.textSecondary)47                }48                Section(L("Privacy")) {49                    Text(L("ORIX Clean has no account, no network code, no analytics and no advertising. Scan results stay in memory; only volume samples, watched-folder sizes, cleanup logs and your saved actions are stored, in a local database."))50                        .font(.callout)51                    LabeledContent(L("Local database")) {52                        HStack {53                            Text(HistoryStore.defaultPath().abbreviatingHome).font(.caption.monospaced()).textSelection(.enabled).lineLimit(1).truncationMode(.middle)54                            Button(L("Reveal")) { NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: HistoryStore.defaultPath())]) }55                        }56                    }57                    Button(L("Erase History…"), role: .destructive) { confirmErase = true }58                        .confirmationDialog(L("Erase all recorded samples and cleanup logs?"), isPresented: $confirmErase) {59                            Button(L("Erase"), role: .destructive) {60                                model.store?.eraseAll()61                                model.operations = []; model.samples = []; model.folderSamples = [:]62                                model.refreshEnvironment()63                            }64                        } message: { Text(L("Your files are not affected. This cannot be undone.")) }65                }66            }67            .formStyle(.grouped)68            .tabItem { Label(L("Privacy & Access"), systemImage: "lock.shield") }6970            Form {71                LabeledContent(L("Version"), value: model.appVersion)72                LabeledContent(L("Updates"), value: L("Manual: download new versions from the release page."))73                Text(L("ORIX Clean does not check for updates on its own because it never connects to the network."))74                    .font(.caption).foregroundStyle(ORIX.Palette.textSecondary)75                LabeledContent(L("Safety rules")) {76                    Text(L("Removal always goes through the preview. System folders, standard folders themselves, application internals and photo-library internals are refused by the deletion engine regardless of what asks."))77                        .font(.caption).foregroundStyle(ORIX.Palette.textSecondary).frame(maxWidth: 380, alignment: .leading)78                }79            }80            .formStyle(.grouped)81            .tabItem { Label(L("About"), systemImage: "info.circle") }82        }83        .frame(width: 640, height: 430)84    }85}86
Files main
Menu

Theme