Skip to content

Commit

Permalink
v3.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alienator88 committed Oct 7, 2024
1 parent b4d676d commit 7f1aaf4
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 137 deletions.
8 changes: 4 additions & 4 deletions Pearcleaner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_BUILD = 62;
APP_VERSION = 3.9.0;
APP_BUILD = 63;
APP_VERSION = 3.9.1;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -607,8 +607,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_BUILD = 62;
APP_VERSION = 3.9.0;
APP_BUILD = 63;
APP_VERSION = 3.9.1;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down
5 changes: 3 additions & 2 deletions Pearcleaner/Logic/AppInfoFetch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import AlinFoundation
class MetadataAppInfoFetcher {
static func getAppInfo(fromMetadata metadata: [String: Any], atPath path: URL) -> AppInfo? {
// Extract metadata attributes for known fields
let displayName = metadata["kMDItemDisplayName"] as? String ?? ""
var displayName = metadata["kMDItemDisplayName"] as? String ?? ""
displayName = displayName.replacingOccurrences(of: ".app", with: "").capitalizingFirstLetter()
let fsName = metadata["kMDItemFSName"] as? String ?? path.lastPathComponent
let appName = displayName.isEmpty ? fsName : displayName

Expand Down Expand Up @@ -152,7 +153,7 @@ class AppInfoUtils {
static func fetchAppIcon(for path: URL, wrapped: Bool, md: Bool = false) -> NSImage? {
let iconPath = wrapped ? (md ? path : path.deletingLastPathComponent().deletingLastPathComponent()) : path
if let appIcon = getIconForFileOrFolderNS(atPath: iconPath) {
return convertICNSToPNG(icon: appIcon, size: NSSize(width: 100, height: 100))
return convertICNSToPNG(icon: appIcon, size: NSSize(width: 50, height: 50))
} else {
printOS("App Icon not found for app at path: \(path)")
return nil
Expand Down
15 changes: 15 additions & 0 deletions Pearcleaner/Logic/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ enum CurrentPage:Int, CaseIterable, Identifiable
}
}

enum SortOption:Int, CaseIterable, Identifiable {
case alphabetical
case size
case creationDate
case contentChangeDate
case lastUsedDate

var id: Int { rawValue }

var title: String {
let titles: [String] = ["App Name", "App Size", "Install Date", "Modified Date", "Last Used Date"]
return titles[rawValue]
}
}


enum CurrentTabView:Int
{
Expand Down
1 change: 1 addition & 0 deletions Pearcleaner/Settings/About.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ struct Sponsor: Identifiable {
let url: URL

static let sponsors: [Sponsor] = [
Sponsor(name: "mzdr (monthly)", url: URL(string: "https://github.com/mzdr")!),
Sponsor(name: "chris3ware", url: URL(string: "https://github.com/chris3ware")!),
Sponsor(name: "fpuhan", url: URL(string: "https://github.com/fpuhan")!),
Sponsor(name: "HungThinhIT", url: URL(string: "https://github.com/HungThinhIT")!),
Expand Down
50 changes: 25 additions & 25 deletions Pearcleaner/Settings/General.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct GeneralSettingsTab: View {
@AppStorage("settings.general.brew") private var brew: Bool = false
@AppStorage("settings.general.oneshot") private var oneShotMode: Bool = false
@AppStorage("settings.general.confirmAlert") private var confirmAlert: Bool = false
@AppStorage("settings.general.selectedSort") var selectedSortAlpha: Bool = true
// @AppStorage("settings.general.selectedSort") var selectedSortAlpha: Bool = true
@AppStorage("settings.general.sizeType") var sizeType: String = "Real"
@State private var isCLISymlinked = false

Expand Down Expand Up @@ -107,28 +107,28 @@ struct GeneralSettingsTab: View {



HStack(spacing: 0) {
Image(systemName: selectedSortAlpha ? "textformat.abc" : "textformat.123")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.primary)
VStack(alignment: .leading, spacing: 5) {
Text("File list sorting order")
.font(.callout)
.foregroundStyle(.primary)
}
Spacer()
Picker("", selection: $selectedSortAlpha) {
Text("Alphabetical")
.tag(true)
Text("File Size")
.tag(false)
}
.buttonStyle(.borderless)
}
.padding(5)
// HStack(spacing: 0) {
// Image(systemName: selectedSortAlpha ? "textformat.abc" : "textformat.123")
// .resizable()
// .scaledToFit()
// .frame(width: 20, height: 20)
// .padding(.trailing)
// .foregroundStyle(.primary)
// VStack(alignment: .leading, spacing: 5) {
// Text("File list sorting order")
// .font(.callout)
// .foregroundStyle(.primary)
// }
// Spacer()
// Picker("", selection: $selectedSortAlpha) {
// Text("Alphabetical")
// .tag(true)
// Text("File Size")
// .tag(false)
// }
// .buttonStyle(.borderless)
// }
// .padding(5)



Expand All @@ -151,8 +151,8 @@ struct GeneralSettingsTab: View {
.tag("Real")
Text("Logical")
.tag("Logical")
Text("Finder")
.tag("Finder")
// Text("Finder")
// .tag("Finder")
}
.buttonStyle(.borderless)

Expand Down
82 changes: 70 additions & 12 deletions Pearcleaner/Views/AppSearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct AppSearchView: View {
@Binding var showPopover: Bool
@State private var showMenu = false
@Binding var isMenuBar: Bool
@AppStorage("settings.general.selectedSortAppsList") var selectedSortAlpha: Bool = true
@AppStorage("settings.general.selectedSortAppsList") var selectedSortOption: SortOption = .alphabetical
@AppStorage("settings.interface.animationEnabled") private var animationEnabled: Bool = true


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

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


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

Button("") {
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
selectedSortAlpha.toggle()
// Cycle through all enum cases using `CaseIterable`
if let nextSortOption = SortOption(rawValue: selectedSortOption.rawValue + 1) {
selectedSortOption = nextSortOption
showPopover = false
showMenu = false
} else {
selectedSortOption = .alphabetical
showPopover = false
showMenu = false
}
}
}
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Sorting: \(selectedSortAlpha ? "Name" : "Size")", help: "Sort app list alphabetically by name or by size", size: 5))
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Sorting: \(selectedSortOption.title)", help: "Sort app list alphabetically by name or by size", size: 5))

if mini && !menubarEnabled {
Button("") {
Expand Down Expand Up @@ -149,15 +158,48 @@ struct AppSearchView: View {
Button("Quit") {
NSApp.terminate(nil)
}
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Quit Pearcleaner", help: "Quit Pearcleaner", size: 5))
.buttonStyle(SimpleButtonStyle(icon: "circle.fill", label: "Quit", help: "Quit Pearcleaner", size: 5))
}

}
.padding()
.background(backgroundView(themeManager: themeManager, glass: glass).padding(-80))
.frame(width: 150)
// .frame(width: 200)

}
} else if search.isEmpty && (!mini || !menubarEnabled) {

Button("") {
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
showMenu.toggle()
}
}
.buttonStyle(SimpleButtonStyle(icon: "line.3.horizontal.decrease.circle", help: selectedSortOption.title, size: 16))
.popover(isPresented: $showMenu, arrowEdge: .bottom) {
VStack(alignment: .leading, spacing: 10) {
HStack {
Spacer()
Text("Sorting Options").font(.subheadline).foregroundStyle(.secondary)
Spacer()
}
Divider()
ForEach(SortOption.allCases) { option in
Button("") {
withAnimation(Animation.easeInOut(duration: animationEnabled ? 0.35 : 0)) {
selectedSortOption = option
showMenu = false
}
}
.buttonStyle(SimpleButtonStyle(icon: selectedSortOption == option ? "circle.inset.filled" : "circle", label: option.title, help: "", size: 5))


}
}
.padding()
.background(backgroundView(themeManager: themeManager, glass: glass).padding(-80))
// .frame(width: 160)
}

}


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

switch selectedSortAlpha {
case true:
return apps.sorted { $0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased() }
case false:
// Sort based on the selected option
switch selectedSortOption {
case .alphabetical:
return apps.sorted {
$0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased()
}
case .size:
return apps.sorted { $0.bundleSize > $1.bundleSize }
case .creationDate:
return apps.sorted { ($0.creationDate ?? Date.distantPast) > ($1.creationDate ?? Date.distantPast) }
case .contentChangeDate:
return apps.sorted { ($0.contentChangeDate ?? Date.distantPast) > ($1.contentChangeDate ?? Date.distantPast) }
case .lastUsedDate:
return apps.sorted { ($0.lastUsedDate ?? Date.distantPast) > ($1.lastUsedDate ?? Date.distantPast) }
}

// switch selectedSortAlpha {
// case true:
// return apps.sorted { $0.appName.replacingOccurrences(of: ".", with: "").lowercased() < $1.appName.replacingOccurrences(of: ".", with: "").lowercased() }
// case false:
// return apps.sorted { $0.bundleSize > $1.bundleSize }
// }
}

}
Expand Down Expand Up @@ -218,7 +276,7 @@ struct SimpleSearchStyle: TextFieldStyle {
Spacer()
Text(isFocused ? "Type to search" : "Click to search")
.font(.subheadline)
.foregroundColor(.primary.opacity(0.2))
.foregroundColor(.secondary)
Spacer()
}
}
Expand Down
Loading

0 comments on commit 7f1aaf4

Please sign in to comment.