-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 회원 탈퇴 시 동의항목 체크 selector로 변경 - 액티비티에 있던 로직들 뷰모델로 변경
- Loading branch information
Showing
6 changed files
with
53 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 20 additions & 19 deletions
39
app/src/main/java/com/ftw/hometerview/ui/withdrawal/WithdrawalViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
package com.ftw.hometerview.ui.withdrawal | ||
|
||
import com.ftw.hometerview.BR | ||
import com.ftw.hometerview.R | ||
import com.ftw.hometerview.adapter.RecyclerItem | ||
import com.ftw.hometerview.dispatcher.Dispatcher | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import com.ftw.hometerview.ui.main.favorite.favoritelist.FavoriteBuildingItem | ||
import com.ftw.hometerview.ui.main.favorite.favoritelist.FavoriteBuildingsViewModel | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.flow.* | ||
|
||
class WithdrawalViewModel( | ||
dispatcher: Dispatcher | ||
) { | ||
|
||
sealed class Event { | ||
object None : Event() | ||
object OnClickWithdrawalFirstCheck : Event() | ||
object OnClickWithdrawalSecondCheck : Event() | ||
object OnClickWithdrawalThirdCheck : Event() | ||
} | ||
|
||
private val _event: MutableStateFlow<Event> = MutableStateFlow(Event.None) | ||
val event: StateFlow<Event> = _event.asStateFlow() | ||
|
||
val withdrawalFirstCheck: MutableStateFlow<Boolean> = MutableStateFlow(false) | ||
val withdrawalSecondCheck: MutableStateFlow<Boolean> = MutableStateFlow(false) | ||
val withdrawalThirdCheck: MutableStateFlow<Boolean> = MutableStateFlow(false) | ||
val withdrawalCheck: MutableStateFlow<Boolean> = MutableStateFlow(false) | ||
|
||
fun onClickWithdrawalFirstCheck() { | ||
_event.value = Event.OnClickWithdrawalFirstCheck | ||
_event.value = Event.None | ||
withdrawalFirstCheck.value = !withdrawalFirstCheck.value | ||
withdrawalCheck.value = withdrawalCheck() | ||
} | ||
|
||
fun onClickWithdrawalSecondCheck() { | ||
_event.value = Event.OnClickWithdrawalSecondCheck | ||
_event.value = Event.None | ||
withdrawalSecondCheck.value = !withdrawalSecondCheck.value | ||
withdrawalCheck.value = withdrawalCheck() | ||
} | ||
|
||
fun onClickWithdrawalThirdCheck() { | ||
_event.value = Event.OnClickWithdrawalThirdCheck | ||
_event.value = Event.None | ||
withdrawalThirdCheck.value = !withdrawalThirdCheck.value | ||
withdrawalCheck.value = withdrawalCheck() | ||
} | ||
|
||
private fun withdrawalCheck(): Boolean { | ||
if (withdrawalFirstCheck.value | ||
&& withdrawalSecondCheck.value | ||
&& withdrawalThirdCheck.value | ||
) return true | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="@color/red_500" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="@color/gray_300" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@drawable/ic_baseline_uncheck_circle_24" android:state_enabled="true" android:state_checked="false"/> | ||
<item android:drawable="@drawable/ic_baseline_check_circle_24" android:state_checked="true" /> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters