feat: challenges, desire sync, how well, memory lane, this or that screens
This commit is contained in:
parent
3f5d7a5cc1
commit
17403b1a75
|
|
@ -112,7 +112,7 @@ class ConnectionChallengesViewModel @Inject constructor(
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
|
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
|
||||||
_uiState.update { it.copy(phase = ChallengesPhase.PICK) }
|
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val partnerId = couple.userIds.firstOrNull { it != uid } ?: uid
|
val partnerId = couple.userIds.firstOrNull { it != uid } ?: uid
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,10 @@ class DesireSyncViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
val uid = gameSessionManager.currentUserId
|
val uid = gameSessionManager.currentUserId
|
||||||
?: return@launch fail("You need to be signed in to play.")
|
?: return@launch fail("You need to be signed in to play.")
|
||||||
val couple = gameSessionManager.getCoupleForUser(uid)
|
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
|
||||||
?: return@launch fail("Pair with your partner to play together.")
|
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
userId = uid
|
userId = uid
|
||||||
coupleId = couple.id
|
coupleId = couple.id
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,10 @@ class HowWellViewModel @Inject constructor(
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val uid = gameSessionManager.currentUserId
|
val uid = gameSessionManager.currentUserId
|
||||||
?: return@launch fail("You need to be signed in to play.")
|
?: return@launch fail("You need to be signed in to play.")
|
||||||
val couple = gameSessionManager.getCoupleForUser(uid)
|
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
|
||||||
?: return@launch fail("Pair with your partner to play together.")
|
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
userId = uid
|
userId = uid
|
||||||
coupleId = couple.id
|
coupleId = couple.id
|
||||||
partnerId = couple.userIds.firstOrNull { it != uid }
|
partnerId = couple.userIds.firstOrNull { it != uid }
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,8 @@ data class MemoryLaneUiState(
|
||||||
val selectedPrompt: String? = null,
|
val selectedPrompt: String? = null,
|
||||||
val isSaving: Boolean = false,
|
val isSaving: Boolean = false,
|
||||||
val error: String? = null,
|
val error: String? = null,
|
||||||
val hasPremium: Boolean = true
|
val hasPremium: Boolean = true,
|
||||||
|
val navigateTo: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
|
|
@ -146,7 +147,7 @@ class MemoryLaneViewModel @Inject constructor(
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
|
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
|
||||||
_uiState.update { it.copy(phase = MemoryLanePhase.ERROR, error = "Link up with a partner to start creating capsules.") }
|
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,6 +175,8 @@ class MemoryLaneViewModel @Inject constructor(
|
||||||
load()
|
load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onNavigated() = _uiState.update { it.copy(navigateTo = null) }
|
||||||
|
|
||||||
fun openCreate() = _uiState.update {
|
fun openCreate() = _uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
phase = MemoryLanePhase.CREATE,
|
phase = MemoryLanePhase.CREATE,
|
||||||
|
|
@ -247,6 +250,10 @@ fun MemoryLaneScreen(
|
||||||
) {
|
) {
|
||||||
val state by viewModel.uiState.collectAsState()
|
val state by viewModel.uiState.collectAsState()
|
||||||
|
|
||||||
|
LaunchedEffect(state.navigateTo) {
|
||||||
|
state.navigateTo?.let { onNavigate(it); viewModel.onNavigated() }
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
|
|
||||||
|
|
@ -170,8 +170,10 @@ class ThisOrThatViewModel @Inject constructor(
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val uid = gameSessionManager.currentUserId
|
val uid = gameSessionManager.currentUserId
|
||||||
?: return@launch fail("You need to be signed in to play.")
|
?: return@launch fail("You need to be signed in to play.")
|
||||||
val couple = gameSessionManager.getCoupleForUser(uid)
|
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
|
||||||
?: return@launch fail("Pair with your partner to play together.")
|
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
userId = uid
|
userId = uid
|
||||||
coupleId = couple.id
|
coupleId = couple.id
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue