package com.gh.gamecenter.feedback.view.suggest

import android.app.Application
import com.gh.gamecenter.common.baselist.ListViewModel
import com.gh.gamecenter.common.entity.SuggestType
import com.gh.gamecenter.feedback.R
import com.gh.gamecenter.feedback.entity.SuggestionItem
import io.reactivex.Observable
import io.reactivex.Single

class SuggestionCategoryViewModel(application: Application) :
    ListViewModel<SuggestionItem, SuggestionItem>(application) {
    override fun provideDataObservable(page: Int): Observable<MutableList<SuggestionItem>>? = null

    override fun provideDataSingle(page: Int): Single<List<SuggestionItem>> {
        return Single.create {
            if (page == 1) {
                it.onSuccess(getSuggestionItemList())
            } else {
                it.onSuccess(emptyList())
            }
        }
    }

    override fun mergeResultLiveData() {
        mResultLiveData.addSource(mListLiveData) {
            mResultLiveData.postValue(it)
        }
    }

    private fun getSuggestionItemList() = listOf(
        SuggestionItem(
            icon = R.drawable.icon_feedback_app,
            name = SuggestType.APP.type,
            des = "助手异常、助手功能建议，点这反馈！"
        ),
        SuggestionItem(
            icon = R.drawable.icon_feedback_game,
            name = SuggestType.GAME.type,
            des = "游戏黑屏、闪退、卡顿…等异常情况，点这反馈！"
        ),
        SuggestionItem(
            icon = R.drawable.icon_feedback_update,
            name = SuggestType.UPDATE.type,
            des = "游戏版本低、没有想要的版本，点这反馈！"
        ),
        SuggestionItem(
            icon = R.drawable.icon_feedback_function,
            name = SuggestType.FUNCTION.type,
            des = "游戏加速、无限资源…等收录需求，点这提交！"
        ),
        SuggestionItem(
            icon = R.drawable.icon_feedback_copyright,
            name = SuggestType.COPYRIGHT.type,
            des = "版权方面的问题，点这反馈！"
        ),
    )
}