Skip to content

Commit

Permalink
#160[fix] NONE을 살리고 equals로 비교
Browse files Browse the repository at this point in the history
  • Loading branch information
stellar-halo committed Feb 7, 2024
1 parent 5e4abb7 commit d7b0701
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class OnboardingViewModel @Inject constructor(
}

companion object {
const val NONE = ""
const val NONE = "NONE"
const val BROWN = "BROWN"
const val GRAY = "GRAY"
const val WHITE = "WHITE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ 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
_isBearSelected.value = false
} else {
_selectedBearType.value = dollType
_isBearSelected.value = true
}
if (isSameBearSelected) _selectedBearType.value = NONE
else _selectedBearType.value = dollType
}

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.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:background="@{viewModel.selectedBearType.equals(@string/none) ? @drawable/shape_gray200_fill_12_rect:@drawable/shape_main1_fill_12_rect}"
android:clickable="@{viewModel.selectedBearType.equals(@string/none) ? false: true}"
android:enabled="@{viewModel.selectedBearType.equals(@string/none) ? false: true}"
android:text="@string/bear_selection_button"
android:textAppearance="@style/body1"
android:textColor="@color/gray000"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<string name="red">RED</string>
<string name="white">WHITE</string>
<string name="gray">GRAY</string>
<string name="none">NONE</string>

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

0 comments on commit d7b0701

Please sign in to comment.