From d835a401994fc21a655a1bed97f33301d408be12 Mon Sep 17 00:00:00 2001 From: leminlimez <59540996+leminlimez@users.noreply.github.com> Date: Wed, 18 Jun 2025 19:09:10 -0400 Subject: [PATCH] ui improvements + fix error popups not showing --- Pocket Poster/Pocket_PosterApp.swift | 13 +++-------- Pocket Poster/Views/ContentView.swift | 22 ++++++------------- .../Views/NavigatorViews/VideoView.swift | 4 ++-- Pocket Poster/Views/SettingsView.swift | 21 ++++-------------- 4 files changed, 16 insertions(+), 44 deletions(-) diff --git a/Pocket Poster/Pocket_PosterApp.swift b/Pocket Poster/Pocket_PosterApp.swift index 22437f0..d2f68aa 100644 --- a/Pocket Poster/Pocket_PosterApp.swift +++ b/Pocket Poster/Pocket_PosterApp.swift @@ -14,7 +14,6 @@ struct Pocket_PosterApp: App { @AppStorage("pbHash") var pbHash: String = "" @State var downloadURL: String? = nil - @State var showDownloadAlert = false var body: some Scene { WindowGroup { @@ -27,14 +26,6 @@ struct Pocket_PosterApp: App { } .transition(.opacity) .animation(.easeOut(duration: 0.5), value: finishedTutorial) - .alert("Download Tendies File", isPresented: $showDownloadAlert) { - Button("OK") { - downloadWallpaper() - } - Button("Cancel", role: .cancel) {} - } message: { - Text("Would you like to download the file \(DownloadManager.getWallpaperNameFromURL(string: downloadURL ?? "/Unknown"))?") - } .onOpenURL(perform: { url in // Download URL if url.absoluteString.starts(with: "pocketposter://download") { @@ -45,7 +36,9 @@ struct Pocket_PosterApp: App { UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.") } else { downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "") - showDownloadAlert = true + UIApplication.shared.confirmAlert(title: "Download Tendies File", body: "Would you like to download the file \(DownloadManager.getWallpaperNameFromURL(string: downloadURL ?? "/Unknown"))?", onOK: { + downloadWallpaper() + }, noCancel: false) } } // App Hash URL diff --git a/Pocket Poster/Views/ContentView.swift b/Pocket Poster/Views/ContentView.swift index 11035aa..8936961 100644 --- a/Pocket Poster/Views/ContentView.swift +++ b/Pocket Poster/Views/ContentView.swift @@ -24,9 +24,6 @@ struct ContentView: View { private let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" @State var showTendiesImporter: Bool = false - - @State var showErrorAlert = false - @State var lastError: String? @State var hideResetHelp: Bool = true var body: some View { @@ -42,7 +39,7 @@ struct ContentView: View { UIImpactFeedbackGenerator(style: .soft).impactOccurred() showTendiesImporter.toggle() }) { - Text("Select Tendies") + Label("Select Tendies", systemImage: "document.circle") } .buttonStyle(TintedButton(color: .green, fullwidth: true)) } @@ -92,11 +89,12 @@ struct ContentView: View { } catch CocoaError.fileWriteFileExists { presentError(ApplyError.collectionsNeedsReset) } catch { + print(error.localizedDescription) presentError(ApplyError.unexpected(info: error.localizedDescription)) } } }) { - Text("Apply") + Label("Apply", systemImage: "checkmark.circle") } .buttonStyle(TintedButton(color: .blue, fullwidth: true)) } @@ -113,7 +111,7 @@ struct ContentView: View { } }, noCancel: false) }) { - Text("Reset Collections") + Label("Reset Collections", systemImage: "arrow.clockwise.circle") } .buttonStyle(TintedButton(color: .red, fullwidth: true)) } @@ -151,15 +149,10 @@ struct ContentView: View { pbManager.selectedTendies.append(contentsOf: url) } case .failure(let error): - lastError = error.localizedDescription - showErrorAlert.toggle() + Haptic.shared.notify(.error) + UIApplication.shared.alert(body: error.localizedDescription) } }) - .alert("Error", isPresented: $showErrorAlert) { - Button("OK") {} - } message: { - Text(lastError ?? "???") - } .overlay { OnBoardingView(cards: resetCollectionsInfo, isFinished: $hideResetHelp) .opacity(hideResetHelp ? 0.0 : 1.0) @@ -176,9 +169,8 @@ struct ContentView: View { SymHandler.cleanup() UIApplication.shared.dismissAlert(animated: false) DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: { - lastError = error.localizedDescription Haptic.shared.notify(.error) - showErrorAlert = true + UIApplication.shared.alert(body: error.localizedDescription) }) } diff --git a/Pocket Poster/Views/NavigatorViews/VideoView.swift b/Pocket Poster/Views/NavigatorViews/VideoView.swift index 3a08c31..9841c61 100644 --- a/Pocket Poster/Views/NavigatorViews/VideoView.swift +++ b/Pocket Poster/Views/NavigatorViews/VideoView.swift @@ -145,8 +145,8 @@ struct DeleteButton: View { } }) { Image(systemName: "minus.circle") - .foregroundStyle(.black) - .font(.title2) + .foregroundStyle(.red) + .font(.title) .background { Circle() .foregroundStyle(.white) diff --git a/Pocket Poster/Views/SettingsView.swift b/Pocket Poster/Views/SettingsView.swift index 80d07c1..1bfd041 100644 --- a/Pocket Poster/Views/SettingsView.swift +++ b/Pocket Poster/Views/SettingsView.swift @@ -14,10 +14,6 @@ struct SettingsView: View { @State var checkingForHash: Bool = false @State var hashCheckTask: Task? = nil - @State var showErrorAlert = false - @State var errorAlertTitle: String? - @State var errorAlertDescr: String? - var body: some View { List { Section { @@ -54,7 +50,7 @@ struct SettingsView: View { UIImpactFeedbackGenerator(style: .soft).impactOccurred() UserDefaults.standard.set(false, forKey: "finishedTutorial") }) { - Text("Replay Tutorial") + Label("Replay Tutorial", systemImage: "questionmark.circle") } Button(action: { @@ -62,17 +58,13 @@ struct SettingsView: View { do { try PosterBoardManager.clearCache() Haptic.shared.notify(.success) - errorAlertTitle = "App Cache Successfully Cleared!" - errorAlertDescr = "" - showErrorAlert = true + UIApplication.shared.alert(title: "App Cache Successfully Cleared!", body: "") } catch { Haptic.shared.notify(.error) - errorAlertTitle = "Error" - errorAlertDescr = error.localizedDescription - showErrorAlert = true + UIApplication.shared.alert(body: error.localizedDescription) } }) { - Text("Clear App Cache") + Label("Clear App Cache", systemImage: "trash.circle") } .foregroundStyle(.red) } header: { @@ -126,11 +118,6 @@ struct SettingsView: View { Label("Credits", systemImage: "wrench.and.screwdriver") } } - .alert(errorAlertTitle ?? "Error", isPresented: $showErrorAlert) { - Button("OK") {} - } message: { - Text(errorAlertDescr ?? "???") - } } func startWaitForHash() {