//
//  LiveRoomInputChatView.swift
//  SodaLive
//
//  Created by klaus on 2024/01/17.
//

import SwiftUI

struct LiveRoomInputChatView: View {
    
    @State private var chatMessage = ""
    
    
    let sendMessage: (String) -> Bool
    
    var body: some View {
        HStack(spacing: 6.7) {
            TextField("채팅을 입력하세요", text: $chatMessage)
                .autocapitalization(.none)
                .disableAutocorrection(true)
                .font(.custom(Font.medium.rawValue, size: 13.3))
                .foregroundColor(.graybb)
                .accentColor(.button)
                .keyboardType(.default)
                .padding(.horizontal, 13.3)
                .padding(.vertical, 18.3)
                .background(Color.gray22)
                .cornerRadius(5.3)
                .frame(maxWidth: .infinity)
                .overlay(
                    RoundedRectangle(cornerRadius: 5.3)
                        .strokeBorder(lineWidth: 1)
                        .foregroundColor(.gray77)
                )
            
            Image("btn_message_send")
                .resizable()
                .frame(width: 35, height: 35)
                .padding(6.7)
                .onTapGesture {
                    if sendMessage(chatMessage) {
                        chatMessage = ""
                    }
                }
        }
        .padding(13.3)
    }
}

struct LiveRoomInputChatView_Previews: PreviewProvider {
    static var previews: some View {
        LiveRoomInputChatView(sendMessage: { _ in return true })
    }
}