diff --git a/Geranium.xcodeproj/project.xcworkspace/xcuserdata/cclerc.xcuserdatad/UserInterfaceState.xcuserstate b/Geranium.xcodeproj/project.xcworkspace/xcuserdata/cclerc.xcuserdatad/UserInterfaceState.xcuserstate index cea58fe..0f89fed 100644 Binary files a/Geranium.xcodeproj/project.xcworkspace/xcuserdata/cclerc.xcuserdatad/UserInterfaceState.xcuserstate and b/Geranium.xcodeproj/project.xcworkspace/xcuserdata/cclerc.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Geranium/Cleaner/CleanerView.swift b/Geranium/Cleaner/CleanerView.swift index 68af326..feafa38 100644 --- a/Geranium/Cleaner/CleanerView.swift +++ b/Geranium/Cleaner/CleanerView.swift @@ -10,6 +10,8 @@ import SwiftUI struct CleanerView: View { @Binding var isTabViewHidden: Bool + @State var exitStatus = false + @State var loadingBarStatus = false @State var buttonAndSelection = true @State private var safariCacheSize: Double = 0 @State private var GlobalCacheSize: Double = 0 @@ -31,139 +33,147 @@ struct CleanerView: View { // OTA Update @State public var OTAPath = "/var/MobileSoftwareUpdate/MobileAsset/AssetsV2/com_apple_MobileAsset_SoftwareUpdate/" var body: some View { - NavigationView { - VStack { - if buttonAndSelection { - if progressAmount >= 0.9 { - Image(systemName: "checkmark") - .foregroundColor(.green) - Text("Done !") - .foregroundStyle(.green) - Button("Exit", action: { + if #available(iOS 16.0, *), UIDevice.current.userInterfaceIdiom == .pad { + cleanerViewMain() + } else { + NavigationView { + cleanerViewMain() + } + } + } + @ViewBuilder + private func cleanerViewMain() -> some View { + VStack { + if buttonAndSelection { + if progressAmount >= 0.9 { + Image(systemName: "checkmark") + .foregroundColor(.green) + Text("Done !") + .foregroundStyle(.green) + Button("Exit", action: { + withAnimation { + isTabViewHidden.toggle() + progressAmount = 0 + safariCacheSize = 0 + GlobalCacheSize = 0 + OTACacheSize = 0 + progressAmount = 0 + } + }) + .padding(10) + .background(.green) + .cornerRadius(8) + .foregroundColor(.black) + .transition(.scale) + } + else { + Button("Clean !", action: { + UIApplication.shared.confirmAlert(title: "Selected options", body: "Safari Caches: \(truelyEnabled(safari))\nGeneral Caches: \(truelyEnabled(appCaches))\nOTA Update Caches: \(truelyEnabled(otaCaches))\nBattery Usage Data: \(truelyEnabled(batteryUsageDat))\n Are you sure you want to permanently delete those files ?", onOK: { + print("") withAnimation { + buttonAndSelection.toggle() isTabViewHidden.toggle() - progressAmount = 0 - safariCacheSize = 0 - GlobalCacheSize = 0 - OTACacheSize = 0 - progressAmount = 0 } - }) - .padding(10) - .background(.green) - .cornerRadius(8) - .foregroundColor(.black) - .transition(.scale) + }, noCancel: false, yes: true) + }) + .padding(10) + .background(Color.accentColor) + .cornerRadius(8) + .foregroundColor(.black) + .transition(.scale) + Toggle(isOn: $safari) { + Image(systemName: "safari") + Text("Safari Caches") + Text(String(format: "%.2f MB", safariCacheSize / (1024 * 1024))) } - else { - Button("Clean !", action: { - UIApplication.shared.confirmAlert(title: "Selected options", body: "Safari Caches: \(truelyEnabled(safari))\nGeneral Caches: \(truelyEnabled(appCaches))\nOTA Update Caches: \(truelyEnabled(otaCaches))\nBattery Usage Data: \(truelyEnabled(batteryUsageDat))\n Are you sure you want to permanently delete those files ?", onOK: { - print("") - withAnimation { - buttonAndSelection.toggle() - isTabViewHidden.toggle() - } - }, noCancel: false, yes: true) - }) - .padding(10) - .background(Color.accentColor) - .cornerRadius(8) - .foregroundColor(.black) - .transition(.scale) - Toggle(isOn: $safari) { - Image(systemName: "safari") - Text("Safari Caches") - Text(String(format: "%.2f MB", safariCacheSize / (1024 * 1024))) + .toggleStyle(checkboxiOS()) + .padding(2) + .onAppear { + calculateDirectorySizeAsync(url: URL(fileURLWithPath: safariCachePath)) { size in + safariCacheSize = size } - .toggleStyle(checkboxiOS()) - .padding(2) - .onAppear { - calculateDirectorySizeAsync(url: URL(fileURLWithPath: safariCachePath)) { size in - safariCacheSize = size - } + } + Toggle(isOn: $appCaches) { + Image(systemName: "app.dashed") + Text("General Caches") + Text(String(format: "%.2f MB", GlobalCacheSize / (1024 * 1024))) + } + .toggleStyle(checkboxiOS()) + .padding(2) + .onAppear { + progressAmount = 0 + safariCacheSize = 0 + GlobalCacheSize = 0 + OTACacheSize = 0 + progressAmount = 0 + // mess + calculateDirectorySizeAsync(url: URL(fileURLWithPath: logCachesPath)) { size in + GlobalCacheSize += size } - Toggle(isOn: $appCaches) { - Image(systemName: "app.dashed") - Text("General Caches") - Text(String(format: "%.2f MB", GlobalCacheSize / (1024 * 1024))) + calculateDirectorySizeAsync(url: URL(fileURLWithPath: logmobileCachesPath)) { size in + GlobalCacheSize += size } - .toggleStyle(checkboxiOS()) - .padding(2) - .onAppear { - progressAmount = 0 - safariCacheSize = 0 - GlobalCacheSize = 0 - OTACacheSize = 0 - progressAmount = 0 - // mess - calculateDirectorySizeAsync(url: URL(fileURLWithPath: logCachesPath)) { size in - GlobalCacheSize += size - } - calculateDirectorySizeAsync(url: URL(fileURLWithPath: logmobileCachesPath)) { size in - GlobalCacheSize += size - } - calculateDirectorySizeAsync(url: URL(fileURLWithPath: tmpCachesPath)) { size in - GlobalCacheSize += size - } - calculateDirectorySizeAsync(url: URL(fileURLWithPath: phototmpCachePath)) { size in - GlobalCacheSize += size - } - calculateDirectorySizeAsync(url: URL(fileURLWithPath: logsCachesPath)) { size in - GlobalCacheSize += size - } - calculateDirectorySizeAsync(url: URL(fileURLWithPath: globalCachesPath)) { size in - GlobalCacheSize += size - } + calculateDirectorySizeAsync(url: URL(fileURLWithPath: tmpCachesPath)) { size in + GlobalCacheSize += size } - - Toggle(isOn: $otaCaches) { - Image(systemName: "restart.circle") - Text("OTA Update Caches") - Text(String(format: "%.2f MB", OTACacheSize / (1024 * 1024))) + calculateDirectorySizeAsync(url: URL(fileURLWithPath: phototmpCachePath)) { size in + GlobalCacheSize += size } - .toggleStyle(checkboxiOS()) - .padding(2) - .onAppear { - calculateDirectorySizeAsync(url: URL(fileURLWithPath: OTAPath)) { size in - OTACacheSize = size - } + calculateDirectorySizeAsync(url: URL(fileURLWithPath: logsCachesPath)) { size in + GlobalCacheSize += size } - - Toggle(isOn: $batteryUsageDat) { - Image(systemName: "battery.100percent") - Text("Battery Usage Data") + calculateDirectorySizeAsync(url: URL(fileURLWithPath: globalCachesPath)) { size in + GlobalCacheSize += size } - .toggleStyle(checkboxiOS()) - .padding(2) } - } - - if !buttonAndSelection { - ProgressBar(value: progressAmount) - .padding(.leading, 50) - .padding(.trailing, 50) - .onAppear { - performCleanup() - if safari { - print("safari") - deleteContentsOfDirectory(atPath: safariCachePath) - } - if appCaches { - print("appcaches") - deleteContentsOfDirectory(atPath: logmobileCachesPath) - deleteContentsOfDirectory(atPath: logCachesPath) - deleteContentsOfDirectory(atPath: logsCachesPath) - deleteContentsOfDirectory(atPath: tmpCachesPath) - deleteContentsOfDirectory(atPath: phototmpCachePath) - deleteContentsOfDirectory(atPath: globalCachesPath) - } - if otaCaches { - print("otacaches") - deleteContentsOfDirectory(atPath: OTAPath) - } + + Toggle(isOn: $otaCaches) { + Image(systemName: "restart.circle") + Text("OTA Update Caches") + Text(String(format: "%.2f MB", OTACacheSize / (1024 * 1024))) + } + .toggleStyle(checkboxiOS()) + .padding(2) + .onAppear { + calculateDirectorySizeAsync(url: URL(fileURLWithPath: OTAPath)) { size in + OTACacheSize = size } + } + + Toggle(isOn: $batteryUsageDat) { + Image(systemName: "battery.100percent") + Text("Battery Usage Data") + } + .toggleStyle(checkboxiOS()) + .padding(2) } } + + if !buttonAndSelection { + ProgressBar(value: progressAmount) + .padding(.leading, 50) + .padding(.trailing, 50) + .onAppear { + performCleanup() + if safari { + print("safari") + deleteContentsOfDirectory(atPath: safariCachePath) + } + if appCaches { + print("appcaches") + deleteContentsOfDirectory(atPath: logmobileCachesPath) + deleteContentsOfDirectory(atPath: logCachesPath) + deleteContentsOfDirectory(atPath: logsCachesPath) + deleteContentsOfDirectory(atPath: tmpCachesPath) + deleteContentsOfDirectory(atPath: phototmpCachePath) + deleteContentsOfDirectory(atPath: globalCachesPath) + } + if otaCaches { + print("otacaches") + deleteContentsOfDirectory(atPath: OTAPath) + } + } + } } .navigationBarTitle("Cleaner") } diff --git a/Geranium/DaemonMan/DaemonView.swift b/Geranium/DaemonMan/DaemonView.swift index 7f5e595..2e7d6bf 100644 --- a/Geranium/DaemonMan/DaemonView.swift +++ b/Geranium/DaemonMan/DaemonView.swift @@ -27,37 +27,46 @@ struct DaemonView: View { init() { self.processes = [] } - var body: some View { - NavigationView { - List { - SearchBar(text: $searchText) - - ForEach(filteredProcesses) { process in - HStack { - Text("PID: \(process.pid)") - Spacer() - Text("Name: \(process.procName)") - } + if #available(iOS 16.0, *) { + NavigationStack { + DaemonMainView() } - .onDelete { indexSet in - guard let index = indexSet.first else { return } - let process = filteredProcesses[index] - //MARK: Probably the WORST EVER WAY to define a daemon's bundle ID. I'll try over objc s0n - daemonManagement(key: "com.apple.\(process.procName)",value: true, plistPath: "/var/db/com.apple.xpc.launchd/disabled.plist") - killall(process.procName) - updateProcesses() - UIApplication.shared.alert(title: "\(process.procName) was successfuly disabled in launchd database", body: "This daemon won't launch next startup.") + } else { + NavigationView { + DaemonMainView() } } - .navigationTitle("Daemons") - .onAppear { - startTimer() + } + @ViewBuilder + private func DaemonMainView() -> some View { + List { + SearchBar(text: $searchText) + + ForEach(filteredProcesses) { process in + HStack { + Text("PID: \(process.pid)") + Spacer() + Text("Name: \(process.procName)") + } } - .onDisappear { - stopTimer() + .onDelete { indexSet in + guard let index = indexSet.first else { return } + let process = filteredProcesses[index] + //MARK: Probably the WORST EVER WAY to define a daemon's bundle ID. I'll try over objc s0n + daemonManagement(key: "com.apple.\(process.procName)",value: true, plistPath: "/var/db/com.apple.xpc.launchd/disabled.plist") + killall(process.procName) + updateProcesses() + UIApplication.shared.alert(title: "\(process.procName) was successfuly disabled in launchd database", body: "This daemon won't launch next startup.") } } + .navigationTitle("Daemons") + .onAppear { + startTimer() + } + .onDisappear { + stopTimer() + } } private func startTimer() { diff --git a/Geranium/HomeView.swift b/Geranium/HomeView.swift index 7b485e5..72a3261 100644 --- a/Geranium/HomeView.swift +++ b/Geranium/HomeView.swift @@ -14,97 +14,107 @@ struct HomeView: View { @State var isDebugSheetOn = false @State var DebugStuff = false var body: some View { - NavigationView { + if #available(iOS 16.0, *) { + NavigationStack { + homeMainView() + } + } else { + NavigationView { + homeMainView() + } + } + } + + @ViewBuilder + private func homeMainView() -> some View { + VStack { VStack { - VStack { - Text("") - .padding(.bottom, 20) - Image(uiImage: Bundle.main.icon!) - .cornerRadius(10) - Text("Geranium") - .font(.title2) - - Text("made by c22dev") - .font(.footnote) - .foregroundColor(.secondary) - .padding(.bottom) - Button("Respring", action: { - respring() - }) - .padding() - Button("Rebuild Icon Cache", action: { - UIApplication.shared.alert(title:"Rebuilding Icon Cache...", body:"Please wait, your phone until your phone repsrings.") - var output = RootHelper.rebuildIconCache() - print(output) - respring() - }) - .padding(.bottom, 24) + Text("") + .padding(.bottom, 20) + Image(uiImage: Bundle.main.icon!) + .cornerRadius(10) + Text("Geranium") + .font(.title2) + + Text("made by c22dev") + .font(.footnote) + .foregroundColor(.secondary) + .padding(.bottom) + Button("Respring", action: { + respring() + }) + .padding() + Button("Rebuild Icon Cache", action: { + UIApplication.shared.alert(title:"Rebuilding Icon Cache...", body:"Please wait, your phone until your phone repsrings.", withButton: false) + var output = RootHelper.rebuildIconCache() + print(output) + }) + .padding(.bottom, 24) + } + ZStack { + if colorScheme == .dark { + Color.black + .ignoresSafeArea() } - ZStack { - if colorScheme == .dark { - Color.black - .ignoresSafeArea() - } - else { - Color.white - .ignoresSafeArea() - } - Text("") - List { - Section (header: Text("Credits")) { - LinkCell(imageLink: "https://cdn.discordapp.com/avatars/470637062870269952/67eb5d0a0501a96ab0a014ae89027e32.webp?size=160", url: "https://github.com/bomberfish", title: "BomberFish") - LinkCell(imageLink: "https://cdn.discordapp.com/avatars/396496265430695947/0904860dfb31d8b1f39f0e7dc4832b1e.webp?size=160", url: "https://github.com/donato-fiore", title: "fiore") - LinkCell(imageLink: "https://cdn.discordapp.com/avatars/412187004407775242/1df69ac879b9e5f98396553eeac80cec.webp?size=160", url: "https://github.com/sourcelocation", title: "sourcelocation") - } + else { + Color.white + .ignoresSafeArea() + } + Text("") + List { + Section (header: Text("Credits")) { + LinkCell(imageLink: "https://cdn.discordapp.com/avatars/470637062870269952/67eb5d0a0501a96ab0a014ae89027e32.webp?size=160", url: "https://github.com/bomberfish", title: "BomberFish") + LinkCell(imageLink: "https://cdn.discordapp.com/avatars/396496265430695947/0904860dfb31d8b1f39f0e7dc4832b1e.webp?size=160", url: "https://github.com/donato-fiore", title: "fiore") + LinkCell(imageLink: "https://cdn.discordapp.com/avatars/412187004407775242/1df69ac879b9e5f98396553eeac80cec.webp?size=160", url: "https://github.com/sourcelocation", title: "sourcelocation") } - // https://stackoverflow.com/a/75516471 - .simultaneousGesture(DragGesture(minimumDistance: 0), including: .all) } + // https://stackoverflow.com/a/75516471 + .simultaneousGesture(DragGesture(minimumDistance: 0), including: .all) } - .toolbar{ - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: { - isDebugSheetOn.toggle() - }) { - Image(systemName: "hammer") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 24, height: 24) - } + } + .toolbar{ + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: { + isDebugSheetOn.toggle() + }) { + Image(systemName: "hammer") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 24, height: 24) } } - .sheet(isPresented: $isDebugSheetOn) { - NavigationView { - List { - Section(header: - HStack { - Image(systemName: "chevron.left.forwardslash.chevron.right") - Text("Debug Stuff") - }, footer: Text("This setting allows you to see experimental values from some app variables.") - ) { - Toggle(isOn: $DebugStuff) { - Text("Debug Info") - } - if DebugStuff { - Text("RootHelper Path : \(RootHelper.whatsthePath())") - } + } + .sheet(isPresented: $isDebugSheetOn) { + NavigationView { + List { + Section(header: + HStack { + Image(systemName: "chevron.left.forwardslash.chevron.right") + Text("Debug Stuff") + }, footer: Text("This setting allows you to see experimental values from some app variables.") + ) { + Toggle(isOn: $DebugStuff) { + Text("Debug Info") + } + if DebugStuff { + Text("RootHelper Path : \(RootHelper.whatsthePath())") } - Section(header: - HStack { - Image(systemName: "play") - Text("Startup Settings") - }, footer: Text("This will personalize app startup pop-ups. Useful for debugging on Simulator or for betas.") + } + Section(header: + HStack { + Image(systemName: "play") + Text("Startup Settings") + }, footer: Text("This will personalize app startup pop-ups. Useful for debugging on Simulator or for betas.") ) { - Toggle(isOn: $tsBypass) { - Text("Bypass TrollStore Pop Up") - } - Toggle(isOn: $updBypass) { - Text("Bypass App Update Pop Up") - } + Toggle(isOn: $tsBypass) { + Text("Bypass TrollStore Pop Up") + } + Toggle(isOn: $updBypass) { + Text("Bypass App Update Pop Up") } } - .navigationTitle("Settings") } + .navigationTitle("Settings") } } } diff --git a/Geranium/LocSim/LocationSimulationView.swift b/Geranium/LocSim/LocationSimulationView.swift index 0fa6513..dd95666 100644 --- a/Geranium/LocSim/LocationSimulationView.swift +++ b/Geranium/LocSim/LocationSimulationView.swift @@ -30,7 +30,19 @@ struct LocationSimulationView: View { @State private var tappedCoordinate: EquatableCoordinate? = nil @State private var selectedKey: String? var body: some View { - NavigationView{ + if #available(iOS 16.0, *) { + NavigationStack { + LocSimMainView() + } + } else { + NavigationView { + LocSimMainView() + } + } + } + + @ViewBuilder + private func LocSimMainView() -> some View { VStack { TextField("Enter latitude", text: $lat) .textFieldStyle(RoundedBorderTextFieldStyle()) @@ -143,7 +155,6 @@ struct LocationSimulationView: View { } } } - } .onChange(of: tappedCoordinate) { newValue in if let coordinate = newValue { lat = String(coordinate.coordinate.latitude) diff --git a/Geranium/The Supviser/SuperviseView.swift b/Geranium/The Supviser/SuperviseView.swift index afc39fc..2b04334 100644 --- a/Geranium/The Supviser/SuperviseView.swift +++ b/Geranium/The Supviser/SuperviseView.swift @@ -12,7 +12,18 @@ struct SuperviseView: View { @State var plistContent = " AllowPairing CloudConfigurationUIComplete ConfigurationSource 0 IsSupervised PostSetupProfileWasInstalled " @State var supervisePath = "/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles/CloudConfigurationDetails.plist" var body: some View { - NavigationView { + if #available(iOS 16.0, *) { + NavigationStack { + SuperviseMainView() + } + } else { + NavigationView { + SuperviseMainView() + } + } + } + @ViewBuilder + private func SuperviseMainView() -> some View { VStack { TextField("Enter organisation name...", text: $organisation_name) .textFieldStyle(RoundedBorderTextFieldStyle()) @@ -68,9 +79,8 @@ struct SuperviseView: View { .background(Color.accentColor) .cornerRadius(8) .foregroundColor(.black) + .navigationBarTitle("The Superviser") } - .navigationBarTitle("The Superviser") - } } }