diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index b62be2c..5eab03a 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -517,7 +517,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -534,7 +534,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -551,7 +551,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; ENABLE_HARDENED_RUNTIME = YES; @@ -568,7 +568,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Pearcleaner/Logic/Styles.swift b/Pearcleaner/Logic/Styles.swift index 34f1393..803c379 100644 --- a/Pearcleaner/Logic/Styles.swift +++ b/Pearcleaner/Logic/Styles.swift @@ -13,7 +13,15 @@ struct SimpleButtonStyle: ButtonStyle { let icon: String let help: String let color: Color - + let shield: Bool? + + init(icon: String, help: String, color: Color, shield: Bool? = nil) { + self.icon = icon + self.help = help + self.color = color + self.shield = shield + } + func makeBody(configuration: Self.Configuration) -> some View { HStack { Image(systemName: icon) @@ -24,7 +32,7 @@ struct SimpleButtonStyle: ButtonStyle { } .padding(8) .background { - if hovered { + if hovered && !(shield ?? false) { // Circle() // .strokeBorder(Color("AccentColor"), lineWidth: 1) RoundedRectangle(cornerRadius: 8) @@ -250,9 +258,73 @@ struct WindowActionButton: ButtonStyle { +struct SentinelToggleStyle: ToggleStyle { + + func makeBody(configuration: Configuration) -> some View { + + HStack { + + ZStack{ + RoundedRectangle(cornerRadius: 50) + .fill(configuration.isOn ? greenBG : redBG) + .frame(width: 70, height: 40) + HStack{ + Image(systemName: "lock.shield") + .resizable() + .scaledToFit() + .frame(width: 26, height: 26) + .padding(.leading, 10) + .foregroundColor(.white) + Spacer() + Image(systemName: "shield") + .resizable() + .scaledToFit() + .frame(width: 26, height: 26) + .padding(.trailing, 10) + .foregroundColor(.white) + } + + } + .frame(width: 70, height: 40, alignment: .center) + .overlay( + Circle() + .foregroundColor(.white) + .shadow(color: .black.opacity(0.5), radius: 3, x: 0, y: 0) + .padding(.all, 4) + .offset(x: configuration.isOn ? 15 : -15, y: 0) + ) + .overlay( + Image(systemName: "power") + .resizable() + .scaledToFit() + .frame(width: 20, height: 20) + .foregroundColor(.black.opacity(0.3)) + .offset(x: configuration.isOn ? 15 : -15, y: 0) + ) + .onTapGesture { + withAnimation(.easeInOut(duration: 0.5)) { + configuration.isOn.toggle() + } + } + .animation(.default, value: configuration.isOn) + } + + + } + +} +private let greenBG: AnyShapeStyle = AnyShapeStyle( + .green.shadow(.inner(radius: 2, x: 0, y: 1)) +) + +private let redBG: AnyShapeStyle = AnyShapeStyle( + .red.shadow(.inner(radius: 2, x: 0, y: 1)) +) + + // Picker //struct PillPicker: View { diff --git a/Pearcleaner/PearcleanerApp.swift b/Pearcleaner/PearcleanerApp.swift index ae686f0..231a701 100644 --- a/Pearcleaner/PearcleanerApp.swift +++ b/Pearcleaner/PearcleanerApp.swift @@ -40,7 +40,7 @@ struct PearcleanerApp: App { #if !DEBUG // Make sure App Support folder exists in the future if needed for storage -// ensureApplicationSupportFolderExists(appState: appState) + ensureApplicationSupportFolderExists(appState: appState) // Check for updates if diskP && diskE { diff --git a/Pearcleaner/Settings/Sentinel.swift b/Pearcleaner/Settings/Sentinel.swift index 8b8e253..7f636e9 100644 --- a/Pearcleaner/Settings/Sentinel.swift +++ b/Pearcleaner/Settings/Sentinel.swift @@ -25,7 +25,7 @@ struct SentinelSettingsTab: View { Spacer() Toggle(isOn: $sentinel, label: { }) - .toggleStyle(.switch) + .toggleStyle(SentinelToggleStyle()) .onChange(of: sentinel) { newValue in if newValue { launchctl(load: true) @@ -45,7 +45,7 @@ struct SentinelSettingsTab: View { } .padding(20) - .frame(width: 400, height: 100) + .frame(width: 450, height: 100) } diff --git a/Pearcleaner/Views/TopBar.swift b/Pearcleaner/Views/TopBar.swift index 8ff1c75..9137f45 100644 --- a/Pearcleaner/Views/TopBar.swift +++ b/Pearcleaner/Views/TopBar.swift @@ -13,6 +13,7 @@ struct TopBar: View { @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 @EnvironmentObject var appState: AppState var body: some View { @@ -75,6 +76,15 @@ struct TopBar: View { Spacer() HStack(alignment: .center, spacing: 5) { + + if sentinel { + Button("") { + // + } + .buttonStyle(SimpleButtonStyle(icon: "lock.shield", help: "Sentinel enabled", color: .green, shield: true)) + } + + Button("") { withAnimation(.easeInOut(duration: 0.5)) { glass.toggle()