mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
add messages to console logs
This commit is contained in:
parent
ba73b5b0f1
commit
621da2bc74
2 changed files with 23 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue