ErrorMessageView.swift 1.2 KB

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