//
//  AudioContentDeleteDialogView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/13.
//

import SwiftUI

struct AudioContentDeleteDialogView: View {
    
    @Binding var isShowing: Bool
    
    let title: String
    let confirmAction: () -> Void
    let showToast: () -> Void
    
    @State private var isAgree = false
    
    var body: some View {
        VStack(spacing: 0) {
            Text("콘텐츠 삭제")
                .font(.custom(Font.bold.rawValue, size: 18.3))
                .foregroundColor(Color(hex: "eeeeee"))
            
            Text("[\(title)]을 삭제하시겠습니까?")
                .font(.custom(Font.medium.rawValue, size: 13.3))
                .foregroundColor(Color(hex: "eeeeee"))
                .padding(.top, 21.3)
            
            HStack(spacing: 13.3) {
                Image(isAgree ? "btn_select_checked" : "btn_select_normal")
                    .resizable()
                    .frame(width: 20, height: 20)
                    .onTapGesture {
                        isAgree.toggle()
                    }
                
                Text("삭제된 콘텐츠는 되돌릴 수 없음을 알고 있습니다.")
                    .font(.custom(Font.medium.rawValue, size: 12))
                    .foregroundColor(Color(hex: "eeeeee"))
                    .onTapGesture {
                        isAgree.toggle()
                    }
            }
            .padding(13.3)
            .background(Color(hex: "303030"))
            .cornerRadius(6.7)
            .padding(.top, 13.3)
            
            Text("콘텐츠를 삭제하더라도 이미 구매한\n사용자는 콘텐츠를 이용할 수 있습니다.")
                .font(.custom(Font.medium.rawValue, size: 12))
                .foregroundColor(Color(hex: "dd4500"))
                .fixedSize(horizontal: false, vertical: true)
                .multilineTextAlignment(.center)
                .padding(.top, 13.3)
            
            HStack(spacing: 12) {
                Text("취소")
                    .font(.custom(Font.bold.rawValue, size: 18.3))
                    .foregroundColor(Color(hex: "9970ff"))
                    .padding(.horizontal, 55)
                    .padding(.vertical, 16)
                    .overlay(
                        RoundedRectangle(cornerRadius: CGFloat(10))
                            .stroke(lineWidth: 1)
                            .foregroundColor(Color(hex: "9970ff"))
                    )
                    .onTapGesture {
                        isShowing = false
                    }
                
                Text("확인")
                    .font(.custom(Font.bold.rawValue, size: 18.3))
                    .foregroundColor(Color(hex: "eeeeee"))
                    .padding(.horizontal, 55)
                    .padding(.vertical, 16)
                    .background(Color(hex: "9970ff"))
                    .cornerRadius(10)
                    .onTapGesture {
                        if isAgree {
                            isShowing = false
                            confirmAction()
                        } else {
                            showToast()
                        }
                    }
            }
            .padding(.top, 13.3)
        }
        .padding(.top, 40)
        .padding(.horizontal, 16.7)
        .padding(.bottom, 16.7)
        .background(Color(hex: "222222"))
        .cornerRadius(10)
    }
}
