//
//  EcaListView.swift
//  forShip
//
//  Created by Mamoru Sugita on 2023/10/18.
//

import SwiftUI

struct EcaListView: View {
    
    let ecas = ["America",
                "Canada",
                "Japan"]
    var body: some View {
        ForEach(ecas, id: \.self){ data in
            AddEcaView(name: data, isRegisterd: .constant(true))
            
            Divider()
        }
    }
}

struct AddEcaView: View {
    let name: String
    @Binding var isRegisterd: Bool
    var body: some View {
        HStack {
            Text("\(name) ECA")
                .padding(17)
            Spacer()
            if isRegisterd{
                Button(action: {
                    isRegisterd.toggle()
                }, label: {
                    Image("icon_plus")
                        .padding()
                })
//                .frame(width: 24, height: 24)
                .background(.primaryActiveIcon)
                .cornerRadius(50)
                .padding()
            }else{
                Text("Registerd")
                    .frame(height: 24)
                    .background(.primaryDisable)
                    .cornerRadius(12)
                    .padding()
            }
            
        }
    }
}

#Preview {
    EcaListView()
}
