//
//  ChatView.swift
//  forShip
//
//  Created by Mamoru Sugita on 2023/10/16.
//

import SwiftUI

struct ChatView: View {
    @State var isEmargency: Bool = false
    @State var isShowMember: Bool = false
    var body: some View {
        ZStack {
            if isEmargency{
                LinearGradient(gradient: Gradient(colors: [.chatEmargencyColor1,  .chatEmargencyColor2]), startPoint: .top, endPoint: .bottom)
                    .ignoresSafeArea()
            }
            VStack(spacing: 0){
                ChatTitleView(isShowMember: $isShowMember)
                
                ZStack{
                    ScrollView(.vertical) {
                        Spacer()
                            .frame(height: 20)
                        OtherChatContentView()
                        
                        MyChatContentView()
                    }
                    HStack {
                        Spacer()
                        VStack{
                            Button{
                                isEmargency.toggle()
                            }label: {
                                Image(systemName: "exclamationmark.triangle.fill")
                                    .foregroundColor(.white)
                                    .frame(width: 48, height: 48)
                                    .background(ColorSet.Notice.color)
                                    .cornerRadius(50)
                            }.padding(9)
                            Spacer()
                        }
                    }
                    if isShowMember{
                        ChatMemberView()
                    }
                }

            }
            ChatInputView()
        }
        .background(ColorSet.BackgroundPrimary.color)
    }
}

#Preview {
    ChatView()
}
