mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-05-17 12:02:43 +00:00
51 lines
1.3 KiB
Swift
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") {}
|
|
}
|