Almost there

This commit is contained in:
Alin
2024-02-29 16:44:44 -07:00
parent faa7ec9457
commit 96f7a1fb5b
26 changed files with 664 additions and 494 deletions
+139 -130
View File
@@ -9,148 +9,157 @@ import SwiftUI
struct AboutSettingsTab: View {
@EnvironmentObject var appState: AppState
var body: some View {
VStack {
HStack(alignment: .center) {
VStack(alignment: .center, spacing: 10){
Spacer()
Image(nsImage: NSApp.applicationIconImage)
.padding()
// .padding(.bottom, 5)
HStack(alignment: .center, spacing: 20) {
Button("") {
loadGithubReleases(appState: appState, manual: true)
}
.buttonStyle(SimpleButtonStyle(icon: "cloud", help: "Update application", color: Color("AccentColor")))
Button("") {
NSWorkspace.shared.open(URL(string: "https://github.com/alienator88/Pearcleaner")!)
}
.buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View repository", color: Color("AccentColor")))
}
Spacer()
}
// .padding()
// .padding(.top, 10)
.frame(width: 250)
VStack(alignment: .center, spacing: 20) {
HStack(alignment: .firstTextBaseline) {
Text(Bundle.main.name)
.font(.title)
.bold()
Spacer()
HStack {
Text("v\(Bundle.main.version)")
Text(" (build \(Bundle.main.buildVersion))")
}
}
Divider()
.padding(.top, -8)
VStack(alignment: .leading) {
HStack{
Image(systemName: "applescript.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
VStack(alignment: .leading){
Text("Privacy Guides")
Text("Inspired by open-source appcleaner script from Sun Knudsen").font(.footnote).foregroundStyle(.gray)
}
Spacer()
Button("") {
NSWorkspace.shared.open(URL(string: "https://sunknudsen.com/privacy-guides/how-to-clean-uninstall-macos-apps-using-appcleaner-open-source-alternative")!)
}
.buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View", color: Color("AccentColor")))
}
.padding()
.background(Color("mode").opacity(0.05))
.cornerRadius(8)
HStack{
Image(systemName: "trash.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
VStack(alignment: .leading){
Text("AppCleaner")
Text("Inspired by AppCleaner from Freemacsoft").font(.footnote).foregroundStyle(.gray)
}
Spacer()
Button(""){
NSWorkspace.shared.open(URL(string: "https://freemacsoft.net/appcleaner/")!)
}
.buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View", color: Color("AccentColor")))
VStack(alignment: .center) {
}
.padding()
.background(Color("mode").opacity(0.05))
.cornerRadius(8)
// HStack{
// Image(systemName: "paintbrush.fill")
// .resizable()
// .aspectRatio(contentMode: .fit)
// .frame(width: 16, height: 16)
// VStack(alignment: .leading){
// Text("Icon")
// Text("Created by Oviotti on DeviantArt").font(.footnote).foregroundStyle(.gray)
// }
// Spacer()
//
// Button("") {
// NSWorkspace.shared.open(URL(string: "https://www.deviantart.com/oviotti/art/AppCleaner-for-macOS-632260251")!)
// }
// .buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View", color: Color("AccentColor")))
//
// }
// .padding()
// .background(Color("mode").opacity(0.05))
// .cornerRadius(8)
}
Spacer()
VStack(alignment: .center, spacing: 10) {
Image(nsImage: NSApp.applicationIconImage)
.padding(.top, 30)
Text(Bundle.main.name)
.font(.title)
.bold()
HStack {
Text("Version \(Bundle.main.version)")
Text("(Build \(Bundle.main.buildVersion))").font(.footnote)
}
.padding(.trailing)
// .padding()
// .padding(.top, 30)
Divider()
.padding()
}
VStack(alignment: .leading) {
HStack() {
Text("Credits and Inspiration").font(.title2)
Spacer()
}
.padding(.leading)
HStack{
Image(systemName: "paintbrush.pointed")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
VStack(alignment: .leading){
Text("Microsoft Designer")
Text("Application icon resource")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
Button(""){
NSWorkspace.shared.open(URL(string: "https://designer.microsoft.com/image-creator")!)
}
.buttonStyle(SimpleButtonStyle(icon: "link", help: "View", color: Color("mode")))
}
.padding(5)
.padding(.leading)
HStack{
Image(systemName: "n.circle")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
VStack(alignment: .leading){
Text("Namelix")
Text("Logo and branding generation")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
Button(""){
NSWorkspace.shared.open(URL(string: "https://namelix.com/")!)
}
.buttonStyle(SimpleButtonStyle(icon: "link", help: "View", color: Color("mode")))
}
.padding(5)
.padding(.leading)
HStack{
Image(systemName: "applescript")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
VStack(alignment: .leading){
Text("Privacy Guides")
Text("Inspired by open-source appcleaner script from Sun Knudsen")
.font(.callout)
.foregroundStyle(.gray)
.lineLimit(2)
}
Spacer()
Button("") {
NSWorkspace.shared.open(URL(string: "https://sunknudsen.com/privacy-guides/how-to-clean-uninstall-macos-apps-using-appcleaner-open-source-alternative")!)
}
.buttonStyle(SimpleButtonStyle(icon: "link", help: "View", color: Color("mode")))
}
.padding(5)
.padding(.leading)
HStack{
Image(systemName: "trash")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
VStack(alignment: .leading){
Text("AppCleaner")
Text("Inspired by AppCleaner from Freemacsoft")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
Button(""){
NSWorkspace.shared.open(URL(string: "https://freemacsoft.net/appcleaner/")!)
}
.buttonStyle(SimpleButtonStyle(icon: "link", help: "View", color: Color("mode")))
}
.padding(5)
.padding(.leading)
Spacer()
}
Spacer()
Text("Made with ❤️ by Alin Lupascu (dev@itsalin.com)").font(.footnote).padding(.bottom)
}
.padding(20)
.frame(width: 750, height: 325)
.frame(width: 500, height: 650)
}
}
extension Bundle {
var name: String {
func string(for key: String) -> String? {
object(forInfoDictionaryKey: key) as? String
@@ -159,14 +168,14 @@ extension Bundle {
?? string(for: "CFBundleName")
?? "N/A"
}
var version: String {
infoDictionary?["CFBundleShortVersionString"] as? String ?? "N/A"
}
var buildVersion: String {
infoDictionary?["CFBundleVersion"] as? String ?? "N/A"
}
}
+213 -64
View File
@@ -18,6 +18,9 @@ struct GeneralSettingsTab: View {
@AppStorage("settings.general.miniview") private var miniView: Bool = true
@AppStorage("settings.general.sidebarWidth") private var sidebarWidth: Double = 280
@AppStorage("displayMode") var displayMode: DisplayMode = .system
@AppStorage("settings.sentinel.enable") private var sentinel: Bool = false
@State private var diskStatus: Bool = false
@State private var accessStatus: Bool = false
@State private var selectedTheme = "Auto"
private let themes = ["Auto", "Dark", "Light"]
@Binding var showPopover: Bool
@@ -25,11 +28,23 @@ struct GeneralSettingsTab: View {
var body: some View {
Form {
VStack {
HStack {
HStack() {
Text("Appearance").font(.title2)
Spacer()
}
.padding(.leading)
HStack(spacing: 0) {
Image(systemName: glass ? "cube.transparent" : "cube.transparent.fill")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
VStack(alignment: .leading, spacing: 5) {
Text("Transparency").font(.title2)
Text("Toggles transparent material")
.font(.footnote)
Text("\(glass ? "Transparent material enabled" : "Transparent material disabled")")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
@@ -37,48 +52,55 @@ struct GeneralSettingsTab: View {
})
.toggleStyle(.switch)
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
HStack {
VStack(alignment: .leading, spacing: 5) {
Text("Sidebar").font(.title2)
Text("Adjust sidebar width")
.font(.footnote)
.foregroundStyle(.gray)
}
HStack(spacing: 0) {
Image(systemName: "sidebar.left")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
Text("Adjust sidebar width")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Slider(value: $sidebarWidth, in: 200...400) {
Text("\(Int(sidebarWidth))")
Slider(value: $sidebarWidth, in: 200...360) {
// Text("\(Int(sidebarWidth))")
}
.padding(.horizontal)
.frame(width: 185)
Button("") {
sidebarWidth = 280
}
.buttonStyle(SimpleButtonStyle(icon: "arrow.uturn.left.circle", help: "Reset to default size", color: Color("mode")))
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
HStack {
HStack(spacing: 0) {
Image(systemName: displayMode.colorScheme == .dark ? "moon.fill" : "sun.max.fill")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
VStack(alignment: .leading, spacing: 5) {
Text("Appearance").font(.title2)
Text("Toggles color mode")
.font(.footnote)
Text("Set color mode")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
Picker("", selection: $selectedTheme) {
ForEach(themes, id: \.self) { theme in
Text(theme)
}
}
.pickerStyle(SegmentedPickerStyle())
// .padding()
.frame(width: 200)
.onChange(of: selectedTheme) { newTheme in
switch newTheme {
case "Auto":
@@ -96,20 +118,33 @@ struct GeneralSettingsTab: View {
break
}
}
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
// =========================================================================================================
Divider()
.padding()
HStack {
HStack() {
Text("Mini Configuration").font(.title2)
Spacer()
}
.padding(.leading)
HStack(spacing: 0) {
Image(systemName: mini ? "square.resize.up" : "square.resize.down")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
VStack(alignment: .leading, spacing: 5) {
Text("Mini").font(.title2)
Text("Toggles a smaller, unified view with hidden app list")
.font(.footnote)
Text("\(mini ? "Mini window mode" : "Full size window mode")")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
@@ -131,18 +166,20 @@ struct GeneralSettingsTab: View {
}
}
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
HStack {
HStack(spacing: 0) {
Image(systemName: miniView ? "square.grid.3x3.square" : "plus.square.dashed")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
VStack(alignment: .leading, spacing: 5) {
Text("Mini - \(miniView ? "Apps List" : "Drop Target")").font(.title2)
Text("Toggles drop target or apps list view on launch")
.font(.footnote)
Text("\(miniView ? "Show apps list on startup" : "Show drop target on startup")")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
@@ -153,17 +190,20 @@ struct GeneralSettingsTab: View {
appState.currentView = newVal ? .apps : .empty
}
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
HStack {
HStack(spacing: 0) {
Image(systemName: popoverStay ? "pin" : "pin.slash")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(.gray)
VStack(alignment: .leading, spacing: 5) {
Text("Mini - \(popoverStay ? "Popover on Top" : "Popover not on Top")").font(.title2)
Text("Keeps file search popover on top in mini mode")
.font(.footnote)
Text("\(popoverStay ? "Popover window doesn't hide on outside click" : "Popover window hides on outside click")")
.font(.callout)
.foregroundStyle(.gray)
}
Spacer()
@@ -171,21 +211,130 @@ struct GeneralSettingsTab: View {
})
.toggleStyle(.switch)
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
.padding(.leading)
// =========================================================================================================
Divider()
.padding()
HStack() {
Text("Permissions").font(.title2)
Spacer()
}
.padding(.leading)
HStack(spacing: 0) {
Image(systemName: diskStatus ? "externaldrive" : "externaldrive")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(diskStatus ? .green : .red)
.saturation(displayMode.colorScheme == .dark ? 0.5 : 1)
Text(diskStatus ? "Full Disk permission granted" : "Full Disk permission **NOT** granted")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Button("") {
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles") {
NSWorkspace.shared.open(url)
}
}
.buttonStyle(SimpleButtonStyle(icon: "folder", help: "View disk permissions pane", color: Color("mode")))
}
.padding(5)
.padding(.leading)
HStack(spacing: 0) {
Image(systemName: accessStatus ? "accessibility" : "accessibility")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(accessStatus ? .green : .red)
.saturation(displayMode.colorScheme == .dark ? 0.5 : 1)
Text(accessStatus ? "Accessibility permission granted" : "Accessibility permission **NOT** granted")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Button("") {
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
NSWorkspace.shared.open(url)
}
}
.buttonStyle(SimpleButtonStyle(icon: "folder", help: "View accessibility permissions pane", color: Color("mode")))
}
.padding(5)
.padding(.leading)
// =========================================================================================================
Divider()
.padding()
HStack() {
Text("Sentinel Monitor").font(.title2)
Spacer()
}
.padding(.leading)
HStack(spacing: 0) {
Image(systemName: sentinel ? "eye.circle" : "eye.slash.circle")
.resizable()
.scaledToFit()
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(sentinel ? .green : .red)
.saturation(displayMode.colorScheme == .dark ? 0.5 : 1)
Text(sentinel ? "Detecting when apps are moved to Trash" : "**NOT** detecting when apps are moved to Trash")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Toggle(isOn: $sentinel, label: {
})
.toggleStyle(.switch)
.onChange(of: sentinel) { newValue in
if newValue {
launchctl(load: true)
} else {
launchctl(load: false)
}
}
}
.padding(5)
.padding(.leading)
Spacer()
}
.onAppear {
diskStatus = checkAndRequestFullDiskAccess(appState: appState, skipAlert: true)
accessStatus = checkAndRequestAccessibilityAccess(appState: appState)
}
}
.padding(20)
.frame(width: 400, height: 500)
.frame(width: 500, height: 650)
}
+85 -39
View File
@@ -18,63 +18,109 @@ struct PermissionsSettingsTab: View {
var body: some View {
Form {
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 15) {
Image(systemName: "internaldrive")
HStack(spacing: 0) {
Image(systemName: diskStatus ? "externaldrive" : "externaldrive")
.resizable()
.scaledToFit()
.frame(width: 20)
VStack(alignment: .leading, spacing: 5) {
Text("Full Disk")
Text(diskStatus ? "Permission granted" : "Permission not granted")
.font(.footnote)
.foregroundStyle(diskStatus ? .green : .red)
}
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(diskStatus ? .green : .red)
Text(diskStatus ? "Full Disk permission granted" : "Full Disk permission not granted")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Button("") {
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles") {
NSWorkspace.shared.open(url)
}
}
.buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View disk permission pane", color: Color("AccentColor")))
.buttonStyle(SimpleButtonStyle(icon: "gear", help: "View disk permissions pane", color: Color("mode")))
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
HStack(spacing: 15) {
Image(systemName: "accessibility")
.padding(5)
HStack(spacing: 0) {
Image(systemName: accessStatus ? "accessibility" : "accessibility")
.resizable()
.scaledToFit()
.frame(width: 20)
VStack(alignment: .leading, spacing: 5) {
Text("Accessibility")
Text(accessStatus ? "Permission granted" : "Permission not granted")
.font(.footnote)
.foregroundStyle(accessStatus ? .green : .red)
}
.frame(width: 20, height: 20)
.padding(.trailing)
.foregroundStyle(accessStatus ? .green : .red)
Text(accessStatus ? "Accessibility permission granted" : "Accessibility permission not granted")
.font(.callout)
.foregroundStyle(.gray)
Spacer()
Button("") {
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
NSWorkspace.shared.open(url)
}
}
.buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View accessibility pane", color: Color("AccentColor")))
.buttonStyle(SimpleButtonStyle(icon: "gear", help: "View accessibility permissions pane", color: Color("mode")))
}
.padding()
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color("mode").opacity(0.05))
)
.padding(5)
// HStack(spacing: 15) {
// Image(systemName: "internaldrive")
// .resizable()
// .scaledToFit()
// .frame(width: 20)
//
// VStack(alignment: .leading, spacing: 5) {
// Text("Full Disk")
// Text(diskStatus ? "Permission granted" : "Permission not granted")
// .font(.footnote)
// .foregroundStyle(diskStatus ? .green : .red)
// }
//
// Spacer()
//
// Button("") {
// if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles") {
// NSWorkspace.shared.open(url)
// }
// }
// .buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View disk permission pane", color: Color("AccentColor")))
// }
// .padding()
// .background(
// RoundedRectangle(cornerRadius: 8)
// .fill(Color("mode").opacity(0.05))
// )
// HStack(spacing: 15) {
// Image(systemName: "accessibility")
// .resizable()
// .scaledToFit()
// .frame(width: 20)
//
// VStack(alignment: .leading, spacing: 5) {
// Text("Accessibility")
// Text(accessStatus ? "Permission granted" : "Permission not granted")
// .font(.footnote)
// .foregroundStyle(accessStatus ? .green : .red)
// }
//
// Spacer()
//
// Button("") {
// if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
// NSWorkspace.shared.open(url)
// }
// }
// .buttonStyle(SimpleButtonStyle(icon: "paperplane", help: "View accessibility pane", color: Color("AccentColor")))
// }
// .padding()
// .background(
// RoundedRectangle(cornerRadius: 8)
// .fill(Color("mode").opacity(0.05))
// )
+11 -11
View File
@@ -20,21 +20,21 @@ struct SettingsView: View {
}
.tag(CurrentTabView.general)
PermissionsSettingsTab()
.tabItem {
Label(CurrentTabView.permissions.title, systemImage: "lock")
}
.tag(CurrentTabView.permissions)
// PermissionsSettingsTab()
// .tabItem {
// Label(CurrentTabView.permissions.title, systemImage: "lock")
// }
// .tag(CurrentTabView.permissions)
SentinelSettingsTab()
.tabItem {
Label(CurrentTabView.sentinel.title, systemImage: "eye.circle")
}
.tag(CurrentTabView.sentinel)
// SentinelSettingsTab()
// .tabItem {
// Label(CurrentTabView.sentinel.title, systemImage: "eye.circle")
// }
// .tag(CurrentTabView.sentinel)
UpdateSettingsTab()
.tabItem {
Label(CurrentTabView.update.title, systemImage: "tray.and.arrow.down")
Label(CurrentTabView.update.title, systemImage: "cloud")
}
.tag(CurrentTabView.update)
+18 -11
View File
@@ -63,24 +63,31 @@ struct UpdateSettingsTab: View {
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
Text("Showing last 3").opacity(0.5).font(.footnote)
Text("Showing last 3 releases")
.font(.callout)
.foregroundStyle(.gray)
HStack(alignment: .center, spacing: 5) {
HStack(alignment: .center, spacing: 20) {
Spacer()
Button("Check"){
Button("Update Notes"){
loadGithubReleases(appState: appState)
}.buttonStyle(BorderedButtonStyle())
}
.buttonStyle(SimpleButtonStyle(icon: "list.bullet", help: "Check release notes", color: Color("mode")))
Button("Force Update"){
loadGithubReleases(appState: appState, manual: true)
}.buttonStyle(BorderedButtonStyle())
}
.buttonStyle(SimpleButtonStyle(icon: "arrow.down.square", help: "Check for updates", color: Color("mode")))
Button("GitHub"){
NSWorkspace.shared.open(URL(string: "https://github.com/alienator88/Pearcleaner/releases")!)
}.buttonStyle(BorderedButtonStyle())
}
.buttonStyle(SimpleButtonStyle(icon: "link", help: "View releases on GitHub", color: Color("mode")))
Spacer()
}
@@ -90,7 +97,7 @@ struct UpdateSettingsTab: View {
}
.padding(20)
.frame(width: 500, height: 400)
.frame(width: 500, height: 650)
}
}