mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 07:19:04 +00:00
v2.0
This commit is contained in:
@@ -10,11 +10,11 @@ import SwiftUI
|
||||
struct AppCommands: Commands {
|
||||
|
||||
let appState: AppState
|
||||
|
||||
|
||||
init(appState: AppState) {
|
||||
self.appState = appState
|
||||
}
|
||||
|
||||
|
||||
var body: some Commands {
|
||||
|
||||
// Pearcleaner Menu
|
||||
@@ -30,9 +30,13 @@ struct AppCommands: Commands {
|
||||
Button {
|
||||
withAnimation(.easeInOut(duration: 0.5)) {
|
||||
// Refresh Apps list
|
||||
appState.reload.toggle()
|
||||
let sortedApps = getSortedApps()
|
||||
appState.sortedApps.userApps = sortedApps.userApps
|
||||
appState.sortedApps.systemApps = sortedApps.systemApps
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
appState.sortedApps.userApps = sortedApps.userApps
|
||||
appState.sortedApps.systemApps = sortedApps.systemApps
|
||||
appState.reload.toggle()
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Text("Refresh Apps")
|
||||
|
||||
@@ -26,6 +26,7 @@ class AppState: ObservableObject
|
||||
@Published var isReminderVisible: Bool = false
|
||||
@Published var releases = [Release]()
|
||||
@Published var progressBar: (String, Double) = ("Ready", 0.0)
|
||||
@Published var reload: Bool = false
|
||||
|
||||
|
||||
//Window
|
||||
|
||||
@@ -269,13 +269,13 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
|
||||
let dispatchGroup = DispatchGroup()
|
||||
let bundleComponents = appInfo.bundleIdentifier.components(separatedBy: ".")
|
||||
var bundle: String = ""
|
||||
var weirdFormatBundle: Bool = false
|
||||
// var weirdFormatBundle: Bool = false
|
||||
if bundleComponents.count >= 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)) {
|
||||
|
||||
@@ -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<Self._Label>) -> 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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user