package com.hongyegroup.cpt_parttime.mvvm

import androidx.fragment.app.Fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import com.guadou.lib_baselib.base.vm.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import javax.inject.Inject

@HiltViewModel
class PartTimeJobDetailViewModel @Inject constructor(
    private val savedStateHandle: SavedStateHandle
) : BaseViewModel() {

    var mFragments = mutableListOf<Fragment>()

    /**
     * 请求工作详情数据
     */
    fun requestJobDetail(): LiveData<Boolean> {
        val liveData = MutableLiveData<Boolean>()

        launchOnUI {
            //开始Loading
            loadStartLoading()

            withContext(Dispatchers.IO) {
                delay(1000)
            }

            loadSuccess()
            liveData.postValue(true)

        }

        return liveData
    }

}