Skip to content

Commit

Permalink
feat : 비로그인 예매하기 -> 로그인 화면
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Feb 15, 2024
1 parent d623cb5 commit fbe0d24
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fun MainNavigation(modifier: Modifier, onClickQrScan: (showId: String, showName:
navController.navigate("ticketing/$showId?salesTicketId=$ticketId&ticketCount=$ticketCount&inviteTicket=$isInviteTicket")
},
viewModel = showViewModel,
navigateToLogin = { navController.navigate("login") },
navigateToReport = {
val showId = entry.arguments?.getString("showId")
navController.navigate("report/$showId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.nexters.boolti.domain.model.ShowDetail
import com.nexters.boolti.domain.model.ShowState
import com.nexters.boolti.presentation.R
Expand All @@ -78,6 +79,7 @@ fun ShowDetailScreen(
onBack: () -> Unit,
onClickHome: () -> Unit,
onClickContent: () -> Unit,
navigateToLogin: () -> Unit,
onTicketSelected: (
showId: String,
ticketId: String,
Expand All @@ -88,7 +90,8 @@ fun ShowDetailScreen(
modifier: Modifier = Modifier,
viewModel: ShowDetailViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsState()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val isLoggedIn by viewModel.loggedIn.collectAsStateWithLifecycle()

val scope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }
Expand Down Expand Up @@ -170,7 +173,11 @@ fun ShowDetailScreen(
},
onClick = {
scope.launch {
showBottomSheet = true
if (isLoggedIn == true) {
showBottomSheet = true
} else {
navigateToLogin()
}
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.nexters.boolti.domain.model.ShowDetail
import com.nexters.boolti.domain.model.TicketingTicket
import com.nexters.boolti.domain.repository.AuthRepository
import com.nexters.boolti.domain.repository.ShowRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.util.UUID
Expand All @@ -19,12 +22,19 @@ import javax.inject.Inject
class ShowDetailViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val showRepository: ShowRepository,
private val authRepository: AuthRepository,
) : ViewModel() {
private val showId: String = checkNotNull(savedStateHandle["showId"])

private val _uiState = MutableStateFlow(ShowDetailUiState())
val uiState: StateFlow<ShowDetailUiState> = _uiState.asStateFlow()

val loggedIn = authRepository.loggedIn.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000),
null,
)

init {
fetchDummyTickets()
fetchShowDetail()
Expand Down

0 comments on commit fbe0d24

Please sign in to comment.