Skip to content

Commit 7f1aaf4

Browse files
committed
v3.9.1
1 parent b4d676d commit 7f1aaf4

File tree

9 files changed

+258
-137
lines changed

9 files changed

+258
-137
lines changed

Pearcleaner.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@
537537
isa = XCBuildConfiguration;
538538
buildSettings = {
539539
ALWAYS_SEARCH_USER_PATHS = NO;
540-
APP_BUILD = 62;
541-
APP_VERSION = 3.9.0;
540+
APP_BUILD = 63;
541+
APP_VERSION = 3.9.1;
542542
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
543543
CLANG_ANALYZER_NONNULL = YES;
544544
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -607,8 +607,8 @@
607607
isa = XCBuildConfiguration;
608608
buildSettings = {
609609
ALWAYS_SEARCH_USER_PATHS = NO;
610-
APP_BUILD = 62;
611-
APP_VERSION = 3.9.0;
610+
APP_BUILD = 63;
611+
APP_VERSION = 3.9.1;
612612
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
613613
CLANG_ANALYZER_NONNULL = YES;
614614
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;

Pearcleaner/Logic/AppInfoFetch.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import AlinFoundation
1414
class MetadataAppInfoFetcher {
1515
static func getAppInfo(fromMetadata metadata: [String: Any], atPath path: URL) -> AppInfo? {
1616
// Extract metadata attributes for known fields
17-
let displayName = metadata["kMDItemDisplayName"] as? String ?? ""
17+
var displayName = metadata["kMDItemDisplayName"] as? String ?? ""
18+
displayName = displayName.replacingOccurrences(of: ".app", with: "").capitalizingFirstLetter()
1819
let fsName = metadata["kMDItemFSName"] as? String ?? path.lastPathComponent
1920
let appName = displayName.isEmpty ? fsName : displayName
2021

@@ -152,7 +153,7 @@ class AppInfoUtils {
152153
static func fetchAppIcon(for path: URL, wrapped: Bool, md: Bool = false) -> NSImage? {
153154
let iconPath = wrapped ? (md ? path : path.deletingLastPathComponent().deletingLastPathComponent()) : path
154155
if let appIcon = getIconForFileOrFolderNS(atPath: iconPath) {
155-
return convertICNSToPNG(icon: appIcon, size: NSSize(width: 100, height: 100))
156+
return convertICNSToPNG(icon: appIcon, size: NSSize(width: 50, height: 50))
156157
} else {
157158
printOS("App Icon not found for app at path: \(path)")
158159
return nil

Pearcleaner/Logic/AppState.swift

+15
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,21 @@ enum CurrentPage:Int, CaseIterable, Identifiable
208208
}
209209
}
210210

211+
enum SortOption:Int, CaseIterable, Identifiable {
212+
case alphabetical
213+
case size
214+
case creationDate
215+
case contentChangeDate
216+
case lastUsedDate
217+
218+
var id: Int { rawValue }
219+
220+
var title: String {
221+
let titles: [String] = ["App Name", "App Size", "Install Date", "Modified Date", "Last Used Date"]
222+
return titles[rawValue]
223+
}
224+
}
225+
211226

212227
enum CurrentTabView:Int
213228
{

Pearcleaner/Settings/About.swift

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ struct Sponsor: Identifiable {
186186
let url: URL
187187

188188
static let sponsors: [Sponsor] = [
189+
Sponsor(name: "mzdr (monthly)", url: URL(string: "https://github.com/mzdr")!),
189190
Sponsor(name: "chris3ware", url: URL(string: "https://github.com/chris3ware")!),
190191
Sponsor(name: "fpuhan", url: URL(string: "https://github.com/fpuhan")!),
191192
Sponsor(name: "HungThinhIT", url: URL(string: "https://github.com/HungThinhIT")!),

Pearcleaner/Settings/General.swift

+25-25
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct GeneralSettingsTab: View {
1919
@AppStorage("settings.general.brew") private var brew: Bool = false
2020
@AppStorage("settings.general.oneshot") private var oneShotMode: Bool = false
2121
@AppStorage("settings.general.confirmAlert") private var confirmAlert: Bool = false
22-
@AppStorage("settings.general.selectedSort") var selectedSortAlpha: Bool = true
22+
// @AppStorage("settings.general.selectedSort") var selectedSortAlpha: Bool = true
2323
@AppStorage("settings.general.sizeType") var sizeType: String = "Real"
2424
@State private var isCLISymlinked = false
2525

@@ -107,28 +107,28 @@ struct GeneralSettingsTab: View {
107107

108108

109109

110-
HStack(spacing: 0) {
111-
Image(systemName: selectedSortAlpha ? "textformat.abc" : "textformat.123")
112-
.resizable()
113-
.scaledToFit()
114-
.frame(width: 20, height: 20)
115-
.padding(.trailing)
116-
.foregroundStyle(.primary)
117-
VStack(alignment: .leading, spacing: 5) {
118-
Text("File list sorting order")
119-
.font(.callout)
120-
.foregroundStyle(.primary)
121-
}
122-
Spacer()
123-
Picker("", selection: $selectedSortAlpha) {
124-
Text("Alphabetical")
125-
.tag(true)
126-
Text("File Size")
127-
.tag(false)
128-
}
129-
.buttonStyle(.borderless)
130-
}
131-
.padding(5)
110+
// HStack(spacing: 0) {
111+
// Image(systemName: selectedSortAlpha ? "textformat.abc" : "textformat.123")
112+
// .resizable()
113+
// .scaledToFit()
114+
// .frame(width: 20, height: 20)
115+
// .padding(.trailing)
116+
// .foregroundStyle(.primary)
117+
// VStack(alignment: .leading, spacing: 5) {
118+
// Text("File list sorting order")
119+
// .font(.callout)
120+
// .foregroundStyle(.primary)
121+
// }
122+
// Spacer()
123+
// Picker("", selection: $selectedSortAlpha) {
124+
// Text("Alphabetical")
125+
// .tag(true)
126+
// Text("File Size")
127+
// .tag(false)
128+
// }
129+
// .buttonStyle(.borderless)
130+
// }
131+
// .padding(5)
132132

133133

134134

@@ -151,8 +151,8 @@ struct GeneralSettingsTab: View {
151151
.tag("Real")
152152
Text("Logical")
153153
.tag("Logical")
154-
Text("Finder")
155-
.tag("Finder")
154+
// Text("Finder")
155+
// .tag("Finder")
156156
}
157157
.buttonStyle(.borderless)
158158

Pearcleaner/Views/AppSearchView.swift

+70-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct AppSearchView: View {
2222
@Binding var showPopover: Bool
2323
@State private var showMenu = false
2424
@Binding var isMenuBar: Bool
25-
@AppStorage("settings.general.selectedSortAppsList") var selectedSortAlpha: Bool = true
25+
@AppStorage("settings.general.selectedSortAppsList") var selectedSortOption: SortOption = .alphabetical
2626
@AppStorage("settings.interface.animationEnabled") private var animationEnabled: Bool = true
2727

2828

@@ -81,10 +81,10 @@ struct AppSearchView: View {
8181
.buttonStyle(SimpleButtonStyle(icon: "arrow.counterclockwise.circle", help: "Refresh apps (⌘+R)", size: 16))
8282
}
8383

84-
SearchBar(search: $search, darker: (mini || menubarEnabled) ? false : true, glass: glass)
84+
SearchBar(search: $search, darker: (mini || menubarEnabled) ? false : true, glass: glass, sidebar: false)
8585

8686

87-
if search.isEmpty {
87+
if search.isEmpty && (mini || menubarEnabled) {
8888
Button("More") {
8989
self.showMenu.toggle()
9090
}
@@ -94,10 +94,19 @@ struct AppSearchView: View {
9494

9595
Button("") {
9696
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
97-
selectedSortAlpha.toggle()
97+
// Cycle through all enum cases using `CaseIterable`
98+
if let nextSortOption = SortOption(rawValue: selectedSortOption.rawValue + 1) {
99+
selectedSortOption = nextSortOption
100+
showPopover = false
101+
showMenu = false
102+
} else {
103+
selectedSortOption = .alphabetical
104+
showPopover = false
105+
showMenu = false
106+
}
98107
}
99108
}
100-
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Sorting: \(selectedSortAlpha ? "Name" : "Size")", help: "Sort app list alphabetically by name or by size", size: 5))
109+
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Sorting: \(selectedSortOption.title)", help: "Sort app list alphabetically by name or by size", size: 5))
101110

102111
if mini && !menubarEnabled {
103112
Button("") {
@@ -149,15 +158,48 @@ struct AppSearchView: View {
149158
Button("Quit") {
150159
NSApp.terminate(nil)
151160
}
152-
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Quit Pearcleaner", help: "Quit Pearcleaner", size: 5))
161+
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Quit", help: "Quit Pearcleaner", size: 5))
153162
}
154163

155164
}
156165
.padding()
157166
.background(backgroundView(themeManager: themeManager, glass: glass).padding(-80))
158-
.frame(width: 150)
167+
// .frame(width: 200)
168+
169+
}
170+
} else if search.isEmpty && (!mini || !menubarEnabled) {
171+
172+
Button("") {
173+
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
174+
showMenu.toggle()
175+
}
176+
}
177+
.buttonStyle(SimpleButtonStyle(icon: "line.3.horizontal.decrease.circle", help: selectedSortOption.title, size: 16))
178+
.popover(isPresented: $showMenu, arrowEdge: .bottom) {
179+
VStack(alignment: .leading, spacing: 10) {
180+
HStack {
181+
Spacer()
182+
Text("Sorting Options").font(.subheadline).foregroundStyle(.secondary)
183+
Spacer()
184+
}
185+
Divider()
186+
ForEach(SortOption.allCases) { option in
187+
Button("") {
188+
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
189+
selectedSortOption = option
190+
showMenu = false
191+
}
192+
}
193+
.buttonStyle(SimpleButtonStyle(icon: selectedSortOption == option ? "circle.inset.filled" : "circle", label: option.title, help: "", size: 5))
194+
159195

196+
}
197+
}
198+
.padding()
199+
.background(backgroundView(themeManager: themeManager, glass: glass).padding(-80))
200+
// .frame(width: 160)
160201
}
202+
161203
}
162204

163205

@@ -174,12 +216,28 @@ struct AppSearchView: View {
174216
apps = appState.sortedApps.filter { $0.appName.localizedCaseInsensitiveContains(search) }
175217
}
176218

177-
switch selectedSortAlpha {
178-
case true:
179-
return apps.sorted { $0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased() }
180-
case false:
219+
// Sort based on the selected option
220+
switch selectedSortOption {
221+
case .alphabetical:
222+
return apps.sorted {
223+
$0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased()
224+
}
225+
case .size:
181226
return apps.sorted { $0.bundleSize > $1.bundleSize }
227+
case .creationDate:
228+
return apps.sorted { ($0.creationDate ?? Date.distantPast) > ($1.creationDate ?? Date.distantPast) }
229+
case .contentChangeDate:
230+
return apps.sorted { ($0.contentChangeDate ?? Date.distantPast) > ($1.contentChangeDate ?? Date.distantPast) }
231+
case .lastUsedDate:
232+
return apps.sorted { ($0.lastUsedDate ?? Date.distantPast) > ($1.lastUsedDate ?? Date.distantPast) }
182233
}
234+
235+
// switch selectedSortAlpha {
236+
// case true:
237+
// return apps.sorted { $0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased() }
238+
// case false:
239+
// return apps.sorted { $0.bundleSize > $1.bundleSize }
240+
// }
183241
}
184242

185243
}
@@ -218,7 +276,7 @@ struct SimpleSearchStyle: TextFieldStyle {
218276
Spacer()
219277
Text(isFocused ? "Type to search" : "Click to search")
220278
.font(.subheadline)
221-
.foregroundColor(.primary.opacity(0.2))
279+
.foregroundColor(.secondary)
222280
Spacer()
223281
}
224282
}

0 commit comments

Comments
 (0)