From abd36709f27a21b12ef13c80a3e9ac2d7819176a Mon Sep 17 00:00:00 2001 From: Alin Date: Fri, 15 Dec 2023 15:12:17 -0700 Subject: [PATCH] v2.0 --- Pearcleaner.xcodeproj/project.pbxproj | 16 +++++++---- .../xcschemes/Pearcleaner Debug.xcscheme | 2 +- .../xcschemes/PearcleanerSentinel.xcscheme | 2 +- Pearcleaner/Logic/AppCommands.swift | 12 +++++--- Pearcleaner/Logic/AppState.swift | 1 + Pearcleaner/Logic/Logic.swift | 17 +++++------ Pearcleaner/Logic/Styles.swift | 28 +++++++++++-------- Pearcleaner/PearcleanerApp.swift | 2 +- Pearcleaner/Settings/General.swift | 2 +- Pearcleaner/Views/AppListItems.swift | 3 +- Pearcleaner/Views/AppListView.swift | 12 ++++---- Pearcleaner/Views/MiniMode.swift | 12 ++++---- Pearcleaner/Views/TopBar.swift | 1 - Pearcleaner/Views/TopBarMini.swift | 8 ++---- 14 files changed, 64 insertions(+), 54 deletions(-) diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index 09fe622..22a5616 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -286,7 +286,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1500; - LastUpgradeCheck = 1500; + LastUpgradeCheck = 1510; TargetAttributes = { C728930E2AFD51EA00C8C1CD = { CreatedOnToolsVersion = 15.0.1; @@ -380,6 +380,7 @@ CODE_SIGN_ENTITLEMENTS = PearcleanerSentinel/PearcleanerSentinel.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; MACOSX_DEPLOYMENT_TARGET = 13.0; @@ -396,6 +397,7 @@ CODE_SIGN_ENTITLEMENTS = PearcleanerSentinel/PearcleanerSentinel.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; MACOSX_DEPLOYMENT_TARGET = 13.0; @@ -441,6 +443,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_ENTITLEMENTS = ""; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -505,6 +508,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_ENTITLEMENTS = ""; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -535,7 +539,8 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -552,7 +557,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.9; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -569,7 +574,8 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -586,7 +592,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.9; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Debug.xcscheme b/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Debug.xcscheme index 9aa3ff6..a14dc88 100644 --- a/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Debug.xcscheme +++ b/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Debug.xcscheme @@ -1,6 +1,6 @@ = 3 { // get last 2 or middle 2 components bundle = bundleComponents[1...2].joined(separator: "").lowercased() } - if bundleComponents[0] != "com" { - weirdFormatBundle = true - } +// if bundleComponents[0] != "com" { +// weirdFormatBundle = true +// } let nameL = appInfo.appName.pearFormat() let bundleIdentifierL = appInfo.bundleIdentifier.pearFormat() let locations = Locations() @@ -319,11 +319,12 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) { if itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 4 && itemL.contains(nameL)) { collection.append(itemURL) } + // This causes too many issues, disabling this filter for now ///////////////////////////////// // Catch Logitech files since Logi is part of word login and can return random files - } else if itemL.contains("logi") && !itemL.contains("login") { - if itemL.contains(bundleComponents[weirdFormatBundle ? 0 : 1]) || itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 3 && itemL.contains(nameL)) { - collection.append(itemURL) - } +// } else if itemL.contains("logi") && !itemL.contains("login") { +// if itemL.contains(bundleComponents[weirdFormatBundle ? 0 : 1]) || itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 3 && itemL.contains(nameL)) { +// collection.append(itemURL) +// } // Catch MS Office files since they have many random folder names and very short names } else if itemL.contains("office") || itemL.contains("oneauth") || itemL.suffix(2).contains("ms") || itemL.contains("onenote") { if itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 4 && itemL.contains(nameL)) { diff --git a/Pearcleaner/Logic/Styles.swift b/Pearcleaner/Logic/Styles.swift index fe3b0ff..768b562 100644 --- a/Pearcleaner/Logic/Styles.swift +++ b/Pearcleaner/Logic/Styles.swift @@ -78,8 +78,8 @@ struct LabeledDivider: View { struct AnimatedSearchStyle: TextFieldStyle { @State private var isHovered = false + @FocusState private var isFocused: Bool @Binding var text: String - @Binding var reload: Bool @EnvironmentObject var appState: AppState func _body(configuration: TextField) -> some View { @@ -105,12 +105,12 @@ struct AnimatedSearchStyle: TextFieldStyle { .onTapGesture { withAnimation { // Refresh Apps list - reload.toggle() + appState.reload.toggle() let sortedApps = getSortedApps() DispatchQueue.main.asyncAfter(deadline: .now() + 1) { appState.sortedApps.userApps = sortedApps.userApps appState.sortedApps.systemApps = sortedApps.systemApps - reload.toggle() + appState.reload.toggle() } } @@ -135,11 +135,16 @@ struct AnimatedSearchStyle: TextFieldStyle { } else { - Image(systemName: "magnifyingglass") - .resizable() - .scaledToFit() - .frame(width: 18, height: 18) - .foregroundColor(isHovered ? Color("mode") : Color("mode").opacity(0.5)) + HStack { + Spacer() + Image(systemName: "magnifyingglass") + .resizable() + .scaledToFit() + .frame(width: 18, height: 18) + .foregroundColor(isHovered ? Color("mode") : Color("mode").opacity(0.5)) + } + .frame(width: 150) + } } .padding(8) @@ -156,8 +161,10 @@ struct AnimatedSearchStyle: TextFieldStyle { .onHover { hovering in withAnimation(Animation.easeInOut(duration: 0.4)) { self.isHovered = hovering + self.isFocused = hovering } } + .focused($isFocused) } } @@ -168,7 +175,6 @@ struct SimpleSearchStyle: TextFieldStyle { @State private var isHovered = false @State var icon: Image? @State var trash: Bool = false - @Binding var reload: Bool @Binding var text: String @EnvironmentObject var appState: AppState @AppStorage("settings.general.mini") private var mini: Bool = false @@ -198,12 +204,12 @@ struct SimpleSearchStyle: TextFieldStyle { .onTapGesture { withAnimation { // Refresh Apps list - reload.toggle() + appState.reload.toggle() let sortedApps = getSortedApps() DispatchQueue.main.asyncAfter(deadline: .now() + 1) { appState.sortedApps.userApps = sortedApps.userApps appState.sortedApps.systemApps = sortedApps.systemApps - reload.toggle() + appState.reload.toggle() } } diff --git a/Pearcleaner/PearcleanerApp.swift b/Pearcleaner/PearcleanerApp.swift index 1cdf79c..30d73e1 100644 --- a/Pearcleaner/PearcleanerApp.swift +++ b/Pearcleaner/PearcleanerApp.swift @@ -20,7 +20,7 @@ struct PearcleanerApp: App { @AppStorage("settings.general.mini") private var mini: Bool = false @State private var search = "" @State private var showPopover: Bool = false - + var body: some Scene { WindowGroup { diff --git a/Pearcleaner/Settings/General.swift b/Pearcleaner/Settings/General.swift index 3768003..2b8b633 100644 --- a/Pearcleaner/Settings/General.swift +++ b/Pearcleaner/Settings/General.swift @@ -99,7 +99,7 @@ struct GeneralSettingsTab: View { .onChange(of: mini) { newVal in resizeWindow(width: 300, height: 300) if mini { - appState.currentView = .apps + appState.currentView = .empty } else { if appState.appInfo.appName.isEmpty { appState.currentView = .empty diff --git a/Pearcleaner/Views/AppListItems.swift b/Pearcleaner/Views/AppListItems.swift index 2401870..6cce39d 100644 --- a/Pearcleaner/Views/AppListItems.swift +++ b/Pearcleaner/Views/AppListItems.swift @@ -10,7 +10,6 @@ import SwiftUI struct AppListItems: View { @EnvironmentObject var appState: AppState -// @Binding var reload: Bool @Binding var search: String @State private var isHovered = false @Environment(\.colorScheme) var colorScheme @@ -67,7 +66,7 @@ struct AppListItems: View { if isHovered || isSelected { RoundedRectangle(cornerRadius: 50) .fill(isSelected ? Color("AccentColor") : Color("mode").opacity(0.5)) - .frame(width: isSelected ? 4 : 2, height: 35) + .frame(width: isSelected ? 4 : 2, height: 30) .padding(.leading, 5) .offset(x: 20) } diff --git a/Pearcleaner/Views/AppListView.swift b/Pearcleaner/Views/AppListView.swift index 2df7eeb..64ccce4 100644 --- a/Pearcleaner/Views/AppListView.swift +++ b/Pearcleaner/Views/AppListView.swift @@ -15,7 +15,6 @@ struct AppListView: View { @State private var showSys: Bool = true @State private var showUsr: Bool = true // @State private var sidebar: Bool = true - @State private var reload: Bool = false @Binding var showPopover: Bool var filteredUserApps: [AppInfo] { @@ -42,7 +41,7 @@ struct AppListView: View { ZStack { HStack(spacing: 0){ - if reload { + if appState.reload { VStack { Spacer() ProgressView("Refreshing applications") @@ -55,7 +54,7 @@ struct AppListView: View { VStack(alignment: .center, spacing: 20) { HStack { - SearchBar(search: $search, reload: $reload) + SearchBar(search: $search) // Button("") { // withAnimation(.easeInOut(duration: 0.5)) { @@ -132,10 +131,10 @@ struct AppListView: View { // Details View VStack(spacing: 0) { if appState.currentView == .empty { - TopBar(reload: $reload) + TopBar() AppDetailsEmptyView(showPopover: $showPopover) } else if appState.currentView == .files { - TopBar(reload: $reload) + TopBar() FilesView(showPopover: $showPopover, search: $search) .id(appState.appInfo.id) } @@ -221,12 +220,11 @@ struct AppDetailsEmptyView: View { struct SearchBar: View { @Binding var search: String - @Binding var reload: Bool var body: some View { HStack { TextField("Search", text: $search) - .textFieldStyle(SimpleSearchStyle(icon: Image(systemName: "magnifyingglass"),trash: true, reload: $reload, text: $search)) + .textFieldStyle(SimpleSearchStyle(icon: Image(systemName: "magnifyingglass"),trash: true, text: $search)) } .frame(height: 30) } diff --git a/Pearcleaner/Views/MiniMode.swift b/Pearcleaner/Views/MiniMode.swift index 10a9146..0063646 100644 --- a/Pearcleaner/Views/MiniMode.swift +++ b/Pearcleaner/Views/MiniMode.swift @@ -14,7 +14,6 @@ struct MiniMode: View { @Binding var search: String @State private var showSys: Bool = true @State private var showUsr: Bool = true - @State private var reload: Bool = false @AppStorage("settings.general.glass") private var glass: Bool = false @Binding var showPopover: Bool @@ -26,15 +25,15 @@ struct MiniMode: View { // Main Mini View VStack(spacing: 0) { if appState.currentView == .empty { - TopBarMini(reload: $reload, search: $search) + TopBarMini(search: $search) MiniEmptyView(showPopover: $showPopover) } else if appState.currentView == .files { - TopBarMini(reload: $reload, search: $search) + TopBarMini(search: $search) FilesView(showPopover: $showPopover, search: $search) .id(appState.appInfo.id) } else if appState.currentView == .apps { - TopBarMini(reload: $reload, search: $search) - MiniAppView(search: $search, reload: $reload, showPopover: $showPopover) + TopBarMini(search: $search) + MiniAppView(search: $search, showPopover: $showPopover) } } // .padding(.leading, appState.sidebar ? 0 : 10) @@ -149,7 +148,6 @@ struct MiniAppView: View { @Binding var search: String @State private var showSys: Bool = true @State private var showUsr: Bool = true - @Binding var reload: Bool @AppStorage("settings.general.mini") private var mini: Bool = false @Binding var showPopover: Bool @@ -174,7 +172,7 @@ struct MiniAppView: View { ZStack { HStack(spacing: 0){ - if reload { + if appState.reload { VStack { Spacer() ProgressView("Refreshing applications") diff --git a/Pearcleaner/Views/TopBar.swift b/Pearcleaner/Views/TopBar.swift index a4cc487..a160d28 100644 --- a/Pearcleaner/Views/TopBar.swift +++ b/Pearcleaner/Views/TopBar.swift @@ -10,7 +10,6 @@ import SwiftUI struct TopBar: View { // @Binding var sidebar: Bool - @Binding var reload: Bool @AppStorage("displayMode") var displayMode: DisplayMode = .system @AppStorage("settings.general.glass") private var glass: Bool = false @AppStorage("settings.sentinel.enable") private var sentinel: Bool = false diff --git a/Pearcleaner/Views/TopBarMini.swift b/Pearcleaner/Views/TopBarMini.swift index 3273f18..05755ab 100644 --- a/Pearcleaner/Views/TopBarMini.swift +++ b/Pearcleaner/Views/TopBarMini.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI struct TopBarMini: View { - @Binding var reload: Bool @AppStorage("displayMode") var displayMode: DisplayMode = .system @AppStorage("settings.sentinel.enable") private var sentinel: Bool = false @AppStorage("settings.general.mini") private var mini: Bool = false @@ -25,7 +24,7 @@ struct TopBarMini: View { // HStack { // Spacer() - SearchBarMini(search: $search, reload: $reload) + SearchBarMini(search: $search) // .frame(width: 150) // .offset(x: 20) // .padding(.horizontal, 30) @@ -102,12 +101,11 @@ struct TopBarMini: View { struct SearchBarMini: View { @Binding var search: String - @Binding var reload: Bool - + var body: some View { HStack { TextField("Search", text: $search) - .textFieldStyle(AnimatedSearchStyle(text: $search, reload: $reload)) + .textFieldStyle(AnimatedSearchStyle(text: $search)) // .textFieldStyle(SimpleSearchStyle(trash: true, reload: $reload, text: $search)) } // .frame(height: 20)