//
//  ChatInputView.swift
//  Sailassist
//
//  Created by Mamoru Sugita on 2023/11/08.
//

import SwiftUI

struct ChatInputView: View {
    @EnvironmentObject private var sceneDelegate: SceneDelegate
    @State var inputText = ""
    @FocusState var isKeyboard : Bool
    var body: some View {
        VStack(spacing: 0){
            Spacer()
            Divider()
            
            HStack(spacing: 10){
                TextField("", text: $inputText, onEditingChanged: { isEdit in
                    sceneDelegate.tabWindow?.isHidden = isEdit
                })
                .focused($isKeyboard)
                .font(FontStyle.SupplementText.font)
                .foregroundColor(ColorSet.BodyChat.color)
                .padding(10)
                .background(ColorSet.ChatForm.color)
                .cornerRadius(5)
                .padding(.vertical, 10)
                .padding(.leading, 20)
                
                Button{
                    isKeyboard = false

                } label: {
                    Image("send")
                        .resizable()
                        .frame(width: 24, height: 24)
                        .padding(10)
                }
                .padding(.vertical, 6)
                .padding(.trailing, 11)
            }
            .background(ColorSet.BackgroundSecondary.color)
        }
        
    }
}

#Preview {
    ChatInputView()
        .environmentObject(SceneDelegate())
}
