From ba51a98fd027b6a37887eb6287c4efc370b1fa61 Mon Sep 17 00:00:00 2001 From: Seunggu Kang Date: Tue, 12 Nov 2024 22:32:12 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20=ED=9C=B4=EB=8C=80=ED=8F=B0=20?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=9D=B8=EC=A6=9D=ED=99=94=EB=A9=B4=20ui?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= =?UTF-8?q?=20=EB=B0=8F=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/designsystem/component/Button.kt | 6 +- .../connectdog/core/util/StringExtension.kt | 6 + domain/.gitignore | 1 + domain/build.gradle.kts | 10 ++ .../feature/home/navigation/HomeNavigation.kt | 7 +- feature/login/build.gradle.kts | 4 + .../feature/login/screen/LoginScreen.kt | 100 +++---------- feature/signup/build.gradle.kts | 4 + .../screen/common/CeritificationScreen.kt | 134 +++++++++--------- .../signup/state/CertificationUiState.kt | 31 ++++ .../viewmodel/CertificationViewModel.kt | 92 ++++++------ feature/signup/src/main/res/values/string.xml | 3 +- gradle/libs.versions.toml | 7 +- settings.gradle.kts | 1 + 14 files changed, 201 insertions(+), 205 deletions(-) create mode 100644 core/util/src/main/java/com/kusitms/connectdog/core/util/StringExtension.kt create mode 100644 domain/.gitignore create mode 100644 domain/build.gradle.kts create mode 100644 feature/signup/src/main/java/com/kusitms/connectdog/signup/state/CertificationUiState.kt diff --git a/core/designsystem/src/main/java/com/kusitms/connectdog/core/designsystem/component/Button.kt b/core/designsystem/src/main/java/com/kusitms/connectdog/core/designsystem/component/Button.kt index 425961806..93b60ebb1 100644 --- a/core/designsystem/src/main/java/com/kusitms/connectdog/core/designsystem/component/Button.kt +++ b/core/designsystem/src/main/java/com/kusitms/connectdog/core/designsystem/component/Button.kt @@ -105,7 +105,8 @@ fun ConnectDogNormalButton( fontSize: Int = 16, modifier: Modifier = Modifier .fillMaxWidth() - .height(56.dp) + .height(56.dp), + enabled: Boolean = true, ) { ConnectDogBottomButton( onClick = onClick, @@ -113,7 +114,8 @@ fun ConnectDogNormalButton( enabledColor = color, modifier = modifier, textColor = textColor, - fontSize = fontSize + fontSize = fontSize, + enabled = enabled ) } diff --git a/core/util/src/main/java/com/kusitms/connectdog/core/util/StringExtension.kt b/core/util/src/main/java/com/kusitms/connectdog/core/util/StringExtension.kt new file mode 100644 index 000000000..d5bb9155d --- /dev/null +++ b/core/util/src/main/java/com/kusitms/connectdog/core/util/StringExtension.kt @@ -0,0 +1,6 @@ +package com.kusitms.connectdog.core.util + +val String.Companion.empty + get() = "" + +fun emptyString(): String = String.empty \ No newline at end of file diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts new file mode 100644 index 000000000..7afdbc404 --- /dev/null +++ b/domain/build.gradle.kts @@ -0,0 +1,10 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + id("java-library") + alias(libs.plugins.org.jetbrains.kotlin.jvm) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 +} \ No newline at end of file diff --git a/feature/home/src/main/java/com/kusitms/connectdog/feature/home/navigation/HomeNavigation.kt b/feature/home/src/main/java/com/kusitms/connectdog/feature/home/navigation/HomeNavigation.kt index 86b496ba0..197981836 100644 --- a/feature/home/src/main/java/com/kusitms/connectdog/feature/home/navigation/HomeNavigation.kt +++ b/feature/home/src/main/java/com/kusitms/connectdog/feature/home/navigation/HomeNavigation.kt @@ -13,7 +13,6 @@ import com.kusitms.connectdog.feature.home.screen.ApplyScreen import com.kusitms.connectdog.feature.home.screen.CompleteApplyScreen import com.kusitms.connectdog.feature.home.screen.DetailScreen import com.kusitms.connectdog.feature.home.screen.FilterSearchRoute -import com.kusitms.connectdog.feature.home.screen.GuideScreen import com.kusitms.connectdog.feature.home.screen.HomeRoute import com.kusitms.connectdog.feature.home.screen.IntermediatorProfileScreen import com.kusitms.connectdog.feature.home.screen.ReviewScreen @@ -221,9 +220,9 @@ fun NavGraphBuilder.homeNavGraph( } composable(route = HomeRoute.guide) { - GuideScreen( - onBackClick = onBackClick - ) +// GuideScreen( +// onBackClick = onBackClick +// ) } composable(route = HomeRoute.notification) { diff --git a/feature/login/build.gradle.kts b/feature/login/build.gradle.kts index 73932f105..945feb1e5 100644 --- a/feature/login/build.gradle.kts +++ b/feature/login/build.gradle.kts @@ -54,6 +54,10 @@ dependencies { kapt(libs.hilt.compiler) implementation(libs.hilt.android) + implementation(libs.orbit.core) + implementation(libs.orbit.compose) + implementation(libs.orbit.viewmodel) + implementation(libs.androidx.compose.navigation) implementation(libs.hilt.navigation.compose) diff --git a/feature/login/src/main/java/com/kusitms/connectdog/feature/login/screen/LoginScreen.kt b/feature/login/src/main/java/com/kusitms/connectdog/feature/login/screen/LoginScreen.kt index 5e3a36040..239a577a4 100644 --- a/feature/login/src/main/java/com/kusitms/connectdog/feature/login/screen/LoginScreen.kt +++ b/feature/login/src/main/java/com/kusitms/connectdog/feature/login/screen/LoginScreen.kt @@ -51,6 +51,7 @@ import com.google.accompanist.pager.rememberPagerState import com.kusitms.connectdog.core.designsystem.component.ConnectDogIconBottomButton import com.kusitms.connectdog.core.designsystem.component.ConnectDogNormalButton import com.kusitms.connectdog.core.designsystem.component.ConnectDogTextField +import com.kusitms.connectdog.core.designsystem.component.SpeechBubble import com.kusitms.connectdog.core.designsystem.theme.ConnectDogTheme import com.kusitms.connectdog.core.designsystem.theme.Gray2 import com.kusitms.connectdog.core.designsystem.theme.KAKAO @@ -147,6 +148,25 @@ private fun LoginContent( ) { val pagerState = rememberPagerState() val coroutineScope = rememberCoroutineScope() + + Row( + modifier = Modifier + .height(37.dp) + .fillMaxWidth(0.5f) + .padding( + start = if(pagerState.currentPage == 0) 0.dp else 10.dp, + end = if(pagerState.currentPage == 0) 10.dp else 0.dp + ) + .align(if(pagerState.currentPage == 0) Alignment.End else Alignment.Start) + ) { + SpeechBubble( + text = "이동봉사 공고 신청자를 모집한다면?", + fontSize = 10, + fontColor = PetOrange, + fontWeight = FontWeight.SemiBold + ) + } + TabRow( modifier = Modifier .padding(start = 10.dp, end = 10.dp), @@ -218,7 +238,6 @@ private fun Volunteer( .fillMaxHeight() .padding(top = 32.dp) ) { - BubbleInfo() Spacer(modifier = Modifier.height(20.dp)) ConnectDogIconBottomButton( iconId = R.drawable.ic_kakao, @@ -334,82 +353,3 @@ private fun SignUpOrLogin( ) } } - -@Composable -private fun BubbleInfo() { - Box { - BubbleShape() - Text( - modifier = Modifier.align(Alignment.Center), - text = "이동봉사 공고를 찾고 계신다면, 이동봉사자 회원으로!", - fontSize = 12.sp, - color = PetOrange, - fontWeight = FontWeight.SemiBold - ) - } -} - -@Composable -private fun BubbleShape() { - val density = LocalDensity.current - val tailWidth = with(density) { 10.dp.toPx() } - val tailHeight = with(density) { 9.dp.toPx() } - val strokeWidth = with(density) { 1.dp.toPx() } - - Canvas( - modifier = Modifier - .height(28.dp) - .fillMaxWidth() - .padding(horizontal = 37.dp) - ) { - val width = size.width - val height = size.height - - val path = Path().apply { - val cornerRadius = 100.dp.toPx() - addRoundRect(RoundRect(0f, 0f, width, height, cornerRadius, cornerRadius)) - } - - val path2 = Path().apply { - val tailStartX = (width / 2) - (tailWidth / 2) - val tailStartY = height - moveTo(tailStartX + 2f, tailStartY) - lineTo(tailStartX + tailWidth - 2f, tailStartY) - } - - val path3 = Path().apply { - val tailStartX = (width / 2) - (tailWidth / 2) - val tailStartY = height - - moveTo(tailStartX, tailStartY) - lineTo(tailStartX + tailWidth / 2, tailStartY + tailHeight) // 꼬리의 끝점 - lineTo(tailStartX + tailWidth, tailStartY) - } - - drawPath( - path = path, - color = PetOrange, - style = Stroke(width = strokeWidth) - ) - - drawPath( - path = path2, - color = Color.White, - style = Stroke(width = strokeWidth + 2.dp.toPx()) - ) - - drawPath( - path = path3, - color = PetOrange, - style = Stroke(width = strokeWidth) - ) - } -} - -@Preview -@Composable -private fun test() { - ConnectDogTheme { - BubbleInfo() - } -} diff --git a/feature/signup/build.gradle.kts b/feature/signup/build.gradle.kts index 00075ff0e..29400106b 100644 --- a/feature/signup/build.gradle.kts +++ b/feature/signup/build.gradle.kts @@ -70,4 +70,8 @@ dependencies { implementation(libs.androidx.compose.material3) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.runtime.livedata) + + implementation(libs.orbit.core) + implementation(libs.orbit.compose) + implementation(libs.orbit.viewmodel) } diff --git a/feature/signup/src/main/java/com/kusitms/connectdog/signup/screen/common/CeritificationScreen.kt b/feature/signup/src/main/java/com/kusitms/connectdog/signup/screen/common/CeritificationScreen.kt index 79e27c566..9038f2eba 100644 --- a/feature/signup/src/main/java/com/kusitms/connectdog/signup/screen/common/CeritificationScreen.kt +++ b/feature/signup/src/main/java/com/kusitms/connectdog/signup/screen/common/CeritificationScreen.kt @@ -4,19 +4,21 @@ import android.annotation.SuppressLint import android.widget.Toast import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer 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.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -28,17 +30,20 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel -import com.kusitms.connectdog.core.designsystem.R import com.kusitms.connectdog.core.designsystem.component.ConnectDogNormalButton import com.kusitms.connectdog.core.designsystem.component.ConnectDogTextField -import com.kusitms.connectdog.core.designsystem.component.ConnectDogTextFieldWithButton +import com.kusitms.connectdog.core.designsystem.component.ConnectDogTextFieldWithTimer import com.kusitms.connectdog.core.designsystem.component.ConnectDogTopAppBar import com.kusitms.connectdog.core.designsystem.component.TopAppBarNavigationType -import com.kusitms.connectdog.core.designsystem.theme.Orange40 -import com.kusitms.connectdog.core.designsystem.theme.PetOrange +import com.kusitms.connectdog.core.designsystem.theme.Gray6 +import com.kusitms.connectdog.core.designsystem.theme.Gray8 import com.kusitms.connectdog.core.util.UserType +import com.kusitms.connectdog.feature.signup.R +import com.kusitms.connectdog.signup.state.CertificationSideEffect import com.kusitms.connectdog.signup.viewmodel.CertificationViewModel import com.kusitms.connectdog.signup.viewmodel.SignUpViewModel +import org.orbitmvi.orbit.compose.collectAsState +import org.orbitmvi.orbit.compose.collectSideEffect @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable @@ -93,17 +98,29 @@ private fun Content( val focusManager = LocalFocusManager.current val interactionSource = remember { MutableInteractionSource() } val context = LocalContext.current - val isSendNumber by remember { viewModel.isSendNumber }.collectAsState() - val isCertified by remember { viewModel.isCertified }.collectAsState() val scrollState = rememberScrollState() + val uiState by viewModel.collectAsState() + LaunchedEffect(key1 = signUpViewModel) { signUpViewModel.isDuplicatePhoneNumber.collect { if (it) { Toast.makeText(context, "중복된 휴대폰 번호입니다.", Toast.LENGTH_SHORT).show() } else { Toast.makeText(context, "인증번호를 전송하였습니다.", Toast.LENGTH_SHORT).show() - onSendMessageClick(viewModel.phoneNumber) + } + } + } + + viewModel.collectSideEffect { sideEffect -> + when (sideEffect) { + is CertificationSideEffect.NavigateToProfile -> { + signUpViewModel.updateName(uiState.name) + signUpViewModel.updatePhoneNumber(uiState.phoneNumber) + when(userType) { + UserType.SOCIAL_VOLUNTEER -> onNavigateToVolunteerProfile(userType) + else -> onNavigateToRegisterEmail(userType) + } } } } @@ -121,87 +138,64 @@ private fun Content( ) { Spacer(modifier = Modifier.height(48.dp)) Text( - text = stringResource(id = com.kusitms.connectdog.feature.signup.R.string.certification_title), + text = stringResource(id = R.string.certification_title), fontSize = 20.sp, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(40.dp)) ConnectDogTextField( - text = viewModel.name, + text = uiState.name, label = "이름", placeholder = "이름 입력", keyboardType = KeyboardType.Text, - onTextChanged = { viewModel.updateName(it) } + onTextChanged = viewModel::onNameChanged ) Spacer(modifier = Modifier.height(12.dp)) - ConnectDogTextFieldWithButton( - text = viewModel.phoneNumber, - width = 62, - height = 27, - textFieldLabel = "휴대폰 번호", + ConnectDogTextField( + text = uiState.phoneNumber, + onTextChanged = viewModel::onPhoneNumberChanged, + label = stringResource(id = R.string.phone_number), placeholder = "'-'빼고 입력", - buttonLabel = "인증 요청", keyboardType = KeyboardType.Number, - padding = 5, - onTextChanged = { if (it.length <= 11) viewModel.updatePhoneNumber(it) }, - onClick = { - if (viewModel.phoneNumber.isEmpty()) { - Toast.makeText(context, "휴대폰 번호를 입력해주세요", Toast.LENGTH_SHORT).show() - } else if (viewModel.phoneNumber.length == 11) { - signUpViewModel.checkIsDuplicatePhoneNumber(userType, viewModel.phoneNumber) - viewModel.updateIsSendNumber(true) - } else { - Toast.makeText(context, "올바른 휴대폰 번호를 입력해주세요", Toast.LENGTH_SHORT).show() - } - } ) - Spacer(modifier = Modifier.height(12.dp)) - ConnectDogTextFieldWithButton( - text = viewModel.certificationNumber, - width = 62, - height = 27, - textFieldLabel = "인증번호", - placeholder = "숫자 6자리", - buttonLabel = "인증 확인", - keyboardType = KeyboardType.Number, - padding = 5, - onTextChanged = { if (it.length <= 6) viewModel.updateCertificationNumber(it) }, - onClick = { - if (!isSendNumber) { - Toast.makeText(context, "먼저 인증번호를 전송해주세요", Toast.LENGTH_SHORT).show() - } else { - if (viewModel.certificationNumber.isEmpty()) { - Toast.makeText(context, "인증 번호를 입력해주세요", Toast.LENGTH_SHORT).show() - } else if (viewModel.certificationNumber.length == 6) { - onVerifyCodeClick(it) { viewModel.updateIsCertified(it) } - } else { - Toast.makeText(context, "인증 번호는 6자리로 입력해주세요", Toast.LENGTH_SHORT).show() - } - } + + if (uiState.isSendCertificationNumber) { + Spacer(modifier = Modifier.height(12.dp)) + ConnectDogTextFieldWithTimer( + text = uiState.certificationNumber, + textFieldLabel = "인증번호", + placeholder = "숫자 6자리", + keyboardType = KeyboardType.Number, + onTextChanged = viewModel::onChangeCertificationNumber, + ) + Spacer(modifier = Modifier.height(28.dp)) + Row( + modifier = Modifier.fillMaxSize(), + horizontalArrangement = Arrangement.Center + ) { + Text( + text = "인증번호가 오지 않는다면?", + color = Gray6, + fontSize = 12.sp + ) + Spacer(modifier = Modifier.width(8.dp)) + Text( + modifier = Modifier.clickable { }, + text = "재발송", + fontSize = 12.sp, + color = Gray8, + fontWeight = FontWeight.SemiBold + ) } - ) - Spacer(modifier = Modifier.height(20.dp)) + } Spacer(modifier = Modifier.weight(1f)) ConnectDogNormalButton( - content = "다음", - color = if (viewModel.name.isNotEmpty() && isCertified) { - PetOrange - } else { - Orange40 - }, + content = uiState.bottomButtonText, + enabled = if(!uiState.isSendCertificationNumber) uiState.enableNext else uiState.enableCertification, modifier = Modifier .fillMaxWidth() .height(56.dp), - onClick = { - if (viewModel.name.isNotEmpty() && isCertified) { - signUpViewModel.updatePhoneNumber(viewModel.phoneNumber) - signUpViewModel.updateName(viewModel.name) - when (userType) { - UserType.SOCIAL_VOLUNTEER -> onNavigateToVolunteerProfile(userType) - else -> onNavigateToRegisterEmail(userType) - } - } - } + onClick = { viewModel.onNextClick(onSendMessageClick, onVerifyCodeClick) } ) Spacer(modifier = Modifier.height((imeHeight + 32).dp)) } diff --git a/feature/signup/src/main/java/com/kusitms/connectdog/signup/state/CertificationUiState.kt b/feature/signup/src/main/java/com/kusitms/connectdog/signup/state/CertificationUiState.kt new file mode 100644 index 000000000..d4df61568 --- /dev/null +++ b/feature/signup/src/main/java/com/kusitms/connectdog/signup/state/CertificationUiState.kt @@ -0,0 +1,31 @@ +package com.kusitms.connectdog.signup.state + +import com.kusitms.connectdog.core.util.emptyString + +data class CertificationUiState( + val name: String, + val phoneNumber: String, + val certificationNumber: String, + val isSendCertificationNumber: Boolean, + val isCertified: Boolean, + val enableNext: Boolean, + val bottomButtonText: String, + val enableCertification: Boolean, +) { + companion object { + fun empty() = CertificationUiState( + name = emptyString(), + phoneNumber = emptyString(), + isSendCertificationNumber = false, + isCertified = false, + enableNext = false, + bottomButtonText = "다음", + enableCertification = false, + certificationNumber = emptyString() + ) + } +} + +sealed class CertificationSideEffect { + object NavigateToProfile: CertificationSideEffect() +} \ No newline at end of file diff --git a/feature/signup/src/main/java/com/kusitms/connectdog/signup/viewmodel/CertificationViewModel.kt b/feature/signup/src/main/java/com/kusitms/connectdog/signup/viewmodel/CertificationViewModel.kt index 507e720fb..08fa8060b 100644 --- a/feature/signup/src/main/java/com/kusitms/connectdog/signup/viewmodel/CertificationViewModel.kt +++ b/feature/signup/src/main/java/com/kusitms/connectdog/signup/viewmodel/CertificationViewModel.kt @@ -1,69 +1,67 @@ package com.kusitms.connectdog.signup.viewmodel -import android.util.Log -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.kusitms.connectdog.core.data.api.model.AdditionalAuthBody -import com.kusitms.connectdog.core.data.repository.ApplyRepository +import com.kusitms.connectdog.signup.state.CertificationSideEffect +import com.kusitms.connectdog.signup.state.CertificationUiState import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.launch +import org.orbitmvi.orbit.ContainerHost +import org.orbitmvi.orbit.syntax.simple.intent +import org.orbitmvi.orbit.syntax.simple.postSideEffect +import org.orbitmvi.orbit.syntax.simple.reduce +import org.orbitmvi.orbit.viewmodel.container import javax.inject.Inject @HiltViewModel -class CertificationViewModel @Inject constructor( - private val applyRepository: ApplyRepository -) : ViewModel() { - private val _isCertified: MutableStateFlow = MutableStateFlow(false) - val isCertified: StateFlow = _isCertified +class CertificationViewModel @Inject constructor() : ContainerHost, ViewModel() { + override val container = container(CertificationUiState.empty()) + private val state: CertificationUiState + get() = container.stateFlow.value - private val _isSendNumber: MutableStateFlow = MutableStateFlow(false) - val isSendNumber: StateFlow = _isSendNumber - - private val _name: MutableState = mutableStateOf("") - val name: String - get() = _name.value - - private val _phoneNumber: MutableState = mutableStateOf("") - val phoneNumber: String - get() = _phoneNumber.value - - private val _certificationNumber: MutableState = mutableStateOf("") - val certificationNumber: String - get() = _certificationNumber.value + fun onNameChanged(name: String) = intent { + reduce { state.copy(name = name) } + enableNextButton() + } - fun updateName(name: String) { - _name.value = name + fun onPhoneNumberChanged(phoneNumber: String) = intent { + if (phoneNumber.length <= 11) reduce { state.copy(phoneNumber = phoneNumber) } + enableNextButton() } - fun updatePhoneNumber(phoneNumber: String) { - _phoneNumber.value = phoneNumber + fun onChangeCertificationNumber(certificationNumber: String) = intent { + if (certificationNumber.length <= 6) reduce { state.copy(certificationNumber = certificationNumber) } + enableCertificationButton() } - fun updateCertificationNumber(certificationNumber: String) { - _certificationNumber.value = certificationNumber + fun onNextClick( + onSendMessageClick: (String) -> Unit, + onVerifyCodeClick: (String, (Boolean) -> Unit) -> Unit + ) { + if(!state.isSendCertificationNumber) sendCertificationNumber(onSendMessageClick) + else checkCertificationNumber(onVerifyCodeClick) } - fun updateIsCertified(isCertified: Boolean) { - _isCertified.value = isCertified + private fun enableNextButton() = intent { + if(state.phoneNumber.length == 11 && state.name.isNotEmpty()) reduce { state.copy(enableNext = true) } + else reduce { state.copy(enableNext = false) } } - fun updateIsSendNumber(value: Boolean) { - _isSendNumber.value = value + private fun enableCertificationButton() = intent { + if(state.certificationNumber.length == 6) reduce { state.copy(enableCertification = true) } + else reduce { state.copy(enableCertification = false) } } - fun postAdditionalAuth() { - val body = AdditionalAuthBody(name = _name.value, phone = _phoneNumber.value) - viewModelScope.launch { - try { - val response = applyRepository.postAdditionalAuth(body) - Log.d("testtts", response.toString()) - } catch (e: Exception) { - Log.d("testttserror", e.message.toString()) - } + private fun checkCertificationNumber(onVerifyCodeClick: (String, (Boolean) -> Unit) -> Unit) { + onVerifyCodeClick(state.certificationNumber) { isCertified -> + if(isCertified) intent { postSideEffect(CertificationSideEffect.NavigateToProfile) } + intent { reduce { state.copy(isCertified = isCertified) } } } } + + private fun sendCertificationNumber(sendMessage: (String) -> Unit) { + sendMessage(state.phoneNumber) + intent { reduce { state.copy(isSendCertificationNumber = true) } } + updateBottomButtonText() + } + + private fun updateBottomButtonText() = intent { reduce { state.copy(bottomButtonText = "인증 확인") } } } diff --git a/feature/signup/src/main/res/values/string.xml b/feature/signup/src/main/res/values/string.xml index 0ad4cfc5d..46fba4197 100644 --- a/feature/signup/src/main/res/values/string.xml +++ b/feature/signup/src/main/res/values/string.xml @@ -4,7 +4,8 @@ 이동봉사 모집자 회원가입 - 이름과 휴대폰 번호를\n입력해주세요 + 휴대폰 번호 인증을\n진행해 주세요 + 휴대폰 번호 한 줄 소개 한 줄 소개 입력 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7b44a584c..ec44bbd4a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,6 +51,7 @@ relay = "0.3.02" gson = "2.10.1" chucker = "4.0.0" +orbit-mvi = "8.0.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "andoroidCoreKtx" } @@ -84,6 +85,10 @@ moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin", version.re retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerializationJson" } javax-inject = { group = "javax.inject", name = "javax.inject", version = "1" } +#orbit-mvi +orbit-compose = { group = "org.orbit-mvi", name = "orbit-compose", version.ref = "orbit-mvi" } +orbit-core = { group = "org.orbit-mvi", name = "orbit-core", version.ref = "orbit-mvi" } +orbit-viewmodel = { group = "org.orbit-mvi", name = "orbit-viewmodel", version.ref = "orbit-mvi" } #hilt hilt-core = { group = "com.google.dagger", name = "hilt-core", version.ref = "hilt" } @@ -117,7 +122,7 @@ compose-shimmer = { group = "com.valentinilk.shimmer", name = "compose-shimmer", accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanistPager" } accompanist-pager-indicators = { group = "com.google.accompanist", name = "accompanist-pager-indicators", version.ref = "accompanistPagerIndicators" } -# social login +# oauth naver-oauth = { group = "com.navercorp.nid", name = "oauth", version.ref = "naverOauth" } kakao-oauth = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakaoOauth" } diff --git a/settings.gradle.kts b/settings.gradle.kts index b39a06dfa..69dbdd5b0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,3 +29,4 @@ include(":feature:mypage") include(":core:util") include(":feature:intermediator") include(":feature:signup") +include(":domain")