ErrorMessageView.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // LoopFollow
  2. // ErrorMessageView.swift
  3. // Created by Jonas Björkert on 2024-07-31.
  4. import Foundation
  5. import SwiftUI
  6. struct ErrorMessageView: View {
  7. var message: String
  8. var buttonTitle: String?
  9. var buttonAction: (() -> Void)?
  10. var body: some View {
  11. VStack(spacing: 20) {
  12. Text(message)
  13. .foregroundColor(.red)
  14. .multilineTextAlignment(.center)
  15. .padding()
  16. .background(
  17. RoundedRectangle(cornerRadius: 10)
  18. .fill(Color.white)
  19. .shadow(color: .gray, radius: 5, x: 0, y: 2)
  20. )
  21. .padding()
  22. if let buttonTitle = buttonTitle, let buttonAction = buttonAction {
  23. Button(action: buttonAction) {
  24. Text(buttonTitle)
  25. .frame(maxWidth: .infinity)
  26. .padding()
  27. .background(Color.blue)
  28. .foregroundColor(.white)
  29. .cornerRadius(8)
  30. }
  31. }
  32. }
  33. .padding()
  34. }
  35. }