//
//  TSEmojisChildViewModel.swift
//  AIEmoji
//
//  Created by 100Years on 2025/1/20.
//

import ObjectMapper

class TSEmojisChildViewModel {
    var emojisType:String
    init(emojisType:String) {
        self.emojisType = emojisType
        creatData()
    }
    
    var dataArray:[TSEmojisModel] = [TSEmojisModel]()
    var colDataArray:[TSComponent] = [TSComponent]()
}

extension TSEmojisChildViewModel {
    
    func creatData(){
        if let dataArray = Mapper<TSEmojisModel>().mapArray(JSONfile: "\(emojisType).json"){
            self.dataArray = dataArray
            creatOneSection()
        }
        
    }
    
    func creatOneSection(){
        let sectionModel = TSEmojisColSectionModel()
        for model in dataArray {
            let itemModel = TSEmojisColItemModel()
            itemModel.dataModel = model
            sectionModel.items.append(itemModel)
        }
        colDataArray.append(sectionModel)
    }
}
