Skip to content

Commit

Permalink
chore/#6: 함수 아래로 보내기
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeeum committed Apr 18, 2024
1 parent 7ed99ae commit 1fbcccd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 38 deletions.
41 changes: 20 additions & 21 deletions app/src/main/java/com/sopt/now/compose/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,6 @@ class LoginActivity : ComponentActivity() {
}
}

fun isLoginAvailable(
context: Context,
userId: String?,
userPw: String?,
userNick: String?,
id: String?,
pw: String?
) {
val message = when {
userId != id || userPw != pw -> R.string.login_error
else -> {
val intent = Intent(context, MainActivity::class.java)
intent.putExtra("userId", userId).putExtra("userPw", userPw)
.putExtra("userNick", userNick)
context.startActivity(intent)
R.string.login_success
}
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}

@Composable
fun LoginUI(userId: String?, userPw: String?, userNick: String?) {
val context = LocalContext.current
Expand Down Expand Up @@ -143,6 +122,26 @@ fun LoginUI(userId: String?, userPw: String?, userNick: String?) {
}
}

fun isLoginAvailable(
context: Context,
userId: String?,
userPw: String?,
userNick: String?,
id: String?,
pw: String?
) {
val message = when {
userId != id || userPw != pw -> R.string.login_error
else -> {
val intent = Intent(context, MainActivity::class.java)
intent.putExtra("userId", userId).putExtra("userPw", userPw)
.putExtra("userNick", userNick)
context.startActivity(intent)
R.string.login_success
}
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview2() {
Expand Down
33 changes: 16 additions & 17 deletions app/src/main/java/com/sopt/now/compose/SignUpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ class SignUpActivity : ComponentActivity() {
}
}

fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) {
val message = when {
id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error
id.length !in 6..10 -> R.string.sign_up_id_error
pw.length !in 8..12 -> R.string.sign_up_pw_error
nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error
etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error
else -> {
val intent = Intent(context, LoginActivity::class.java)
intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick)
context.startActivity(intent)
R.string.sign_up_success
}
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}

@Composable
fun SignUpUI() {
val context = LocalContext.current
Expand Down Expand Up @@ -142,6 +125,22 @@ fun SignUpUI() {
}
}
}
fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) {
val message = when {
id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error
id.length !in 6..10 -> R.string.sign_up_id_error
pw.length !in 8..12 -> R.string.sign_up_pw_error
nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error
etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error
else -> {
val intent = Intent(context, LoginActivity::class.java)
intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick)
context.startActivity(intent)
R.string.sign_up_success
}
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}

@Preview(showBackground = true)
@Composable
Expand Down

0 comments on commit 1fbcccd

Please sign in to comment.