Dont show export button when there are no logs to export, use content unavailable view for a loading indicator.

This commit is contained in:
Garth Vander Houwen 2024-06-06 14:06:39 -07:00
parent b31998be6c
commit 1c7c102090

View file

@ -54,6 +54,12 @@ struct AppLog: View {
}
.searchable(text: $searchTerm, prompt: "Search")
.disabled(selection != nil)
.overlay {
if logs.isEmpty {
ContentUnavailableView("Getting Logs . . .", systemImage: "scroll")
}
}
.onChange(of: sortOrder) { _, sortOrder in
withAnimation {
logs.sort(using: sortOrder)
@ -90,12 +96,14 @@ struct AppLog: View {
)
.navigationBarTitle("Debug Logs", displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
exportString = logToCsvFile(log: logs)
isExporting = true
}) {
Image(systemName: "square.and.arrow.down")
if !logs.isEmpty {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
exportString = logToCsvFile(log: logs)
isExporting = true
}) {
Image(systemName: "square.and.arrow.down")
}
}
}
}