Skip to content

Commit

Permalink
chore/#11 : 프로젝트 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
serioushyeon committed Dec 9, 2024
1 parent f8cf39a commit 32cfffa
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign
package org.sopt.and.presentation.auth.signin

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -33,8 +33,8 @@ import org.sopt.and.core.component.ServiceAccountItemRow
import org.sopt.and.core.component.textField.WavveCommonPasswordField
import org.sopt.and.core.component.textField.WavveCommonTextField
import org.sopt.and.core.component.topBar.BackButtonTopBar
import org.sopt.and.presentation.sign.component.WavveBasicButton
import org.sopt.and.presentation.sign.viewmodel.SignInViewModel
import org.sopt.and.presentation.auth.signin.component.WavveBasicButton
import org.sopt.and.presentation.auth.signin.viewmodel.SignInViewModel
import org.sopt.and.core.designsystem.theme.Gray3
import org.sopt.and.core.designsystem.theme.Gray4
import org.sopt.and.core.designsystem.theme.WavveBg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.state
package org.sopt.and.presentation.auth.signin

data class SignInState (
val username: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.component
package org.sopt.and.presentation.auth.signin.component

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.viewmodel
package org.sopt.and.presentation.auth.signin.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand All @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.sopt.and.presentation.sign.state.SignInState
import org.sopt.and.presentation.auth.signin.SignInState
import org.sopt.and.domain.model.entity.BaseResult
import org.sopt.and.domain.model.entity.UserData
import org.sopt.and.domain.model.entity.UserLoginResult
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign
package org.sopt.and.presentation.auth.signup

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -29,10 +29,10 @@ import androidx.hilt.navigation.compose.hiltViewModel
import kotlinx.coroutines.flow.collectLatest
import org.sopt.and.R
import org.sopt.and.core.component.ServiceAccountItemRow
import org.sopt.and.presentation.sign.component.HelperText
import org.sopt.and.presentation.sign.component.SignUpTextField
import org.sopt.and.presentation.sign.component.SignUpPasswordField
import org.sopt.and.presentation.sign.viewmodel.SignUpViewModel
import org.sopt.and.presentation.auth.signup.component.HelperText
import org.sopt.and.presentation.auth.signup.component.SignUpTextField
import org.sopt.and.presentation.auth.signup.component.SignUpPasswordField
import org.sopt.and.presentation.auth.signup.viewmodel.SignUpViewModel
import org.sopt.and.core.designsystem.theme.Gray3
import org.sopt.and.core.designsystem.theme.Gray4
import org.sopt.and.core.designsystem.theme.WavveBg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sopt.and.presentation.sign.state
package org.sopt.and.presentation.auth.signup

data class SignUpState (
data class SignUpState(
val username: String = "",
val password: String = "",
val hobby: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.component
package org.sopt.and.presentation.auth.signup.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.component
package org.sopt.and.presentation.auth.signup.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.component
package org.sopt.and.presentation.auth.signup.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.presentation.sign.viewmodel
package org.sopt.and.presentation.auth.signup.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand All @@ -14,7 +14,7 @@ import org.sopt.and.domain.model.entity.BaseResult
import org.sopt.and.domain.model.entity.UserData
import org.sopt.and.domain.model.entity.UserRegisterResult
import org.sopt.and.domain.usecase.RegisterUserUseCase
import org.sopt.and.presentation.sign.state.SignUpState
import org.sopt.and.presentation.auth.signup.SignUpState
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -89,31 +89,16 @@ class SignUpViewModel @Inject constructor(
_signUpState.update { currentState ->
currentState.copy(
isValid = _signUpState.value.isUserNameValid &&
_signUpState.value.isPasswordValid &&
_signUpState.value.isHobbyValid
_signUpState.value.isPasswordValid &&
_signUpState.value.isHobbyValid
)
}
}

/* 기존 wavve 제약사항
private fun validateEmail(email: String): Boolean {
return Patterns.EMAIL_ADDRESS.matcher(email).matches()
}
private fun validatePassword(password: String): Boolean {
val hasUpperCase = password.any { it.isUpperCase() }
val hasLowerCase = password.any { it.isLowerCase() }
val hasDigit = password.any { it.isDigit() }
val hasSpecialChar = password.any { !it.isLetterOrDigit() }
val lengthValid = password.length in 8..20
val complexityValid = listOf(hasUpperCase, hasLowerCase, hasDigit, hasSpecialChar).count { it } >= 3
return lengthValid && complexityValid
}
*/

//과제 기능 명세에 따른 제약사항, 공통 기능이지만 제약사항 변경 시를 대비해 각각 함수 분리
private fun validateUserName(email: String): Boolean {
return email.isNotBlank() && email.length <= 8
}

private fun validatePassword(password: String): Boolean {
return password.isNotBlank() && password.length <= 8
}
Expand All @@ -125,13 +110,14 @@ class SignUpViewModel @Inject constructor(
private suspend fun setSignUpSuccess(value: Boolean) {
_signUpSuccess.emit(value)
}

fun registerUser() {
viewModelScope.launch {
when (val result = registerUserUseCase(
UserData(
_signUpState.value.username,
_signUpState.value.password,
_signUpState.value.hobby
_signUpState.value.username,
_signUpState.value.password,
_signUpState.value.hobby
)
)
) {
Expand All @@ -140,6 +126,7 @@ class SignUpViewModel @Inject constructor(
_errorMessageState.value = null
setSignUpSuccess(true)
}

is BaseResult.Error -> {
_registerUserResultState.value = null
_errorMessageState.value = result.message
Expand All @@ -149,7 +136,9 @@ class SignUpViewModel @Inject constructor(
}
}

suspend fun resetSignUpSuccess() {
setSignUpSuccess(false)
fun resetSignUpSuccess() {
viewModelScope.launch {
setSignUpSuccess(false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.sopt.and.core.navigation.Screen
import org.sopt.and.presentation.home.HomeScreen
import org.sopt.and.presentation.mypage.MyScreen
import org.sopt.and.presentation.search.SearchScreen
import org.sopt.and.presentation.sign.SignInScreen
import org.sopt.and.presentation.sign.SignUpScreen
import org.sopt.and.presentation.auth.signin.SignInScreen
import org.sopt.and.presentation.auth.signup.SignUpScreen
import org.sopt.and.core.designsystem.theme.WavveBg

@Composable
Expand Down

0 comments on commit 32cfffa

Please sign in to comment.