package com.gh.gamecenter.qa.answer.detail

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * 这是一个 activity 级别的 viewModel 它的子 fragment 可以共享它
 */
class AnswerDetailContainerViewModel : ViewModel() {

    var answerIdList = arrayListOf<String>()

    var scroll = MutableLiveData<Int>()
    var answerListChange = MutableLiveData<Boolean>()

    fun appendAnswer(id: String) {
        answerIdList.add(id)
        answerListChange.postValue(true)
    }

    fun showPreviousAnswer() {
        scroll.postValue(SCROLL_TO_PREVIOUS_ANSWER)
    }

    fun showNextAnswer() {
        scroll.postValue(SCROLL_TO_NEXT_ANSWER)
    }

    companion object {
        const val SCROLL_TO_PREVIOUS_ANSWER = 0x1
        const val SCROLL_TO_NEXT_ANSWER = 0x2
    }
}