Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

2.6 KB
Raw Blame
import AppKit
import PeelCore
import SwiftUI

/// One file a search found: where it is and what Peel knows about moving it.
struct FileSearchFileView: View {
    let file: FoundFile

    var body: some View {
        Form {
            Section {
                HStack(alignment: .center, spacing: 18) {
                    AppIcon(url: file.url)
                        .frame(width: 64, height: 64)
                    Text(verbatim: file.url.lastPathComponent)
                        .pageTitle()
                        .help(Text(verbatim: file.url.lastPathComponent))
                    Spacer(minLength: 0)
                }
                .padding(.vertical, 8)
                .listRowSeparator(.hidden)
            }

            Section {
                LabeledContent("Where") {
                    Text(verbatim: file.url.abbreviatedPath)
                        .textSelection(.enabled)
                        .help(Text(verbatim: file.url.fullPath))
                    ShowInFinderButton(url: file.url)
                }
                .labeledContentStyle(.oneLine)
                LabeledContent("Size") {
                    Text(file.size.byteCount).monospacedDigit()
                }
                LabeledContent("Modified") {
                    Text(file.modificationDate, format: .relative(presentation: .named))
                }
                if file.requiresPrivileges {
                    Text("File Search moves only what your account can move. Use Finder for this one.")
                        .font(.callout)
                        .foregroundStyle(.secondary)
                }
                if file.belongsToAnApp {
                    Text("An app keeps this in its Library folder, and may be using it right now.")
                        .font(.callout)
                        .foregroundStyle(.secondary)
                }
                if let heldBack = file.heldBack {
                    Text(heldBack.explanation)
                        .font(.callout)
                        .foregroundStyle(.secondary)
                }
                if file.freesLessThanItsLength {
                    Text("Moving this frees less than its length of \(file.length.byteCount): another file shares its storage, or it takes less space than that.")
                        .font(.callout)
                        .foregroundStyle(.secondary)
                }
            } header: {
                Text("Details")
            }
        }
        .formStyle(.grouped)
        .navigationTitle(Text(verbatim: file.url.lastPathComponent))
        .toolbar(removing: .title)
    }
}