Skip to content

Commit 5e4abb7

Browse files
committed
#160[fix] 곰 미선택시 버튼 비활성화를 위한 boolean 변수 생성
1 parent f99a962 commit 5e4abb7

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

app/src/main/java/com/sopetit/softie/ui/onboarding/bearselection/BearSelectionViewModel.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ class BearSelectionViewModel @Inject constructor(
1414
) : ViewModel() {
1515
private val _selectedBearType: MutableLiveData<String> = MutableLiveData(NONE)
1616
val selectedBearType: LiveData<String> get() = _selectedBearType
17+
private val _isBearSelected: MutableLiveData<Boolean> = MutableLiveData(false)
18+
val isBearSelected: LiveData<Boolean> get() = _isBearSelected
1719

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

21-
if (isSameBearSelected) _selectedBearType.value = NONE
22-
else _selectedBearType.value = dollType
23+
if (isSameBearSelected) {
24+
_selectedBearType.value = NONE
25+
_isBearSelected.value = false
26+
} else {
27+
_selectedBearType.value = dollType
28+
_isBearSelected.value = true
29+
}
2330
}
2431

2532
fun setBearType() {

app/src/main/res/layout/fragment_onboarding_bear_selection.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100
android:layout_marginHorizontal="20dp"
101101
android:layout_marginBottom="34dp"
102102
style="?android:attr/borderlessButtonStyle"
103-
android:background="@{viewModel.selectedBearType != @string/none ? @drawable/shape_main1_fill_12_rect : @drawable/shape_gray200_fill_12_rect}"
104-
android:clickable="@{viewModel.selectedBearType != @string/none ? true : false}"
105-
android:enabled="@{viewModel.selectedBearType != @string/none ? true : false}"
103+
android:background="@{viewModel.isBearSelected ? @drawable/shape_main1_fill_12_rect: @drawable/shape_gray200_fill_12_rect}"
104+
android:clickable="@{viewModel.isBearSelected ? true: false}"
105+
android:enabled="@{viewModel.isBearSelected ? true: false}"
106106
android:text="@string/bear_selection_button"
107107
android:textAppearance="@style/body1"
108108
android:textColor="@color/gray000"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<string name="red">RED</string>
77
<string name="white">WHITE</string>
88
<string name="gray">GRAY</string>
9-
<string name="none"></string>
109

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

0 commit comments

Comments
 (0)