//
//  TopViewModel.swift
//  AcaMate
//
//  Created by TAnine on 2/13/25.
//

import SwiftUI

class TopViewModel: ObservableObject {
    @Published var btnVM = ButtonViewModel()
    
    @Published var titleName: String = ""
    
    let leftBtnID = UUID()
    let rightBtnID = UUID()
    
    init() {

        btnVM.btnStates[leftBtnID] = ButtonState()
        btnVM.btnStates[rightBtnID] = ButtonState()
    }
    
    func setLeftBtn(_ image: Image? = nil, text: String? = nil, font: Font? = nil, size: CGPoint, action: @escaping VOID_TO_VOID) {
        btnVM.setSize(for: leftBtnID, newWidth: size.x, newHeight: size.y)
        if text != nil {
            btnVM.setText(for: leftBtnID, newText: text, newFont: font)
        } else if let image = image {
            btnVM.setImage(for: leftBtnID, newImage: image)
        }
        btnVM.setAction(for: leftBtnID, newAction: action)
    }
    
    func setRightBtn(_ image: Image? = nil, text: String? = nil, font: Font? = nil, size: CGPoint, action: @escaping VOID_TO_VOID) {
        btnVM.setSize(for: rightBtnID, newWidth: size.x, newHeight: size.y)
        if text != nil {
            btnVM.setText(for: rightBtnID, newText: text, newFont: font)
        } else if let image = image {
            btnVM.setImage(for: rightBtnID, newImage: image)
        }
        btnVM.setAction(for: rightBtnID, newAction: action)
    }
}
