Skip to content

Commit

Permalink
#160[fix] 곰 미선택시 버튼 비활성화를 위한 boolean 변수 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
stellar-halo committed Feb 7, 2024
1 parent f99a962 commit 5e4abb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ class BearSelectionViewModel @Inject constructor(
) : ViewModel() {
private val _selectedBearType: MutableLiveData<String> = MutableLiveData(NONE)
val selectedBearType: LiveData<String> get() = _selectedBearType
private val _isBearSelected: MutableLiveData<Boolean> = MutableLiveData(false)
val isBearSelected: LiveData<Boolean> get() = _isBearSelected

fun selectBearType(dollType: String) {
val isSameBearSelected = _selectedBearType.value == dollType

if (isSameBearSelected) _selectedBearType.value = NONE
else _selectedBearType.value = dollType
if (isSameBearSelected) {
_selectedBearType.value = NONE
_isBearSelected.value = false
} else {
_selectedBearType.value = dollType
_isBearSelected.value = true
}
}

fun setBearType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="34dp"
style="?android:attr/borderlessButtonStyle"
android:background="@{viewModel.selectedBearType != @string/none ? @drawable/shape_main1_fill_12_rect : @drawable/shape_gray200_fill_12_rect}"
android:clickable="@{viewModel.selectedBearType != @string/none ? true : false}"
android:enabled="@{viewModel.selectedBearType != @string/none ? true : false}"
android:background="@{viewModel.isBearSelected ? @drawable/shape_main1_fill_12_rect: @drawable/shape_gray200_fill_12_rect}"
android:clickable="@{viewModel.isBearSelected ? true: false}"
android:enabled="@{viewModel.isBearSelected ? true: false}"
android:text="@string/bear_selection_button"
android:textAppearance="@style/body1"
android:textColor="@color/gray000"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<string name="red">RED</string>
<string name="white">WHITE</string>
<string name="gray">GRAY</string>
<string name="none"></string>

<!-- util -->
<string name="finish_app_toast_msg">뒤로가기를 한 번 더 누르면 종료됩니다</string>
Expand Down

0 comments on commit 5e4abb7

Please sign in to comment.