From ddf640129d2899053033d84f62b726d85a887b8b Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Tue, 30 Jan 2024 20:13:24 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20#95=20:=20=EB=92=A4=EB=A1=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B8=B0=20=EB=B2=84=ED=8A=BC=EA=B3=BC=20=EC=A7=88?= =?UTF-8?q?=EB=AC=B8=20=EC=95=9E=20=EB=92=A4=20=EC=A0=84=ED=99=98=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../survey/SurveyQuestionContent.kt | 110 ++++++++++++++---- 1 file changed, 90 insertions(+), 20 deletions(-) diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/SurveyQuestionContent.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/SurveyQuestionContent.kt index 0d9dda43..ee7c892f 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/SurveyQuestionContent.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/SurveyQuestionContent.kt @@ -1,5 +1,7 @@ package com.wap.wapp.feature.management.survey +import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -8,6 +10,7 @@ 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.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll @@ -20,12 +23,14 @@ 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.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp +import com.wap.wapp.core.designresource.R.drawable import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappRoundedTextField @@ -36,12 +41,15 @@ import com.wap.wapp.core.model.survey.QuestionType internal fun SurveyQuestionContent( question: String, questionType: QuestionType, + questionNumber: Int, + totalQuestionNumber: Int, onQuestionChanged: (String) -> Unit, onQuestionTypeChanged: (QuestionType) -> Unit, + onPreviousQuestionButtonClicked: () -> Unit, + onNextQuestionButtonClicked: () -> Unit, + onPreviousButtonClicked: () -> Unit, onNextButtonClicked: () -> Unit, onAddSurveyQuestionButtonClicked: () -> Unit, - currentQuestionIndex: Int, - totalQuestionIndex: Int, ) { val scrollState = rememberScrollState() @@ -66,19 +74,11 @@ internal fun SurveyQuestionContent( color = WappTheme.colors.white, ) - Text( - color = WappTheme.colors.white, - style = WappTheme.typography.contentRegular, - text = buildAnnotatedString { - withStyle( - style = SpanStyle( - WappTheme.colors.yellow34, - ), - ) { append(currentQuestionIndex.toString()) } - append(" / $totalQuestionIndex") - }, - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), + SurveyQuestionNumberText( + questionNumber = questionNumber + 1, + totalQuestionNumber = totalQuestionNumber + 1, + onPreviousQuestionButtonClicked = onPreviousQuestionButtonClicked, + onNextQuestionButtonClicked = onNextQuestionButtonClicked, ) } @@ -125,15 +125,65 @@ internal fun SurveyQuestionContent( onAddSurveyQuestionButtonClicked() }, onNextButtonClicked = onNextButtonClicked, + onPreviousButtonClicked = onPreviousButtonClicked, modifier = Modifier.padding(top = 10.dp, bottom = 20.dp), ) } } @Composable -private fun SurveyQuestionTypeDescription( - type: QuestionType, +private fun SurveyQuestionNumberText( + questionNumber: Int, + totalQuestionNumber: Int, + onPreviousQuestionButtonClicked: () -> Unit, + onNextQuestionButtonClicked: () -> Unit, ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.End, + verticalAlignment = Alignment.CenterVertically, + ) { + // 이전 질문 버튼 + if (questionNumber > 1) { + Image( + painter = painterResource(id = drawable.ic_back), + contentDescription = stringResource(R.string.previous_question), + modifier = Modifier + .size(14.dp) + .padding(end = 4.dp) + .clickable { onPreviousQuestionButtonClicked() }, + ) + } + + Text( + color = WappTheme.colors.white, + style = WappTheme.typography.contentRegular, + text = buildAnnotatedString { + withStyle( + style = SpanStyle( + WappTheme.colors.yellow34, + ), + ) { append(questionNumber.toString()) } + append(" / $totalQuestionNumber") + }, + ) + + // 다음 질문 버튼 + if (questionNumber < totalQuestionNumber) { + Image( + painter = painterResource(id = drawable.ic_forward), + contentDescription = stringResource(R.string.next_question), + modifier = Modifier + .size(14.dp) + .padding(start = 4.dp) + .clickable { onNextQuestionButtonClicked() }, + ) + } + } +} + +@Composable +private fun SurveyQuestionTypeDescription(type: QuestionType) { when (type) { QuestionType.SUBJECTIVE -> { Text( @@ -240,21 +290,41 @@ private fun SurveyQuestionTypeCard( private fun SurveyQuestionButton( onAddSurveyQuestionButtonClicked: () -> Unit, onNextButtonClicked: () -> Unit, + onPreviousButtonClicked: () -> Unit, modifier: Modifier = Modifier, ) { + Column( + modifier = Modifier + .fillMaxWidth() + .clickable { onAddSurveyQuestionButtonClicked() }, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Image( + painter = painterResource(id = drawable.ic_add_question), + contentDescription = stringResource(id = R.string.add_survey_question), + modifier = Modifier.size(40.dp), + ) + + Text( + text = stringResource(id = R.string.add_survey_question), + color = WappTheme.colors.yellow34, + style = WappTheme.typography.labelRegular, + ) + } + Row( horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier, ) { WappButton( - onClick = onAddSurveyQuestionButtonClicked, - textRes = R.string.add_survey_question, + textRes = R.string.previous, + onClick = onPreviousButtonClicked, modifier = Modifier.weight(1f), ) WappButton( - onClick = onNextButtonClicked, textRes = R.string.next, + onClick = onNextButtonClicked, modifier = Modifier.weight(1f), ) }