IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/Views/ErrorView.swift
Thomas Ricouard 058500f91e Swiftformat .
2024-03-11 09:05:52 +01:00

51 lines
1.3 KiB
Swift

import SwiftUI
public struct ErrorView: View {
public let title: LocalizedStringKey
public let message: LocalizedStringKey
public let buttonTitle: LocalizedStringKey
public let onButtonPress: () -> Void
public init(title: LocalizedStringKey, message: LocalizedStringKey, buttonTitle: LocalizedStringKey, onButtonPress: @escaping (() -> Void)) {
self.title = title
self.message = message
self.buttonTitle = buttonTitle
self.onButtonPress = onButtonPress
}
public var body: some View {
HStack {
Spacer()
VStack {
Image(systemName: "exclamationmark.triangle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxHeight: 50)
Text(title)
.font(.scaledTitle)
.padding(.top, 16)
Text(message)
.font(.scaledSubheadline)
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
Button {
onButtonPress()
} label: {
Text(buttonTitle)
}
.buttonStyle(.bordered)
.padding(.top, 16)
}
.padding(.top, 100)
.padding(.layoutPadding)
Spacer()
}
}
}
#Preview {
ErrorView(title: "Error",
message: "Error loading. Please try again",
buttonTitle: "Retry") {}
}