ErrorMessageView.swift 1.1 KB

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