-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into feat/#478
# Conflicts: # backend/src/test/java/com/festago/support/SetUpMockito.java
- Loading branch information
Showing
49 changed files
with
858 additions
and
510 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
23 changes: 14 additions & 9 deletions
23
android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeViewModel.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,27 +1,32 @@ | ||
package com.festago.festago.presentation.ui.home | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.festago.festago.presentation.ui.home.HomeItemType.FESTIVAL_LIST | ||
import com.festago.festago.presentation.ui.home.HomeItemType.MY_PAGE | ||
import com.festago.festago.presentation.ui.home.HomeItemType.TICKET_LIST | ||
import com.festago.festago.presentation.util.MutableSingleLiveData | ||
import com.festago.festago.presentation.util.SingleLiveData | ||
import com.festago.festago.repository.AuthRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class HomeViewModel @Inject constructor(private val authRepository: AuthRepository) : ViewModel() { | ||
|
||
private val _event = MutableSingleLiveData<HomeEvent>() | ||
val event: SingleLiveData<HomeEvent> = _event | ||
private val _event = MutableSharedFlow<HomeEvent>() | ||
val event: SharedFlow<HomeEvent> = _event.asSharedFlow() | ||
|
||
fun loadHomeItem(homeItemType: HomeItemType) { | ||
when { | ||
homeItemType == FESTIVAL_LIST -> _event.setValue(HomeEvent.ShowFestivalList) | ||
!authRepository.isSigned -> _event.setValue(HomeEvent.ShowSignIn) | ||
homeItemType == TICKET_LIST -> _event.setValue(HomeEvent.ShowTicketList) | ||
homeItemType == MY_PAGE -> _event.setValue(HomeEvent.ShowMyPage) | ||
viewModelScope.launch { | ||
when { | ||
homeItemType == FESTIVAL_LIST -> _event.emit(HomeEvent.ShowFestivalList) | ||
!authRepository.isSigned -> _event.emit(HomeEvent.ShowSignIn) | ||
homeItemType == TICKET_LIST -> _event.emit(HomeEvent.ShowTicketList) | ||
homeItemType == MY_PAGE -> _event.emit(HomeEvent.ShowMyPage) | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.