Skip to content

Commit

Permalink
[FEATURE] #63 : 설문조사 페이지 BottomNavigation 전환 시 화면 줄어졌다가 커지는 현상 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Dec 27, 2023
1 parent 5c3c3bc commit 154f89c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class ManagementViewModel @Inject constructor(
private val _errorFlow: MutableSharedFlow<Throwable> = MutableSharedFlow()
val errorFlow: SharedFlow<Throwable> = _errorFlow.asSharedFlow()

// for test
private val _managerState: MutableStateFlow<ManagerState> =
MutableStateFlow(ManagerState.Manager)
MutableStateFlow(ManagerState.Init)
val managerState: StateFlow<ManagerState> = _managerState.asStateFlow()

private val _surveyList: MutableStateFlow<List<Survey>> = MutableStateFlow(emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
Expand All @@ -26,6 +25,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.CircleLoader
import com.wap.designsystem.component.WappTitle
import com.wap.wapp.core.commmon.extensions.toSupportingText
import com.wap.wapp.core.commmon.util.DateUtil.yyyyMMddFormatter
Expand All @@ -39,43 +39,44 @@ internal fun SurveyScreen(
viewModel: SurveyViewModel,
navigateToSurveyAnswer: (Int) -> Unit,
) {
val context = LocalContext.current
val surveyFormListUiState = viewModel.surveyFormListUiState.collectAsState().value
val snackBarHostState = remember { SnackbarHostState() }
Column(modifier = Modifier.fillMaxSize()) {
val context = LocalContext.current
val surveyFormListUiState = viewModel.surveyFormListUiState.collectAsState().value
val snackBarHostState = remember { SnackbarHostState() }

LaunchedEffect(true) {
viewModel.surveyEvent.collectLatest {
when (it) {
is SurveyViewModel.SurveyUiEvent.Failure -> {
snackBarHostState.showSnackbar(it.throwable.toSupportingText())
}
LaunchedEffect(true) {
viewModel.surveyEvent.collectLatest {
when (it) {
is SurveyViewModel.SurveyUiEvent.Failure -> {
snackBarHostState.showSnackbar(it.throwable.toSupportingText())
}

is SurveyViewModel.SurveyUiEvent.AlreadySubmitted -> {
snackBarHostState.showSnackbar(
context.getString(R.string.alreay_submitted_description),
)
}
is SurveyViewModel.SurveyUiEvent.AlreadySubmitted -> {
snackBarHostState.showSnackbar(
context.getString(R.string.alreay_submitted_description),
)
}

is SurveyViewModel.SurveyUiEvent.NotSubmitted -> {
navigateToSurveyAnswer(it.eventId)
is SurveyViewModel.SurveyUiEvent.NotSubmitted -> {
navigateToSurveyAnswer(it.eventId)
}
}
}
}
}

when (surveyFormListUiState) {
is SurveyViewModel.SurveyFormListUiState.Init -> { }
is SurveyViewModel.SurveyFormListUiState.Success -> {
SurveyContent(
surveyFormList = surveyFormListUiState.surveyFormList,
snackBarHostState = snackBarHostState,
selectedSurveyForm = viewModel::isSubmittedSurvey,
)
when (surveyFormListUiState) {
is SurveyViewModel.SurveyFormListUiState.Init -> CircleLoader()
is SurveyViewModel.SurveyFormListUiState.Success -> {
SurveyContent(
surveyFormList = surveyFormListUiState.surveyFormList,
snackBarHostState = snackBarHostState,
selectedSurveyForm = viewModel::isSubmittedSurvey,
)
}
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SurveyContent(
surveyFormList: List<SurveyForm>,
Expand Down

0 comments on commit 154f89c

Please sign in to comment.