package com.abbidot.tracker.vm

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.retrofit2.NetworkApi
import kotlinx.coroutines.launch

/**
 *Created  by .yzq on 2022/3/24/024.
 * @link
 * @description:
 */
class FeedbackViewModel : ViewModel() {

    val mFeedbackResultLiveData = MutableLiveData<Result<String>>()

    /**
     *用户意见反馈
     *  type=反馈问题类型 type 1为APP 2为设备 3其它
     */
    fun feedback(activity: BaseActivity<*>,
                 type: Int,
                 userId: String,
                 content: String,
                 imgurls: String,
                 email: String) {
        activity.showLoading(true)
        viewModelScope.launch {
            val result = NetworkApi.feedback(type, userId, content, imgurls, email)
            mFeedbackResultLiveData.value = result
        }
    }
}