-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] 사장님 로그인 기능 구현 #378
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
87f114e
사장님 로그인 기능 구현
hsgo2430 249ba41
1차 피드백 적용
hsgo2430 9368eb5
1차 피드백 적용
hsgo2430 f77262e
2차 코멘트 수정
hsgo2430 a0f773b
Merge branch 'develop' of https://github.com/BCSDLab/KOIN_ANDROID int…
hsgo2430 2c8675b
로그인 방식 수정 및 UI 변경
hsgo2430 03cb2f4
로그인 1차 코멘트 수정
hsgo2430 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...src/main/java/in/koreatech/business/feature/findpassword/navigator/ChangePasswordRoute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
.../business/feature/findpassword/passwordauthentication/PasswordAuthenticationSideEffect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
317 changes: 317 additions & 0 deletions
317
business/src/main/java/in/koreatech/business/feature/signin/SignInScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,317 @@ | ||
package `in`.koreatech.business.feature.signin | ||
|
||
import android.content.res.Configuration.UI_MODE_NIGHT_YES | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.clickable | ||
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.foundation.layout.width | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material.Divider | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.RectangleShape | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.input.PasswordVisualTransformation | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import `in`.koreatech.koin.core.R | ||
import `in`.koreatech.business.ui.theme.Blue1 | ||
import `in`.koreatech.business.ui.theme.ColorAccent | ||
import `in`.koreatech.business.ui.theme.ColorPrimary | ||
import `in`.koreatech.business.ui.theme.ColorSecondaryText | ||
import `in`.koreatech.koin.core.toast.ToastUtil | ||
import org.orbitmvi.orbit.compose.collectAsState | ||
import org.orbitmvi.orbit.compose.collectSideEffect | ||
|
||
|
||
@Composable | ||
fun SignInScreen( | ||
modifier: Modifier = Modifier, | ||
navigateToSignUp: () -> Unit, | ||
navigateToFindPassword: () -> Unit, | ||
navigateToMain: () -> Unit, | ||
viewModel: SignInViewModel = hiltViewModel() | ||
) { | ||
val state = viewModel.collectAsState().value | ||
|
||
SignInScreenImpl( | ||
modifier = modifier, | ||
id = state.id, | ||
password = state.password, | ||
nullErrorMessage = state.nullErrorMessage, | ||
notValidateField = state.notValidateField, | ||
onIdChange = { | ||
id -> viewModel.insertId(id) | ||
}, | ||
onPasswordChange = { | ||
password -> viewModel.insertPassword(password) | ||
}, | ||
onSignInClick = { | ||
viewModel.login() | ||
}, | ||
onSignUpClick = {viewModel.navigateToSignUp()}, | ||
onFindPasswordClick = {viewModel.navigateToFindPassword()} | ||
) | ||
|
||
HandleSideEffects(viewModel, navigateToSignUp, navigateToFindPassword, navigateToMain) | ||
} | ||
@Composable | ||
fun SignInScreenImpl( | ||
modifier: Modifier = Modifier, | ||
id: String = "", | ||
password: String = "", | ||
nullErrorMessage: String = "", | ||
notValidateField: Boolean = false, | ||
onIdChange: (String) -> Unit = {}, | ||
onPasswordChange: (String) -> Unit = {}, | ||
onSignInClick: () -> Unit = {}, | ||
onSignUpClick: () -> Unit = {}, | ||
onFindPasswordClick: () -> Unit = {} | ||
){ | ||
Column(modifier = modifier.fillMaxSize()) { | ||
|
||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp, vertical = 95.dp), | ||
horizontalArrangement = Arrangement.Center, | ||
verticalAlignment = Alignment.CenterVertically | ||
){ | ||
Image( | ||
painter = painterResource(id = R.drawable.koin_owner_logo), | ||
contentDescription = "Koin Owner Logo", | ||
modifier = Modifier | ||
.size(150.dp), | ||
alignment = Alignment.CenterStart | ||
) | ||
} | ||
|
||
|
||
BasicTextField( | ||
value = id, | ||
onValueChange = onIdChange, | ||
maxLines = 1, | ||
textStyle = TextStyle(fontSize = 15.sp), | ||
decorationBox = { innerTextField -> | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
Box( | ||
contentAlignment = Alignment.CenterStart, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
if (id.isEmpty()) { | ||
Text( | ||
stringResource(R.string.phone_number), | ||
color = Blue1, | ||
fontSize = 15.sp | ||
) | ||
} | ||
innerTextField() | ||
} | ||
Divider( | ||
color = if (notValidateField) ColorAccent else Blue1, | ||
thickness = 1.dp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 4.dp) | ||
) | ||
} | ||
}, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp) | ||
.padding(bottom = 28.dp) | ||
) | ||
|
||
BasicTextField( | ||
value = password, | ||
onValueChange = onPasswordChange, | ||
maxLines = 1, | ||
visualTransformation = PasswordVisualTransformation(), | ||
textStyle = TextStyle(fontSize = 15.sp), | ||
decorationBox = { innerTextField -> | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
Box( | ||
contentAlignment = Alignment.CenterStart, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
if (password.isEmpty()) { | ||
Text( | ||
stringResource(R.string.password), | ||
color = Blue1, | ||
fontSize = 15.sp | ||
) | ||
} | ||
innerTextField() | ||
} | ||
|
||
Divider( | ||
color = if (notValidateField) ColorAccent else Blue1, | ||
thickness = 1.dp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 4.dp) | ||
) | ||
} | ||
}, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp) | ||
) | ||
|
||
Text( | ||
modifier = Modifier | ||
.padding(horizontal = 32.dp) | ||
.padding(top = 4.dp) | ||
, | ||
fontSize = 11.sp, | ||
text = if(notValidateField) nullErrorMessage else "", | ||
color = ColorAccent | ||
) | ||
|
||
Button( | ||
onClick = onSignInClick, | ||
shape = RectangleShape, | ||
colors = ButtonDefaults.buttonColors(ColorAccent), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp) | ||
.padding(top = 40.dp) | ||
.padding(bottom = 16.dp) | ||
.height(44.dp) | ||
|
||
) { | ||
Text( | ||
stringResource(R.string.navigation_item_login), | ||
color = Color.White, | ||
fontSize = 15.sp, | ||
fontWeight = FontWeight.Bold | ||
) | ||
} | ||
|
||
Button( | ||
onClick = onSignUpClick, | ||
shape = RectangleShape, | ||
colors = ButtonDefaults.buttonColors(ColorPrimary), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp) | ||
.padding(top = 16.dp, bottom = 24.dp) | ||
.height(44.dp) | ||
|
||
) { | ||
Text( | ||
stringResource(R.string.sign_up), | ||
color = Color.White, | ||
fontSize = 15.sp, | ||
fontWeight = FontWeight.Bold | ||
) | ||
} | ||
|
||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(35.dp) | ||
.padding(horizontal = 127.dp) | ||
.clickable { | ||
onFindPasswordClick() | ||
}, | ||
horizontalArrangement = Arrangement.Center, | ||
verticalAlignment = Alignment.CenterVertically | ||
){ | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_password), | ||
contentDescription = "password_icon", | ||
modifier = Modifier | ||
.height(20.dp) | ||
.width(20.dp) | ||
.padding(end = 4.dp) | ||
) | ||
|
||
Text( | ||
stringResource(R.string.password_find), | ||
color = ColorSecondaryText, | ||
fontSize = 13.sp, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun HandleSideEffects( | ||
viewModel: SignInViewModel, | ||
navigateToSignUp: () -> Unit, | ||
navigateToFindPassword: () -> Unit, | ||
navigateToMain: () -> Unit) | ||
{ | ||
val context = LocalContext.current | ||
viewModel.collectSideEffect { sideEffect -> | ||
when (sideEffect) { | ||
is SignInSideEffect.NavigateToMain -> navigateToMain() | ||
is SignInSideEffect.NavigateToFindPassword -> navigateToFindPassword() | ||
is SignInSideEffect.NavigateToSignUp -> navigateToSignUp() | ||
is SignInSideEffect.ShowMessage -> { | ||
viewModel.setErrorMessage(sideEffect.message) | ||
} | ||
is SignInSideEffect.ShowNullMessage -> { | ||
val message = when (sideEffect.type) { | ||
ErrorType.NullPhoneNumber -> context.getString(R.string.phone_number_is_null) | ||
ErrorType.NullPassword -> context.getString(R.string.password_is_null) | ||
} | ||
viewModel.setErrorMessage(message) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreViewSignInScreen( | ||
modifier: Modifier = Modifier, | ||
id: String = "", | ||
password: String = "", | ||
onIdChange: (String) -> Unit = {}, | ||
onPasswordChange: (String) -> Unit = {}, | ||
onSignInClick: () -> Unit = {}, | ||
onSignUpClick: () -> Unit = {}, | ||
onFindPasswordClick: () -> Unit = {} | ||
){ | ||
SignInScreenImpl( | ||
modifier = modifier, | ||
id = id, | ||
password = password, | ||
onIdChange = onIdChange, | ||
onPasswordChange = onPasswordChange, | ||
onSignInClick = onSignInClick, | ||
onSignUpClick = onSignUpClick, | ||
onFindPasswordClick = onFindPasswordClick | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
business/src/main/java/in/koreatech/business/feature/signin/SignInSideEffect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package `in`.koreatech.business.feature.signin | ||
|
||
sealed class SignInSideEffect { | ||
|
||
object NavigateToSignUp: SignInSideEffect() | ||
|
||
object NavigateToFindPassword: SignInSideEffect() | ||
|
||
object NavigateToMain: SignInSideEffect() | ||
|
||
data class ShowNullMessage(val type: ErrorType): SignInSideEffect() | ||
|
||
data class ShowMessage(val message: String): SignInSideEffect() | ||
} | ||
|
||
enum class ErrorType { | ||
NullPhoneNumber, | ||
NullPassword | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 방법이 있었군요...!
한번 공부를 해봐야겠어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 방법이 있군요...
한번 공부를 해봐야겠네요!