//
//  MapTaskView.swift
//  forShip
//
//  Created by Mamoru Sugita on 2023/10/17.
//

import SwiftUI

enum TaskViewMode{
    case SwitchingMenu
    case EcaList
    case EcaSetting
}


struct MapTaskView: View {
    @State private var contentTitle: String = "title"
    @State var viewMode: TaskViewMode = .SwitchingMenu
    var body: some View {
        VStack{
            Capsule()
                .foregroundColor(Color(.systemGray5))
                .frame(width: 45, height: 3)
                .padding(.top, 10)

            //タイトルエリア
            HStack{
                
                Button(action: {
                    viewMode = .SwitchingMenu
                }, label: {
                    if viewMode != .SwitchingMenu{
                        Image("ink_02")
                    }
                })
                .frame(width: 48, height: 48)
                
                
                Spacer()
                
                Text(contentTitle)
                    .frame(height: 20)
                    .padding(.vertical, 14)
                
                Spacer()
                
                
                Button(action: {
                    
                }, label: {
                    Image("closeIcon")
                })
                .frame(width: 48, height: 48)

                
                    
            }
            .padding(EdgeInsets(top: 10, leading: 8, bottom: 13, trailing: 17))
            
            
            Divider()
                .background(ColorSet.LineColor03.color)
            
            ScrollView(.vertical){
                switch viewMode {
                case .SwitchingMenu:
                    TaskSwitchingMenuView(viewMode: $viewMode)
                case .EcaList:
                    EcaListView()
                case .EcaSetting:
                    EcaSettingView()
                }
                
            }
            .padding(.leading, 20)
            .padding(.trailing, 10)
            
        }.onAppear{
            EcaCoordinatesTable().setEcaData()
        }
    }
}

#Preview {
    MapTaskView()
}
