//
//  LiveRoomNoChattingDialogView.swift
//  SodaLive
//
//  Created by klaus on 2023/10/11.
//

import SwiftUI
import Kingfisher

struct LiveRoomNoChattingDialogView: View {
    
    let nickname: String
    let profileUrl: String
    let confirmAction: () -> Void
    let cancelAction: () -> Void
    
    var body: some View {
        ZStack {
            Color.black
                .opacity(0.5)
                .frame(width: screenSize().width, height: screenSize().height)
            
            VStack(spacing: 21) {
                Text("채팅금지")
                    .font(.custom(Font.bold.rawValue, size: 18.3))
                    .foregroundColor(Color(hex: "bbbbbb"))
                
                HStack(spacing: 8) {
                    KFImage(URL(string: profileUrl))
                        .cancelOnDisappear(true)
                        .downsampling(
                            size: CGSize(
                                width: 26.7,
                                height: 26.7
                            )
                        )
                        .resizable()
                        .frame(width: 26.7, height: 26.7)
                    
                    Text(nickname)
                        .font(.custom(Font.medium.rawValue, size: 16.7))
                        .foregroundColor(Color(hex: "bbbbbb"))
                }
                
                Text("3분간 채팅금지를 하겠습니까?")
                    .font(.custom(Font.medium.rawValue, size: 15))
                    .foregroundColor(Color(hex: "bbbbbb"))
                
                HStack(spacing: 13.3) {
                    Text("취소")
                        .font(.custom(Font.bold.rawValue, size: 15.3))
                        .foregroundColor(Color.button)
                        .padding(.vertical, 16)
                        .frame(width: (screenSize().width - 80) / 2)
                        .background(Color.button.opacity(0.13))
                        .cornerRadius(8)
                        .overlay(
                            RoundedRectangle(cornerRadius: 8)
                                .stroke(Color.button, lineWidth: 1)
                        )
                        .onTapGesture { cancelAction() }
                    
                    Text("확인")
                        .font(.custom(Font.bold.rawValue, size: 15.3))
                        .foregroundColor(Color(hex: "ffffff"))
                        .padding(.vertical, 16)
                        .frame(width: (screenSize().width - 80) / 2)
                        .background(Color.button)
                        .cornerRadius(8)
                        .onTapGesture { confirmAction() }
                }
            }
            .padding(.top, 40)
            .padding(.bottom, 16.7)
            .padding(.horizontal, 16.7)
            .background(Color.gray22)
            .cornerRadius(10)
        }
    }
}

struct LiveRoomNoChattingDialogView_Previews: PreviewProvider {
    static var previews: some View {
        LiveRoomNoChattingDialogView(
            nickname: "닉네임",
            profileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
            confirmAction: {},
            cancelAction: {}
        )
    }
}