import SwiftUI

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

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

        //燃料切り替え
        ScrollViewReader { proxy in
            ScrollView(.vertical){
                FuelSwitchingView(taskViewModel: taskViewModel)
            }
            .onChange(of: taskViewModel.viewMode){ newViewMode in
                proxy.scrollTo(0, anchor: .top)
            }
        }

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

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