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
Tell apart the parts of one app that carry its name
Țugui Dragoșfcfd2ff09f4c
diff --git a/Peel/Views/Extensions/ExtensionList.swift b/Peel/Views/Extensions/ExtensionList.swiftindex aec9ce98..a7a829eb 100644--- a/Peel/Views/Extensions/ExtensionList.swift+++ b/Peel/Views/Extensions/ExtensionList.swift@@ -9,12 +9,7 @@ struct ExtensionList: View {private var listed: [AppExtension] {let all = extensions.extensions ?? []guard !searchText.isEmpty else { return all }- return all.filter {- SearchText.matches($0.name, searchText)- || $0.owner.map { owner in SearchText.matches(owner, searchText) } == true- || $0.point.map { point in SearchText.matches(point, searchText) } == true- || SearchText.matches($0.identifier, searchText)- }+ return all.filter { $0.matches(searchText) }}var body: some View {@@ -105,21 +100,15 @@ private struct ExtensionRow: View {let showsVersion: Boolvar body: some View {- ToolRow(systemImage: item.kind.systemImage) {+ ToolRow(systemImage: item.kind.systemImage, symbolName: item.kind.title) {Text(verbatim: item.name).lineLimit(1)} details: {if showsVersion, let version = item.shownVersion {Text("Version \(version)").lineLimit(1)- } else if item.goneApp != nil, let name = item.appName {- Text("\(name), no longer installed")- .lineLimit(1)- } else if let owner = item.owner {- Text(verbatim: owner)- .lineLimit(1)- } else if let point = item.pointName {- Text(verbatim: point)+ } else if let detail = item.rowDetail {+ Text(verbatim: detail).lineLimit(1)}} trailing: {diff --git a/Peel/Views/Extensions/ExtensionText.swift b/Peel/Views/Extensions/ExtensionText.swiftindex 9bd70858..59b7ed2e 100644--- a/Peel/Views/Extensions/ExtensionText.swift+++ b/Peel/Views/Extensions/ExtensionText.swift@@ -9,6 +9,20 @@ extension AppExtension {guard let point else { return nil }return ExtensionPoint(point).map { String(localized: $0.word) } ?? point}++ /// What a row says under the name: the app it came with, or what it plugs into when it carries the app's own+ /// name, so that the parts of one app named after it read apart.+ var rowDetail: String? {+ if goneApp != nil, let name = appName { return String(localized: "\(name), no longer installed") }+ guard let owner else { return pointName }+ guard let pointName, name.localizedCaseInsensitiveCompare(owner) == .orderedSame else { return owner }+ return pointName+ }++ /// Whether a search for `text` finds it, by what its row and page say as well as by its identifiers.+ func matches(_ text: String) -> Bool {+ [name, owner, pointName, point, identifier].contains { $0.map { SearchText.matches($0, text) } == true }+ }}/// An extension point Peel has a word for. Its identifiers come from Apple's App Extension Keys documentationdiff --git a/Peel/Views/ToolRow.swift b/Peel/Views/ToolRow.swiftindex d0eddfcd..46ee251c 100644--- a/Peel/Views/ToolRow.swift+++ b/Peel/Views/ToolRow.swift@@ -4,6 +4,8 @@ import SwiftUI/// mark at the trailing edge.struct ToolRow<Title: View, Details: View, Trailing: View>: View {let systemImage: String+ /// What VoiceOver says of the symbol when it tells something the row's words don't, such as an item's kind.+ var symbolName: LocalizedStringResource?@ViewBuilder let title: Title@ViewBuilder let details: Details@ViewBuilder let trailing: Trailing@@ -15,7 +17,8 @@ struct ToolRow<Title: View, Details: View, Trailing: View>: View {.foregroundStyle(.secondary).frame(width: 28, height: 28).background(.quaternary, in: .circle)- .accessibilityHidden(true)+ .accessibilityLabel(symbolName.map { Text($0) } ?? Text(verbatim: ""))+ .accessibilityHidden(symbolName == nil)VStack(alignment: .leading, spacing: 1) {titledetails@@ -30,8 +33,15 @@ struct ToolRow<Title: View, Details: View, Trailing: View>: View {}extension ToolRow where Trailing == EmptyView {- init(systemImage: String, @ViewBuilder title: () -> Title, @ViewBuilder details: () -> Details) {- self.init(systemImage: systemImage, title: title, details: details, trailing: { EmptyView() })+ init(+ systemImage: String,+ symbolName: LocalizedStringResource? = nil,+ @ViewBuilder title: () -> Title,+ @ViewBuilder details: () -> Details+ ) {+ self.init(+ systemImage: systemImage, symbolName: symbolName, title: title, details: details, trailing: { EmptyView() }+ )}}diff --git a/PeelTests/ExtensionTextTests.swift b/PeelTests/ExtensionTextTests.swiftnew file mode 100644index 00000000..e7f90cd2--- /dev/null+++ b/PeelTests/ExtensionTextTests.swift@@ -0,0 +1,34 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++struct ExtensionTextTests {+ private func part(name: String, owner: String?, point: String?) -> AppExtension {+ AppExtension(+ identifier: "org.example.app.part", name: name, kind: .appExtension, point: point, owner: owner,+ url: URL(filePath: "/Applications/Example.app/Contents/PlugIns/Part.appex"), election: .on,+ teamIdentifier: nil, reportedState: nil+ )+ }++ @Test func aRowNamedLikeItsAppSaysWhatItPlugsInto() throws {+ let widget = part(name: "Example", owner: "Example", point: "com.apple.widgetkit-extension")+ let share = part(name: "Example", owner: "Example", point: "com.apple.share-services")++ #expect(widget.rowDetail == widget.pointName)+ #expect(widget.rowDetail != share.rowDetail, "two parts of one app read apart")+ #expect(part(name: "Example Widget", owner: "Example", point: "com.apple.widgetkit-extension").rowDetail == "Example")+ #expect(part(name: "Example", owner: nil, point: "com.apple.FinderSync").rowDetail == part(+ name: "Example", owner: nil, point: "com.apple.FinderSync"+ ).pointName)+ }++ @Test func findsAPartByTheWordItsPageShows() throws {+ let widget = part(name: "Example", owner: "Example", point: "com.apple.widgetkit-extension")+ let word = try #require(widget.pointName)++ #expect(widget.matches(word))+ #expect(!part(name: "Example", owner: "Example", point: "com.apple.share-services").matches(word))+ }+}