2024-MacC-M14-Medio / SqoopDesignSystem / Sources / SQComponents / SQViews / PopUp / SQPopUp.swift
SQPopUp.swift
Raw
//
//  SQPopUp.swift
//  Temp
//
//  Created by Greem on 10/31/24.
//

import SwiftUI
import SqoopDesignSystem

///  .
public struct SQPopUp: View {
    
    public let label: LabelItem
    public let button: SQPopUpButton
    public let popUpDesc: String?
    
    /// label:  ,    .
    /// button:  .
    public init(label: LabelItem,
                button: SQPopUpButton,
                popUpDesc:String?) {
        self.label = label
        self.button = button
        self.popUpDesc = popUpDesc
    }
    /// label:  ,    .
    /// buttonAction:   .
    /// btnTitle:   .
    /// popUpDesc:    .
    public init(label: LabelItem,
                btnAction: @escaping ()->Void,
                btnTitle:()->String,
                popUpDesc: ()->String?) {
        self.label = label
        self.button = SQPopUpButton(title: btnTitle(), action: btnAction)
        self.popUpDesc = popUpDesc()
    }
    public var body: some View {
        VStack(spacing: 0) {
            PopUpAlertLabel(icon: label.icon ?? .error,
                            title: label.title).padding(.horizontal, 16)
            
            button.padding(.horizontal, 16)
            if let popUpDesc {
                PopUpDescription(popUpDesc: popUpDesc)
                    .padding(.vertical, 20)
            } else {
                Rectangle().fill(.clear).frame(height: 4)
            }
        }
        .padding(.vertical, 8)
        .background(Color.bgGrey3)
        .clipShape(RoundedRectangle(cornerRadius: 10))
        .frame(minWidth: 343,maxWidth: 408)
    }
}




#Preview {
    ZStack {
        Color.black.ignoresSafeArea(.all)
        
        SQPopUp(label: .init(icon: .info, title: "sadf")) {
            print("Hello world")
        } btnTitle: { "버튼명" }
        popUpDesc: { "설명은 이렇게 넣는거야!!" }
        
    }.loadSqoopFontSystem()
}