Created
August 22, 2025 12:11
-
-
Save ifucolo/0aac368652ba6591193301771f8c27da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class ChapletFlowViewModel( | |
| private val challengeRepository: ChallengeRepository | |
| ) : ViewModel() { | |
| private val _shouldCloseFlow = MutableSharedFlow<Boolean>() | |
| val shouldCloseFlow: SharedFlow<Boolean> = _shouldCloseFlow | |
| val backStack = mutableStateListOf<ChapletRoutes>() | |
| init { | |
| if (backStack.isEmpty()) { | |
| backStack.add(ChapletRoutes.Start) | |
| } | |
| } | |
| fun navigateTo(route: ChapletRoutes) { | |
| backStack.add(route) | |
| } | |
| fun onChapletDone() { | |
| viewModelScope.launch { | |
| challengeRepository.updateChallengeV2(ChallengeId.CHAPLETS) | |
| _shouldCloseFlow.emit(true) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment