//
//  BottomSheetFragment.swift
//

import SwiftUI

public struct BottomSheetFragment<Content: View>: Fragment {

    public let content: Content

    public init(_ content: Content) {
        self.content = content
    }

    public func accept<VisitorType>(visitor: VisitorType) where VisitorType : FragmentVisitor {
        visitor.visit(self)
    }

    public func activateConstraints(superview: UIView, view: UIView) {
        NSLayoutConstraint.activate([
            view.topAnchor.constraint(equalTo: superview.centerYAnchor),
            view.bottomAnchor.constraint(equalTo: superview.bottomAnchor),
            view.leadingAnchor.constraint(equalTo: superview.leadingAnchor),
            view.trailingAnchor.constraint(equalTo: superview.trailingAnchor),
        ])
    }

    public func makeViewController() -> some UIViewController {
        UIHostingController(rootView: content.border(Color.red))
    }
}

