ui improvements + fix error popups not showing

This commit is contained in:
leminlimez committed 2025-06-18 19:09:10 -04:00
1 parent 54aa8e20a3
commit d835a40199
4 files changed
+16 -44

No files matched your search

+3 -10
View File
@@ -14,7 +14,6 @@ struct Pocket_PosterApp: App {
@AppStorage("pbHash") var pbHash: String = "" @AppStorage("pbHash") var pbHash: String = ""
@State var downloadURL: String? = nil @State var downloadURL: String? = nil
@State var showDownloadAlert = false
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
@@ -27,14 +26,6 @@ struct Pocket_PosterApp: App {
} }
.transition(.opacity) .transition(.opacity)
.animation(.easeOut(duration: 0.5), value: finishedTutorial) .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 .onOpenURL(perform: { url in
// Download URL // Download URL
if url.absoluteString.starts(with: "pocketposter://download") { 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.") UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
} else { } else {
downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "") 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 // App Hash URL
+7 -15
View File
@@ -24,9 +24,6 @@ struct ContentView: View {
private let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" private let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? ""
@State var showTendiesImporter: Bool = false @State var showTendiesImporter: Bool = false
@State var showErrorAlert = false
@State var lastError: String?
@State var hideResetHelp: Bool = true @State var hideResetHelp: Bool = true
var body: some View { var body: some View {
@@ -42,7 +39,7 @@ struct ContentView: View {
UIImpactFeedbackGenerator(style: .soft).impactOccurred() UIImpactFeedbackGenerator(style: .soft).impactOccurred()
showTendiesImporter.toggle() showTendiesImporter.toggle()
}) { }) {
Text("Select Tendies") Label("Select Tendies", systemImage: "document.circle")
} }
.buttonStyle(TintedButton(color: .green, fullwidth: true)) .buttonStyle(TintedButton(color: .green, fullwidth: true))
} }
@@ -92,11 +89,12 @@ struct ContentView: View {
} catch CocoaError.fileWriteFileExists { } catch CocoaError.fileWriteFileExists {
presentError(ApplyError.collectionsNeedsReset) presentError(ApplyError.collectionsNeedsReset)
} catch { } catch {
print(error.localizedDescription)
presentError(ApplyError.unexpected(info: error.localizedDescription)) presentError(ApplyError.unexpected(info: error.localizedDescription))
} }
} }
}) { }) {
Text("Apply") Label("Apply", systemImage: "checkmark.circle")
} }
.buttonStyle(TintedButton(color: .blue, fullwidth: true)) .buttonStyle(TintedButton(color: .blue, fullwidth: true))
} }
@@ -113,7 +111,7 @@ struct ContentView: View {
} }
}, noCancel: false) }, noCancel: false)
}) { }) {
Text("Reset Collections") Label("Reset Collections", systemImage: "arrow.clockwise.circle")
} }
.buttonStyle(TintedButton(color: .red, fullwidth: true)) .buttonStyle(TintedButton(color: .red, fullwidth: true))
} }
@@ -151,15 +149,10 @@ struct ContentView: View {
pbManager.selectedTendies.append(contentsOf: url) pbManager.selectedTendies.append(contentsOf: url)
} }
case .failure(let error): case .failure(let error):
lastError = error.localizedDescription Haptic.shared.notify(.error)
showErrorAlert.toggle() UIApplication.shared.alert(body: error.localizedDescription)
} }
}) })
.alert("Error", isPresented: $showErrorAlert) {
Button("OK") {}
} message: {
Text(lastError ?? "???")
}
.overlay { .overlay {
OnBoardingView(cards: resetCollectionsInfo, isFinished: $hideResetHelp) OnBoardingView(cards: resetCollectionsInfo, isFinished: $hideResetHelp)
.opacity(hideResetHelp ? 0.0 : 1.0) .opacity(hideResetHelp ? 0.0 : 1.0)
@@ -176,9 +169,8 @@ struct ContentView: View {
SymHandler.cleanup() SymHandler.cleanup()
UIApplication.shared.dismissAlert(animated: false) UIApplication.shared.dismissAlert(animated: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: { DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: {
lastError = error.localizedDescription
Haptic.shared.notify(.error) Haptic.shared.notify(.error)
showErrorAlert = true UIApplication.shared.alert(body: error.localizedDescription)
}) })
} }
@@ -145,8 +145,8 @@ struct DeleteButton: View {
} }
}) { }) {
Image(systemName: "minus.circle") Image(systemName: "minus.circle")
.foregroundStyle(.black) .foregroundStyle(.red)
.font(.title2) .font(.title)
.background { .background {
Circle() Circle()
.foregroundStyle(.white) .foregroundStyle(.white)
+4 -17
View File
@@ -14,10 +14,6 @@ struct SettingsView: View {
@State var checkingForHash: Bool = false @State var checkingForHash: Bool = false
@State var hashCheckTask: Task<Void, any Error>? = nil @State var hashCheckTask: Task<Void, any Error>? = nil
@State var showErrorAlert = false
@State var errorAlertTitle: String?
@State var errorAlertDescr: String?
var body: some View { var body: some View {
List { List {
Section { Section {
@@ -54,7 +50,7 @@ struct SettingsView: View {
UIImpactFeedbackGenerator(style: .soft).impactOccurred() UIImpactFeedbackGenerator(style: .soft).impactOccurred()
UserDefaults.standard.set(false, forKey: "finishedTutorial") UserDefaults.standard.set(false, forKey: "finishedTutorial")
}) { }) {
Text("Replay Tutorial") Label("Replay Tutorial", systemImage: "questionmark.circle")
} }
Button(action: { Button(action: {
@@ -62,17 +58,13 @@ struct SettingsView: View {
do { do {
try PosterBoardManager.clearCache() try PosterBoardManager.clearCache()
Haptic.shared.notify(.success) Haptic.shared.notify(.success)
errorAlertTitle = "App Cache Successfully Cleared!" UIApplication.shared.alert(title: "App Cache Successfully Cleared!", body: "")
errorAlertDescr = ""
showErrorAlert = true
} catch { } catch {
Haptic.shared.notify(.error) Haptic.shared.notify(.error)
errorAlertTitle = "Error" UIApplication.shared.alert(body: error.localizedDescription)
errorAlertDescr = error.localizedDescription
showErrorAlert = true
} }
}) { }) {
Text("Clear App Cache") Label("Clear App Cache", systemImage: "trash.circle")
} }
.foregroundStyle(.red) .foregroundStyle(.red)
} header: { } header: {
@@ -126,11 +118,6 @@ struct SettingsView: View {
Label("Credits", systemImage: "wrench.and.screwdriver") Label("Credits", systemImage: "wrench.and.screwdriver")
} }
} }
.alert(errorAlertTitle ?? "Error", isPresented: $showErrorAlert) {
Button("OK") {}
} message: {
Text(errorAlertDescr ?? "???")
}
} }
func startWaitForHash() { func startWaitForHash() {