added popup for applying tendies

This commit is contained in:
leminlimez committed 2025-06-03 15:49:34 -04:00
1 parent 89e13bd7d4
commit a67a28737e
1 file changed
+16 -24
+16 -24
View File
@@ -24,7 +24,6 @@ struct ContentView: View {
var selectedTendies: Binding<[URL]> var selectedTendies: Binding<[URL]>
@State var showErrorAlert = false @State var showErrorAlert = false
@State var showSuccessAlert = false
@State var lastError: String? @State var lastError: String?
@State var hideResetHelp: Bool = true @State var hideResetHelp: Bool = true
@@ -67,24 +66,24 @@ struct ContentView: View {
if !selectedTendies.wrappedValue.isEmpty { if !selectedTendies.wrappedValue.isEmpty {
Button(action: { Button(action: {
UIImpactFeedbackGenerator(style: .soft).impactOccurred() UIImpactFeedbackGenerator(style: .soft).impactOccurred()
// UIApplication.shared.alert(title: NSLocalizedString("Applying Tendies...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false) UIApplication.shared.alert(title: NSLocalizedString("Applying Tendies...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false)
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
do { do {
try PosterBoardManager.applyTendies(selectedTendies.wrappedValue, appHash: pbHash) try PosterBoardManager.applyTendies(selectedTendies.wrappedValue, appHash: pbHash)
selectedTendies.wrappedValue.removeAll() selectedTendies.wrappedValue.removeAll()
try? FileManager.default.removeItem(at: PosterBoardManager.getTendiesStoreURL()) try? FileManager.default.removeItem(at: PosterBoardManager.getTendiesStoreURL())
Haptic.shared.notify(.success) Haptic.shared.notify(.success)
// UIApplication.shared.dismissAlert(animated: true) UIApplication.shared.dismissAlert(animated: false)
lastError = "The PosterBoard app will now open. Please close it from the app switcher." UIApplication.shared.confirmAlert(title: "Success!", body: "The PosterBoard app will now open. Please close it from the app switcher.", onOK: {
showSuccessAlert.toggle() PosterBoardManager.runShortcut(named: "PosterBoard")
} catch { }, noCancel: true)
Haptic.shared.notify(.error) } catch {
// UIApplication.shared.dismissAlert(animated: true) Haptic.shared.notify(.error)
lastError = error.localizedDescription UIApplication.shared.dismissAlert(animated: false)
showErrorAlert.toggle() UIApplication.shared.alert(body: error.localizedDescription)
}
} }
// }
}) { }) {
Text("Apply") Text("Apply")
} }
@@ -136,13 +135,6 @@ struct ContentView: View {
} message: { } message: {
Text(lastError ?? "???") Text(lastError ?? "???")
} }
.alert("Success!", isPresented: $showSuccessAlert) {
Button("OK") {
PosterBoardManager.runShortcut(named: "PosterBoard")
}
} 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)