diff --git a/core/designsystem/src/main/java/kr/boostcamp_2024/course/designsystem/ui/annotation/PreviewAnnotations.kt b/core/designsystem/src/main/java/kr/boostcamp_2024/course/designsystem/ui/annotation/PreviewAnnotations.kt index ea18fe88..68b0141b 100644 --- a/core/designsystem/src/main/java/kr/boostcamp_2024/course/designsystem/ui/annotation/PreviewAnnotations.kt +++ b/core/designsystem/src/main/java/kr/boostcamp_2024/course/designsystem/ui/annotation/PreviewAnnotations.kt @@ -6,3 +6,7 @@ import androidx.compose.ui.tooling.preview.Preview @Preview(locale = "ko") @Preview(locale = "ko", uiMode = UI_MODE_NIGHT_YES) annotation class PreviewKoLightDark + +@Preview(locale = "ko", showBackground = true) +@Preview(locale = "ko", showBackground = true, uiMode = UI_MODE_NIGHT_YES) +annotation class PreviewKoLightDarkBackground diff --git a/feature/main/src/main/java/kr/boostcamp_2024/course/main/presentation/NotificationScreen.kt b/feature/main/src/main/java/kr/boostcamp_2024/course/main/presentation/NotificationScreen.kt index 38e1f385..332899a0 100644 --- a/feature/main/src/main/java/kr/boostcamp_2024/course/main/presentation/NotificationScreen.kt +++ b/feature/main/src/main/java/kr/boostcamp_2024/course/main/presentation/NotificationScreen.kt @@ -17,9 +17,9 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.domain.model.Notification import kr.boostcamp_2024.course.domain.model.NotificationWithGroupInfo @@ -29,7 +29,7 @@ import kr.boostcamp_2024.course.main.component.NotificationTopAppBar import kr.boostcamp_2024.course.main.viewmodel.NotificationViewModel @Composable -fun NotificationScreen( +internal fun NotificationScreen( viewModel: NotificationViewModel = hiltViewModel(), onNavigationButtonClick: () -> Unit, ) { @@ -54,7 +54,7 @@ fun NotificationScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun NotificationScreen( +private fun NotificationScreen( notificationInfos: List, onRejectClick: (String) -> Unit, onAcceptClick: (Notification) -> Unit, @@ -98,7 +98,7 @@ fun NotificationScreen( } } -@Preview +@PreviewKoLightDark @Composable private fun NotificationScreenPreview() { WeQuizTheme { diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizOwnerDialog.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizOwnerDialog.kt index aba68786..30dfe562 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizOwnerDialog.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizOwnerDialog.kt @@ -3,13 +3,13 @@ package kr.boostcamp_2024.course.quiz.component import androidx.compose.runtime.Composable import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizBaseDialog import kr.boostcamp_2024.course.quiz.R @Composable -fun QuizOwnerDialog( +internal fun QuizOwnerDialog( isQuit: Boolean = false, onDismissButtonClick: () -> Unit, onFinishQuizButtonClick: () -> Unit, @@ -37,14 +37,14 @@ fun QuizOwnerDialog( } } -@Preview +@PreviewKoLightDark @Composable -fun OwnerQuitQuizDialogPreview() { +private fun QuizOwnerDialogPreview() { WeQuizTheme { QuizOwnerDialog( isQuit = true, - onDismissButtonClick = { /* no-op */ }, - onFinishQuizButtonClick = { /* no-op */ }, + onDismissButtonClick = {}, + onFinishQuizButtonClick = {}, ) } } diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizSolveTimeSlider.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizSolveTimeSlider.kt index ba4245b3..59cdd951 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizSolveTimeSlider.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizSolveTimeSlider.kt @@ -13,12 +13,12 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDarkBackground @OptIn(ExperimentalMaterial3Api::class) @Composable -fun QuizSolveTimeSlider( +internal fun QuizSolveTimeSlider( value: Float, steps: Int, valueRange: ClosedFloatingPointRange, @@ -48,9 +48,9 @@ fun QuizSolveTimeSlider( ) } -@Preview(showBackground = true) +@PreviewKoLightDarkBackground @Composable -fun QuizSolveTimeSliderPreview() { +private fun QuizSolveTimeSliderPreview() { QuizSolveTimeSlider( value = 0f, steps = 10, diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizTopAppBar.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizTopAppBar.kt index 5171aa47..0e27469b 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizTopAppBar.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/QuizTopAppBar.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDarkBackground import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizBaseDialog import kr.boostcamp_2024.course.domain.model.BaseQuiz import kr.boostcamp_2024.course.domain.model.Category @@ -31,7 +32,7 @@ import kr.boostcamp_2024.course.quiz.R @Composable @OptIn(ExperimentalMaterial3Api::class) -fun QuizTopAppBar( +internal fun QuizTopAppBar( category: Category?, quiz: BaseQuiz?, currentUserId: String?, @@ -57,11 +58,11 @@ fun QuizTopAppBar( navigationIcon = { IconButton( onClick = - if (quiz is RealTimeQuiz && quiz.waitingUsers.contains(currentUserId) && quiz.isStarted.not()) { - { showDialog = true } - } else { - { onNavigationButtonClick() } - }, + if (quiz is RealTimeQuiz && quiz.waitingUsers.contains(currentUserId) && quiz.isStarted.not()) { + { showDialog = true } + } else { + { onNavigationButtonClick() } + }, ) { Icon( imageVector = Icons.AutoMirrored.Default.ArrowBack, @@ -127,3 +128,30 @@ fun QuizTopAppBar( ) } } + + +@PreviewKoLightDarkBackground +@Composable +private fun QuizTopAppBarPreview() { + QuizTopAppBar( + category = Category(id = "", name = "", description = "", categoryImageUrl = "", quizzes = emptyList()), + quiz = RealTimeQuiz( + id = "", + title = "", + isStarted = false, + questions = emptyList(), + userOmrs = emptyList(), + currentQuestion = 0, + ownerId = "", + isFinished = false, + waitingUsers = emptyList(), + description = "", + quizImageUrl = null, + ), + currentUserId = "", + onWaitingRealTimeQuizButtonClick = {}, + onNavigationButtonClick = {}, + onSettingMenuClick = { _, _ -> }, + onDeleteMenuClick = { _, _ -> }, + ) +} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RadioTextButton.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RadioTextButton.kt index dd27b5fe..649f3c7d 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RadioTextButton.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RadioTextButton.kt @@ -11,14 +11,14 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDarkBackground @Composable -fun RadioTextButton( +internal fun RadioTextButton( text: String, selected: Boolean, onclick: () -> Unit, ) { - Row( modifier = Modifier .fillMaxWidth() @@ -41,3 +41,15 @@ fun RadioTextButton( ) } } + + + +@PreviewKoLightDarkBackground +@Composable +private fun RadioTextButtonPreview() { + RadioTextButton( + text = "문제", + selected = true, + onclick = {}, + ) +} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuestion.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuestion.kt index 519a8505..64477b6d 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuestion.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuestion.kt @@ -12,9 +12,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDarkBackground @Composable -fun RealTimeQuestion( +internal fun RealTimeQuestion( isOwner: Boolean = false, questions: List, selectedIndex: Int, @@ -49,3 +50,12 @@ fun RealTimeQuestion( } } } + +@PreviewKoLightDarkBackground +@Composable +private fun RealTimeQuestionPreview() { + RealTimeQuestion( + questions = listOf("문제1", "문제2", "문제3", "문제4", "문제5"), + selectedIndex = 0, + ) +} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuizGuideContent.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuizGuideContent.kt index 9734dafb..5697ab10 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuizGuideContent.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/RealTimeQuizGuideContent.kt @@ -12,12 +12,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDarkBackground import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizLocalRoundedImage import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizRightChatBubble import kr.boostcamp_2024.course.quiz.R @Composable -fun RealTimeQuizGuideContent( +internal fun RealTimeQuizGuideContent( ownerName: String, totalParticipants: Int, submittedParticipants: Int, @@ -52,3 +53,13 @@ fun RealTimeQuizGuideContent( ) } } + +@PreviewKoLightDarkBackground +@Composable +private fun RealTimeQuizGuideContentPreview() { + RealTimeQuizGuideContent( + ownerName = "이훈", + totalParticipants = 10, + submittedParticipants = 5, + ) +} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/UserQuestion.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/UserQuestion.kt deleted file mode 100644 index fd090502..00000000 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/component/UserQuestion.kt +++ /dev/null @@ -1,54 +0,0 @@ -package kr.boostcamp_2024.course.quiz.component - -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.foundation.selection.selectable -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.RadioButton -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@Composable -fun UserQuestion( - questions: List, - selectedIndex: Int, - onOptionSelected: (Int) -> Unit, - enable: Boolean, -) { - Column( - modifier = Modifier.padding(horizontal = 16.dp).padding(bottom = 20.dp), - verticalArrangement = Arrangement.spacedBy(10.dp), - ) { - questions.forEachIndexed { index, option -> - Row( - modifier = Modifier.fillMaxWidth() - .padding(bottom = 10.dp) - .selectable( - selected = selectedIndex == index, - onClick = { onOptionSelected(index) }, - enabled = enable, - ), - ) { - RadioButton( - selected = selectedIndex == index, - onClick = null, - modifier = Modifier.padding(8.dp), - ) - Text( - text = option, - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier - .padding(end = 8.dp) - .align(Alignment.CenterVertically), - ) - } - } - } -} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/CreateQuestionScreen.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/CreateQuestionScreen.kt index e2f08c6c..5b117604 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/CreateQuestionScreen.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/CreateQuestionScreen.kt @@ -43,10 +43,10 @@ import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.quiz.R import kr.boostcamp_2024.course.quiz.component.CreateBlankQuestionContent @@ -58,7 +58,7 @@ import kr.boostcamp_2024.course.quiz.viewmodel.CreateQuestionUiState import kr.boostcamp_2024.course.quiz.viewmodel.CreateQuestionViewModel @Composable -fun CreateQuestionScreen( +internal fun CreateQuestionScreen( onNavigationButtonClick: () -> Unit, onCreateQuestionSuccess: () -> Unit, viewModel: CreateQuestionViewModel = hiltViewModel(), @@ -118,7 +118,7 @@ fun CreateQuestionScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun CreateQuestionScreen( +private fun CreateQuestionScreen( uiState: CreateQuestionUiState, focusRequester: FocusRequester, snackBarHostState: SnackbarHostState, @@ -307,13 +307,46 @@ fun CreateQuestionScreen( } } -@Preview(showBackground = true) +@PreviewKoLightDark @Composable -fun CreateQuestionScreenPreview() { +private fun CreateQuestionScreenPreview() { + val previewCreateQuestionUiState = CreateQuestionUiState( + isLoading = false, + showDialog = false, + snackBarMessage = null, + creationSuccess = false, + selectedQuestionTypeIndex = 0, + ) + val previewOption = listOf( + stringResource(R.string.txt_create_general_question), + stringResource(R.string.txt_blank_question), + ) + WeQuizTheme { CreateQuestionScreen( + uiState = previewCreateQuestionUiState, + focusRequester = remember { FocusRequester() }, + snackBarHostState = remember { SnackbarHostState() }, + onTitleChanged = {}, + onDescriptionChanged = {}, + onSolutionChanged = {}, onNavigationButtonClick = {}, - onCreateQuestionSuccess = {}, + onChoiceTextChanged = { _, _ -> }, + onSelectedChoiceNumChanged = {}, + onCreateQuestionButtonClick = {}, + onQuestionTypeIndexChange = {}, + selectedQuestionTypeIndex = 0, + options = previewOption, + isBlankQuestion = false, + blankQuestionItems = listOf(), + onAddBlankItemButtonClick = {}, + onAddTextItemButtonClick = {}, + onBlankQuestionItemValueChanged = { _, _ -> }, + onContentRemove = {}, + onCreateBlankQuestionButtonClick = {}, + isCreateBlankButtonValid = true, + isCreateTextButtonValid = true, + onShowDialog = {}, ) } } diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/QuestionDetailScreen.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/QuestionDetailScreen.kt index e6aa8570..b2f0f6f5 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/QuestionDetailScreen.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/question/QuestionDetailScreen.kt @@ -23,10 +23,11 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.domain.model.BlankQuestion import kr.boostcamp_2024.course.domain.model.ChoiceQuestion @@ -39,10 +40,11 @@ import kr.boostcamp_2024.course.quiz.component.QuestionItems import kr.boostcamp_2024.course.quiz.component.QuestionSolution import kr.boostcamp_2024.course.quiz.component.QuestionTitle import kr.boostcamp_2024.course.quiz.presentation.quiz.QuizStatisticsDialog +import kr.boostcamp_2024.course.quiz.utils.QuestionParameterProvider import kr.boostcamp_2024.course.quiz.viewmodel.QuestionDetailViewModel @Composable -fun QuestionDetailScreen( +internal fun QuestionDetailScreen( viewModel: QuestionDetailViewModel = hiltViewModel(), onNavigationButtonClick: () -> Unit, ) { @@ -59,7 +61,7 @@ fun QuestionDetailScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun QuestionDetailScreen( +private fun QuestionDetailScreen( question: Question?, errorMessage: String?, onNavigationButtonClick: () -> Unit, @@ -136,22 +138,16 @@ fun QuestionDetailScreen( } } -@Preview + +@PreviewKoLightDark @Composable -fun QuestionDetailScreenPreview() { +private fun QuestionDetailScreenPreview( + @PreviewParameter(QuestionParameterProvider::class) question: Question, +) { WeQuizTheme { QuestionDetailScreen( onNavigationButtonClick = {}, - question = BlankQuestion( - id = "1", - title = "문제 제목", - questionContent = listOf( - mapOf("text" to "이훈"), - mapOf("text" to "은 바나나를 좋아한다"), - ), - solution = "문제 해설", - userAnswers = emptyList(), - ), + question = question, errorMessage = null, userAnswer = listOf(0, 0, 0, 0), ) diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/GeneralQuizResultScreen.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/GeneralQuizResultScreen.kt index a4f643ed..3ce7bb5b 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/GeneralQuizResultScreen.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/GeneralQuizResultScreen.kt @@ -1,6 +1,5 @@ package kr.boostcamp_2024.course.quiz.presentation.quiz -import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -36,19 +35,22 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizLocalRoundedImage import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizRightChatBubble import kr.boostcamp_2024.course.domain.model.ChoiceQuestion +import kr.boostcamp_2024.course.domain.model.Question import kr.boostcamp_2024.course.domain.model.QuestionResult import kr.boostcamp_2024.course.domain.model.QuizResult import kr.boostcamp_2024.course.quiz.R +import kr.boostcamp_2024.course.quiz.utils.QuizResultParameterProvider @OptIn(ExperimentalMaterial3Api::class) @Composable -fun GeneralQuizResultScreen( +internal fun GeneralQuizResultScreen( quizTitle: String?, quizResult: QuizResult?, onNavigationButtonClick: () -> Unit, @@ -102,7 +104,7 @@ fun GeneralQuizResultScreen( } @Composable -fun GeneralQuizResultContent( +private fun GeneralQuizResultContent( totalQuestions: Int, correctQuestions: Int, ) { @@ -136,7 +138,7 @@ fun GeneralQuizResultContent( } @Composable -fun GeneralQuestionResultListContent( +private fun GeneralQuestionResultListContent( questionResults: List, onQuestionClick: (String) -> Unit, ) { @@ -158,7 +160,7 @@ fun GeneralQuestionResultListContent( } @Composable -fun GeneralQuestionResultItem( +private fun GeneralQuestionResultItem( questionResult: QuestionResult, onQuestionClick: (String) -> Unit, ) { @@ -209,17 +211,22 @@ fun GeneralQuestionResultItem( } } -@Preview( - showBackground = true, - uiMode = Configuration.UI_MODE_NIGHT_YES, -) -@Preview(showBackground = true) +@PreviewKoLightDark @Composable -fun GeneralQuizResultScreenPreview() { +private fun GeneralQuizResultScreenPreview( + @PreviewParameter(QuizResultParameterProvider::class) questionResults: List, +) { + val generalQuizResultPreviewUserOmrAnswers = listOf(0, 1, "") WeQuizTheme { - QuizResultScreen( + GeneralQuizResultScreen( + quizTitle = "퀴즈 타이틀", + quizResult = QuizResult( + questions = questionResults, + userOmrAnswers = generalQuizResultPreviewUserOmrAnswers, + ), onNavigationButtonClick = {}, - onQuestionClick = {}, + onQuestionClick = { _ -> }, + snackbarHostState = remember { SnackbarHostState() }, ) } } diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/OwnerQuizResultScreen.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/OwnerQuizResultScreen.kt index e1baf4ca..a5f0912d 100644 --- a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/OwnerQuizResultScreen.kt +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/presentation/quiz/OwnerQuizResultScreen.kt @@ -1,6 +1,5 @@ package kr.boostcamp_2024.course.quiz.presentation.quiz -import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -35,18 +34,20 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizLocalRoundedImage import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizRightChatBubble import kr.boostcamp_2024.course.domain.model.ChoiceQuestion import kr.boostcamp_2024.course.domain.model.Question import kr.boostcamp_2024.course.quiz.R +import kr.boostcamp_2024.course.quiz.utils.QuizResultParameterProvider @OptIn(ExperimentalMaterial3Api::class) @Composable -fun OwnerQuizResultScreen( +internal fun OwnerQuizResultScreen( questions: List? = null, quizTitle: String?, onQuestionClick: (String) -> Unit, @@ -95,7 +96,7 @@ fun OwnerQuizResultScreen( } @Composable -fun OwnerQuizResultContent() { +private fun OwnerQuizResultContent() { Row( modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(24.dp), @@ -119,7 +120,7 @@ fun OwnerQuizResultContent() { } @Composable -fun OwnerQuestionResultListContent( +private fun OwnerQuestionResultListContent( questions: List, onQuestionClick: (String) -> Unit, ) { @@ -142,7 +143,7 @@ fun OwnerQuestionResultListContent( } @Composable -fun OwnerQuestionResultItem( +private fun OwnerQuestionResultItem( question: Question, onQuestionClick: (String) -> Unit, ) { @@ -186,19 +187,18 @@ fun OwnerQuestionResultItem( } } -@Preview( - showBackground = true, - uiMode = Configuration.UI_MODE_NIGHT_YES, -) -@Preview(showBackground = true) + +@PreviewKoLightDark @Composable -fun OwnerQuizResultScreenPreview() { +private fun OwnerQuizResultScreenPreview( + @PreviewParameter(QuizResultParameterProvider::class) questionResults: List, +) { WeQuizTheme { OwnerQuizResultScreen( onNavigationButtonClick = {}, onQuestionClick = {}, - questions = emptyList(), - quizTitle = "", + questions = questionResults, + quizTitle = "퀴즈 결과 프리뷰", snackbarHostState = remember { SnackbarHostState() }, ) } diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuestionParameterProvider.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuestionParameterProvider.kt new file mode 100644 index 00000000..94d9d88e --- /dev/null +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuestionParameterProvider.kt @@ -0,0 +1,30 @@ +package kr.boostcamp_2024.course.quiz.utils + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import kr.boostcamp_2024.course.domain.model.BlankQuestion +import kr.boostcamp_2024.course.domain.model.ChoiceQuestion +import kr.boostcamp_2024.course.domain.model.Question + +internal class QuestionParameterProvider : PreviewParameterProvider { + override val values = sequenceOf( + BlankQuestion( + id = "1", + title = "문제 제목", + questionContent = listOf( + mapOf("text" to "바나나", "type" to "blank"), + mapOf("text" to "는 원래 하얗다", "type" to "text"), + ), + solution = "문제 해설", + userAnswers = emptyList(), + ), + ChoiceQuestion( + id = "2", + "문제 제목", + description = "문제 설명", + solution = "문제 해설", + answer = 0, + choices = listOf("객관식 1", "객관식 2", "객관식 3", "객관식 4"), + userAnswers = emptyList(), + ), + ) +} diff --git a/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuizResultParameterProvider.kt b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuizResultParameterProvider.kt new file mode 100644 index 00000000..944b164d --- /dev/null +++ b/feature/quiz/src/main/java/kr/boostcamp_2024/course/quiz/utils/QuizResultParameterProvider.kt @@ -0,0 +1,38 @@ +package kr.boostcamp_2024.course.quiz.utils + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import kr.boostcamp_2024.course.domain.model.BlankQuestion +import kr.boostcamp_2024.course.domain.model.ChoiceQuestion +import kr.boostcamp_2024.course.domain.model.Question + +class QuizResultParameterProvider: PreviewParameterProvider> { + override val values = sequenceOf( + listOf( + ChoiceQuestion( + id = "1", + title = "1번 문제", + solution = null, + description = "1번 문제 설명", + answer = 1, + choices = listOf(), + userAnswers = listOf(), + ), + ChoiceQuestion( + id = "2", + title = "2번 문제", + solution = null, + description = "2번 문제 설명", + answer = 1, + choices = listOf(), + userAnswers = listOf(), + ), + BlankQuestion( + id = "3", + title = "3번 문제 (낱말 맞추기)", + solution = null, + userAnswers = emptyList(), + questionContent = emptyList(), + ), + ) + ) +} diff --git a/feature/study/src/main/java/kr/boostcamp_2024/course/study/presentation/CreateStudyScreen.kt b/feature/study/src/main/java/kr/boostcamp_2024/course/study/presentation/CreateStudyScreen.kt index 40358155..270c8848 100644 --- a/feature/study/src/main/java/kr/boostcamp_2024/course/study/presentation/CreateStudyScreen.kt +++ b/feature/study/src/main/java/kr/boostcamp_2024/course/study/presentation/CreateStudyScreen.kt @@ -23,10 +23,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import kr.boostcamp_2024.course.designsystem.ui.annotation.PreviewKoLightDark import kr.boostcamp_2024.course.designsystem.ui.theme.WeQuizTheme import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizCircularProgressIndicator import kr.boostcamp_2024.course.designsystem.ui.theme.component.WeQuizValidateTextField @@ -36,7 +36,7 @@ import kr.boostcamp_2024.course.study.component.CreateStudyTopAppBar import kr.boostcamp_2024.course.study.component.StudySubmitButton @Composable -fun CreateStudyScreen( +internal fun CreateStudyScreen( viewmodel: CreateStudyViewModel = hiltViewModel(), snackBarHostState: SnackbarHostState = remember { SnackbarHostState() }, onNavigationButtonClick: () -> Unit, @@ -82,7 +82,7 @@ fun CreateStudyScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun CreateStudyScreen( +private fun CreateStudyScreen( isEditMode: Boolean, defaultStudyImageUri: String?, currentStudyImage: ByteArray?, @@ -169,15 +169,15 @@ fun CreateStudyScreen( } } -fun isValidateNumber(inputNumber: String): Boolean { +private fun isValidateNumber(inputNumber: String): Boolean { if (inputNumber.isBlank()) return true val isValid = inputNumber.matches(Regex("^-?\\d+\$")) return isValid && inputNumber.toIntOrNull()?.let { it in 2..50 } == true } -@Preview(showBackground = true) +@PreviewKoLightDark @Composable -fun CreateStudyScreenPreview() { +private fun CreateStudyScreenPreview() { WeQuizTheme { CreateStudyScreen( isEditMode = false,