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 ce9e1de05..80ba7518b 100644
--- a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt
+++ b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt
@@ -30,7 +30,9 @@ import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingNavi
import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingScreen
import com.wap.wapp.feature.splash.navigation.splashNavigationRoute
import com.wap.wapp.feature.splash.navigation.splashScreen
-import com.wap.wapp.feature.survey.check.navigation.surveyCheckScreen
+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
import com.wap.wapp.feature.survey.navigation.navigateToSurvey
import com.wap.wapp.feature.survey.navigation.navigateToSurveyAnswer
import com.wap.wapp.feature.survey.navigation.surveyNavGraph
@@ -77,9 +79,11 @@ fun WappNavHost(
navigateToSurvey = navController::navigateToSurvey,
navigateToSurveyAnswer = navController::navigateToSurveyAnswer,
navigateToSignIn = navController::navigateToSignIn,
+ navigateToSurveyCheck = navController::navigateToSurveyCheck,
)
- surveyCheckScreen(
- navigateToManagement = navController::navigateToManagement,
+ surveyCheckNavGraph(
+ navigateToSurveyCheck = navController::navigateToSurveyCheck,
+ navigateToSurveyDetail = navController::navigateToSurveyDetail,
)
managementSurveyNavGraph(
navigateToManagement = navController::navigateToManagement,
diff --git a/core/designresource/src/main/res/drawable/ic_magnifier.xml b/core/designresource/src/main/res/drawable/ic_magnifier.xml
new file mode 100644
index 000000000..70296bddf
--- /dev/null
+++ b/core/designresource/src/main/res/drawable/ic_magnifier.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckScreen.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckScreen.kt
index 18da64b02..c38c022f0 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckScreen.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckScreen.kt
@@ -1,116 +1,73 @@
package com.wap.wapp.feature.survey.check
import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.verticalScroll
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
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.WappButton
+import com.wap.designsystem.component.CircleLoader
+import com.wap.designsystem.component.WappMainTopBar
import com.wap.wapp.core.commmon.extensions.toSupportingText
-import com.wap.wapp.core.model.survey.QuestionType
import kotlinx.coroutines.flow.collectLatest
@Composable
-internal fun SurveyCheckRoute(
+internal fun SurveyCheckScreen(
viewModel: SurveyCheckViewModel = hiltViewModel(),
- surveyId: String,
- navigateToManagement: () -> Unit,
+ navigateToSurveyDetail: (String) -> Unit,
) {
- val surveyUiState by viewModel.surveyUiState.collectAsStateWithLifecycle()
+ val surveyListUiState = viewModel.surveyListUiState.collectAsStateWithLifecycle().value
val snackBarHostState = remember { SnackbarHostState() }
LaunchedEffect(true) {
- viewModel.getSurvey(surveyId)
- }
-
- LaunchedEffect(true) {
- viewModel.surveyCheckUiEvent.collectLatest {
- when (it) {
- is SurveyCheckViewModel.SurveyUiEvent.Failure -> {
- snackBarHostState.showSnackbar(it.throwable.toSupportingText())
- }
- }
+ viewModel.errorFlow.collectLatest {
+ snackBarHostState.showSnackbar(it.toSupportingText())
}
}
- SurveyCheckScreen(
- snackBarHostState = snackBarHostState,
- surveyUiState = surveyUiState,
- onDoneButtonClicked = { navigateToManagement() },
- onBackButtonClicked = { navigateToManagement() },
- )
-}
-
-@Composable
-internal fun SurveyCheckScreen(
- snackBarHostState: SnackbarHostState,
- surveyUiState: SurveyCheckViewModel.SurveyUiState,
- onDoneButtonClicked: () -> Unit,
- onBackButtonClicked: () -> Unit,
-) {
- val scrollState = rememberScrollState()
-
Scaffold(
+ modifier = Modifier.fillMaxSize(),
+ containerColor = WappTheme.colors.backgroundBlack,
+ snackbarHost = { SnackbarHost(snackBarHostState) },
topBar = {
- SurveyCheckTopBar(
- onBackButtonClicked = onBackButtonClicked,
+ WappMainTopBar(
+ titleRes = R.string.survey_check,
+ contentRes = R.string.survey_check_content,
)
},
- snackbarHost = { SnackbarHost(snackBarHostState) },
- containerColor = WappTheme.colors.backgroundBlack,
+ contentWindowInsets = WindowInsets(0.dp),
) { paddingValues ->
- Column(
- modifier = Modifier
- .padding(paddingValues)
- .padding(vertical = 16.dp, horizontal = 8.dp)
- .fillMaxSize()
- .verticalScroll(scrollState),
- verticalArrangement = Arrangement.spacedBy(32.dp),
- ) {
- when (surveyUiState) {
- is SurveyCheckViewModel.SurveyUiState.Init -> {}
-
- is SurveyCheckViewModel.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)
- }
+ when (surveyListUiState) {
+ is SurveyCheckViewModel.SurveyListUiState.Init -> {
+ CircleLoader(modifier = Modifier.fillMaxSize())
+ }
- QuestionType.SUBJECTIVE -> {
- SubjectiveQuestionCard(surveyAnswer)
- }
- }
- }
+ is SurveyCheckViewModel.SurveyListUiState.Success -> {
+ LazyColumn(
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
+ .padding(paddingValues),
+ ) {
+ val surveyList = surveyListUiState.surveyList
+ items(surveyList) { survey ->
+ SurveyItemCard(
+ onCardClicked = navigateToSurveyDetail,
+ survey = survey,
+ )
}
-
- WappButton(
- onClick = onDoneButtonClicked,
- textRes = com.wap.wapp.core.designsystem.R.string.done,
- )
}
}
}
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckViewModel.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckViewModel.kt
index fcb375ff6..54a4a2f20 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckViewModel.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckViewModel.kt
@@ -2,13 +2,11 @@ package com.wap.wapp.feature.survey.check
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.wap.wapp.core.domain.usecase.survey.GetSurveyUseCase
+import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase
import com.wap.wapp.core.model.survey.Survey
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.SharedFlow
-import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
@@ -16,34 +14,33 @@ import javax.inject.Inject
@HiltViewModel
class SurveyCheckViewModel @Inject constructor(
- private val getSurveyUseCase: GetSurveyUseCase,
+ private val getSurveyListUseCase: GetSurveyListUseCase,
) : ViewModel() {
- private val _surveyCheckUiEvent: MutableSharedFlow = MutableSharedFlow()
- val surveyCheckUiEvent: SharedFlow = _surveyCheckUiEvent.asSharedFlow()
+ private val _surveyListUiState: MutableStateFlow =
+ MutableStateFlow(SurveyListUiState.Init)
+ val surveyListUiState = _surveyListUiState.asStateFlow()
- private val _surveyUiState: MutableStateFlow =
- MutableStateFlow(SurveyUiState.Init)
- val surveyUiState: StateFlow = _surveyUiState.asStateFlow()
+ private val _errorFlow: MutableSharedFlow = MutableSharedFlow()
+ val errorFlow = _errorFlow.asSharedFlow()
- fun getSurvey(surveyId: String) {
+ init {
+ getSurveyList()
+ }
+
+ private fun getSurveyList() {
viewModelScope.launch {
- getSurveyUseCase(surveyId)
- .onSuccess { survey ->
- _surveyUiState.value = SurveyUiState.Success(survey)
+ getSurveyListUseCase()
+ .onSuccess { surveyList ->
+ _surveyListUiState.value = SurveyListUiState.Success(surveyList)
}
.onFailure { throwable ->
- _surveyCheckUiEvent.emit(SurveyUiEvent.Failure(throwable))
+ _errorFlow.emit(throwable)
}
}
}
- sealed class SurveyUiState {
- data object Init : SurveyUiState()
-
- data class Success(val survey: Survey) : SurveyUiState()
- }
-
- sealed class SurveyUiEvent {
- data class Failure(val throwable: Throwable) : SurveyUiEvent()
+ sealed class SurveyListUiState {
+ data object Init : SurveyListUiState()
+ data class Success(val surveyList: List) : SurveyListUiState()
}
}
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt
new file mode 100644
index 000000000..e958b9a05
--- /dev/null
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt
@@ -0,0 +1,61 @@
+package com.wap.wapp.feature.survey.check
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import com.wap.designsystem.WappTheme
+import com.wap.wapp.core.model.survey.Survey
+
+@Composable
+internal fun SurveyItemCard(
+ onCardClicked: (String) -> Unit,
+ survey: Survey,
+) {
+ Card(
+ colors = CardDefaults.cardColors(
+ containerColor = WappTheme.colors.black25,
+ ),
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { onCardClicked(survey.surveyId) },
+ ) {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(16.dp),
+ modifier = Modifier.padding(16.dp),
+ ) {
+ Row(
+ horizontalArrangement = Arrangement.End,
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Text(
+ text = survey.title,
+ modifier = Modifier.weight(1f),
+ maxLines = 1,
+ color = WappTheme.colors.white,
+ style = WappTheme.typography.titleBold,
+ )
+
+ Text(
+ text = survey.eventName,
+ color = WappTheme.colors.grayA2,
+ style = WappTheme.typography.captionMedium,
+ )
+ }
+
+ Text(
+ text = survey.userName,
+ color = WappTheme.colors.grayBD,
+ style = WappTheme.typography.contentMedium,
+ )
+ }
+ }
+}
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/ObjectiveQuestionCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/ObjectiveQuestionCard.kt
similarity index 98%
rename from feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/ObjectiveQuestionCard.kt
rename to feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/ObjectiveQuestionCard.kt
index 89c9a4fbc..70d019c67 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/ObjectiveQuestionCard.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/ObjectiveQuestionCard.kt
@@ -1,4 +1,4 @@
-package com.wap.wapp.feature.survey.check
+package com.wap.wapp.feature.survey.check.detail
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SubjectiveQuestionCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt
similarity index 96%
rename from feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SubjectiveQuestionCard.kt
rename to feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt
index 3943e3b60..586c7e715 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SubjectiveQuestionCard.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SubjectiveQuestionCard.kt
@@ -1,4 +1,4 @@
-package com.wap.wapp.feature.survey.check
+package com.wap.wapp.feature.survey.check.detail
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
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
new file mode 100644
index 000000000..63331fec9
--- /dev/null
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailScreen.kt
@@ -0,0 +1,114 @@
+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.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.SnackbarHost
+import androidx.compose.material3.SnackbarHostState
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+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.WappButton
+import com.wap.wapp.core.commmon.extensions.toSupportingText
+import com.wap.wapp.core.model.survey.QuestionType
+import kotlinx.coroutines.flow.collectLatest
+
+@Composable
+internal fun SurveyDetailRoute(
+ viewModel: SurveyDetailViewModel = hiltViewModel(),
+ surveyId: String,
+ navigateToSurveyCheck: () -> Unit,
+) {
+ val surveyUiState by viewModel.surveyUiState.collectAsStateWithLifecycle()
+ val snackBarHostState = remember { SnackbarHostState() }
+
+ LaunchedEffect(true) {
+ viewModel.getSurvey(surveyId)
+ }
+
+ LaunchedEffect(true) {
+ viewModel.errorFlow.collectLatest {
+ snackBarHostState.showSnackbar(it.toSupportingText())
+ }
+ }
+
+ SurveyDetailScreen(
+ snackBarHostState = snackBarHostState,
+ surveyUiState = surveyUiState,
+ onDoneButtonClicked = { navigateToSurveyCheck() },
+ onBackButtonClicked = { navigateToSurveyCheck() },
+ )
+}
+
+@Composable
+internal fun SurveyDetailScreen(
+ snackBarHostState: SnackbarHostState,
+ surveyUiState: SurveyDetailViewModel.SurveyUiState,
+ onDoneButtonClicked: () -> Unit,
+ onBackButtonClicked: () -> Unit,
+) {
+ val scrollState = rememberScrollState()
+
+ Scaffold(
+ topBar = {
+ SurveyDetailTopBar(
+ onBackButtonClicked = onBackButtonClicked,
+ )
+ },
+ 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),
+ ) {
+ when (surveyUiState) {
+ is SurveyDetailViewModel.SurveyUiState.Init -> {}
+
+ 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,
+ )
+ }
+ }
+ }
+ }
+}
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckTopBar.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailTopBar.kt
similarity index 93%
rename from feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckTopBar.kt
rename to feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailTopBar.kt
index 6e8578020..ec08152d3 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyCheckTopBar.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailTopBar.kt
@@ -1,4 +1,4 @@
-package com.wap.wapp.feature.survey.check
+package com.wap.wapp.feature.survey.check.detail
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.WindowInsets
@@ -17,10 +17,11 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.wap.designsystem.WappTheme
import com.wap.wapp.core.designresource.R.drawable
+import com.wap.wapp.feature.survey.check.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
-internal fun SurveyCheckTopBar(
+internal fun SurveyDetailTopBar(
onBackButtonClicked: () -> Unit,
) {
CenterAlignedTopAppBar(
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
new file mode 100644
index 000000000..065e8370b
--- /dev/null
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyDetailViewModel.kt
@@ -0,0 +1,45 @@
+package com.wap.wapp.feature.survey.check.detail
+
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.wap.wapp.core.domain.usecase.survey.GetSurveyUseCase
+import com.wap.wapp.core.model.survey.Survey
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asSharedFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class SurveyDetailViewModel @Inject constructor(
+ private val getSurveyUseCase: GetSurveyUseCase,
+) : ViewModel() {
+ private val _errorFlow: MutableSharedFlow = MutableSharedFlow()
+ val errorFlow: SharedFlow = _errorFlow.asSharedFlow()
+
+ private val _surveyUiState: MutableStateFlow =
+ MutableStateFlow(SurveyUiState.Init)
+ val surveyUiState: StateFlow = _surveyUiState.asStateFlow()
+
+ fun getSurvey(surveyId: String) {
+ viewModelScope.launch {
+ getSurveyUseCase(surveyId)
+ .onSuccess { survey ->
+ _surveyUiState.value = SurveyUiState.Success(survey)
+ }
+ .onFailure { throwable ->
+ _errorFlow.emit(throwable)
+ }
+ }
+ }
+
+ sealed class SurveyUiState {
+ data object Init : SurveyUiState()
+
+ data class Success(val survey: Survey) : SurveyUiState()
+ }
+}
diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyInformationCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyInformationCard.kt
similarity index 97%
rename from feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyInformationCard.kt
rename to feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyInformationCard.kt
index e49c282b1..bb29d5ce1 100644
--- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyInformationCard.kt
+++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/detail/SurveyInformationCard.kt
@@ -1,4 +1,4 @@
-package com.wap.wapp.feature.survey.check
+package com.wap.wapp.feature.survey.check.detail
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -17,6 +17,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.wap.designsystem.WappTheme
+import com.wap.wapp.feature.survey.check.R
@Composable
internal fun SurveyInformationCard(
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 a9b4d4d26..d853fc4ee 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
@@ -7,32 +7,44 @@ import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import androidx.navigation.navOptions
-import com.wap.wapp.feature.survey.check.SurveyCheckRoute
+import com.wap.wapp.feature.survey.check.SurveyCheckScreen
+import com.wap.wapp.feature.survey.check.detail.SurveyDetailRoute
-const val SURVEY_CHECK_ROUTE = "survey/check/{surveyId}"
-
-fun NavController.navigateToSurveyCheck(
+fun NavController.navigateToSurveyDetail(
surveyId: String,
navOptions: NavOptions? = navOptions {},
-) {
- this.navigate("survey/check/$surveyId", navOptions)
-}
+) = this.navigate(SurveyCheckRoute.surveyDetailRoute(surveyId), navOptions)
-fun NavGraphBuilder.surveyCheckScreen(
- navigateToManagement: () -> Unit,
+fun NavController.navigateToSurveyCheck(navOptions: NavOptions? = navOptions {}) =
+ this.navigate(SurveyCheckRoute.surveyCheckRoute, navOptions)
+
+fun NavGraphBuilder.surveyCheckNavGraph(
+ navigateToSurveyDetail: (String) -> Unit,
+ navigateToSurveyCheck: () -> Unit,
) {
+ composable(route = SurveyCheckRoute.surveyCheckRoute) {
+ SurveyCheckScreen(
+ navigateToSurveyDetail = navigateToSurveyDetail,
+ )
+ }
+
composable(
- route = SURVEY_CHECK_ROUTE,
+ route = SurveyCheckRoute.surveyDetailRoute("{id}"),
arguments = listOf(
- navArgument("surveyId") {
+ navArgument("id") {
type = NavType.StringType
},
),
) { navBackStackEntry ->
- val surveyId = navBackStackEntry.arguments?.getString("surveyId") ?: ""
- SurveyCheckRoute(
- navigateToManagement = navigateToManagement,
+ val surveyId = navBackStackEntry.arguments?.getString("id") ?: ""
+ SurveyDetailRoute(
+ navigateToSurveyCheck = navigateToSurveyCheck,
surveyId = surveyId,
)
}
}
+
+object SurveyCheckRoute {
+ const val surveyCheckRoute = "survey/check"
+ fun surveyDetailRoute(surveyId: String) = "survey/detail/$surveyId"
+}
diff --git a/feature/survey-check/src/main/res/values/strings.xml b/feature/survey-check/src/main/res/values/strings.xml
index e154b6647..1d7a88ea7 100644
--- a/feature/survey-check/src/main/res/values/strings.xml
+++ b/feature/survey-check/src/main/res/values/strings.xml
@@ -4,4 +4,6 @@
이름
다음
일정
+ 설문 확인
+ 구성원이 작성한 설문을 확인하세요 !
diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyContent.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyContent.kt
new file mode 100644
index 000000000..6f3c0c1af
--- /dev/null
+++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyContent.kt
@@ -0,0 +1,95 @@
+package com.wap.wapp.feature.survey
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.ElevatedButton
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import com.wap.designsystem.WappTheme
+import com.wap.wapp.core.designresource.R
+import com.wap.wapp.feature.survey.R.string
+import com.wap.wapp.core.model.survey.SurveyForm
+
+@Composable
+internal fun SurveyContent(
+ surveyFormList: List,
+ isManager: Boolean,
+ paddingValues: PaddingValues,
+ selectedSurveyForm: (String) -> Unit,
+ onSurveyCheckButtonClicked: () -> Unit,
+) {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(16.dp),
+ horizontalAlignment = Alignment.End,
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
+ .padding(paddingValues),
+ ) {
+ LazyColumn(
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ modifier = Modifier
+ .weight(1f)
+ .fillMaxWidth(),
+ ) {
+ items(surveyFormList) { surveyForm ->
+ if (surveyForm.isAfterDeadline()) {
+ SurveyFormItemCard(
+ surveyForm = surveyForm,
+ selectedSurveyForm = selectedSurveyForm,
+ )
+ }
+ }
+ }
+
+ if (isManager) {
+ SurveyCheckButton(onSurveyCheckButtonClicked = onSurveyCheckButtonClicked)
+ }
+ }
+}
+
+@Composable
+private fun SurveyCheckButton(
+ onSurveyCheckButtonClicked: () -> Unit,
+) {
+ ElevatedButton(
+ modifier = Modifier.height(48.dp),
+ onClick = { onSurveyCheckButtonClicked() },
+ colors = ButtonDefaults.buttonColors(
+ contentColor = WappTheme.colors.black,
+ containerColor = WappTheme.colors.yellow34,
+ disabledContentColor = WappTheme.colors.white,
+ disabledContainerColor = WappTheme.colors.grayA2,
+ ),
+ shape = RoundedCornerShape(10.dp),
+ content = {
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(
+ text = stringResource(string.go_to_survey_check),
+ style = WappTheme.typography.contentRegular,
+ )
+
+ Icon(
+ painter = painterResource(id = R.drawable.ic_magnifier),
+ contentDescription = stringResource(string.survey_check_description),
+ )
+ }
+ },
+ )
+}
diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt
new file mode 100644
index 000000000..0d2c71ee7
--- /dev/null
+++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt
@@ -0,0 +1,59 @@
+package com.wap.wapp.feature.survey
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import com.wap.designsystem.WappTheme
+import com.wap.wapp.core.model.survey.SurveyForm
+
+@Composable
+internal fun SurveyFormItemCard(
+ surveyForm: SurveyForm,
+ selectedSurveyForm: (String) -> Unit,
+) {
+ Card(
+ colors = CardDefaults.cardColors(
+ containerColor = WappTheme.colors.black25,
+ ),
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { selectedSurveyForm(surveyForm.surveyFormId) },
+ ) {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(16.dp),
+ modifier = Modifier.padding(16.dp),
+ ) {
+ Row(
+ horizontalArrangement = Arrangement.End,
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Text(
+ text = surveyForm.title,
+ color = WappTheme.colors.white,
+ modifier = Modifier.weight(1f),
+ maxLines = 1,
+ style = WappTheme.typography.titleBold,
+ )
+ Text(
+ text = surveyForm.calculateDeadline(),
+ color = WappTheme.colors.yellow34,
+ style = WappTheme.typography.captionMedium,
+ )
+ }
+ Text(
+ text = surveyForm.content,
+ color = WappTheme.colors.grayBD,
+ style = WappTheme.typography.contentMedium,
+ )
+ }
+ }
+}
diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt
index 5f65ab93f..bb5a64b7d 100644
--- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt
+++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt
@@ -1,22 +1,10 @@
package com.wap.wapp.feature.survey
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.PaddingValues
-import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
-import androidx.compose.material3.Card
-import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
-import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -26,13 +14,11 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.WappMainTopBar
import com.wap.wapp.core.commmon.extensions.toSupportingText
-import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.user.UserRole
import kotlinx.coroutines.flow.collectLatest
@@ -41,11 +27,13 @@ internal fun SurveyScreen(
viewModel: SurveyViewModel,
navigateToSignIn: () -> Unit,
navigateToSurveyAnswer: (String) -> Unit,
+ navigateToSurveyCheck: () -> Unit,
) {
val context = LocalContext.current
val surveyFormListUiState = viewModel.surveyFormListUiState.collectAsStateWithLifecycle().value
val snackBarHostState = remember { SnackbarHostState() }
- var isShowGuestDialog by rememberSaveable { mutableStateOf(false) }
+ var isGuest by rememberSaveable { mutableStateOf(false) }
+ var isManager by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(true) {
viewModel.surveyEvent.collectLatest {
@@ -74,12 +62,15 @@ internal fun SurveyScreen(
is SurveyViewModel.UserRoleUiState.Success -> {
when (userRoleUiState.userRole) {
UserRole.GUEST -> {
- isShowGuestDialog = true
+ isGuest = true
}
// 비회원이 아닌 경우, 목록 호출
- UserRole.MEMBER, UserRole.MANAGER -> {
+ UserRole.MEMBER -> viewModel.getSurveyFormList()
+
+ UserRole.MANAGER -> {
viewModel.getSurveyFormList()
+ isManager = true
}
}
}
@@ -104,82 +95,19 @@ internal fun SurveyScreen(
is SurveyViewModel.SurveyFormListUiState.Success -> {
SurveyContent(
surveyFormList = surveyFormListUiState.surveyFormList,
+ isManager = isManager,
paddingValues = paddingValues,
selectedSurveyForm = viewModel::isSubmittedSurvey,
+ onSurveyCheckButtonClicked = navigateToSurveyCheck,
)
}
}
}
- if (isShowGuestDialog) {
+ if (isGuest) {
SurveyGuestDialog(
- onDismissRequest = { isShowGuestDialog = false },
+ onDismissRequest = { isGuest = false },
onButtonClicked = navigateToSignIn,
)
}
}
-
-@Composable
-private fun SurveyContent(
- surveyFormList: List,
- paddingValues: PaddingValues,
- selectedSurveyForm: (String) -> Unit,
-) {
- LazyColumn(
- verticalArrangement = Arrangement.spacedBy(8.dp),
- modifier = Modifier
- .padding(paddingValues)
- .padding(horizontal = 16.dp),
- ) {
- items(surveyFormList) { surveyForm ->
- if (surveyForm.isAfterDeadline()) {
- SurveyFormItemCard(
- surveyForm = surveyForm,
- selectedSurveyForm = selectedSurveyForm,
- )
- }
- }
- }
-}
-
-@Composable
-private fun SurveyFormItemCard(
- surveyForm: SurveyForm,
- selectedSurveyForm: (String) -> Unit,
-) {
- Card(
- colors = CardDefaults.cardColors(
- containerColor = WappTheme.colors.black25,
- ),
- modifier = Modifier
- .fillMaxWidth()
- .clickable { selectedSurveyForm(surveyForm.surveyFormId) },
- ) {
- Column(
- verticalArrangement = Arrangement.spacedBy(16.dp),
- modifier = Modifier.padding(16.dp),
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- ) {
- Text(
- text = surveyForm.title,
- color = WappTheme.colors.white,
- style = WappTheme.typography.titleBold,
- )
- Text(
- text = surveyForm.calculateDeadline(),
- color = WappTheme.colors.yellow34,
- style = WappTheme.typography.captionMedium,
- modifier = Modifier.fillMaxWidth(),
- textAlign = TextAlign.End,
- )
- }
- Text(
- text = surveyForm.content,
- color = WappTheme.colors.grayBD,
- style = WappTheme.typography.contentMedium,
- )
- }
- }
-}
diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt
index 0a6642742..5b515da6a 100644
--- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt
+++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt
@@ -15,14 +15,18 @@ fun NavController.navigateToSurvey(navOptions: NavOptions? = navOptions {}) {
this.navigate(SurveyRoute.route, navOptions)
}
-fun NavController.navigateToSurveyAnswer(eventId: String, navOptions: NavOptions? = navOptions {}) {
- navigate(SurveyRoute.answerRoute(eventId), navOptions)
+fun NavController.navigateToSurveyAnswer(
+ surveyFormId: String,
+ navOptions: NavOptions? = navOptions {},
+) {
+ navigate(SurveyRoute.answerRoute(surveyFormId), navOptions)
}
fun NavGraphBuilder.surveyNavGraph(
navigateToSurveyAnswer: (String) -> Unit,
navigateToSurvey: () -> Unit,
navigateToSignIn: () -> Unit,
+ navigateToSurveyCheck: () -> Unit,
) {
composable(route = SurveyRoute.route) {
SurveyScreen(
@@ -31,6 +35,7 @@ fun NavGraphBuilder.surveyNavGraph(
navigateToSurveyAnswer = { surveyFormId ->
navigateToSurveyAnswer(surveyFormId)
},
+ navigateToSurveyCheck = navigateToSurveyCheck,
)
}
diff --git a/feature/survey/src/main/res/values/strings.xml b/feature/survey/src/main/res/values/strings.xml
index 2855ada2f..3eb026338 100644
--- a/feature/survey/src/main/res/values/strings.xml
+++ b/feature/survey/src/main/res/values/strings.xml
@@ -14,4 +14,6 @@
앗 회원이 아니시네요 !
회원만 설문을 작성할 수 있어요.
비회원으로 둘러보기
+ 작성된 설문 보러가기
+ 작성된 설문 보러가기 아이콘