Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
import AppKit
import PeelCore
import SwiftUI
struct PluginDetailView: View {
@Environment(PluginLibrary.self) private var plugins
@Environment(HelperModel.self) private var helper
@Environment(RemovalHistoryStore.self) private var history
@State private var isConfirmingRemoval = false
@Environment(RemovalOutcome.self) private var outcome
let plugin: Plugin
var body: some View {
Form {
Section {
HStack(spacing: 18) {
AppIcon(url: plugin.url)
.frame(width: 56, height: 56)
VStack(alignment: .leading, spacing: 6) {
Text(verbatim: plugin.name)
.pageTitle()
.help(Text(verbatim: plugin.name))
FlowLayout(spacing: 6) {
Badge(title: Text(plugin.category.title), systemImage: "powerplug")
if plugin.isInstalledForAllUsers {
NoteBadge(
title: Text("All users"), systemImage: "person.2",
name: String(localized: "All users"),
detail: Text("It’s in /Library, so every account on this Mac has it.")
)
}
}
}
Spacer(minLength: 0)
}
.padding(.vertical, 4)
}
Section {
if let identifier = plugin.bundleIdentifier {
LabeledContent("Identifier") {
Text(verbatim: identifier)
.textSelection(.enabled)
.help(Text(verbatim: identifier))
}
.labeledContentStyle(.oneLine)
}
if let origin = plugin.origin {
LabeledContent("Installed with") {
switch origin {
case .installedApp(let name): Text(verbatim: name)
case .goneApp(let name): Text("\(name), no longer on this Mac")
}
}
}
if let version = plugin.version {
LabeledContent("Version") {
Text(verbatim: version)
}
}
LabeledContent("Size") {
Text(plugin.size.byteCount)
.monospacedDigit()
}
LabeledContent("Location") {
Text(verbatim: plugin.url.abbreviatedPath)
.textSelection(.enabled)
.help(Text(verbatim: plugin.url.fullPath))
ShowInFinderButton(url: plugin.url)
}
.labeledContentStyle(.oneLine)
}
if isLocked {
Section {
HelperRequiredBanner(need: .moving(1))
}
}
Section {
RemovalsHeldBanner()
if let refusal = plugin.refusal {
Text(refusal.explanation)
.font(.callout)
.foregroundStyle(.secondary)
}
}
PageActions {
BusyShown(isBusy: plugins.isRemoving) { isShown in
if isShown {
ProgressView()
.controlSize(.small)
}
}
Button("Move to Trash") {
isConfirmingRemoval = true
}
.buttonStyle(.borderedProminent)
.disabled(
isLocked || plugin.refusal != nil || plugins.isRemoving || plugins.isScanning
|| !history.mayMove
)
}
}
.formStyle(.grouped)
.dimmedWhileBusy(plugins.isScanning)
.navigationTitle(plugin.name)
.toolbar(removing: .title)
.confirmationDialog(
Text.movingToTrash(plugin.name, SizeTotal([plugin.size])),
isPresented: $isConfirmingRemoval
) {
Button("Move to Trash") {
Task {
let sizes = [URL: Int64](measured: [(plugin.url, plugin.size)])
let result = await history.moving(tool: .plugins, source: plugin.name, sizes: sizes) {
await plugins.moveToTrash(plugin) { result in
await history.record(result, tool: .plugins, source: plugin.name, sizes: sizes)
}
}
outcome.report(result)
if !result.trashed.isEmpty {
await plugins.refresh()
}
}
}
Button("Cancel", role: .cancel) {}
} message: {
Text(verbatim: plugin.whenMoved.map { String(localized: $0) }.joined(separator: "\n\n"))
}
}
private var isLocked: Bool {
plugin.requiresPrivileges && plugin.refusal == nil && !helper.canAct
}
}
extension Plugin {
/// What the question before a move says, a paragraph each.
var whenMoved: [LocalizedStringResource] {
let forAllUsers: [LocalizedStringResource] = isInstalledForAllUsers
? ["Every account on this Mac has it, so moving it takes it from all of them."] : []
return whatGoes + forAllUsers
}
private var whenItLoads: [LocalizedStringResource] {
if isWhereNothingLoadsIt {
return ["macOS loads plug-ins like this one only from /Library, so nothing loads this one and moving it changes nothing."]
}
return switch noLongerLoaded {
case .quickLookGenerator:
["macOS no longer loads Quick Look generators like this one, so moving it changes nothing."]
case .internetPlugIn:
["macOS and today’s browsers no longer load plug-ins like this one, so moving it changes nothing."]
case .contextualMenuItem:
["macOS no longer loads contextual menu items like this one, so moving it changes nothing."]
case nil where category == .cameraPlugIns:
[
"macOS loads plug-ins like this one only when legacy video device support has been restored in macOS Recovery. If it has, apps that use it may stop working.",
"System Settings > Privacy & Security > Camera shows a warning when that support has been restored.",
]
case nil:
[]
}
}
private var whatGoes: [LocalizedStringResource] {
if !whenItLoads.isEmpty {
return staysInTheTrash
? whenItLoads + ["History can’t put it back, since Peel’s helper puts back into that folder only what is root’s alone, but you can drag it back out in Finder."]
: whenItLoads
}
return switch (isAQuickAction, staysInTheTrash) {
case (true, true):
["It leaves the Services menu and Quick Actions, and it may be one someone made in Automator on this Mac. History can’t put it back, since code is loaded from its folder and it isn’t root’s alone, but you can drag it back out in Finder."]
case (true, false):
["It leaves the Services menu and Quick Actions, and it may be one someone made in Automator on this Mac."]
case (false, true):
if case .installedApp(let name) = origin {
["\(name) and other apps that use it may stop working. History can’t put it back, since code is loaded from its folder and it isn’t root’s alone, but you can drag it back out in Finder."]
} else {
["Apps that use it may stop working. History can’t put it back, since code is loaded from its folder and it isn’t root’s alone, but you can drag it back out in Finder."]
}
case (false, false):
if case .installedApp(let name) = origin {
["\(name) and other apps that use it may stop working."]
} else {
["Apps that use it may stop working."]
}
}
}
}