add messages to console logs

This commit is contained in:
neoarz 2025-03-31 20:16:48 -04:00
parent ba73b5b0f1
commit 621da2bc74
2 changed files with 23 additions and 19 deletions

View file

@ -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

View file

@ -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()
}