import SwiftUI

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

    var body: some View {
        //タイトルエリア
        HStack{
            Button(action: {
                taskViewModel.viewMode = .MenuList
            }, label: {
                Image("ink_02")
            })
            .frame(width: 48, height: 48)

            Spacer()

            Text(TaskViewMode.NgaNotification.title)
                .font(FontStyle.TitleL.font)
                .frame(height: 20)
                .padding(.vertical, 14)

            Spacer()

            Button(action: {
            }, label: {
            })
            .frame(width: 48, height: 48)
        }
        .padding(EdgeInsets(top: 10, leading: 8, bottom: 13, trailing: 17))

        Divider()
            .background(ColorSet.LineColor03.color)

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

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

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