Skip to content

Commit

Permalink
Merge pull request #263 from School-of-Company/refactor/262-refactor-…
Browse files Browse the repository at this point in the history
…email-module

🔀 :: (#262) - refactor email module
  • Loading branch information
audgns10 authored Aug 13, 2024
2 parents a058f4d + 60006ce commit 0c29c57
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 177 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.msg.design_system.util

fun String.checkEmailRegex(): Boolean {
val emailRegex = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\$"
return this.matches(emailRegex.toRegex())
}
fun String.checkEmailRegex(): Boolean = this.matches("^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\$".toRegex())

fun String.checkPasswordRegex(): Boolean {
val passwordRegex = "^(?=.*[0-9])(?=.*[A-Za-z])(?=.*[@#$%^&+=!?.])(?=\\S+$).{8,24}.$"
return this.matches(passwordRegex.toRegex())
}
fun String.checkPasswordRegex(): Boolean = this.matches("^(?=.*[0-9])(?=.*[^A-Za-z0-9]).{8,}$".toRegex())
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -21,6 +22,7 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bitgoeul.email.viewmodel.EmailViewModel
import com.msg.common.event.Event
import com.msg.design_system.R
Expand All @@ -36,6 +38,8 @@ internal fun EmailSendInformRoute(
onMoveNewPasswordClicked: () -> Unit,
viewModel: EmailViewModel = hiltViewModel(LocalContext.current as ComponentActivity)
) {
val emailText by viewModel.email.collectAsStateWithLifecycle()

val context = LocalContext.current
val activity = LocalContext.current as ComponentActivity
val coroutineScope = rememberCoroutineScope()
Expand Down Expand Up @@ -68,7 +72,7 @@ internal fun EmailSendInformRoute(

EmailSendInformScreen(
onBackClicked = onBackClicked,
emailText = viewModel.email.value
emailText = emailText
)
}

Expand Down Expand Up @@ -132,7 +136,6 @@ internal fun EmailSendInformScreen(
Spacer(modifier = modifier.weight(1f))

}

}
}
}
125 changes: 61 additions & 64 deletions feature/email/src/main/java/com/bitgoeul/email/InputEmailScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
Expand All @@ -23,6 +24,7 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bitgoeul.email.viewmodel.EmailViewModel
import com.msg.design_system.R
import com.msg.design_system.component.button.BitgoeulButton
Expand All @@ -38,13 +40,14 @@ internal fun InputEmailRoute(
onNextClicked: () -> Unit,
viewModel: EmailViewModel = hiltViewModel(LocalContext.current as ComponentActivity)
) {
val focusManager = LocalFocusManager.current
val isEmail by viewModel.email.collectAsStateWithLifecycle()

InputEmailScreen(
focusManager = focusManager,
email = isEmail,
onEmailChange = viewModel::onEmailChange,
onBackClicked = onBackClicked,
onNextClicked = { email ->
viewModel.email.value = email
viewModel.onEmailChange(email)
viewModel.sendLinkToEmail()
onNextClicked()
}
Expand All @@ -54,79 +57,73 @@ internal fun InputEmailRoute(
@Composable
internal fun InputEmailScreen(
modifier: Modifier = Modifier,
focusManager: FocusManager,
email: String,
onEmailChange: (String) -> Unit,
focusManager: FocusManager = LocalFocusManager.current,
onBackClicked: () -> Unit,
onNextClicked: (String) -> Unit,
) {
val email = remember { mutableStateOf("") }

CompositionLocalProvider(LocalFocusManager provides focusManager) {
BitgoeulAndroidTheme { color, typography ->
Surface {
Column(
modifier = modifier
.background(color = color.WHITE)
.padding(horizontal = 28.dp)
.fillMaxSize()
.pointerInput(Unit) {
detectTapGestures {
focusManager.clearFocus()
}
BitgoeulAndroidTheme { color, typography ->
Surface {
Column(
modifier = modifier
.background(color = color.WHITE)
.padding(horizontal = 28.dp)
.fillMaxSize()
.pointerInput(Unit) {
detectTapGestures {
focusManager.clearFocus()
}
) {
Spacer(modifier = modifier.height(20.dp))

GoBackTopBar(
icon = { GoBackIcon() },
text = stringResource(id = R.string.go_back)
) {
onBackClicked()
}
) {
Spacer(modifier = modifier.height(20.dp))

GoBackTopBar(
icon = { GoBackIcon() },
text = stringResource(id = R.string.go_back)
) {
onBackClicked()
}

Spacer(modifier = modifier.height(16.dp))
Spacer(modifier = modifier.height(16.dp))

Text(
text = stringResource(id = R.string.find_password),
style = typography.titleLarge,
color = color.BLACK
)
Text(
text = stringResource(id = R.string.find_password),
style = typography.titleLarge,
color = color.BLACK
)

Text(
text = stringResource(id = R.string.email_authentication_process),
style = typography.bodySmall,
color = color.G2
)
Text(
text = stringResource(id = R.string.email_authentication_process),
style = typography.bodySmall,
color = color.G2
)

Spacer(modifier = modifier.height(32.dp))
Spacer(modifier = modifier.height(32.dp))

DefaultTextField(
modifier = modifier.fillMaxWidth(),
onValueChange = { inputEmail ->
email.value = inputEmail
},
errorText = "",
isDisabled = false,
isError = false,
isLinked = false,
isReverseTrailingIcon = false,
onButtonClicked = {},
placeholder = stringResource(id = R.string.email)
)
DefaultTextField(
modifier = modifier.fillMaxWidth(),
onValueChange = onEmailChange,
errorText = "",
isDisabled = false,
isError = false,
isLinked = false,
isReverseTrailingIcon = false,
onButtonClicked = {},
placeholder = stringResource(id = R.string.email)
)

Spacer(modifier = modifier.weight(1f))
Spacer(modifier = modifier.weight(1f))

BitgoeulButton(
text = "다음으로",
modifier = Modifier
.padding(bottom = 14.dp)
.fillMaxWidth()
.height(52.dp),
state = if (email.value.isNotEmpty()) ButtonState.Enable else ButtonState.Disable,
onClicked = {
onNextClicked(email.value)
}
)
}
BitgoeulButton(
modifier = modifier
.padding(bottom = 14.dp)
.fillMaxWidth()
.height(52.dp),
text = "다음으로",
state = if (email.isNotEmpty()) ButtonState.Enable else ButtonState.Disable,
onClicked = { onNextClicked(email) }
)
}
}
}
Expand Down
Loading

0 comments on commit 0c29c57

Please sign in to comment.