Skip to content

Commit

Permalink
♻️ :: ID 강제 로직 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
JunJaBoy committed Oct 4, 2023
1 parent dd905b6 commit ebba8f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Scaffold
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -44,18 +49,23 @@ fun SignInScreen(navController: NavController) {
is SignInViewModel.Event.Success -> {
navController.navigate(AppNavigationItem.Main.route) { popUpTo(0) }
}

is SignInViewModel.Event.BadRequest -> {
makeToast(context, "잘못된 요청입니다")
}

is SignInViewModel.Event.NotFound -> {
makeToast(context, "아이디와 비밀번호를 확인해주세요")
}

is SignInViewModel.Event.Timeout -> {
makeToast(context, "요청 시간이 초과되었습니다")
}

is SignInViewModel.Event.TooManyRequest -> {
makeToast(context, "현재 요청이 너무 많습니다")
}

is SignInViewModel.Event.FetchIdSuccess -> {
userId = it.data
}
Expand All @@ -67,7 +77,10 @@ fun SignInScreen(navController: NavController) {
onSignInClick = { signInViewModel.signIn(it) },
onFindAccountClick = {
//makeToast(context, "Xquare 페이스북 페이지로 문의 해주세요.")
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/profile.php?id=100091948951498"))
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://www.facebook.com/profile.php?id=100091948951498")
)
context.startActivity(intent)
//TODO("아이디/비밀번호 찾기로 이동")
},
Expand All @@ -85,7 +98,7 @@ private fun SignIn(
val context = LocalContext.current
var accountId by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
if (userId.isNotBlank()) accountId = userId

val isSignInEnabled = accountId.isNotEmpty() && password.isNotEmpty()
Scaffold(
modifier = Modifier
Expand All @@ -109,7 +122,7 @@ private fun SignIn(
Column(Modifier.padding(horizontal = 16.dp)) {
TextField(
text = accountId,
placeholder = "아이디",
placeholder = userId.ifBlank { "아이디" },
onTextChange = { text ->
accountId = text
}
Expand All @@ -126,7 +139,7 @@ private fun SignIn(
}
Spacer(Modifier.size(16.dp))
ColoredLargeButton(text = "로그인", isEnabled = isSignInEnabled) {
onSignInClick(SignInEntity(accountId, password, getToken(context).toString() ))
onSignInClick(SignInEntity(accountId, password, getToken(context).toString()))
}
Spacer(Modifier.size(16.dp))
Body2(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.xquare.xquare_android.feature.signin

import com.xquare.domain.entity.auth.SignInEntity
import com.xquare.domain.exception.*
import com.xquare.domain.exception.BadRequestException
import com.xquare.domain.exception.NotFoundException
import com.xquare.domain.exception.TimeoutException
import com.xquare.domain.exception.TooManyRequestException
import com.xquare.domain.usecase.auth.FetchIdUseCase
import com.xquare.domain.usecase.auth.SignInUseCase
import com.xquare.xquare_android.base.BaseViewModel
Expand Down Expand Up @@ -30,15 +33,15 @@ class SignInViewModel @Inject constructor(
fun fetchId() = execute(
job = { fetchIdUseCase.execute(Unit) },
onSuccess = { emitEvent(Event.FetchIdSuccess(it)) },
onFailure = { }
onFailure = { }
)

sealed class Event {
object Success : SignInViewModel.Event()
object Success : Event()
object BadRequest : Event()
object NotFound : Event()
object Timeout : Event()
object TooManyRequest : Event()
data class FetchIdSuccess(val data: String) : Event()
}
}
}

0 comments on commit ebba8f2

Please sign in to comment.