From 8bf6db66dfd2ea2fbed68f1409b4af0ad688707a Mon Sep 17 00:00:00 2001 From: eunseo Date: Mon, 9 Dec 2024 20:58:32 +0900 Subject: [PATCH 1/7] =?UTF-8?q?moneymong-520=20feat:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moneymong/model/sign/UnivResponse.kt | 4 +- .../agency/search/AgencySearchViewModel.kt | 2 +- .../moneymong/moneymong/home/HomeScreen.kt | 12 +- .../moneymong/feature/sign/SignUpScreen.kt | 268 +++++++++++------- .../moneymong/feature/sign/item/UnivItem.kt | 7 +- .../sign/navigation/SignUpNavigation.kt | 9 +- .../navigation/SignUpUniversityNavigation.kt | 35 +++ .../sign/sideeffect/SignUpSideEffect.kt | 1 - .../sideeffect/SignUpUniversitySideEffect.kt | 6 + .../feature/sign/state/SignUpState.kt | 10 +- .../sign/state/SignUpUniversityState.kt | 31 ++ .../moneymong/feature/sign/util/AgencyType.kt | 8 + .../feature/sign/view/SearchUnivView.kt | 10 +- .../feature/sign/view/SignUpButtonView.kt | 27 +- .../feature/sign/view/SignUpTitleView.kt | 11 +- .../feature/sign/view/SignUpUniversity.kt | 223 +++++++++++++++ .../viewmodel/SignUpUniversityViewModel.kt | 171 +++++++++++ .../feature/sign/viewmodel/SignUpViewModel.kt | 115 ++------ 18 files changed, 725 insertions(+), 225 deletions(-) create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpUniversityNavigation.kt create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpUniversitySideEffect.kt create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt create mode 100644 feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt diff --git a/core/model/src/main/java/com/moneymong/moneymong/model/sign/UnivResponse.kt b/core/model/src/main/java/com/moneymong/moneymong/model/sign/UnivResponse.kt index 46dbf79f..6fb08df1 100644 --- a/core/model/src/main/java/com/moneymong/moneymong/model/sign/UnivResponse.kt +++ b/core/model/src/main/java/com/moneymong/moneymong/model/sign/UnivResponse.kt @@ -1,6 +1,6 @@ package com.moneymong.moneymong.model.sign data class UnivResponse( - val universityName: String, - val grade: Int + val universityName: String?, + val grade: Int? ) \ No newline at end of file diff --git a/feature/agency/src/main/java/com/moneymong/moneymong/feature/agency/search/AgencySearchViewModel.kt b/feature/agency/src/main/java/com/moneymong/moneymong/feature/agency/search/AgencySearchViewModel.kt index 323d3b74..37d057ed 100644 --- a/feature/agency/src/main/java/com/moneymong/moneymong/feature/agency/search/AgencySearchViewModel.kt +++ b/feature/agency/src/main/java/com/moneymong/moneymong/feature/agency/search/AgencySearchViewModel.kt @@ -65,7 +65,7 @@ class AgencySearchViewModel @Inject constructor( isLoading = false, joinedAgencies = fetchMyAgenciesResult.getOrThrow() .map { myAgencyResponse -> myAgencyResponse.toAgency() }, - isUniversityStudent = fetchMyUniversityResult.getOrThrow().universityName.isNotBlank(), + isUniversityStudent = fetchMyUniversityResult.getOrThrow().universityName?.isNotBlank() ?: false , ) } } else { diff --git a/feature/home/src/main/java/com/moneymong/moneymong/home/HomeScreen.kt b/feature/home/src/main/java/com/moneymong/moneymong/home/HomeScreen.kt index a0752ac0..2f690615 100644 --- a/feature/home/src/main/java/com/moneymong/moneymong/home/HomeScreen.kt +++ b/feature/home/src/main/java/com/moneymong/moneymong/home/HomeScreen.kt @@ -29,8 +29,10 @@ import com.moneymong.moneymong.feature.sign.navigation.loginScreen import com.moneymong.moneymong.feature.sign.navigation.navigateLogin import com.moneymong.moneymong.feature.sign.navigation.navigateSignComplete import com.moneymong.moneymong.feature.sign.navigation.navigateSignUp +import com.moneymong.moneymong.feature.sign.navigation.navigateSignUpUniversity import com.moneymong.moneymong.feature.sign.navigation.signCompleteScreen import com.moneymong.moneymong.feature.sign.navigation.signUpScreen +import com.moneymong.moneymong.feature.sign.navigation.signUpUniversity import com.moneymong.moneymong.feature.sign.navigation.splashRoute import com.moneymong.moneymong.feature.sign.navigation.splashScreen import com.moneymong.moneymong.home.navigation.rememberHomeNavigator @@ -99,7 +101,15 @@ fun HomeScreen( ) signUpScreen( - navigateToSignComplete = homeNavController::navigateSignComplete, + navigateToLedger = homeNavController::navigateLedger, + navigateToSignUniversity = homeNavController::navigateSignUpUniversity, + navigateToAgency = homeNavController::navigateAgency, + navigateUp = homeNavController::navigateUp + ) + + signUpUniversity( + navigateToLedger = homeNavController::navigateLedger, + navigateToAgency = homeNavController::navigateAgency, navigateUp = homeNavController::navigateUp ) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt index b3e98d26..b722b8d3 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt @@ -1,47 +1,66 @@ package com.moneymong.moneymong.feature.sign +import android.annotation.SuppressLint import androidx.activity.compose.BackHandler +import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box 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.size +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Icon import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.moneymong.moneymong.common.ui.noRippleClickable import com.moneymong.moneymong.design_system.R +import com.moneymong.moneymong.design_system.component.selection.MDSSelection +import com.moneymong.moneymong.design_system.component.textfield.MDSTextField +import com.moneymong.moneymong.design_system.component.textfield.util.MDSTextFieldIcons import com.moneymong.moneymong.design_system.error.ErrorDialog import com.moneymong.moneymong.design_system.error.ErrorScreen +import com.moneymong.moneymong.design_system.theme.Blue04 +import com.moneymong.moneymong.design_system.theme.Body2 +import com.moneymong.moneymong.design_system.theme.Body3 import com.moneymong.moneymong.design_system.theme.Gray07 import com.moneymong.moneymong.design_system.theme.MMHorizontalSpacing import com.moneymong.moneymong.design_system.theme.White import com.moneymong.moneymong.feature.sign.sideeffect.SignUpSideEffect import com.moneymong.moneymong.feature.sign.state.SignUpState -import com.moneymong.moneymong.feature.sign.view.SearchUnivView -import com.moneymong.moneymong.feature.sign.view.SignCompleteCheckedView +import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.feature.sign.view.SignUpButtonView -import com.moneymong.moneymong.feature.sign.view.SignUpGradeView import com.moneymong.moneymong.feature.sign.view.SignUpTitleView import com.moneymong.moneymong.feature.sign.viewmodel.SignUpViewModel import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect +@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable fun SignUpScreen( - navigateToSignComplete: () -> Unit, + navigateToLedger: () -> Unit, + navigateToSignUpUniversity : (String, AgencyType?) -> Unit, + navigateToAgency : () -> Unit, navigateUp: () -> Unit, viewModel: SignUpViewModel = hiltViewModel() ) { @@ -72,14 +91,14 @@ fun SignUpScreen( Scaffold( modifier = Modifier .fillMaxSize() - .background(White) - .padding(horizontal = MMHorizontalSpacing), + .background(White), topBar = { Row( modifier = Modifier .fillMaxWidth() .height(44.dp) - .background(White), + .background(White) + .padding(horizontal = MMHorizontalSpacing), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start ) { @@ -96,10 +115,11 @@ fun SignUpScreen( ) } }, - content = { innerPadding -> + content = { SignUpContent( - modifier = Modifier.padding(innerPadding), - navigateToSignComplete = navigateToSignComplete, + navigateToLedger = navigateToLedger, + navigateToSignUpUniversity = navigateToSignUpUniversity, + navigateToAgency = navigateToAgency, viewModel = viewModel, state = state ) @@ -111,137 +131,193 @@ fun SignUpScreen( @Composable fun SignUpContent( - modifier: Modifier = Modifier, - navigateToSignComplete: () -> Unit, + navigateToLedger: () -> Unit, + navigateToSignUpUniversity : (String, AgencyType?) -> Unit, + navigateToAgency : () -> Unit, viewModel: SignUpViewModel, state: SignUpState ) { + val focusManager = LocalFocusManager.current + LaunchedEffect(key1 = state.isUnivCreated) { if (state.isUnivCreated) { - navigateToSignComplete() + viewModel.registerAgency() + } + } + + LaunchedEffect(key1 = state.isAgencyCreated) { + if (state.isAgencyCreated) { + navigateToLedger() } } viewModel.collectSideEffect { when (it) { - is SignUpSideEffect.UniversitiesApi -> { - viewModel.searchUniv(it.univ) - } - is SignUpSideEffect.CreateUniversityApi -> { viewModel.createUniv(it.universityName, it.grade) } + else -> {} } } Box( - modifier = modifier + modifier = Modifier .fillMaxSize() .background(color = White) ) { Column( - modifier = Modifier.fillMaxSize(), + modifier = Modifier.fillMaxSize() + .padding(horizontal = MMHorizontalSpacing), horizontalAlignment = Alignment.Start ) { SignUpTitleView( modifier = Modifier .fillMaxWidth() - .padding(top = 8.dp), - subTitleState = state.subTitleState + .height(89.dp) + .padding(top = 12.dp, bottom = 12.dp), ) - Box( + Column( modifier = Modifier - .padding(top = 40.dp) + .padding(top = 28.dp, end = 28.dp) .fillMaxWidth() ) { - if (!state.isSelected) { - SearchUnivView( - isFilled = state.isFilled, - isFilledChanged = { isFilled -> viewModel.isFilledChanged(isFilled) }, - isListVisible = state.isListVisible, - isListVisibleChanged = { isListVisible -> - viewModel.isListVisibleChanged( - isListVisible - ) - }, - isItemSelectedChanged = { isItemSelected -> - viewModel.isItemSelectedChanged( - isItemSelected - ) - }, - isItemSelected = state.isItemSelected, - textValue = state.textValue, - universityResponse = state.universityResponse, - onClick = { - viewModel.isSelectedChanged(true) - viewModel.selectedUnivChanged(it) - }, - onChange = { viewModel.textValueChanged(it) }, - onSearchIconClicked = { - viewModel.eventEmit(SignUpSideEffect.UniversitiesApi(it)) - }, - value = state.textValue, - isButtonVisibleChanged = { isButtonVisible -> viewModel.isButtonVisibleChanged(isButtonVisible)} + Text( + text = "소속 유형", + style = Body2, + color = Color.Black + ) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + horizontalArrangement = Arrangement.spacedBy(10.dp) + ) { + MDSSelection( + modifier = Modifier.weight(1f), + text = "기타 모임", + enabled = true, + isSelected = state.agencyType == AgencyType.GENERAL, + onClick = { viewModel.onChangeAgencyType(AgencyType.GENERAL) } + ) + MDSSelection( + modifier = Modifier.weight(1f), + text = "동아리", + enabled = true, + isSelected = state.agencyType == AgencyType.CLUB, + onClick = { viewModel.onChangeAgencyType(AgencyType.CLUB) } + ) + MDSSelection( + modifier = Modifier.weight(1f), + text = "학생회", + enabled = true, + isSelected = state.agencyType == AgencyType.STUDENT_COUNCIL, + onClick = { viewModel.onChangeAgencyType(AgencyType.STUDENT_COUNCIL) } + ) + } + } + AnimatedVisibility(visible = state.MDSSelected) { + Column( + modifier = Modifier + .padding(top = 28.dp), + ) { + Text( + text = "소속 이름", + style = Body2, + color = Blue04 ) - } else { - Column(modifier = Modifier.fillMaxSize()) { - SignCompleteCheckedView( - modifier = Modifier.fillMaxWidth(), - text = state.selectedUniv, - onChanged = { - viewModel.isSelectedChanged(false) + MDSTextField( + modifier = Modifier + .fillMaxWidth() + .onFocusChanged { focusState -> + if (focusState.isFocused) { + viewModel.updateEdittextFocused(true) + } else { + viewModel.updateEdittextFocused(false) + } }, - onSelectedGrade = { viewModel.selectedGradeChange(null) }, - onItemSelectedChanged = { viewModel.isItemSelectedChanged(it) }, - isEnableChanged = { viewModel.isEnabledChanged(it) } - ) - SignUpGradeView( - modifier = Modifier.fillMaxWidth(), - selectedGrade = state.selectedGrade, - selectedGradeChange = {selectedGrade -> viewModel.selectedGradeChange(selectedGrade)}, - onClick = { viewModel.isEnabledChanged(true) }, - changeGradeInfor = { viewModel.gradeInforChanged(it) } - ) - } + value = state.agencyName, + onValueChange = viewModel::updateAgencyName, + title = "", + isFilled = false, + singleLine = true, + maxCount = 50, + placeholder = "", + icon = MDSTextFieldIcons.Clear, + onIconClick = { viewModel.updateAgencyName(TextFieldValue()) }, + keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) + ) } } } - Box( + Column( modifier = Modifier .fillMaxWidth() .align(Alignment.BottomCenter) ) { - if(state.isButtonVisible){ - SignUpButtonView( - modifier = Modifier.fillMaxWidth(), - isEnabled = state.isEnabled, - visiblePopUpError = state.visiblePopUpError, - popUpErrorMessage = state.popUpErrorMessage, - visiblePopUpErrorChanged = { visiblePopUpError -> - viewModel.visiblePopUpErrorChanged(visiblePopUpError) - }, - onCreateUniversity = { - viewModel.eventEmit( - SignUpSideEffect.CreateUniversityApi( - state.selectedUniv, - state.gradeInfor - ) + SignUpButtonView( + modifier = Modifier.fillMaxWidth() + .padding(horizontal = if (state.editTextFocused) 0.dp else MMHorizontalSpacing), + isEnabled = state.isButtonVisible, + visiblePopUpError = state.visiblePopUpError, + popUpErrorMessage = state.popUpErrorMessage, + visiblePopUpErrorChanged = { visiblePopUpError -> + viewModel.visiblePopUpErrorChanged(visiblePopUpError) + }, + onCreateUniversity = { + viewModel.eventEmit( + SignUpSideEffect.CreateUniversityApi( + state.selectedUniv, + state.gradeInfor ) - }, + ) + }, + navigateToSignUpUniversity = { agencyName, agencyType -> + navigateToSignUpUniversity(agencyName, agencyType) + }, + agencyName = state.agencyName.text, + agencyType = state.agencyType, + pageType = 1 + ) + + if (!state.editTextFocused){ + Spacer(modifier = Modifier.height(60.dp)) + } + + } + + if (!state.editTextFocused) { + Column( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.BottomCenter) + ) { + Spacer(modifier = Modifier.height(16.dp)) + + Text( + modifier = Modifier + .fillMaxWidth() + .noRippleClickable { + viewModel.eventEmit( + SignUpSideEffect.CreateUniversityApi( + state.selectedUniv, + state.gradeInfor + ) + ) + navigateToAgency() + }, + textAlign = TextAlign.Center, + text = "총무에게 초대받았어요", + style = Body3, + color = Blue04 ) + + Spacer(modifier = Modifier.height(24.dp)) + } } } } - -@Preview -@Composable -fun Preview(){ - SignUpScreen( - navigateUp = {}, - navigateToSignComplete = {} - ) -} \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt index 80dfb41a..615b7ee3 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt @@ -29,7 +29,8 @@ fun UnivItem( isItemSelectedChanged: (Boolean) -> Unit, univs: University, onClick: (String) -> Unit, - isButtonVisibleChanged : (Boolean) -> Unit + isButtonVisibleChanged : (Boolean) -> Unit, + selectedUniv : String ) { Row( modifier = Modifier @@ -50,7 +51,7 @@ fun UnivItem( ) Text( text = univs.schoolName, - color = if (isItemSelected) Blue04 else Black, + color = if (selectedUniv == univs.schoolName) Blue04 else Black, style = Body4, modifier = Modifier .weight(1f) @@ -62,7 +63,7 @@ fun UnivItem( painter = painterResource(id = R.drawable.ic_check), contentDescription = null, modifier = Modifier.size(24.dp), - tint = if (isItemSelected) Blue04 else Gray03 + tint = if (selectedUniv == univs.schoolName) Blue04 else Gray03 ) } } \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpNavigation.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpNavigation.kt index 82bf301a..f7fed170 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpNavigation.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpNavigation.kt @@ -5,6 +5,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.moneymong.moneymong.feature.sign.SignUpScreen +import com.moneymong.moneymong.feature.sign.util.AgencyType const val signUpRoute = "signup_route" @@ -13,12 +14,16 @@ fun NavController.navigateSignUp(navOptions: NavOptions? = null) { } fun NavGraphBuilder.signUpScreen( - navigateToSignComplete: () -> Unit, + navigateToLedger: () -> Unit, + navigateToSignUniversity : (String, AgencyType?) -> Unit, + navigateToAgency : () -> Unit, navigateUp: () -> Unit ) { composable(route = signUpRoute) { SignUpScreen( - navigateToSignComplete = navigateToSignComplete, + navigateToLedger = navigateToLedger, + navigateToSignUpUniversity = navigateToSignUniversity, + navigateToAgency = navigateToAgency, navigateUp = navigateUp ) } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpUniversityNavigation.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpUniversityNavigation.kt new file mode 100644 index 00000000..65f8df38 --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/navigation/SignUpUniversityNavigation.kt @@ -0,0 +1,35 @@ +package com.moneymong.moneymong.feature.sign.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.moneymong.moneymong.feature.sign.util.AgencyType +import com.moneymong.moneymong.feature.sign.view.SignUpUniversity + +const val signUpUniversityRoute = "signup_university_route" + +fun NavController.navigateSignUpUniversity(agencyName: String, agencyType: AgencyType?, navOptions: NavOptions? = null) { + val routeWithParams = "signup_university_route?agencyName=$agencyName&agencyType=${agencyType?.name}" + navigate(route = routeWithParams, navOptions = navOptions) +} + +fun NavGraphBuilder.signUpUniversity( + navigateToLedger: () -> Unit, + navigateToAgency : () -> Unit, + navigateUp: () -> Unit, +) { + + composable(route = "$signUpUniversityRoute?agencyName={agencyName}&agencyType={agencyType}") { navBackStackEntry -> + val agencyName = navBackStackEntry.arguments?.getString("agencyName") ?: "" + val agencyType = navBackStackEntry.arguments?.getString("agencyType")?.let { AgencyType.valueOf(it) }.run { AgencyType.CLUB } + + SignUpUniversity( + navigateToLedger = navigateToLedger, + navigateToAgency = navigateToAgency, + navigateUp = navigateUp, + agencyName = agencyName, + agencyType = agencyType + ) + } +} diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpSideEffect.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpSideEffect.kt index e553a26e..30ef0232 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpSideEffect.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpSideEffect.kt @@ -3,7 +3,6 @@ package com.moneymong.moneymong.feature.sign.sideeffect import com.moneymong.moneymong.common.base.SideEffect sealed class SignUpSideEffect : SideEffect { - data class UniversitiesApi(val univ: String) : SignUpSideEffect() data class CreateUniversityApi( val universityName : String, val grade: Int diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpUniversitySideEffect.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpUniversitySideEffect.kt new file mode 100644 index 00000000..4de12bf2 --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/sideeffect/SignUpUniversitySideEffect.kt @@ -0,0 +1,6 @@ +package com.moneymong.moneymong.feature.sign.sideeffect + +import com.moneymong.moneymong.common.base.SideEffect + +sealed class SignUpUniversitySideEffect : SideEffect { +} \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt index d2dd3200..aa781cd3 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt @@ -2,12 +2,13 @@ package com.moneymong.moneymong.feature.sign.state import androidx.compose.ui.text.input.TextFieldValue import com.moneymong.moneymong.common.base.State +import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.feature.sign.util.Grade import com.moneymong.moneymong.model.sign.UniversitiesResponse data class SignUpState( //screen - val isSelected: Boolean = false, + val isSelected: Boolean? = null, val selectedUniv: String = "", val textValue: TextFieldValue = TextFieldValue(), val isEnabled: Boolean = false, @@ -18,15 +19,20 @@ data class SignUpState( val isFilled: Boolean = false, val universityResponse: UniversitiesResponse? = null, val isUnivCreated : Boolean = false, + val isAgencyCreated : Boolean = false, + val editTextFocused : Boolean = false, + val MDSSelected : Boolean = false, //item val isItemSelected : Boolean = false, val selectedGrade : Grade? = null, + val agencyType : AgencyType? = null, + val agencyName : TextFieldValue = TextFieldValue(), //error val visibleError : Boolean = false, val errorMessage : String = "", val visiblePopUpError : Boolean = false, val popUpErrorMessage : String = "", - val isButtonVisible : Boolean = true, + val isButtonVisible : Boolean = false, ) : State \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt new file mode 100644 index 00000000..94a8c051 --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt @@ -0,0 +1,31 @@ +package com.moneymong.moneymong.feature.sign.state + +import androidx.compose.ui.text.input.TextFieldValue +import com.moneymong.moneymong.common.base.State +import com.moneymong.moneymong.feature.sign.util.AgencyType +import com.moneymong.moneymong.model.sign.UniversitiesResponse + +data class SignUpUniversityState ( + //screen + val isSelected: Boolean? = null, + val selectedUniv: String = "", + val textValue: TextFieldValue = TextFieldValue(), + val isEnabled: Boolean = false, + val gradeInfor: Int = 0, + //view + val isListVisible: Boolean = false, + val isFilled: Boolean = false, + val universityResponse: UniversitiesResponse? = null, + //item + val isItemSelected : Boolean = false, + val agencyType : AgencyType? = null, + //error + val visibleError : Boolean = false, + val errorMessage : String = "", + val visiblePopUpError : Boolean = false, + val popUpErrorMessage : String = "", + val isButtonVisible : Boolean = true, + + val isUnivCreated : Boolean = false, + val isAgencyCreated : Boolean = false, +): State \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt new file mode 100644 index 00000000..0d561f2c --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt @@ -0,0 +1,8 @@ +package com.moneymong.moneymong.feature.sign.util + +enum class AgencyType(val text: String) { + GENERAL("GENERAL"), + CLUB("CLUB"), + STUDENT_COUNCIL("STUDENT_COUNCIL"), + NONE("NONE") +} diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt index f08c941c..283502ef 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt @@ -49,6 +49,7 @@ fun SearchUnivView( universityResponse: UniversitiesResponse?, value: TextFieldValue, isButtonVisibleChanged: (Boolean) -> Unit, + selectedUniv : String ) { val keyboardController = LocalSoftwareKeyboardController.current @@ -122,7 +123,8 @@ fun SearchUnivView( isItemSelectedChanged = isItemSelectedChanged, univs = universityResponse.universities, onClick = onClick, - isButtonVisibleChanged = isButtonVisibleChanged + isButtonVisibleChanged = isButtonVisibleChanged, + selectedUniv = selectedUniv ) } else { Column( @@ -148,7 +150,8 @@ fun UnivList( isItemSelectedChanged: (Boolean) -> Unit, univs: List, onClick: (String) -> Unit, - isButtonVisibleChanged: (Boolean) -> Unit + isButtonVisibleChanged: (Boolean) -> Unit, + selectedUniv: String ) { LazyColumn { items(univs) { univ -> @@ -157,7 +160,8 @@ fun UnivList( isItemSelectedChanged = isItemSelectedChanged, univs = univ, onClick = onClick, - isButtonVisibleChanged = isButtonVisibleChanged + isButtonVisibleChanged = isButtonVisibleChanged, + selectedUniv = selectedUniv ) } } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt index 6b83058b..919d17ae 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt @@ -16,6 +16,7 @@ import com.moneymong.moneymong.design_system.component.button.MDSButtonType import com.moneymong.moneymong.design_system.error.ErrorDialog import com.moneymong.moneymong.design_system.theme.Blue04 import com.moneymong.moneymong.design_system.theme.Body3 +import com.moneymong.moneymong.feature.sign.util.AgencyType @Composable fun SignUpButtonView( @@ -25,6 +26,10 @@ fun SignUpButtonView( popUpErrorMessage: String, visiblePopUpErrorChanged: (Boolean) -> Unit, onCreateUniversity: () -> Unit, + navigateToSignUpUniversity : (String, AgencyType?) -> Unit, + agencyName: String, + agencyType: AgencyType?, + pageType : Int ) { if (visiblePopUpError) { ErrorDialog( @@ -38,30 +43,16 @@ fun SignUpButtonView( modifier = modifier ) { MDSButton( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth() + .height(56.dp), onClick = { - onCreateUniversity() + if(agencyType == AgencyType.GENERAL || pageType == 2) onCreateUniversity() else if (agencyType != AgencyType.GENERAL && pageType == 1) navigateToSignUpUniversity(agencyName, agencyType) }, - text = "가입하기", + text = if(agencyType == AgencyType.GENERAL || pageType == 2) "등록하기" else "다음으로", type = MDSButtonType.PRIMARY, size = MDSButtonSize.LARGE, enabled = isEnabled ) - Spacer(modifier = Modifier.height(16.dp)) - Text( - modifier = Modifier - .fillMaxWidth() - .noRippleClickable { - onCreateUniversity() - }, - textAlign = TextAlign.Center, - text = "입력할 대학 정보가 없어요", - color = Blue04, - style = Body3 - ) - - Spacer(modifier = Modifier.height(28.dp)) - } } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpTitleView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpTitleView.kt index dad5d7e5..476e3f85 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpTitleView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpTitleView.kt @@ -15,23 +15,16 @@ import com.moneymong.moneymong.design_system.theme.Heading2 import com.moneymong.moneymong.design_system.theme.White @Composable -fun SignUpTitleView(modifier: Modifier = Modifier, subTitleState: Boolean) { +fun SignUpTitleView(modifier: Modifier = Modifier, /*subTitleState: Boolean*/) { Column( modifier = modifier.background(White), horizontalAlignment = Alignment.Start ) { Text( - text = "대학정보를 알려주세요!", + text = "회비관리가 필요한\n소속정보를 알려주세요!", style = Heading2, color = Black ) - Text( - modifier = Modifier.padding(top= 8.dp), - text = "학교 이름과 학년을 선택해주세요.", - style = Body3, - color = if (!subTitleState) Gray06.copy(alpha = 0.4f) else Gray06 - - ) } } \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt new file mode 100644 index 00000000..ce80745b --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -0,0 +1,223 @@ +package com.moneymong.moneymong.feature.sign.view + +import android.annotation.SuppressLint +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +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.layout.size +import androidx.compose.material3.Icon +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import com.moneymong.moneymong.common.ui.noRippleClickable +import com.moneymong.moneymong.design_system.R +import com.moneymong.moneymong.design_system.error.ErrorDialog +import com.moneymong.moneymong.design_system.error.ErrorScreen +import com.moneymong.moneymong.design_system.theme.Black +import com.moneymong.moneymong.design_system.theme.Body3 +import com.moneymong.moneymong.design_system.theme.Gray06 +import com.moneymong.moneymong.design_system.theme.Gray07 +import com.moneymong.moneymong.design_system.theme.Gray08 +import com.moneymong.moneymong.design_system.theme.Heading2 +import com.moneymong.moneymong.design_system.theme.MMHorizontalSpacing +import com.moneymong.moneymong.design_system.theme.White +import com.moneymong.moneymong.feature.sign.SignUpContent +import com.moneymong.moneymong.feature.sign.sideeffect.SignUpSideEffect +import com.moneymong.moneymong.feature.sign.sideeffect.SignUpUniversitySideEffect +import com.moneymong.moneymong.feature.sign.state.SignUpUniversityState +import com.moneymong.moneymong.feature.sign.util.AgencyType +import com.moneymong.moneymong.feature.sign.viewmodel.SignUpUniversityViewModel +import com.moneymong.moneymong.feature.sign.viewmodel.SignUpViewModel +import org.orbitmvi.orbit.compose.collectAsState +import org.orbitmvi.orbit.compose.collectSideEffect + +@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") +@Composable +fun SignUpUniversity( + navigateToLedger : () -> Unit, + navigateToAgency : () -> Unit, + navigateUp : () -> Unit, + agencyName : String, + agencyType: AgencyType, + viewModel: SignUpUniversityViewModel = hiltViewModel() +){ + val state = viewModel.collectAsState().value + + BackHandler { + navigateUp() + } + + if(state.visibleError){ + ErrorScreen( + modifier = Modifier.fillMaxSize(), + message = state.errorMessage, + onRetry = { + viewModel.visibleErrorChanged(false) + } + ) + } + else if(state.visiblePopUpError){ + ErrorDialog( + message = state.popUpErrorMessage, + onConfirm = { + viewModel.visiblePopUpErrorChanged(false) + } + ) + } + else { + Scaffold( + modifier = Modifier + .fillMaxSize() + .background(White) + .padding(horizontal = MMHorizontalSpacing), + topBar = { + Row( + modifier = Modifier + .fillMaxWidth() + .height(44.dp) + .background(White), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Start + ) { + Icon( + painter = painterResource(id = R.drawable.ic_chevron_left), + contentDescription = null, + modifier = Modifier + .size(24.dp) + .background(White) + .noRippleClickable { + navigateUp() + }, + tint = Gray07 + ) + } + }, + content = { + SignUpUniversityContent( + navigateToLedger = navigateToLedger, + agencyName = agencyName, + agencyType = agencyType, + viewModel = viewModel, + state = state + ) + } + ) + } +} + +@Composable +fun SignUpUniversityContent ( + navigateToLedger: () -> Unit, + agencyName: String, + agencyType: AgencyType, + viewModel: SignUpUniversityViewModel, + state: SignUpUniversityState + +) { + + LaunchedEffect(key1 = state.isUnivCreated) { + if (state.isUnivCreated) { + viewModel.registerAgency(agencyName, agencyType) + } + } + + LaunchedEffect(key1 = state.isAgencyCreated) { + if (state.isAgencyCreated) { + navigateToLedger() + } + } + + Column( + modifier = Modifier.background(White) + ) { + Text( + modifier = Modifier.padding(top = 12.dp, bottom = 8.dp), + text = "어디 학교 교내 동아리인가요?", + style = Heading2, + color = Black + ) + Text( + modifier = Modifier.padding(bottom = 12.dp), + text = "소속 대학교를 알려주세요", + style = Body3, + color = Gray06 + ) + + SearchUnivView( + modifier = Modifier + .padding(top = 28.dp, bottom = 28.dp,) + .fillMaxWidth() + .height(0.dp) + .weight(1.0F), + isFilled = state.isFilled, + isFilledChanged = { isFilled -> viewModel.isFilledChanged(isFilled) }, + isListVisible = state.isListVisible, + isListVisibleChanged = { isListVisible -> + viewModel.isListVisibleChanged( + isListVisible + ) + }, + isItemSelectedChanged = { isItemSelected -> + viewModel.isItemSelectedChanged( + isItemSelected + ) + }, + isItemSelected = state.isItemSelected, + textValue = state.textValue, + universityResponse = state.universityResponse, + onClick = { + viewModel.isSelectedChanged(true) + viewModel.selectedUnivChanged(it) + }, + onChange = { viewModel.textValueChanged(it) }, + onSearchIconClicked = { + viewModel.searchUniv(it) + }, + value = state.textValue, + isButtonVisibleChanged = { isButtonVisible -> + viewModel.isButtonVisibleChanged( + isButtonVisible + ) + }, + selectedUniv = state.selectedUniv + ) + + Column( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + verticalArrangement = Arrangement.Bottom + ) { + SignUpButtonView( + modifier = Modifier.fillMaxWidth(), + isEnabled = state.isItemSelected, + visiblePopUpError = state.visiblePopUpError, + popUpErrorMessage = state.popUpErrorMessage, + visiblePopUpErrorChanged = { visiblePopUpError -> + viewModel.visiblePopUpErrorChanged(visiblePopUpError) + }, + onCreateUniversity = { + viewModel.createUniv(state.selectedUniv, state.gradeInfor) + }, + navigateToSignUpUniversity = { agencyName, agencyType -> }, + agencyName = agencyName, + agencyType = agencyType, + pageType = 2 + ) + } + } +} diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt new file mode 100644 index 00000000..b16f9d07 --- /dev/null +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt @@ -0,0 +1,171 @@ +package com.moneymong.moneymong.feature.sign.viewmodel + +import android.view.View +import androidx.compose.ui.text.input.TextFieldValue +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.moneymong.moneymong.common.base.BaseViewModel +import com.moneymong.moneymong.domain.usecase.agency.RegisterAgencyUseCase +import com.moneymong.moneymong.domain.usecase.signup.SchoolInfoUseCase +import com.moneymong.moneymong.domain.usecase.university.CreateUniversityUseCase +import com.moneymong.moneymong.domain.usecase.university.SearchUniversityUseCase +import com.moneymong.moneymong.feature.sign.sideeffect.SignUpUniversitySideEffect +import com.moneymong.moneymong.feature.sign.state.SignUpUniversityState +import com.moneymong.moneymong.feature.sign.util.AgencyType +import com.moneymong.moneymong.model.agency.AgencyRegisterRequest +import com.moneymong.moneymong.model.sign.UnivRequest +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.launch +import org.orbitmvi.orbit.annotation.OrbitExperimental +import org.orbitmvi.orbit.syntax.simple.blockingIntent +import org.orbitmvi.orbit.syntax.simple.intent +import org.orbitmvi.orbit.syntax.simple.reduce +import javax.inject.Inject + +@HiltViewModel +class SignUpUniversityViewModel @Inject constructor( + private val createUniversityUseCase: CreateUniversityUseCase, + private val registerAgencyUseCase : RegisterAgencyUseCase, + private val schoolInfoUseCase : SchoolInfoUseCase, + private val searchUniversityUseCase: SearchUniversityUseCase +) : BaseViewModel(SignUpUniversityState()){ + + fun searchUniv(searchQuery: String) = intent { + searchUniversityUseCase(searchQuery) + .onSuccess { + reduce { + state.copy( + universityResponse = it + ) + } + }.onFailure { + reduce { + state.copy( + visibleError = true, + errorMessage = it.message.toString() + ) + } + } + } + + + fun createUniv(universityName: String?, grade: Int?) = intent { + val body = UnivRequest(universityName, grade) + createUniversityUseCase(body) + .onSuccess { + storeSchoolInfoProvided(true) + reduce { + state.copy( + isUnivCreated = true + ) + } + } + .onFailure { + reduce { + state.copy( + visiblePopUpError = true, + popUpErrorMessage = it.message.toString() + ) + } + } + } + + fun registerAgency(agencyName: String, agencyType: AgencyType) = intent{ + registerAgencyUseCase(AgencyRegisterRequest(agencyName, agencyType.text)) + .onSuccess { + reduce { + state.copy( + isAgencyCreated = true + ) + } + } + .onFailure { + reduce { + state.copy( + visiblePopUpError = true, + popUpErrorMessage = it.message.toString() + ) + } + } + + } + + private fun storeSchoolInfoProvided(infoExist : Boolean ){ + viewModelScope.launch { + schoolInfoUseCase.invoke(infoExist) + } + } + + fun isSelectedChanged(isSelected: Boolean) = intent { + reduce { + state.copy( + isSelected = isSelected + ) + } + } + + fun selectedUnivChanged(selectedUniv: String) = intent { + reduce { + state.copy( + selectedUniv = selectedUniv + ) + } + } + + @OptIn(OrbitExperimental::class) + fun textValueChanged(textValue: TextFieldValue) = blockingIntent { + reduce { + state.copy( + textValue = textValue + ) + } + } + + fun isFilledChanged(isFilled: Boolean) = intent { + reduce { + state.copy( + isFilled = isFilled + ) + } + } + + fun isListVisibleChanged(isListVisible: Boolean) = intent { + reduce { + state.copy( + isListVisible = isListVisible + ) + } + } + + fun isItemSelectedChanged(isItemSelected: Boolean) = intent { + reduce { + state.copy( + isItemSelected = isItemSelected + ) + } + } + + fun isButtonVisibleChanged(isButtonVisible: Boolean) = intent { + reduce { + state.copy( + isButtonVisible = isButtonVisible + ) + } + } + + fun visiblePopUpErrorChanged(visiblePopUpError: Boolean) = intent { + reduce { + state.copy( + visiblePopUpError = visiblePopUpError, + ) + } + } + + fun visibleErrorChanged(visibleError: Boolean) = intent { + reduce { + state.copy( + visibleError = visibleError, + ) + } + } +} \ No newline at end of file diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt index 85fe8a43..2b3a61f8 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt @@ -3,12 +3,16 @@ package com.moneymong.moneymong.feature.sign.viewmodel import androidx.compose.ui.text.input.TextFieldValue import androidx.lifecycle.viewModelScope import com.moneymong.moneymong.common.base.BaseViewModel +import com.moneymong.moneymong.domain.usecase.agency.AgencyJoinUseCase +import com.moneymong.moneymong.domain.usecase.agency.RegisterAgencyUseCase import com.moneymong.moneymong.domain.usecase.signup.SchoolInfoUseCase import com.moneymong.moneymong.domain.usecase.university.CreateUniversityUseCase import com.moneymong.moneymong.domain.usecase.university.SearchUniversityUseCase import com.moneymong.moneymong.feature.sign.sideeffect.SignUpSideEffect import com.moneymong.moneymong.feature.sign.state.SignUpState +import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.feature.sign.util.Grade +import com.moneymong.moneymong.model.agency.AgencyRegisterRequest import com.moneymong.moneymong.model.sign.UnivRequest import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineScope @@ -23,10 +27,10 @@ import javax.inject.Inject @HiltViewModel class SignUpViewModel @Inject constructor( private val createUniversityUseCase: CreateUniversityUseCase, - private val searchUniversityUseCase: SearchUniversityUseCase, + private val registerAgencyUseCase: RegisterAgencyUseCase, private val schoolInfoUseCase: SchoolInfoUseCase, ) : BaseViewModel(SignUpState()) { - fun createUniv(universityName: String?, grade: Int?) = intent { + fun createUniv(universityName: String, grade: Int) = intent { val body = UnivRequest(universityName, grade) createUniversityUseCase(body) .onSuccess { @@ -47,133 +51,70 @@ class SignUpViewModel @Inject constructor( } } - fun searchUniv(searchQuery: String) = intent { - searchUniversityUseCase(searchQuery) + fun registerAgency() = intent{ + registerAgencyUseCase(AgencyRegisterRequest(state.agencyName.text, AgencyType.GENERAL.text)) .onSuccess { reduce { state.copy( - universityResponse = it + isAgencyCreated = true ) } - }.onFailure { + } + .onFailure { reduce { state.copy( - visibleError = true, - errorMessage = it.message.toString() + visiblePopUpError = true, + popUpErrorMessage = it.message.toString() ) } } + } - fun storeSchoolInfoProvided(infoExist : Boolean ){ + private fun storeSchoolInfoProvided(infoExist : Boolean ){ viewModelScope.launch { schoolInfoUseCase.invoke(infoExist) } } - fun isSelectedChanged(isSelected: Boolean) = intent { - reduce { - state.copy( - isSelected = isSelected - ) - } - } - - fun selectedUnivChanged(selectedUniv: String) = intent { - reduce { - state.copy( - selectedUniv = selectedUniv - ) - } - } - - @OptIn(OrbitExperimental::class) - fun textValueChanged(textValue: TextFieldValue) = blockingIntent { - reduce { - state.copy( - textValue = textValue - ) - } - } - - fun isEnabledChanged(isEnable: Boolean) = intent { - reduce { - state.copy( - isEnabled = isEnable - ) - } - } - - fun subTitleStateChanged(subTitleState: Boolean) = intent { - reduce { - state.copy( - subTitleState = subTitleState - ) - } - } - - fun gradeInforChanged(gradeInfor: Int) = intent { - reduce { - state.copy( - gradeInfor = gradeInfor - ) - } - } - - - fun isFilledChanged(isFilled: Boolean) = intent { - reduce { - state.copy( - isFilled = isFilled - ) - } - } - - fun isListVisibleChanged(isListVisible: Boolean) = intent { - reduce { - state.copy( - isListVisible = isListVisible - ) - } - } - - fun isItemSelectedChanged(isItemSelected: Boolean) = intent { + fun visiblePopUpErrorChanged(visiblePopUpError: Boolean) = intent { reduce { state.copy( - isItemSelected = isItemSelected + visiblePopUpError = visiblePopUpError, ) } } - fun selectedGradeChange(selectedGrade: Grade?) = intent { + fun visibleErrorChanged(visibleError: Boolean) = intent { reduce { state.copy( - selectedGrade = selectedGrade + visibleError = visibleError, ) } } - fun visiblePopUpErrorChanged(visiblePopUpError: Boolean) = intent { - reduce { + fun onChangeAgencyType(agencyType: AgencyType) = intent{ + reduce{ state.copy( - visiblePopUpError = visiblePopUpError, + agencyType = agencyType, + MDSSelected = true, ) } } - fun visibleErrorChanged(visibleError: Boolean) = intent { + fun updateAgencyName(agencyName: TextFieldValue)= intent{ reduce { state.copy( - visibleError = visibleError, + agencyName = agencyName, + isButtonVisible = agencyName.text != "" && state.agencyType != null ) } } - - fun isButtonVisibleChanged(isButtonVisible: Boolean) = intent { + fun updateEdittextFocused(focusState : Boolean) = intent { reduce { state.copy( - isButtonVisible = isButtonVisible + editTextFocused = focusState ) } } From 674211f41525b73719e0660320adeeacb666deed Mon Sep 17 00:00:00 2001 From: eunseo Date: Sun, 29 Dec 2024 00:16:38 +0900 Subject: [PATCH 2/7] =?UTF-8?q?moneymong-520=20Fix:=20=ED=9D=AC=EC=A7=81?= =?UTF-8?q?=EB=8B=98=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design_system/component/button/Button.kt | 5 +- .../moneymong/feature/sign/SignUpScreen.kt | 38 +++++++--- .../feature/sign/state/SignUpState.kt | 4 ++ .../sign/state/SignUpUniversityState.kt | 4 ++ .../moneymong/feature/sign/util/AgencyType.kt | 2 +- .../feature/sign/view/SearchUnivView.kt | 11 ++- .../feature/sign/view/SignUpButtonView.kt | 18 ++--- .../feature/sign/view/SignUpUniversity.kt | 71 +++++++++++-------- .../viewmodel/SignUpUniversityViewModel.kt | 17 +++++ 9 files changed, 117 insertions(+), 53 deletions(-) diff --git a/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/button/Button.kt b/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/button/Button.kt index 732bd0f1..b9a158ed 100644 --- a/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/button/Button.kt +++ b/core/design-system/src/main/java/com/moneymong/moneymong/design_system/component/button/Button.kt @@ -30,6 +30,7 @@ fun MDSButton( @DrawableRes iconResource: Int? = null, enabled: Boolean = true, contentHorizontalPadding: Dp = 0.dp, + cornerShape : Dp = 10.dp, ) { val backgroundColor = if (enabled) type.backgroundColor else disabledBackgroundColor val contentColor = if (enabled) type.contentColor else disabledContentColor @@ -38,10 +39,10 @@ fun MDSButton( modifier = modifier .background( color = backgroundColor, - shape = RoundedCornerShape(10.dp) + shape = RoundedCornerShape(cornerShape) ) .clip( - RoundedCornerShape(10.dp) + RoundedCornerShape(cornerShape) ) .clickable( onClick = onClick, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt index b722b8d3..c90673b3 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt @@ -116,7 +116,9 @@ fun SignUpScreen( } }, content = { + paddingValues -> SignUpContent( + modifier = Modifier.padding(paddingValues), navigateToLedger = navigateToLedger, navigateToSignUpUniversity = navigateToSignUpUniversity, navigateToAgency = navigateToAgency, @@ -131,6 +133,7 @@ fun SignUpScreen( @Composable fun SignUpContent( + modifier: Modifier, navigateToLedger: () -> Unit, navigateToSignUpUniversity : (String, AgencyType?) -> Unit, navigateToAgency : () -> Unit, @@ -142,7 +145,11 @@ fun SignUpContent( LaunchedEffect(key1 = state.isUnivCreated) { if (state.isUnivCreated) { - viewModel.registerAgency() + if(state.isInvited){ + navigateToAgency() + }else { + viewModel.registerAgency() + } } } @@ -152,6 +159,10 @@ fun SignUpContent( } } + LaunchedEffect(key1 = state.isUnivCreated) { + + } + viewModel.collectSideEffect { when (it) { is SignUpSideEffect.CreateUniversityApi -> { @@ -162,12 +173,13 @@ fun SignUpContent( } Box( - modifier = Modifier + modifier = modifier .fillMaxSize() .background(color = White) ) { Column( - modifier = Modifier.fillMaxSize() + modifier = Modifier + .fillMaxSize() .padding(horizontal = MMHorizontalSpacing), horizontalAlignment = Alignment.Start ) { @@ -180,7 +192,8 @@ fun SignUpContent( Column( modifier = Modifier - .padding(top = 28.dp, end = 28.dp) + .padding(vertical = 28.dp) +// .padding(top = 28.dp, end = 28.dp) .fillMaxWidth() ) { Text( @@ -233,6 +246,7 @@ fun SignUpContent( .onFocusChanged { focusState -> if (focusState.isFocused) { viewModel.updateEdittextFocused(true) + viewModel.changeButtonCornerShape(0.dp) } else { viewModel.updateEdittextFocused(false) } @@ -246,7 +260,12 @@ fun SignUpContent( placeholder = "", icon = MDSTextFieldIcons.Clear, onIconClick = { viewModel.updateAgencyName(TextFieldValue()) }, - keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), + keyboardActions = KeyboardActions( + onDone = { + focusManager.clearFocus() + viewModel.changeButtonCornerShape(10.dp) + } + ), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) ) } @@ -259,7 +278,8 @@ fun SignUpContent( .align(Alignment.BottomCenter) ) { SignUpButtonView( - modifier = Modifier.fillMaxWidth() + modifier = Modifier + .fillMaxWidth() .padding(horizontal = if (state.editTextFocused) 0.dp else MMHorizontalSpacing), isEnabled = state.isButtonVisible, visiblePopUpError = state.visiblePopUpError, @@ -280,7 +300,8 @@ fun SignUpContent( }, agencyName = state.agencyName.text, agencyType = state.agencyType, - pageType = 1 + pageType = 1, + cornerShape = state.buttonCornerShape ) if (!state.editTextFocused){ @@ -307,7 +328,8 @@ fun SignUpContent( state.gradeInfor ) ) - navigateToAgency() + viewModel.changeInvitedType(true) +// navigateToAgency() }, textAlign = TextAlign.Center, text = "총무에게 초대받았어요", diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt index aa781cd3..1145e682 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpState.kt @@ -1,6 +1,8 @@ package com.moneymong.moneymong.feature.sign.state import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp import com.moneymong.moneymong.common.base.State import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.feature.sign.util.Grade @@ -14,6 +16,8 @@ data class SignUpState( val isEnabled: Boolean = false, val subTitleState: Boolean = false, val gradeInfor: Int = 0, + val isInvited : Boolean = false, + val buttonCornerShape : Dp = 10.dp, //view val isListVisible: Boolean = false, val isFilled: Boolean = false, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt index 94a8c051..d5f2053c 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/state/SignUpUniversityState.kt @@ -1,6 +1,8 @@ package com.moneymong.moneymong.feature.sign.state import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp import com.moneymong.moneymong.common.base.State import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.model.sign.UniversitiesResponse @@ -12,6 +14,8 @@ data class SignUpUniversityState ( val textValue: TextFieldValue = TextFieldValue(), val isEnabled: Boolean = false, val gradeInfor: Int = 0, + val buttonCornerShape : Dp = 10.dp, + val editTextFocused : Boolean = false, //view val isListVisible: Boolean = false, val isFilled: Boolean = false, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt index 0d561f2c..78b9ae70 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/util/AgencyType.kt @@ -2,7 +2,7 @@ package com.moneymong.moneymong.feature.sign.util enum class AgencyType(val text: String) { GENERAL("GENERAL"), - CLUB("CLUB"), + CLUB("IN_SCHOOL_CLUB"), STUDENT_COUNCIL("STUDENT_COUNCIL"), NONE("NONE") } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt index 283502ef..002bcf47 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.moneymong.moneymong.design_system.component.textfield.MDSTextField import com.moneymong.moneymong.design_system.component.textfield.util.MDSTextFieldIcons @@ -49,7 +50,9 @@ fun SearchUnivView( universityResponse: UniversitiesResponse?, value: TextFieldValue, isButtonVisibleChanged: (Boolean) -> Unit, - selectedUniv : String + selectedUniv : String, + changeButtonCornerShape : (Dp) -> Unit, + changeEditTextFocus : (Boolean) -> Unit ) { val keyboardController = LocalSoftwareKeyboardController.current @@ -82,6 +85,10 @@ fun SearchUnivView( .onFocusChanged { focusState -> if (focusState.isFocused) { isButtonVisibleChanged(false) + changeButtonCornerShape(0.dp) + changeEditTextFocus(true) + }else{ + changeEditTextFocus(false) } }, value = value, @@ -111,6 +118,8 @@ fun SearchUnivView( onDone = { isFilledChanged(true) keyboardController?.hide() + changeButtonCornerShape(10.dp) + changeEditTextFocus(false) } ) ) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt index 919d17ae..65ae16c9 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt @@ -1,21 +1,15 @@ package com.moneymong.moneymong.feature.sign.view import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.moneymong.moneymong.common.ui.noRippleClickable import com.moneymong.moneymong.design_system.component.button.MDSButton import com.moneymong.moneymong.design_system.component.button.MDSButtonSize import com.moneymong.moneymong.design_system.component.button.MDSButtonType import com.moneymong.moneymong.design_system.error.ErrorDialog -import com.moneymong.moneymong.design_system.theme.Blue04 -import com.moneymong.moneymong.design_system.theme.Body3 import com.moneymong.moneymong.feature.sign.util.AgencyType @Composable @@ -29,7 +23,8 @@ fun SignUpButtonView( navigateToSignUpUniversity : (String, AgencyType?) -> Unit, agencyName: String, agencyType: AgencyType?, - pageType : Int + pageType : Int, + cornerShape : Dp = 10.dp ) { if (visiblePopUpError) { ErrorDialog( @@ -43,15 +38,16 @@ fun SignUpButtonView( modifier = modifier ) { MDSButton( - modifier = Modifier.fillMaxWidth() - .height(56.dp), + modifier = Modifier.fillMaxWidth(), +// .height(56.dp), onClick = { if(agencyType == AgencyType.GENERAL || pageType == 2) onCreateUniversity() else if (agencyType != AgencyType.GENERAL && pageType == 1) navigateToSignUpUniversity(agencyName, agencyType) }, text = if(agencyType == AgencyType.GENERAL || pageType == 2) "등록하기" else "다음으로", type = MDSButtonType.PRIMARY, size = MDSButtonSize.LARGE, - enabled = isEnabled + enabled = isEnabled, + cornerShape = cornerShape ) } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt index ce80745b..7160a958 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -19,7 +19,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -31,19 +30,13 @@ import com.moneymong.moneymong.design_system.theme.Black import com.moneymong.moneymong.design_system.theme.Body3 import com.moneymong.moneymong.design_system.theme.Gray06 import com.moneymong.moneymong.design_system.theme.Gray07 -import com.moneymong.moneymong.design_system.theme.Gray08 import com.moneymong.moneymong.design_system.theme.Heading2 import com.moneymong.moneymong.design_system.theme.MMHorizontalSpacing import com.moneymong.moneymong.design_system.theme.White -import com.moneymong.moneymong.feature.sign.SignUpContent -import com.moneymong.moneymong.feature.sign.sideeffect.SignUpSideEffect -import com.moneymong.moneymong.feature.sign.sideeffect.SignUpUniversitySideEffect import com.moneymong.moneymong.feature.sign.state.SignUpUniversityState import com.moneymong.moneymong.feature.sign.util.AgencyType import com.moneymong.moneymong.feature.sign.viewmodel.SignUpUniversityViewModel -import com.moneymong.moneymong.feature.sign.viewmodel.SignUpViewModel import org.orbitmvi.orbit.compose.collectAsState -import org.orbitmvi.orbit.compose.collectSideEffect @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable @@ -82,14 +75,14 @@ fun SignUpUniversity( Scaffold( modifier = Modifier .fillMaxSize() - .background(White) - .padding(horizontal = MMHorizontalSpacing), + .background(White), topBar = { Row( modifier = Modifier .fillMaxWidth() .height(44.dp) - .background(White), + .background(White) + .padding(horizontal = MMHorizontalSpacing), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start ) { @@ -107,7 +100,9 @@ fun SignUpUniversity( } }, content = { + paddingValues -> SignUpUniversityContent( + modifier = Modifier.padding(paddingValues), navigateToLedger = navigateToLedger, agencyName = agencyName, agencyType = agencyType, @@ -121,6 +116,7 @@ fun SignUpUniversity( @Composable fun SignUpUniversityContent ( + modifier : Modifier, navigateToLedger: () -> Unit, agencyName: String, agencyType: AgencyType, @@ -141,21 +137,26 @@ fun SignUpUniversityContent ( } } - Column( - modifier = Modifier.background(White) - ) { - Text( - modifier = Modifier.padding(top = 12.dp, bottom = 8.dp), - text = "어디 학교 교내 동아리인가요?", - style = Heading2, - color = Black - ) - Text( - modifier = Modifier.padding(bottom = 12.dp), - text = "소속 대학교를 알려주세요", - style = Body3, - color = Gray06 - ) + Box(modifier = Modifier.fillMaxSize()) { + + Column( + modifier = modifier + .background(White) + .padding(horizontal = MMHorizontalSpacing), + + ) { + Text( + modifier = Modifier.padding(top = 12.dp, bottom = 8.dp), + text = "어디 학교 교내 동아리인가요?", + style = Heading2, + color = Black + ) + Text( + modifier = Modifier.padding(bottom = 12.dp), + text = "소속 대학교를 알려주세요", + style = Body3, + color = Gray06 + ) SearchUnivView( modifier = Modifier @@ -193,17 +194,26 @@ fun SignUpUniversityContent ( isButtonVisible ) }, - selectedUniv = state.selectedUniv + selectedUniv = state.selectedUniv, + changeButtonCornerShape = { cornerShape -> + viewModel.changeButtonCornerShape( + cornerShape + ) + }, + changeEditTextFocus = { editTextFocused -> viewModel.changeEditTextFocus(editTextFocused) } ) + } + Column( modifier = Modifier .fillMaxWidth() - .align(Alignment.CenterHorizontally), + .align(Alignment.BottomCenter) , verticalArrangement = Arrangement.Bottom ) { SignUpButtonView( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth() + .padding(horizontal = if (state.editTextFocused) 0.dp else MMHorizontalSpacing), isEnabled = state.isItemSelected, visiblePopUpError = state.visiblePopUpError, popUpErrorMessage = state.popUpErrorMessage, @@ -213,10 +223,11 @@ fun SignUpUniversityContent ( onCreateUniversity = { viewModel.createUniv(state.selectedUniv, state.gradeInfor) }, - navigateToSignUpUniversity = { agencyName, agencyType -> }, + navigateToSignUpUniversity = { agencyName, agencyType -> }, agencyName = agencyName, agencyType = agencyType, - pageType = 2 + pageType = 2, + cornerShape = state.buttonCornerShape ) } } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt index b16f9d07..fe034780 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpUniversityViewModel.kt @@ -2,6 +2,7 @@ package com.moneymong.moneymong.feature.sign.viewmodel import android.view.View import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.Dp import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.moneymong.moneymong.common.base.BaseViewModel @@ -168,4 +169,20 @@ class SignUpUniversityViewModel @Inject constructor( ) } } + + fun changeButtonCornerShape(cornerShape : Dp) = intent{ + reduce{ + state.copy( + buttonCornerShape = cornerShape + ) + } + } + + fun changeEditTextFocus(isFocused : Boolean) = intent { + reduce { + state.copy( + editTextFocused = isFocused + ) + } + } } \ No newline at end of file From 6b219d1fd1eabd3ff70e5d349ae9a3a8394a9ee1 Mon Sep 17 00:00:00 2001 From: eunseo Date: Sun, 29 Dec 2024 00:17:08 +0900 Subject: [PATCH 3/7] =?UTF-8?q?moneymong-520=20Fix:=20=ED=9D=AC=EC=A7=81?= =?UTF-8?q?=EB=8B=98=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moneymong/feature/sign/item/UnivItem.kt | 2 +- .../feature/sign/viewmodel/SignUpViewModel.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt index 615b7ee3..2a59d3b6 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/item/UnivItem.kt @@ -37,7 +37,7 @@ fun UnivItem( .background(White) .fillMaxWidth() .noRippleClickable { - isItemSelectedChanged(!isItemSelected) + isItemSelectedChanged(true) onClick(univs.schoolName) isButtonVisibleChanged(true) } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt index 2b3a61f8..282e5e87 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt @@ -1,6 +1,7 @@ package com.moneymong.moneymong.feature.sign.viewmodel import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.Dp import androidx.lifecycle.viewModelScope import com.moneymong.moneymong.common.base.BaseViewModel import com.moneymong.moneymong.domain.usecase.agency.AgencyJoinUseCase @@ -119,4 +120,20 @@ class SignUpViewModel @Inject constructor( } } + fun changeInvitedType(invited : Boolean) = intent { + reduce { + state.copy( + isInvited = invited + ) + } + } + + fun changeButtonCornerShape (cornerShape: Dp) = intent { + reduce { + state.copy( + buttonCornerShape = cornerShape + ) + } + } + } \ No newline at end of file From 084136c501a32482ac64b61113ad7e6685ec59ce Mon Sep 17 00:00:00 2001 From: jhg3410 Date: Sun, 29 Dec 2024 13:56:38 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EB=A7=88=EC=9D=B4=EB=AA=BD=20=ED=95=99?= =?UTF-8?q?=EB=85=84=20=EC=A0=95=EB=B3=B4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/mymong/main/MyMongScreen.kt | 1 - .../feature/mymong/main/MyMongState.kt | 1 - .../feature/mymong/main/MyMongViewModel.kt | 1 - .../mymong/main/view/MyMongInfoView.kt | 16 ++------ .../moneymong/feature/sign/SignUpScreen.kt | 40 ++++++++----------- .../feature/sign/view/SignUpButtonView.kt | 13 +++--- .../feature/sign/view/SignUpUniversity.kt | 38 +++++++++--------- .../feature/sign/viewmodel/SignUpViewModel.kt | 23 ++++------- 8 files changed, 57 insertions(+), 76 deletions(-) diff --git a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongScreen.kt b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongScreen.kt index 74d1a373..7eecaeb5 100644 --- a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongScreen.kt +++ b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongScreen.kt @@ -101,7 +101,6 @@ fun MyMongScreen( name = state.name, email = state.email, university = state.university, - grade = state.grade, getInfo = viewModel::getInfo ) Spacer(modifier = Modifier.height(16.dp)) diff --git a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongState.kt b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongState.kt index 8973dcb4..5c0e37e1 100644 --- a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongState.kt +++ b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongState.kt @@ -6,7 +6,6 @@ data class MyMongState( val name: String = "", val email: String = "", val university: String = "", - val grade: Int = 0, val infoErrorMessage: String = "", val logoutErrorMessage: String = "", val isInfoLoading: Boolean = true, diff --git a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongViewModel.kt b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongViewModel.kt index a93db28e..28ba3dbc 100644 --- a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongViewModel.kt +++ b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/MyMongViewModel.kt @@ -53,7 +53,6 @@ class MyMongViewModel @Inject constructor( name = it.name, email = it.email, university = it.university.orEmpty(), - grade = it.grade ) } }.onFailure { diff --git a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/view/MyMongInfoView.kt b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/view/MyMongInfoView.kt index e0e4e7c2..01721d10 100644 --- a/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/view/MyMongInfoView.kt +++ b/feature/mymong/src/main/java/com/moneymong/moneymong/feature/mymong/main/view/MyMongInfoView.kt @@ -43,7 +43,6 @@ internal fun MyMongInfoView( name: String, email: String, university: String, - grade: Int, getInfo: () -> Unit ) { Box( @@ -66,10 +65,7 @@ internal fun MyMongInfoView( email = email ) Spacer(modifier = Modifier.height(20.dp)) - UniversityInfo( - university = university, - grade = grade - ) + UniversityInfo(university = university) } } } @@ -123,14 +119,10 @@ private fun Profile( @Composable fun UniversityInfo( - university: String, - grade: Int + university: String ) { - val universityInfoText = when { - university.isEmpty() -> "정보 없음" - grade == 5 -> "$university ${grade}학년 이상" - else -> "$university ${grade}학년" - } + + val universityInfoText = university.ifEmpty { "정보 없음" } Box( modifier = Modifier diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt index c90673b3..9035a178 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt @@ -30,7 +30,6 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.moneymong.moneymong.common.ui.noRippleClickable @@ -59,8 +58,8 @@ import org.orbitmvi.orbit.compose.collectSideEffect @Composable fun SignUpScreen( navigateToLedger: () -> Unit, - navigateToSignUpUniversity : (String, AgencyType?) -> Unit, - navigateToAgency : () -> Unit, + navigateToSignUpUniversity: (String, AgencyType?) -> Unit, + navigateToAgency: () -> Unit, navigateUp: () -> Unit, viewModel: SignUpViewModel = hiltViewModel() ) { @@ -70,7 +69,7 @@ fun SignUpScreen( navigateUp() } - if(state.visibleError){ + if (state.visibleError) { ErrorScreen( modifier = Modifier.fillMaxSize(), message = state.errorMessage, @@ -78,16 +77,14 @@ fun SignUpScreen( viewModel.visibleErrorChanged(false) } ) - } - else if(state.visiblePopUpError){ + } else if (state.visiblePopUpError) { ErrorDialog( message = state.popUpErrorMessage, onConfirm = { viewModel.visiblePopUpErrorChanged(false) } ) - } - else{ + } else { Scaffold( modifier = Modifier .fillMaxSize() @@ -115,8 +112,7 @@ fun SignUpScreen( ) } }, - content = { - paddingValues -> + content = { paddingValues -> SignUpContent( modifier = Modifier.padding(paddingValues), navigateToLedger = navigateToLedger, @@ -135,8 +131,8 @@ fun SignUpScreen( fun SignUpContent( modifier: Modifier, navigateToLedger: () -> Unit, - navigateToSignUpUniversity : (String, AgencyType?) -> Unit, - navigateToAgency : () -> Unit, + navigateToSignUpUniversity: (String, AgencyType?) -> Unit, + navigateToAgency: () -> Unit, viewModel: SignUpViewModel, state: SignUpState ) { @@ -145,9 +141,9 @@ fun SignUpContent( LaunchedEffect(key1 = state.isUnivCreated) { if (state.isUnivCreated) { - if(state.isInvited){ + if (state.isInvited) { navigateToAgency() - }else { + } else { viewModel.registerAgency() } } @@ -168,7 +164,6 @@ fun SignUpContent( is SignUpSideEffect.CreateUniversityApi -> { viewModel.createUniv(it.universityName, it.grade) } - else -> {} } } @@ -186,8 +181,7 @@ fun SignUpContent( SignUpTitleView( modifier = Modifier .fillMaxWidth() - .height(89.dp) - .padding(top = 12.dp, bottom = 12.dp), + .padding(vertical = 12.dp), ) Column( @@ -233,8 +227,8 @@ fun SignUpContent( AnimatedVisibility(visible = state.MDSSelected) { Column( modifier = Modifier - .padding(top = 28.dp), - ) { + .padding(top = 28.dp), + ) { Text( text = "소속 이름", style = Body2, @@ -262,9 +256,9 @@ fun SignUpContent( onIconClick = { viewModel.updateAgencyName(TextFieldValue()) }, keyboardActions = KeyboardActions( onDone = { - focusManager.clearFocus() - viewModel.changeButtonCornerShape(10.dp) - } + focusManager.clearFocus() + viewModel.changeButtonCornerShape(10.dp) + } ), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) ) @@ -304,7 +298,7 @@ fun SignUpContent( cornerShape = state.buttonCornerShape ) - if (!state.editTextFocused){ + if (!state.editTextFocused) { Spacer(modifier = Modifier.height(60.dp)) } diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt index 65ae16c9..b53eba20 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpButtonView.kt @@ -20,11 +20,11 @@ fun SignUpButtonView( popUpErrorMessage: String, visiblePopUpErrorChanged: (Boolean) -> Unit, onCreateUniversity: () -> Unit, - navigateToSignUpUniversity : (String, AgencyType?) -> Unit, + navigateToSignUpUniversity: (String, AgencyType?) -> Unit, agencyName: String, agencyType: AgencyType?, - pageType : Int, - cornerShape : Dp = 10.dp + pageType: Int, + cornerShape: Dp = 10.dp ) { if (visiblePopUpError) { ErrorDialog( @@ -41,9 +41,12 @@ fun SignUpButtonView( modifier = Modifier.fillMaxWidth(), // .height(56.dp), onClick = { - if(agencyType == AgencyType.GENERAL || pageType == 2) onCreateUniversity() else if (agencyType != AgencyType.GENERAL && pageType == 1) navigateToSignUpUniversity(agencyName, agencyType) + if (agencyType == AgencyType.GENERAL || pageType == 2) onCreateUniversity() else if (agencyType != AgencyType.GENERAL && pageType == 1) navigateToSignUpUniversity( + agencyName, + agencyType + ) }, - text = if(agencyType == AgencyType.GENERAL || pageType == 2) "등록하기" else "다음으로", + text = if (agencyType == AgencyType.GENERAL || pageType == 2) "등록하기" else "다음으로", type = MDSButtonType.PRIMARY, size = MDSButtonSize.LARGE, enabled = isEnabled, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt index 7160a958..91f0829c 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -41,20 +41,20 @@ import org.orbitmvi.orbit.compose.collectAsState @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable fun SignUpUniversity( - navigateToLedger : () -> Unit, - navigateToAgency : () -> Unit, - navigateUp : () -> Unit, - agencyName : String, + navigateToLedger: () -> Unit, + navigateToAgency: () -> Unit, + navigateUp: () -> Unit, + agencyName: String, agencyType: AgencyType, viewModel: SignUpUniversityViewModel = hiltViewModel() -){ +) { val state = viewModel.collectAsState().value BackHandler { navigateUp() } - if(state.visibleError){ + if (state.visibleError) { ErrorScreen( modifier = Modifier.fillMaxSize(), message = state.errorMessage, @@ -62,16 +62,14 @@ fun SignUpUniversity( viewModel.visibleErrorChanged(false) } ) - } - else if(state.visiblePopUpError){ + } else if (state.visiblePopUpError) { ErrorDialog( message = state.popUpErrorMessage, onConfirm = { viewModel.visiblePopUpErrorChanged(false) } ) - } - else { + } else { Scaffold( modifier = Modifier .fillMaxSize() @@ -99,8 +97,7 @@ fun SignUpUniversity( ) } }, - content = { - paddingValues -> + content = { paddingValues -> SignUpUniversityContent( modifier = Modifier.padding(paddingValues), navigateToLedger = navigateToLedger, @@ -115,8 +112,8 @@ fun SignUpUniversity( } @Composable -fun SignUpUniversityContent ( - modifier : Modifier, +fun SignUpUniversityContent( + modifier: Modifier, navigateToLedger: () -> Unit, agencyName: String, agencyType: AgencyType, @@ -160,7 +157,7 @@ fun SignUpUniversityContent ( SearchUnivView( modifier = Modifier - .padding(top = 28.dp, bottom = 28.dp,) + .padding(top = 28.dp, bottom = 28.dp) .fillMaxWidth() .height(0.dp) .weight(1.0F), @@ -200,7 +197,11 @@ fun SignUpUniversityContent ( cornerShape ) }, - changeEditTextFocus = { editTextFocused -> viewModel.changeEditTextFocus(editTextFocused) } + changeEditTextFocus = { editTextFocused -> + viewModel.changeEditTextFocus( + editTextFocused + ) + } ) } @@ -208,11 +209,12 @@ fun SignUpUniversityContent ( Column( modifier = Modifier .fillMaxWidth() - .align(Alignment.BottomCenter) , + .align(Alignment.BottomCenter), verticalArrangement = Arrangement.Bottom ) { SignUpButtonView( - modifier = Modifier.fillMaxWidth() + modifier = Modifier + .fillMaxWidth() .padding(horizontal = if (state.editTextFocused) 0.dp else MMHorizontalSpacing), isEnabled = state.isItemSelected, visiblePopUpError = state.visiblePopUpError, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt index 282e5e87..8d5c463d 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/viewmodel/SignUpViewModel.kt @@ -4,23 +4,16 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.Dp import androidx.lifecycle.viewModelScope import com.moneymong.moneymong.common.base.BaseViewModel -import com.moneymong.moneymong.domain.usecase.agency.AgencyJoinUseCase import com.moneymong.moneymong.domain.usecase.agency.RegisterAgencyUseCase import com.moneymong.moneymong.domain.usecase.signup.SchoolInfoUseCase import com.moneymong.moneymong.domain.usecase.university.CreateUniversityUseCase -import com.moneymong.moneymong.domain.usecase.university.SearchUniversityUseCase import com.moneymong.moneymong.feature.sign.sideeffect.SignUpSideEffect import com.moneymong.moneymong.feature.sign.state.SignUpState import com.moneymong.moneymong.feature.sign.util.AgencyType -import com.moneymong.moneymong.feature.sign.util.Grade import com.moneymong.moneymong.model.agency.AgencyRegisterRequest import com.moneymong.moneymong.model.sign.UnivRequest import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.orbitmvi.orbit.annotation.OrbitExperimental -import org.orbitmvi.orbit.syntax.simple.blockingIntent import org.orbitmvi.orbit.syntax.simple.intent import org.orbitmvi.orbit.syntax.simple.reduce import javax.inject.Inject @@ -52,7 +45,7 @@ class SignUpViewModel @Inject constructor( } } - fun registerAgency() = intent{ + fun registerAgency() = intent { registerAgencyUseCase(AgencyRegisterRequest(state.agencyName.text, AgencyType.GENERAL.text)) .onSuccess { reduce { @@ -72,7 +65,7 @@ class SignUpViewModel @Inject constructor( } - private fun storeSchoolInfoProvided(infoExist : Boolean ){ + private fun storeSchoolInfoProvided(infoExist: Boolean) { viewModelScope.launch { schoolInfoUseCase.invoke(infoExist) } @@ -94,8 +87,8 @@ class SignUpViewModel @Inject constructor( } } - fun onChangeAgencyType(agencyType: AgencyType) = intent{ - reduce{ + fun onChangeAgencyType(agencyType: AgencyType) = intent { + reduce { state.copy( agencyType = agencyType, MDSSelected = true, @@ -103,7 +96,7 @@ class SignUpViewModel @Inject constructor( } } - fun updateAgencyName(agencyName: TextFieldValue)= intent{ + fun updateAgencyName(agencyName: TextFieldValue) = intent { reduce { state.copy( agencyName = agencyName, @@ -112,7 +105,7 @@ class SignUpViewModel @Inject constructor( } } - fun updateEdittextFocused(focusState : Boolean) = intent { + fun updateEdittextFocused(focusState: Boolean) = intent { reduce { state.copy( editTextFocused = focusState @@ -120,7 +113,7 @@ class SignUpViewModel @Inject constructor( } } - fun changeInvitedType(invited : Boolean) = intent { + fun changeInvitedType(invited: Boolean) = intent { reduce { state.copy( isInvited = invited @@ -128,7 +121,7 @@ class SignUpViewModel @Inject constructor( } } - fun changeButtonCornerShape (cornerShape: Dp) = intent { + fun changeButtonCornerShape(cornerShape: Dp) = intent { reduce { state.copy( buttonCornerShape = cornerShape From d8bfa5630b5f085751d64e67be79a808345e0dc5 Mon Sep 17 00:00:00 2001 From: jhg3410 Date: Sun, 29 Dec 2024 14:17:24 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EB=8C=80=ED=95=99=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20"=EC=B4=9D=EB=AC=B4=EC=97=90=EA=B2=8C=20?= =?UTF-8?q?=EC=B4=88=EB=8C=80=20=EB=B0=9B=EC=95=98=EC=96=B4=EC=9A=94"=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/sign/view/SignUpUniversity.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt index 91f0829c..d7eb9f7d 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box 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 @@ -20,6 +21,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.moneymong.moneymong.common.ui.noRippleClickable @@ -27,6 +29,7 @@ import com.moneymong.moneymong.design_system.R import com.moneymong.moneymong.design_system.error.ErrorDialog import com.moneymong.moneymong.design_system.error.ErrorScreen import com.moneymong.moneymong.design_system.theme.Black +import com.moneymong.moneymong.design_system.theme.Blue04 import com.moneymong.moneymong.design_system.theme.Body3 import com.moneymong.moneymong.design_system.theme.Gray06 import com.moneymong.moneymong.design_system.theme.Gray07 @@ -231,6 +234,21 @@ fun SignUpUniversityContent( pageType = 2, cornerShape = state.buttonCornerShape ) + if (!state.editTextFocused) { + Spacer(modifier = Modifier.height(16.dp)) + Text( + modifier = Modifier + .fillMaxWidth() + .noRippleClickable { + viewModel.createUniv(state.selectedUniv, state.gradeInfor) + }, + textAlign = TextAlign.Center, + text = "총무에게 초대받았어요", + style = Body3, + color = Blue04 + ) + Spacer(modifier = Modifier.height(24.dp)) + } } } -} +} \ No newline at end of file From 0c3dac02704fd641b586b5a430e10bbd414a6300 Mon Sep 17 00:00:00 2001 From: jhg3410 Date: Sun, 29 Dec 2024 14:27:26 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[=EB=8C=80=ED=95=99=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4]=20=EB=93=B1=EB=A1=9D=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20editText=20=ED=8F=AC=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EB=B3=80=ED=99=94=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/sign/view/SearchUnivView.kt | 26 ++++++++----------- .../feature/sign/view/SignUpUniversity.kt | 3 +-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt index 002bcf47..084f9bff 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SearchUnivView.kt @@ -13,10 +13,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusChanged -import androidx.compose.ui.platform.LocalSoftwareKeyboardController +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.Dp @@ -26,14 +25,14 @@ import com.moneymong.moneymong.design_system.component.textfield.util.MDSTextFie import com.moneymong.moneymong.design_system.theme.Body4 import com.moneymong.moneymong.design_system.theme.Gray05 import com.moneymong.moneymong.design_system.theme.White -import com.moneymong.moneymong.model.sign.University import com.moneymong.moneymong.feature.sign.item.UnivItem import com.moneymong.moneymong.model.sign.UniversitiesResponse +import com.moneymong.moneymong.model.sign.University import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.debounce -@OptIn(ExperimentalComposeUiApi::class, FlowPreview::class) +@OptIn(FlowPreview::class) @Composable fun SearchUnivView( modifier: Modifier = Modifier, @@ -50,12 +49,12 @@ fun SearchUnivView( universityResponse: UniversitiesResponse?, value: TextFieldValue, isButtonVisibleChanged: (Boolean) -> Unit, - selectedUniv : String, - changeButtonCornerShape : (Dp) -> Unit, - changeEditTextFocus : (Boolean) -> Unit + selectedUniv: String, + changeButtonCornerShape: (Dp) -> Unit, + changeEditTextFocus: (Boolean) -> Unit ) { - val keyboardController = LocalSoftwareKeyboardController.current + val focusManager = LocalFocusManager.current val debouncePeriod = 300L val queryState = remember { MutableStateFlow("") } @@ -65,10 +64,9 @@ fun SearchUnivView( .debounce(debouncePeriod) .collect { query -> Log.d("query", query) - if(query.isEmpty() && value.text.isNotEmpty()){ + if (query.isEmpty() && value.text.isNotEmpty()) { onSearchIconClicked(value.text) - } - else{ + } else { onSearchIconClicked(query) } isFilledChanged(false) @@ -83,12 +81,10 @@ fun SearchUnivView( modifier = Modifier .fillMaxWidth() .onFocusChanged { focusState -> + changeEditTextFocus(focusState.isFocused) if (focusState.isFocused) { isButtonVisibleChanged(false) changeButtonCornerShape(0.dp) - changeEditTextFocus(true) - }else{ - changeEditTextFocus(false) } }, value = value, @@ -117,8 +113,8 @@ fun SearchUnivView( keyboardActions = KeyboardActions( onDone = { isFilledChanged(true) - keyboardController?.hide() changeButtonCornerShape(10.dp) + focusManager.clearFocus() changeEditTextFocus(false) } ) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt index d7eb9f7d..3e779de5 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -143,8 +143,7 @@ fun SignUpUniversityContent( modifier = modifier .background(White) .padding(horizontal = MMHorizontalSpacing), - - ) { + ) { Text( modifier = Modifier.padding(top = 12.dp, bottom = 8.dp), text = "어디 학교 교내 동아리인가요?", From b66242914e139048f2ef78cdb041d1037177769f Mon Sep 17 00:00:00 2001 From: jhg3410 Date: Sun, 29 Dec 2024 14:37:36 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4]=20=EC=A4=91=EB=B3=B5=EB=90=9C=20padding=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moneymong/moneymong/feature/sign/SignUpScreen.kt | 5 +---- .../moneymong/feature/sign/view/SignUpUniversity.kt | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt index 9035a178..c6b97c11 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/SignUpScreen.kt @@ -225,10 +225,7 @@ fun SignUpContent( } } AnimatedVisibility(visible = state.MDSSelected) { - Column( - modifier = Modifier - .padding(top = 28.dp), - ) { + Column { Text( text = "소속 이름", style = Body2, diff --git a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt index 3e779de5..3e6ea7c9 100644 --- a/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt +++ b/feature/sign/src/main/java/com/moneymong/moneymong/feature/sign/view/SignUpUniversity.kt @@ -159,9 +159,8 @@ fun SignUpUniversityContent( SearchUnivView( modifier = Modifier - .padding(top = 28.dp, bottom = 28.dp) .fillMaxWidth() - .height(0.dp) + .padding(top = 28.dp, bottom = 28.dp) .weight(1.0F), isFilled = state.isFilled, isFilledChanged = { isFilled -> viewModel.isFilledChanged(isFilled) },