diff --git a/StikJIT/Views/ConsoleLogsView.swift b/StikJIT/Views/ConsoleLogsView.swift index 9529ffe..77180d4 100644 --- a/StikJIT/Views/ConsoleLogsView.swift +++ b/StikJIT/Views/ConsoleLogsView.swift @@ -14,9 +14,8 @@ struct ConsoleLogsView: View { @State private var autoScroll = true @State private var scrollView: ScrollViewProxy? = nil - // Alert handlin - @State private var showingExportAlert = false - @State private var showingCopyAlert = false + // Alert handling + @State private var showingCustomAlert = false @State private var alertMessage = "" @State private var alertTitle = "" @State private var isError = false @@ -119,13 +118,13 @@ struct ConsoleLogsView: View { alertTitle = "Logs Exported" alertMessage = "Logs have been saved to Files app in StikJIT folder." isError = false - showingExportAlert = true + showingCustomAlert = true } catch { // Set error alert variables and show the alert alertTitle = "Export Failed" alertMessage = "Failed to save logs: \(error.localizedDescription)" isError = true - showingExportAlert = true + showingCustomAlert = true } }) { HStack { @@ -166,7 +165,7 @@ struct ConsoleLogsView: View { alertTitle = "Logs Copied" alertMessage = "Logs have been copied to clipboard." isError = false - showingCopyAlert = true + showingCustomAlert = true }) { HStack { Text("Copy Logs") @@ -220,16 +219,21 @@ struct ConsoleLogsView: View { } } .navigationViewStyle(StackNavigationViewStyle()) - .alert(alertTitle, isPresented: $showingExportAlert) { - Button("OK", role: .cancel) { } - } message: { - Text(alertMessage) - } - .alert(alertTitle, isPresented: $showingCopyAlert) { - Button("OK", role: .cancel) { } - } message: { - Text(alertMessage) - } + .overlay( + ZStack { + if showingCustomAlert { + CustomErrorView( + title: alertTitle, + message: alertMessage, + onDismiss: { + showingCustomAlert = false + }, + showButton: true, + primaryButtonText: "OK" + ) + } + } + ) } // Creates an NSAttributedString that combines timestamp, type, and message diff --git a/StikJIT/Views/Custom Error View.swift b/StikJIT/Views/Custom Error View.swift index f7f6cbf..530f07b 100644 --- a/StikJIT/Views/Custom Error View.swift +++ b/StikJIT/Views/Custom Error View.swift @@ -112,7 +112,7 @@ struct CustomErrorView: View { .opacity(opacity) } .onAppear { - // Made animation faster (0.25s instead of 0.4s) + withAnimation(.spring(response: 0.25, dampingFraction: 0.7)) { opacity = 1 scale = 1 @@ -121,13 +121,13 @@ struct CustomErrorView: View { } private func dismissWithAnimation() { - // Made dismiss animation faster (0.15s instead of 0.2s) + withAnimation(.easeOut(duration: 0.15)) { opacity = 0 scale = 0.8 } - // Delay the actual dismissal to allow the animation to complete + DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { onDismiss() }