import ComposableArchitecture
import Foundation
import SwiftUI

struct BrandedAlertModifier<AlertView: View>: ViewModifier {
    let alertView: AlertView
    let animationDelay: TimeInterval
    let dismissAlert: () -> Void

    func body(content: Content) -> some View {
        ZStack {
            content

            Color.SemanticV1.backgroundBlockOverlay
                .opacity(0.75)
                .transition(.opacity.animation(.easeOut.delay(animationDelay)))
                .onTapGesture {
                    dismissAlert()
                }
                .overlay {
                    alertView
                }
                .ignoresSafeArea()
        }
        .background(
            Color.clear
                .frame(maxWidth: .infinity, maxHeight: .infinity)
        )
    }
}
