룰렛 설정 - 설정된 적이 없을 때 기본 캔 설정 5 -> 0으로 변경

This commit is contained in:
klaus 2023-12-07 11:06:21 +09:00
parent 2883c63e07
commit 29e293e6b5
2 changed files with 11 additions and 5 deletions

View File

@ -93,7 +93,13 @@ class RouletteSettingsFragment : BaseFragment<FragmentRouletteSettingsBinding>(
viewModel.toastLiveData.observe(viewLifecycleOwner) { it?.let { showToast(it) } }
viewModel.canLiveData.observe(viewLifecycleOwner) { binding.etSetPrice.setText("$it") }
viewModel.canLiveData.observe(viewLifecycleOwner) {
if (it > 0) {
binding.etSetPrice.setText("$it")
} else {
binding.etSetPrice.setText("")
}
}
viewModel.isLoading.observe(viewLifecycleOwner) {
if (it) {

View File

@ -30,7 +30,7 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
val isActiveLiveData: LiveData<Boolean>
get() = _isActiveLiveData
private val _canLiveData = MutableLiveData(5)
private val _canLiveData = MutableLiveData(0)
val canLiveData: LiveData<Int>
get() = _canLiveData
@ -39,7 +39,7 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
get() = _roulettePreviewLiveData
private val options = mutableListOf<RouletteOption>()
var can = 5
var can = 0
var isActive = false
fun plusWeight(optionIndex: Int) {
@ -195,10 +195,10 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
recalculatePercentages(options)
} else {
_isActiveLiveData.value = false
_canLiveData.value = 5
_canLiveData.value = 0
isActive = false
can = 5
can = 0
options.add(RouletteOption(title = "", weight = 1))
options.add(RouletteOption(title = "", weight = 1))