//
//  NotificationSettingsDialog.swift
//  SodaLive
//
//  Created by klaus on 2023/08/11.
//

import SwiftUI

struct NotificationSettingsDialog: View {
    
    @StateObject var viewModel = NotificationSettingsDialogViewModel()
    
    var body: some View {
        GeometryReader { geo in
            ZStack {
                Color.black
                    .opacity(0.5)
                    .frame(width: geo.size.width, height: geo.size.height)
                
                VStack(spacing: 0) {
                    HStack(spacing: 0) {
                        Text("라이브 알림")
                            .font(.custom(Font.bold.rawValue, size: 15))
                            .foregroundColor(Color(hex: "eeeeee"))
                        
                        Spacer()
                        
                        Image(viewModel.live ? "btn_toggle_on_big" : "btn_toggle_off_big")
                            .resizable()
                            .frame(width: 44, height: 27)
                            .onTapGesture {
                                viewModel.live.toggle()
                            }
                    }
                    
                    Rectangle()
                        .frame(height: 1)
                        .foregroundColor(Color(hex: "909090"))
                        .padding(.vertical, 13)
                    
                    HStack(spacing: 0) {
                        Text("콘텐츠 업로드 알림")
                            .font(.custom(Font.bold.rawValue, size: 15))
                            .foregroundColor(Color(hex: "eeeeee"))
                        
                        Spacer()
                        
                        Image(viewModel.uploadContent ? "btn_toggle_on_big" : "btn_toggle_off_big")
                            .resizable()
                            .frame(width: 44, height: 27)
                            .onTapGesture {
                                viewModel.uploadContent.toggle()
                            }
                    }
                    
                    Rectangle()
                        .frame(height: 1)
                        .foregroundColor(Color(hex: "909090"))
                        .padding(.vertical, 13)
                    
                    HStack(spacing: 0) {
                        Text("메시지 알림")
                            .font(.custom(Font.bold.rawValue, size: 15))
                            .foregroundColor(Color(hex: "eeeeee"))
                        
                        Spacer()
                        
                        Image(viewModel.message ? "btn_toggle_on_big" : "btn_toggle_off_big")
                            .resizable()
                            .frame(width: 44, height: 27)
                            .onTapGesture {
                                viewModel.message.toggle()
                            }
                    }
                    
                    Text("확인")
                        .font(.custom(Font.bold.rawValue, size: 15.3))
                        .foregroundColor(Color(hex: "ffffff"))
                        .padding(.vertical, 16)
                        .frame(width: (geo.size.width - 66.7) * 2 / 3)
                        .background(Color(hex: "3bb9f1"))
                        .cornerRadius(8)
                        .padding(.top, 33.3)
                        .onTapGesture {
                            viewModel.submit()
                        }
                }
                .padding(26.7)
                .frame(width: geo.size.width - 26.7, alignment: .center)
                .background(Color(hex: "222222"))
                .cornerRadius(10)
            }
        }
    }
}

struct NotificationSettingsDialog_Previews: PreviewProvider {
    static var previews: some View {
        NotificationSettingsDialog()
    }
}