//
//  LiveRoomDialogView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/14.
//

import SwiftUI

struct LiveRoomDialogView: View {
    
    let content: String
    
    let cancelTitle: String?
    let cancelAction: (() -> Void)?
    
    let confirmTitle: String?
    let confirmAction: (() -> Void)?
    
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            HStack(alignment: .center, spacing: 11.7) {
                Image(content.contains("룰렛") ? "ic_roulette" : "ic_request_speak")
                    .resizable()
                    .frame(width: 36, height: 36)
                
                Text(content)
                    .font(.custom(Font.medium.rawValue, size: 13.3))
                    .foregroundColor(Color(hex: "eeeeee"))
            }
            .padding(.horizontal, 26.7)
            
            HStack(spacing: 10) {
                Spacer()
                
                if let cancelTitle = cancelTitle, let cancelAction = cancelAction {
                    Text(cancelTitle)
                        .font(.custom(Font.medium.rawValue, size: 10))
                        .foregroundColor(.white)
                        .padding(.horizontal, 8)
                        .padding(.vertical, 8.3)
                        .background(Color.white.opacity(0.2))
                        .cornerRadius(13.3)
                        .overlay(
                            RoundedRectangle(cornerRadius: 13.3)
                                .strokeBorder()
                                .foregroundColor(.white)
                        )
                        .onTapGesture { cancelAction() }
                }
                
                if let confirmTitle = confirmTitle, let confirmAction = confirmAction {
                    Text(confirmTitle)
                        .font(.custom(Font.medium.rawValue, size: 10))
                        .foregroundColor(Color(hex: "3bb9f1"))
                        .padding(.horizontal, 8)
                        .padding(.vertical, 8.3)
                        .background(Color.white)
                        .cornerRadius(13.3)
                        .onTapGesture { confirmAction() }
                }
            }
            .padding(.horizontal, 26.7)
            .padding(.top, confirmTitle != nil || cancelTitle != nil ? 10 : 0)
        }
        .padding(.vertical, 20)
        .background(Color(hex: "3bb9f1"))
        .cornerRadius(16.7)
        .padding(.horizontal, 26.7)
        .frame(width: screenSize().width)
    }
}