From 7a0d8fdaeaec0deb013fc7c3c6d15a10f8fc1258 Mon Sep 17 00:00:00 2001 From: Alin Date: Mon, 27 Nov 2023 13:52:12 -0700 Subject: [PATCH] v1.7 --- Pearcleaner.xcodeproj/project.pbxproj | 8 +- .../xcschemes/Pearcleaner Release.xcscheme | 103 ------------------ Pearcleaner/Logic/Logic.swift | 2 + Pearcleaner/PearcleanerApp.swift | 25 +++++ Pearcleaner/Views/AppListItems.swift | 20 +--- Pearcleaner/Views/AppListView.swift | 27 ++++- Pearcleaner/Views/DropTarget.swift | 10 ++ Pearcleaner/Views/MiniMode.swift | 71 ++++++++---- 8 files changed, 117 insertions(+), 149 deletions(-) delete mode 100644 Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Release.xcscheme diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index f445577..74624bc 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -535,7 +535,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -552,7 +552,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.6; + MARKETING_VERSION = 1.7; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -569,7 +569,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -586,7 +586,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.6; + MARKETING_VERSION = 1.7; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Release.xcscheme b/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Release.xcscheme deleted file mode 100644 index 0f406db..0000000 --- a/Pearcleaner.xcodeproj/xcshareddata/xcschemes/Pearcleaner Release.xcscheme +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pearcleaner/Logic/Logic.swift b/Pearcleaner/Logic/Logic.swift index 3f84b91..6ffab60 100644 --- a/Pearcleaner/Logic/Logic.swift +++ b/Pearcleaner/Logic/Logic.swift @@ -82,6 +82,8 @@ func getAppInfo(atPath path: URL) -> AppInfo? { appName = localizedName } else if let bundleName = bundle.infoDictionary?["CFBundleName"] as? String { appName = bundleName + } else { + appName = path.deletingPathExtension().lastPathComponent } // Check if the icon file name has an .icns extension, if not, add it if !appIconFileName.hasSuffix(".icns") { diff --git a/Pearcleaner/PearcleanerApp.swift b/Pearcleaner/PearcleanerApp.swift index 49395f8..cce6132 100644 --- a/Pearcleaner/PearcleanerApp.swift +++ b/Pearcleaner/PearcleanerApp.swift @@ -39,6 +39,29 @@ struct PearcleanerApp: App { .preferredColorScheme(displayMode.colorScheme) .alert(isPresented: $appState.showAlert) { presentAlert(appState: appState) } .handlesExternalEvents(preferring: Set(arrayLiteral: "pear"), allowing: Set(arrayLiteral: "*")) + .onOpenURL(perform: { url in + let deeplinkManager = DeeplinkManager() + deeplinkManager.manage(url: url, appState: appState) + }) + .onDrop(of: ["public.file-url"], isTargeted: nil) { providers, _ in + for provider in providers { + provider.loadItem(forTypeIdentifier: "public.file-url") { data, error in + if let data = data as? Data, let url = URL(dataRepresentation: data, relativeTo: nil) { + let deeplinkManager = DeeplinkManager() + deeplinkManager.manage(url: url, appState: appState) + // // Check if the file URL has a ".app" extension + // if url.pathExtension.lowercased() == "app" { + // // Handle the dropped file URL here + // print("Dropped .app file URL: \(url)") + // } else { + // // Print a message for non-.app files + // print("Unsupported file type. Only .app files are accepted.") + // } + } + } + } + return true + } .onAppear { NSWindow.allowsAutomaticWindowTabbing = false @@ -110,9 +133,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { // func application(_ sender: NSApplication, open urls: [URL]) { // for url in urls { // if url.pathExtension == "app" { +// writeLog(string: url.path) // print("Dropped app path:", url.path) // } // } // } + } diff --git a/Pearcleaner/Views/AppListItems.swift b/Pearcleaner/Views/AppListItems.swift index 3ef142e..b7c2d71 100644 --- a/Pearcleaner/Views/AppListItems.swift +++ b/Pearcleaner/Views/AppListItems.swift @@ -25,12 +25,7 @@ struct AppListItems: View { var body: some View { VStack(alignment: .leading, spacing: 5) { HStack(alignment: .center) { -// if isHovered || isSelected { -// Circle() -// .fill(Color("AccentColor")) -// .frame(width: 10) -// .padding(5) -// } + if let appIcon = appInfo.appIcon { Image(nsImage: appIcon) .resizable() @@ -106,18 +101,5 @@ struct AppListItems: View { } } } -// .popover(isPresented: $appState.showPopover, arrowEdge: .trailing) { -// VStack { -// FilesView() -// .id(appState.appInfo.id) -// } -// .background( -// Rectangle() -// .background(colorScheme == .dark ? .black.opacity(0.8) : .white) -// .padding(-80) -// ) -// .frame(minWidth: 500, minHeight: 500) -// -// } } } diff --git a/Pearcleaner/Views/AppListView.swift b/Pearcleaner/Views/AppListView.swift index 51b3ac0..f991385 100644 --- a/Pearcleaner/Views/AppListView.swift +++ b/Pearcleaner/Views/AppListView.swift @@ -146,10 +146,29 @@ struct AppListView: View { Spacer() } .edgesIgnoringSafeArea(.all) - .onOpenURL(perform: { url in - let deeplinkManager = DeeplinkManager() - deeplinkManager.manage(url: url, appState: appState) - }) +// .onOpenURL(perform: { url in +// let deeplinkManager = DeeplinkManager() +// deeplinkManager.manage(url: url, appState: appState) +// }) +// .onDrop(of: ["public.file-url"], isTargeted: nil) { providers, _ in +// for provider in providers { +// provider.loadItem(forTypeIdentifier: "public.file-url") { data, error in +// if let data = data as? Data, let url = URL(dataRepresentation: data, relativeTo: nil) { +// let deeplinkManager = DeeplinkManager() +// deeplinkManager.manage(url: url, appState: appState) +// // // Check if the file URL has a ".app" extension +// // if url.pathExtension.lowercased() == "app" { +// // // Handle the dropped file URL here +// // print("Dropped .app file URL: \(url)") +// // } else { +// // // Print a message for non-.app files +// // print("Unsupported file type. Only .app files are accepted.") +// // } +// } +// } +// } +// return true +// } // MARK: Background for whole app // .background(Color("bg").opacity(1)) // .background(VisualEffect(material: .sidebar, blendingMode: .behindWindow).edgesIgnoringSafeArea(.all)) diff --git a/Pearcleaner/Views/DropTarget.swift b/Pearcleaner/Views/DropTarget.swift index ae0cb8b..26ee37b 100644 --- a/Pearcleaner/Views/DropTarget.swift +++ b/Pearcleaner/Views/DropTarget.swift @@ -34,6 +34,15 @@ struct DropTarget: View, DropDelegate { Spacer() ZStack { +// Color("mode") +// .mask( +// Image(mini ? "pear" : "logo") +// .resizable() +// .scaledToFit() +// .frame(minWidth: mini ? 104 : 300) +// .frame(maxWidth: mini ? 104 : 500) +// .padding(mini ? 20 : 10) +// ) LinearGradient(gradient: Gradient(colors: [.pink, .orange]), startPoint: .leading, endPoint: .trailing) .mask( Image(mini ? "pear" : "logo") @@ -54,6 +63,7 @@ struct DropTarget: View, DropDelegate { .frame(maxWidth: .infinity, maxHeight: .infinity) .background { RoundedRectangle(cornerRadius: 8) +// .fill(LinearGradient(gradient: Gradient(colors: [.pink, .orange]), startPoint: .leading, endPoint: .trailing)) .strokeBorder(LinearGradient(gradient: Gradient(colors: [.pink, .orange]), startPoint: .leading, endPoint: .trailing), style: StrokeStyle(lineWidth: 3, dash: [11.0], dashPhase: phase)) .onAppear { withAnimation(.linear.speed(0.5).repeat(while: ants, autoreverses: false)) { diff --git a/Pearcleaner/Views/MiniMode.swift b/Pearcleaner/Views/MiniMode.swift index e022c01..184459b 100644 --- a/Pearcleaner/Views/MiniMode.swift +++ b/Pearcleaner/Views/MiniMode.swift @@ -39,16 +39,49 @@ struct MiniMode: View { } // .padding(.leading, appState.sidebar ? 0 : 10) .transition(.move(edge: .leading)) - + .popover(isPresented: $showPopover, arrowEdge: .trailing) { + VStack { + FilesView(showPopover: $showPopover) + .id(appState.appInfo.id) + } + .background( + Rectangle() + .fill(Color("pop")) + .padding(-80) + ) + .frame(minWidth: 600, minHeight: 500) + + } + } .frame(minWidth: 300, minHeight: 300) .edgesIgnoringSafeArea(.all) .background(glass ? GlassEffect(material: .sidebar, blendingMode: .behindWindow).edgesIgnoringSafeArea(.all) : nil) - .onOpenURL(perform: { url in - let deeplinkManager = DeeplinkManager() - deeplinkManager.manage(url: url, appState: appState) - }) + +// .onOpenURL(perform: { url in +// let deeplinkManager = DeeplinkManager() +// deeplinkManager.manage(url: url, appState: appState) +// }) +// .onDrop(of: ["public.file-url"], isTargeted: nil) { providers, _ in +// for provider in providers { +// provider.loadItem(forTypeIdentifier: "public.file-url") { data, error in +// if let data = data as? Data, let url = URL(dataRepresentation: data, relativeTo: nil) { +// let deeplinkManager = DeeplinkManager() +// deeplinkManager.manage(url: url, appState: appState) +//// // Check if the file URL has a ".app" extension +//// if url.pathExtension.lowercased() == "app" { +//// // Handle the dropped file URL here +//// print("Dropped .app file URL: \(url)") +//// } else { +//// // Print a message for non-.app files +//// print("Unsupported file type. Only .app files are accepted.") +//// } +// } +// } +// } +// return true +// } // MARK: Background for whole app // .background(Color("bg").opacity(1)) // .background(VisualEffect(material: .sidebar, blendingMode: .behindWindow).edgesIgnoringSafeArea(.all)) @@ -193,20 +226,20 @@ struct MiniAppView: View { } } .transition(.move(edge: .leading)) - .popover(isPresented: $showPopover, arrowEdge: .trailing) { - VStack { - FilesView(showPopover: $showPopover) - .id(appState.appInfo.id) - } - .background( - Rectangle() - .fill(Color("pop")) -// .background(Color("pop")) - .padding(-80) - ) - .frame(minWidth: 600, minHeight: 500) - - } +// .popover(isPresented: $showPopover, arrowEdge: .trailing) { +// VStack { +// FilesView(showPopover: $showPopover) +// .id(appState.appInfo.id) +// } +// .background( +// Rectangle() +// .fill(Color("pop")) +//// .background(Color("pop")) +// .padding(-80) +// ) +// .frame(minWidth: 600, minHeight: 500) +// +// } } }