import SwiftUI

struct EcaListMainView: View {
    @ObservedObject var taskViewModel = TaskViewModel()

    var body: some View {
        TaskTitleView(
            taskViewModel: taskViewModel,
            title: TaskViewMode.EcaList.title,
            viewMode: TaskViewMode.FuelSwitching
        )

        ScrollViewReader { proxy in
            ScrollView(.vertical){
                EcaListView(taskViewModel: taskViewModel)
            }
            .onChange(of: taskViewModel.viewMode){ newViewMode in
                proxy.scrollTo(0, anchor: .top)
            }
        }

        Spacer()
            .frame(height: 55)
    }
}

#Preview {
    EcaListMainView(taskViewModel: TaskViewModel())
}
