OverlayState.swift 429 B

1234567891011121314151617
  1. import SwiftUI
  2. class OverlayState: ObservableObject {
  3. @Published var isVisible: Bool = false
  4. @Published var overlayContent = AnyView(EmptyView()) // Holds the content of the overlay
  5. func showOverlay<Content: View>(_ content: Content) {
  6. overlayContent = AnyView(content)
  7. isVisible = true
  8. }
  9. func hideOverlay() {
  10. isVisible = false
  11. overlayContent = AnyView(EmptyView())
  12. }
  13. }