//
//  TopView.swift
//  AcaMate
//
//  Created by TAnine on 2/4/25.
//

import SwiftUI

struct TopView: View {
    @ObservedObject var topVM: TopViewModel
    
    var body: some View {
        HStack(alignment: .center, spacing: 12) {
            SimpleBtnView(vm: topVM.btnVM, id: topVM.leftBtnID)
                .background {
                    if let state = topVM.btnVM.btnStates[topVM.leftBtnID], state.image == nil,  state.text != nil {
                        Circle()
                            .strokeBorder(Color(.Second.normal) ,lineWidth: 4)
                            .frame(width: state.width, height: state.height)
                    }
                }
                .padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 0))
            
            Text("\(topVM.titleName)")
                .foregroundStyle(Color(.Text.detail))
                .font(.nps(font: .bold, size: 20))
                .frame(height: 40)
                .padding(EdgeInsets(top: 12, leading: 12, bottom: 12, trailing: 12))
            Spacer(minLength: 1)
            
            SimpleBtnView(vm: topVM.btnVM, id: topVM.rightBtnID)
                .background {
                    if let state = topVM.btnVM.btnStates[topVM.rightBtnID], state.image == nil, state.text != nil {
                        Circle()
                            .strokeBorder(Color(.Second.normal) ,lineWidth: 4)
                            .frame(width: state.width, height: state.height)
                    }
                }
                .padding(EdgeInsets(top: 12, leading: 0, bottom: 12, trailing: 24))
        }
        .background {
            Rectangle()
                .foregroundStyle(Color(.Other.cell))
                .ignoresSafeArea(edges: .top)
        }
        .frame(maxWidth: .infinity)
        .onAppear {
            
        }
    }
    
    
}
