mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 04:58:56 +00:00
v1.3 and v1.4
This commit is contained in:
@@ -15,108 +15,66 @@ struct PearcleanerApp: App {
|
||||
@AppStorage("settings.updater.updateTimeframe") private var updateTimeframe: Int = 1
|
||||
@AppStorage("settings.permissions.disk") private var diskP: Bool = false
|
||||
@AppStorage("settings.permissions.events") private var diskE: Bool = false
|
||||
@AppStorage("displayMode") var displayMode: DisplayMode = .dark
|
||||
@AppStorage("displayMode") var displayMode: DisplayMode = .system
|
||||
@AppStorage("settings.general.mini") private var mini: Bool = false
|
||||
@State private var search = ""
|
||||
|
||||
var body: some Scene {
|
||||
|
||||
|
||||
WindowGroup {
|
||||
if !mini {
|
||||
AppListView(search: $search)
|
||||
.environmentObject(appState)
|
||||
.frame(minWidth: 1020, minHeight: 700)
|
||||
.preferredColorScheme(displayMode.colorScheme)
|
||||
.alert(isPresented: $appState.showAlert) { presentAlert(appState: appState) }
|
||||
.handlesExternalEvents(preferring: Set(arrayLiteral: "pear"), allowing: Set(arrayLiteral: "*"))
|
||||
.onAppear {
|
||||
NSWindow.allowsAutomaticWindowTabbing = false
|
||||
|
||||
// Get Apps
|
||||
let sortedApps = getSortedApps()
|
||||
appState.sortedApps.userApps = sortedApps.userApps
|
||||
appState.sortedApps.systemApps = sortedApps.systemApps
|
||||
|
||||
Task {
|
||||
|
||||
#if !DEBUG
|
||||
|
||||
// Make sure App Support folder exists in the future if needed for storage
|
||||
ensureApplicationSupportFolderExists(appState: appState)
|
||||
let fileManager = FileManager.default
|
||||
let destinationURL = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!.appendingPathComponent("Pearcleaner").appendingPathComponent("Pearcleaner.zip")
|
||||
try? fileManager.removeItem(at: destinationURL)
|
||||
|
||||
// Check for updates
|
||||
if diskP && diskE {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
|
||||
// Check for disk/accessibility permissions
|
||||
_ = checkAndRequestFullDiskAccess(appState: appState)
|
||||
|
||||
|
||||
// TIMERS ////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Check for app updates every 8 hours or whatever user saved setting. Also refresh autosuggestion list
|
||||
let updateSeconds = updateTimeframe.daysToSeconds
|
||||
_ = Timer.scheduledTimer(withTimeInterval: updateSeconds, repeats: true) { _ in
|
||||
DispatchQueue.main.async {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MiniMode(search: $search)
|
||||
.environmentObject(appState)
|
||||
.frame(minWidth: 500, minHeight: 450)
|
||||
.preferredColorScheme(displayMode.colorScheme)
|
||||
.alert(isPresented: $appState.showAlert) { presentAlert(appState: appState) }
|
||||
.handlesExternalEvents(preferring: Set(arrayLiteral: "pear"), allowing: Set(arrayLiteral: "*"))
|
||||
.onAppear {
|
||||
NSWindow.allowsAutomaticWindowTabbing = false
|
||||
|
||||
// Get Apps
|
||||
let sortedApps = getSortedApps()
|
||||
appState.sortedApps.userApps = sortedApps.userApps
|
||||
appState.sortedApps.systemApps = sortedApps.systemApps
|
||||
|
||||
Task {
|
||||
|
||||
#if !DEBUG
|
||||
|
||||
// Make sure App Support folder exists in the future if needed for storage
|
||||
ensureApplicationSupportFolderExists(appState: appState)
|
||||
let fileManager = FileManager.default
|
||||
let destinationURL = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!.appendingPathComponent("Pearcleaner").appendingPathComponent("Pearcleaner.zip")
|
||||
try? fileManager.removeItem(at: destinationURL)
|
||||
|
||||
// Check for updates
|
||||
if diskP && diskE {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
|
||||
// Check for disk/accessibility permissions
|
||||
_ = checkAndRequestFullDiskAccess(appState: appState)
|
||||
|
||||
|
||||
// TIMERS ////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Check for app updates every 8 hours or whatever user saved setting. Also refresh autosuggestion list
|
||||
let updateSeconds = updateTimeframe.daysToSeconds
|
||||
_ = Timer.scheduledTimer(withTimeInterval: updateSeconds, repeats: true) { _ in
|
||||
DispatchQueue.main.async {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Group {
|
||||
|
||||
if !mini {
|
||||
AppListView(search: $search)
|
||||
.frame(minWidth: 800, minHeight: 500)
|
||||
} else {
|
||||
MiniMode(search: $search)
|
||||
.frame(minWidth: 300, minHeight: 300)
|
||||
}
|
||||
|
||||
}
|
||||
.environmentObject(appState)
|
||||
.preferredColorScheme(displayMode.colorScheme)
|
||||
.alert(isPresented: $appState.showAlert) { presentAlert(appState: appState) }
|
||||
.handlesExternalEvents(preferring: Set(arrayLiteral: "pear"), allowing: Set(arrayLiteral: "*"))
|
||||
.onAppear {
|
||||
NSWindow.allowsAutomaticWindowTabbing = false
|
||||
|
||||
// Get Apps
|
||||
let sortedApps = getSortedApps()
|
||||
appState.sortedApps.userApps = sortedApps.userApps
|
||||
appState.sortedApps.systemApps = sortedApps.systemApps
|
||||
|
||||
Task {
|
||||
|
||||
#if !DEBUG
|
||||
|
||||
// Make sure App Support folder exists in the future if needed for storage
|
||||
ensureApplicationSupportFolderExists(appState: appState)
|
||||
|
||||
// Check for updates
|
||||
if diskP && diskE {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
|
||||
// Check for disk/accessibility permissions
|
||||
_ = checkAndRequestFullDiskAccess(appState: appState)
|
||||
|
||||
|
||||
// TIMERS ////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Check for app updates every 8 hours or whatever user saved setting. Also refresh autosuggestion list
|
||||
let updateSeconds = updateTimeframe.daysToSeconds
|
||||
_ = Timer.scheduledTimer(withTimeInterval: updateSeconds, repeats: true) { _ in
|
||||
DispatchQueue.main.async {
|
||||
loadGithubReleases(appState: appState)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
.windowStyle(.hiddenTitleBar)
|
||||
@@ -125,6 +83,7 @@ struct PearcleanerApp: App {
|
||||
.commands {
|
||||
AppCommands(appState: appState)
|
||||
CommandGroup(replacing: .newItem, addition: { })
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user