package com.sybotan.android.demo.viewmodel

import android.app.Application
import androidx.lifecycle.viewModelScope
import cn.sagacloud.android.cadengine.types.FloorData
import com.framework.mvvm.model.db.entity.task.InfosforFloor
import com.framework.mvvm.model.repository.AdmRepository
import com.google.gson.Gson
import com.sybotan.android.demo.activities.BaseActivity
import com.sybotan.android.demo.activities.Space3DActivity
import com.sybotan.base.utils.SJsonUtil
import kotlinx.coroutines.launch
import org.kodein.di.DI
import org.kodein.di.DIAware
import org.kodein.di.android.x.closestDI
import org.kodein.di.instance
import java.io.File


/**
 * Created by lihao.
 * Date: 2021/6/9
 */
class Space3DVM(
    app: Application,
    b: (name: String, params: Any) -> Unit, activity: BaseActivity,
    private val projectId: String,
    private val buildingId: String,
    private val floorId: String, //建筑id
) : BaseViewModel(app, b, activity), DIAware {
    private val gson = Gson()

    override val di: DI by closestDI()
    val repo: AdmRepository by instance()

    fun getFloorSpace() {
        viewModelScope.launch {
            val spaces = repo.getSpaceByFloorId(floorId)
            val floor = repo.getObject(floorId)
            mEmitter.SendDirective(FLOOR_OBJECT, floor)
            mEmitter.SendDirective(FLOOR_SPACE, spaces)
        }
    }

    companion object {
        const val FLOOR_SPACE = "FLOOR_SPACE"
        const val FLOOR_OBJECT = "FLOOR_OBJECT"
    }
}