Impressia/Vernissage/Widgets/ErrorView.swift

36 lines
1020 B
Swift
Raw Normal View History

2023-02-01 18:40:28 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import SwiftUI
struct ErrorView: View {
public var error: Error
public var refreshAction: (() async -> Void)?
var body: some View {
VStack {
Image(systemName: "exclamationmark.triangle.fill")
.resizable()
.foregroundColor(.accentColor)
.frame(width: 64, height: 64, alignment: .center)
Text("\(error.localizedDescription)")
.multilineTextAlignment(.center)
if let refreshAction {
Button {
Task {
await refreshAction()
}
} label: {
Text("global.title.refresh", comment: "Refresh")
2023-02-01 18:40:28 +01:00
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}
}