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.

Show Orphaned Files' doubt as a symbol with secondary words

Țugui Dragoș8e3c86d876fb
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index f34d5628..0005bcbf 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -162,12 +162,12 @@ private struct BackgroundItemRow: View {
.lineLimit(1)
.truncationMode(.middle)
if item.isUnreadable {
- WarningLabel(title: Text("macOS can’t load this file"))
+ StatusLabel(title: Text("macOS can’t load this file"))
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
} else if item.isOrphan {
- WarningLabel(title: Text("Nothing left to run"))
+ StatusLabel(title: Text("Nothing left to run"))
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
@@ -184,7 +184,7 @@ private struct BackgroundItemRow: View {
.lineLimit(1)
}
if item.unusualCommand != nil {
- WarningLabel(title: Text("Unusual command"))
+ StatusLabel(title: Text("Unusual command"))
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index deffa962..accc8786 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -159,9 +159,17 @@ private struct OrphanGroupRow: View {
}
// Shows why Peel thinks nothing uses these files, not a date the user would have to interpret. It is
// shown whole, since the app's name can come last.
- group.confidence.summary
- .font(.caption)
- .rowTint(group.confidence.tint)
+ Group {
+ if let tint = group.confidence.tint {
+ StatusLabel(
+ title: group.confidence.summary, systemImage: group.confidence.systemImage, tint: tint
+ )
+ } else {
+ group.confidence.summary
+ }
+ }
+ .font(.caption)
+ .foregroundStyle(.secondary)
}
Spacer(minLength: 6)
Text(group.movable.text)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index d95f584f..bb8ce4db 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -322,8 +322,8 @@ extension OrphanConfidence {
}
/// Orange only when Peel is unsure. Being sure is the usual case here and needs no color.
- var tint: Color {
- level == .unsure ? .orange : .secondary
+ var tint: Color? {
+ level == .unsure ? .orange : nil
}
var systemImage: String {
diff --git a/Peel/Views/Settings/AppFoldersSection.swift b/Peel/Views/Settings/AppFoldersSection.swift
index b7c7a0fc..ed827c19 100644
--- a/Peel/Views/Settings/AppFoldersSection.swift
+++ b/Peel/Views/Settings/AppFoldersSection.swift
@@ -35,13 +35,13 @@ struct AppFoldersSection: View {
.foregroundStyle(.secondary)
} else {
HStack {
- WarningLabel(title: Text("Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one."))
+ StatusLabel(title: Text("Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one."))
Spacer()
Button("Start Over") { library.startFoldersOver() }
}
}
if library.couldNotSaveFolders {
- WarningLabel(title: Text("Peel couldn’t save the app folders."))
+ StatusLabel(title: Text("Peel couldn’t save the app folders."))
}
HStack {
Button("Add Folder…", systemImage: "plus") {
diff --git a/Peel/Views/Settings/HomebrewSection.swift b/Peel/Views/Settings/HomebrewSection.swift
index ff5fec22..089466b5 100644
--- a/Peel/Views/Settings/HomebrewSection.swift
+++ b/Peel/Views/Settings/HomebrewSection.swift
@@ -22,7 +22,7 @@ struct HomebrewSection: View {
Text(verbatim: "brew")
}
if couldNotSave {
- WarningLabel(title: Text("Peel couldn’t save which `brew` to run."))
+ StatusLabel(title: Text("Peel couldn’t save which `brew` to run."))
}
HStack {
Button("Choose…") { isChoosing = true }
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index 4077e051..3c8b2ade 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -284,7 +284,7 @@ private struct GeneralSettingsView: View {
"When you move an app to the Trash yourself, Peel offers to remove the files it left behind. Peel watches the Trash while it is open, or while it is in the menu bar.")
if watchesTrash, trashMonitor.status == .needsFullDiskAccess {
HStack {
- WarningLabel(title: Text("Peel needs Full Disk Access to watch the Trash."), systemImage: "lock.trianglebadge.exclamationmark")
+ StatusLabel(title: Text("Peel needs Full Disk Access to watch the Trash."), systemImage: "lock.trianglebadge.exclamationmark")
Spacer()
// Goes through `HomeModel`, so Home offers "Reopen Peel" afterward: Full Disk Access
// applies only to a process started after it is granted.
@@ -293,7 +293,7 @@ private struct GeneralSettingsView: View {
}
}
} else if watchesTrash, trashMonitor.status == .unavailable {
- WarningLabel(title: Text("Peel isn’t watching the Trash right now. It tries again each time you come back to Peel."))
+ StatusLabel(title: Text("Peel isn’t watching the Trash right now. It tries again each time you come back to Peel."))
}
toggle("Warn when the disk is almost full", isOn: $warnsWhenDiskIsNearlyFull,
"When less than a tenth of the disk your home folder is on is available, Peel sends a notification that opens Space. It checks only while it is running.")
@@ -303,7 +303,7 @@ private struct GeneralSettingsView: View {
"Starts Peel when you log in. “Watch the Trash” works only while Peel is running.")
if needsApprovalToOpenAtLogin {
HStack {
- WarningLabel(title: Text("Peel is turned off in Login Items & Extensions, so macOS won’t start it."))
+ StatusLabel(title: Text("Peel is turned off in Login Items & Extensions, so macOS won’t start it."))
Spacer()
Button("Open System Settings") {
SMAppService.openSystemSettingsLoginItems()
@@ -311,7 +311,7 @@ private struct GeneralSettingsView: View {
}
}
if let loginItemFailure {
- WarningLabel(title: Text(loginItemFailure))
+ StatusLabel(title: Text(loginItemFailure))
.textSelection(.enabled)
}
}
diff --git a/Peel/Views/StatusLabel.swift b/Peel/Views/StatusLabel.swift
new file mode 100644
index 00000000..fd76fe85
--- /dev/null
+++ b/Peel/Views/StatusLabel.swift
@@ -0,0 +1,18 @@
+import SwiftUI
+
+/// A warning or a state beside a setting or under a row. The symbol takes the color and the words keep the text's
+/// own: a colored word reads under 4.5:1 on a light background, orange at about 2.3.
+struct StatusLabel: View {
+ let title: Text
+ var systemImage = "exclamationmark.triangle"
+ var tint: Color = .orange
+
+ var body: some View {
+ Label {
+ title
+ } icon: {
+ Image(systemName: systemImage)
+ .rowTint(tint)
+ }
+ }
+}
diff --git a/Peel/Views/WarningLabel.swift b/Peel/Views/WarningLabel.swift
deleted file mode 100644
index 04eb4ca5..00000000
--- a/Peel/Views/WarningLabel.swift
+++ /dev/null
@@ -1,17 +0,0 @@
-import SwiftUI
-
-/// A warning beside a setting or under a row. The symbol takes the warning's color and the words keep the text's
-/// own: orange words read at about 2.3 to 1 on a light background, under the 4.5 to 1 text needs.
-struct WarningLabel: View {
- let title: Text
- var systemImage = "exclamationmark.triangle"
-
- var body: some View {
- Label {
- title
- } icon: {
- Image(systemName: systemImage)
- .foregroundStyle(.orange)
- }
- }
-}