diff --git a/app/src/main/java/com/wap/wapp/MainActivity.kt b/app/src/main/java/com/wap/wapp/MainActivity.kt index 8b6e9df7..04fcb523 100644 --- a/app/src/main/java/com/wap/wapp/MainActivity.kt +++ b/app/src/main/java/com/wap/wapp/MainActivity.kt @@ -118,7 +118,7 @@ private fun handleBottomBarState( eventEditNavigationRoute -> setBottomBarState(false) SurveyRoute.answerRoute("{id}") -> setBottomBarState(false) surveyCheckRoute -> setBottomBarState(false) - SurveyCheckRoute.surveyDetailRoute("{id}") -> setBottomBarState(false) + SurveyCheckRoute.surveyDetailRoute("{id}", "{backStack}") -> setBottomBarState(false) else -> setBottomBarState(true) } diff --git a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt index e1a5c3f6..648f7036 100644 --- a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt +++ b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt @@ -37,6 +37,7 @@ import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingScre import com.wap.wapp.feature.splash.navigation.splashNavigationRoute import com.wap.wapp.feature.splash.navigation.splashScreen import com.wap.wapp.feature.survey.check.navigation.SurveyCheckRoute.surveyCheckRoute +import com.wap.wapp.feature.survey.check.navigation.SurveyDetailBackStack import com.wap.wapp.feature.survey.check.navigation.navigateToSurveyCheck import com.wap.wapp.feature.survey.check.navigation.navigateToSurveyDetail import com.wap.wapp.feature.survey.check.navigation.surveyCheckNavGraph @@ -98,6 +99,7 @@ fun WappNavHost( navOptions { popUpTo(surveyCheckRoute) { inclusive = true } }, ) }, + navigateToProfile = navController::navigateToProfile, ) managementSurveyNavGraph( navigateToManagement = navController::navigateToManagement, @@ -111,16 +113,17 @@ fun WappNavHost( navigateToSignIn = { navController.navigateToSignIn(navOptions { popUpTo(profileNavigationRoute) }) }, + navigateToSurveyDetail = { surveyId -> + navController.navigateToSurveyDetail( + surveyId = surveyId, + backStack = SurveyDetailBackStack.PROFILE, + navOptions = navOptions { popUpTo(profileNavigationRoute) }, + ) + }, ) attendanceScreen( navigateToSignIn = { - navController.navigateToSignIn( - navOptions { - popUpTo( - attendanceNavigationRoute, - ) - }, - ) + navController.navigateToSignIn(navOptions { popUpTo(attendanceNavigationRoute) }) }, navigateToAttendanceManagement = navController::navigateToAttendanceManagement, ) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 78b7aac0..79e135e6 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -41,6 +41,7 @@ internal fun ProfileRoute( navigateToProfileSetting: (String) -> Unit, navigateToAttendance: () -> Unit, navigateToSignIn: () -> Unit, + navigateToSurveyDetail: (String) -> Unit, ) { val todayEventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val recentEventsState by viewModel.recentEvents.collectAsStateWithLifecycle() @@ -67,6 +68,7 @@ internal fun ProfileRoute( navigateToProfileSetting = navigateToProfileSetting, navigateToAttendance = navigateToAttendance, navigateToSignIn = navigateToSignIn, + navigateToSurveyDetail = navigateToSurveyDetail, ) } @@ -81,6 +83,7 @@ internal fun ProfileScreen( navigateToProfileSetting: (String) -> Unit, navigateToAttendance: () -> Unit, navigateToSignIn: () -> Unit, + navigateToSurveyDetail: (String) -> Unit, ) { val scrollState = rememberScrollState() @@ -137,6 +140,7 @@ internal fun ProfileScreen( userRespondedSurveysState = userRespondedSurveysState, attendanceCardBoardColor = WappTheme.colors.blue4FF, navigateToAttendance = navigateToAttendance, + navigateToSurveyDetail = navigateToSurveyDetail, ) } @@ -161,6 +165,7 @@ internal fun ProfileScreen( userRespondedSurveysState = userRespondedSurveysState, attendanceCardBoardColor = WappTheme.colors.yellow34, navigateToAttendance = navigateToAttendance, + navigateToSurveyDetail = navigateToSurveyDetail, ) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt index da585a5f..4acbd438 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt @@ -19,13 +19,13 @@ import com.wap.wapp.core.model.survey.Survey internal fun WappSurveyHistoryRow( survey: Survey, modifier: Modifier = Modifier, - onClick: () -> Unit = {}, + onClick: (String) -> Unit, ) { Row( verticalAlignment = Alignment.CenterVertically, modifier = modifier .padding(horizontal = 10.dp) - .clickable { onClick() }, + .clickable { onClick(survey.surveyId) }, ) { Row( verticalAlignment = Alignment.CenterVertically, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt index 0f428055..0bfff2eb 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt @@ -17,12 +17,14 @@ fun NavGraphBuilder.profileScreen( navigateToProfileSetting: (String) -> Unit, navigateToAttendance: () -> Unit, navigateToSignIn: () -> Unit, + navigateToSurveyDetail: (String) -> Unit, ) { composable(route = profileNavigationRoute) { ProfileRoute( navigateToProfileSetting = navigateToProfileSetting, navigateToAttendance = navigateToAttendance, navigateToSignIn = navigateToSignIn, + navigateToSurveyDetail = navigateToSurveyDetail, ) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt index 69ec1923..d2d0488c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt @@ -47,6 +47,7 @@ internal fun UserProfile( userRespondedSurveysState: ProfileViewModel.SurveysState, attendanceCardBoardColor: Color, navigateToAttendance: () -> Unit, + navigateToSurveyDetail: (String) -> Unit, ) { Column(modifier = Modifier.padding(horizontal = 10.dp)) { ProfileAttendanceCard( @@ -63,6 +64,7 @@ internal fun UserProfile( MySurveyHistory( userRespondedSurveysState = userRespondedSurveysState, + navigateToSurveyDetail = navigateToSurveyDetail, modifier = Modifier.padding(vertical = 20.dp), ) } @@ -204,6 +206,7 @@ private fun MyAttendanceStatus( @Composable private fun MySurveyHistory( userRespondedSurveysState: ProfileViewModel.SurveysState, + navigateToSurveyDetail: (String) -> Unit, modifier: Modifier = Modifier, ) { Column(modifier = modifier) { @@ -243,7 +246,10 @@ private fun MySurveyHistory( items = userRespondedSurveysState.surveys, key = { survey -> survey.surveyId }, ) { survey -> - WappSurveyHistoryRow(survey) + WappSurveyHistoryRow( + survey, + onClick = navigateToSurveyDetail, + ) } } } diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt index 586c7e71..0303056a 100644 --- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt +++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt @@ -34,15 +34,20 @@ internal fun SubjectiveQuestionCard(surveyAnswer: SurveyAnswer) { color = WappTheme.colors.white, textAlign = TextAlign.Start, ) + Spacer(modifier = Modifier.height(16.dp)) Text( text = surveyAnswer.questionAnswer, style = WappTheme.typography.contentRegular, - color = WappTheme.colors.white, + color = WappTheme.colors.yellow34, textAlign = TextAlign.Start, ) - Divider() + + Divider( + color = WappTheme.colors.gray82, + modifier = Modifier.padding(top = 5.dp), + ) } } } diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailScreen.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailScreen.kt index 63331fec..c8f080ee 100644 --- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailScreen.kt +++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailScreen.kt @@ -2,6 +2,8 @@ package com.wap.wapp.feature.survey.check.detail import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState @@ -18,19 +20,30 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme +import com.wap.designsystem.component.CircleLoader import com.wap.designsystem.component.WappButton import com.wap.wapp.core.commmon.extensions.toSupportingText import com.wap.wapp.core.model.survey.QuestionType +import com.wap.wapp.feature.survey.check.navigation.SurveyDetailBackStack import kotlinx.coroutines.flow.collectLatest @Composable internal fun SurveyDetailRoute( viewModel: SurveyDetailViewModel = hiltViewModel(), surveyId: String, + backStack: String, navigateToSurveyCheck: () -> Unit, + navigateToProfile: () -> Unit, ) { val surveyUiState by viewModel.surveyUiState.collectAsStateWithLifecycle() val snackBarHostState = remember { SnackbarHostState() } + val navigateToPrevPage = { + if (backStack == SurveyDetailBackStack.SURVEY_CHECK.name) { + navigateToSurveyCheck() + } else { + navigateToProfile() + } + } LaunchedEffect(true) { viewModel.getSurvey(surveyId) @@ -45,8 +58,8 @@ internal fun SurveyDetailRoute( SurveyDetailScreen( snackBarHostState = snackBarHostState, surveyUiState = surveyUiState, - onDoneButtonClicked = { navigateToSurveyCheck() }, - onBackButtonClicked = { navigateToSurveyCheck() }, + onDoneButtonClicked = navigateToPrevPage, + onBackButtonClicked = navigateToPrevPage, ) } @@ -65,50 +78,60 @@ internal fun SurveyDetailScreen( onBackButtonClicked = onBackButtonClicked, ) }, + contentWindowInsets = WindowInsets(0.dp), snackbarHost = { SnackbarHost(snackBarHostState) }, containerColor = WappTheme.colors.backgroundBlack, ) { paddingValues -> Column( modifier = Modifier - .padding(paddingValues) - .padding(vertical = 16.dp, horizontal = 8.dp) .fillMaxSize() - .verticalScroll(scrollState), - verticalArrangement = Arrangement.spacedBy(32.dp), + .padding(paddingValues) + .padding(top = 16.dp, start = 8.dp, end = 8.dp), ) { - when (surveyUiState) { - is SurveyDetailViewModel.SurveyUiState.Init -> {} + Column( + modifier = Modifier + .weight(1f) + .fillMaxSize() + .verticalScroll(scrollState), + verticalArrangement = Arrangement.spacedBy(32.dp), + ) { + when (surveyUiState) { + is SurveyDetailViewModel.SurveyUiState.Loading -> { + Spacer(modifier = Modifier.weight(1f)) - is SurveyDetailViewModel.SurveyUiState.Success -> { - SurveyInformationCard( - title = surveyUiState.survey.title, - content = surveyUiState.survey.content, - userName = surveyUiState.survey.userName, - eventName = surveyUiState.survey.eventName, - ) + CircleLoader(modifier = Modifier.fillMaxSize()) - Column( - verticalArrangement = Arrangement.spacedBy(32.dp), - ) { - surveyUiState.survey.surveyAnswerList.forEach { surveyAnswer -> - when (surveyAnswer.questionType) { - QuestionType.OBJECTIVE -> { - ObjectiveQuestionCard(surveyAnswer) - } + Spacer(modifier = Modifier.weight(1f)) + } - QuestionType.SUBJECTIVE -> { - SubjectiveQuestionCard(surveyAnswer) + is SurveyDetailViewModel.SurveyUiState.Success -> { + SurveyInformationCard( + title = surveyUiState.survey.title, + content = surveyUiState.survey.content, + userName = surveyUiState.survey.userName, + eventName = surveyUiState.survey.eventName, + ) + + Column( + verticalArrangement = Arrangement.spacedBy(32.dp), + ) { + surveyUiState.survey.surveyAnswerList.forEach { surveyAnswer -> + when (surveyAnswer.questionType) { + QuestionType.OBJECTIVE -> ObjectiveQuestionCard(surveyAnswer) + + QuestionType.SUBJECTIVE -> SubjectiveQuestionCard(surveyAnswer) } } } } - - WappButton( - onClick = onDoneButtonClicked, - textRes = com.wap.wapp.core.designsystem.R.string.done, - ) } } + + WappButton( + onClick = onDoneButtonClicked, + textRes = com.wap.wapp.core.designsystem.R.string.done, + modifier = Modifier.padding(vertical = 20.dp), + ) } } } diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailViewModel.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailViewModel.kt index 065e8370..f3198e96 100644 --- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailViewModel.kt +++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailViewModel.kt @@ -22,7 +22,7 @@ class SurveyDetailViewModel @Inject constructor( val errorFlow: SharedFlow = _errorFlow.asSharedFlow() private val _surveyUiState: MutableStateFlow = - MutableStateFlow(SurveyUiState.Init) + MutableStateFlow(SurveyUiState.Loading) val surveyUiState: StateFlow = _surveyUiState.asStateFlow() fun getSurvey(surveyId: String) { @@ -38,8 +38,7 @@ class SurveyDetailViewModel @Inject constructor( } sealed class SurveyUiState { - data object Init : SurveyUiState() - + data object Loading : SurveyUiState() data class Success(val survey: Survey) : SurveyUiState() } } diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/navigation/SurveyCheckNavigation.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/navigation/SurveyCheckNavigation.kt index 57961327..aede9359 100644 --- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/navigation/SurveyCheckNavigation.kt +++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/navigation/SurveyCheckNavigation.kt @@ -12,8 +12,9 @@ import com.wap.wapp.feature.survey.check.detail.SurveyDetailRoute fun NavController.navigateToSurveyDetail( surveyId: String, + backStack: SurveyDetailBackStack = SurveyDetailBackStack.SURVEY_CHECK, navOptions: NavOptions? = navOptions {}, -) = this.navigate(SurveyCheckRoute.surveyDetailRoute(surveyId), navOptions) +) = this.navigate(SurveyCheckRoute.surveyDetailRoute(surveyId, backStack.name), navOptions) fun NavController.navigateToSurveyCheck(navOptions: NavOptions? = navOptions {}) = this.navigate(SurveyCheckRoute.surveyCheckRoute, navOptions) @@ -22,6 +23,7 @@ fun NavGraphBuilder.surveyCheckNavGraph( navigateToSurveyDetail: (String) -> Unit, navigateToSurveyCheck: () -> Unit, navigateToSurvey: () -> Unit, + navigateToProfile: () -> Unit, ) { composable(route = SurveyCheckRoute.surveyCheckRoute) { SurveyCheckScreen( @@ -31,22 +33,33 @@ fun NavGraphBuilder.surveyCheckNavGraph( } composable( - route = SurveyCheckRoute.surveyDetailRoute("{id}"), + route = SurveyCheckRoute.surveyDetailRoute("{id}", "{backStack}"), arguments = listOf( navArgument("id") { type = NavType.StringType }, + navArgument("backStack") { + type = NavType.StringType + }, ), ) { navBackStackEntry -> val surveyId = navBackStackEntry.arguments?.getString("id") ?: "" + val backStack = navBackStackEntry.arguments?.getString("backStack") ?: "SURVEY_CHECK" SurveyDetailRoute( - navigateToSurveyCheck = navigateToSurveyCheck, surveyId = surveyId, + backStack = backStack, + navigateToSurveyCheck = navigateToSurveyCheck, + navigateToProfile = navigateToProfile, ) } } object SurveyCheckRoute { const val surveyCheckRoute = "survey/check" - fun surveyDetailRoute(surveyId: String) = "survey/detail/$surveyId" + fun surveyDetailRoute(surveyId: String, backStack: String) = + "survey/detail/$surveyId/$backStack" +} + +enum class SurveyDetailBackStack { + SURVEY_CHECK, PROFILE }