ui improvements + fix error popups not showing
This commit is contained in:
1 parent
54aa8e20a3
commit
d835a40199
4 files changed
+16
-44
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ struct DeleteButton: View {
|
||||
}
|
||||
}) {
|
||||
Image(systemName: "minus.circle")
|
||||
.foregroundStyle(.black)
|
||||
.font(.title2)
|
||||
.foregroundStyle(.red)
|
||||
.font(.title)
|
||||
.background {
|
||||
Circle()
|
||||
.foregroundStyle(.white)
|
||||
|
||||
@@ -14,10 +14,6 @@ struct SettingsView: View {
|
||||
@State var checkingForHash: Bool = false
|
||||
@State var hashCheckTask: Task<Void, any Error>? = 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() {
|
||||
|
||||
Reference in new issue
Block a user