Skip to content

Commit

Permalink
[MOD/#8] MBTI 입력 기능 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed May 12, 2023
1 parent a532abb commit a1e8550
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 75 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/org/android/go/sopt/domain/model/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ package org.android.go.sopt.domain.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import org.android.go.sopt.util.type.MBTI
import org.android.go.sopt.util.type.MBTI.NONE

@Parcelize
data class User(
val id: String = "",
val pwd: String = "",
val name: String = "익명",
val specialty: String = "",
val mbti: MBTI = NONE,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ package org.android.go.sopt.presentation.login

import android.app.Activity
import android.content.Intent
import android.content.Intent.EXTRA_USER
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import dagger.hilt.android.AndroidEntryPoint
import org.android.go.sopt.R
import org.android.go.sopt.databinding.ActivityLoginBinding
import org.android.go.sopt.domain.model.User
import org.android.go.sopt.presentation.main.MainActivity
import org.android.go.sopt.presentation.signup.SignupActivity
import org.android.go.sopt.util.state.LocalUiState.Failure
import org.android.go.sopt.util.state.LocalUiState.Success
import org.android.go.sopt.util.binding.BindingActivity
import org.android.go.sopt.util.extension.getCompatibleParcelableExtra
import org.android.go.sopt.util.extension.setOnSingleClickListener
import org.android.go.sopt.util.extension.showSnackbar
import org.android.go.sopt.util.extension.showToast
import org.android.go.sopt.util.state.LocalUiState.Failure
import org.android.go.sopt.util.state.LocalUiState.Success

@AndroidEntryPoint
class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_login) {
Expand All @@ -36,11 +33,7 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
val signupResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val resultData = result.data ?: return@registerForActivityResult
resultData.getCompatibleParcelableExtra<User>(EXTRA_USER)?.let { user ->
viewModel.setSavedUser(user)
showSnackbar(binding.root, getString(R.string.login_signup_success_msg))
}
showSnackbar(binding.root, getString(R.string.login_signup_success_msg))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import org.android.go.sopt.domain.model.User
import org.android.go.sopt.domain.repository.AuthRepository
import org.android.go.sopt.util.state.LocalUiState
import org.android.go.sopt.util.state.LocalUiState.Failure
Expand All @@ -15,8 +14,6 @@ import javax.inject.Inject
class LoginViewModel @Inject constructor(
private val authRepository: AuthRepository,
) : ViewModel() {
var signedUpUser = User()

private val _loginState = MutableLiveData<LocalUiState>()
val loginState: LiveData<LocalUiState>
get() = _loginState
Expand All @@ -29,21 +26,19 @@ class LoginViewModel @Inject constructor(
}

private fun setupAutoLogin() {
if (authRepository.getAutoLogin() && authRepository.getSignedUpUser() != null) _loginState.value = Success
}

fun setSavedUser(savedUser: User) {
this.signedUpUser = savedUser
if (authRepository.getAutoLogin() && authRepository.getSignedUpUser() != null) {
_loginState.value = Success
}
}

private fun isValidInput() =
!id.value.isNullOrBlank() && id.value == signedUpUser.id && !pwd.value.isNullOrBlank() && pwd.value == signedUpUser.pwd
private fun isValidInput() = !id.value.isNullOrBlank() && !pwd.value.isNullOrBlank()

fun login() {
if (!isValidInput()) {
_loginState.value = Failure(null)
return
}
// TODO : 로그인 정보 저장
authRepository.setAutoLogin(true)
_loginState.value = Success
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.android.go.sopt.presentation.signup

import android.app.Activity
import android.content.Intent
import android.content.Intent.EXTRA_USER
import android.os.Bundle
import androidx.activity.viewModels
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -71,7 +70,6 @@ class SignupActivity : BindingActivity<ActivitySignupBinding>(R.layout.activity_

private fun navigateToLoginScreen() {
Intent(this, LoginActivity::class.java).apply {
this.putExtra(EXTRA_USER, viewModel.getUser())
setResult(Activity.RESULT_OK, this)
if (!isFinishing) finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto
import org.android.go.sopt.domain.model.User
import org.android.go.sopt.domain.repository.AuthRepository
import org.android.go.sopt.util.safeValueOf
import org.android.go.sopt.util.state.RemoteUiState
import org.android.go.sopt.util.state.RemoteUiState.Error
import org.android.go.sopt.util.state.RemoteUiState.Failure
import org.android.go.sopt.util.state.RemoteUiState.Success
import org.android.go.sopt.util.type.MBTI
import org.android.go.sopt.util.type.MBTI.NONE
import retrofit2.HttpException
import timber.log.Timber
import javax.inject.Inject
Expand Down Expand Up @@ -44,10 +40,6 @@ class SignupViewModel @Inject constructor(
private val specialty: String
get() = _specialty.value?.trim() ?: ""

val _mbti = MutableLiveData("")
private val mbti: MBTI
get() = safeValueOf(_mbti.value?.trim()?.uppercase(), NONE)

private fun isValidId() = id.isNotBlank() && id.length in MIN_ID_LENGTH..MAX_ID_LENGTH

private fun isValidPwd() = pwd.isNotBlank() && pwd.length in MIN_PWD_LENGTH..MAX_PWD_LENGTH
Expand Down Expand Up @@ -80,7 +72,6 @@ class SignupViewModel @Inject constructor(
viewModelScope.launch {
authRepository.postSignup(requestPostSignUpDto)
.onSuccess { response ->
authRepository.setSignedUpUser(getUser())
_signupState.value = Success
Timber.d("POST SIGNUP SUCCESS : $response")
}
Expand All @@ -97,16 +88,6 @@ class SignupViewModel @Inject constructor(
}
}

fun getUser(): User {
return User(
id = id,
pwd = pwd,
name = name,
specialty = specialty,
mbti = mbti,
)
}

companion object {
const val MIN_ID_LENGTH = 6
const val MAX_ID_LENGTH = 10
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/org/android/go/sopt/util/type/MBTI.kt

This file was deleted.

26 changes: 0 additions & 26 deletions app/src/main/res/layout/activity_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_signup_specialty_label" />

<TextView
android:id="@+id/tv_signup_mbti_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/signup_mbti_label"
android:textAppearance="?attr/textAppearanceHeadlineSmall"
android:textColor="?colorOnBackground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/et_signup_specialty" />

<EditText
android:id="@+id/et_signup_mbti"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:hint="@string/signup_mbti_hint"
android:imeOptions="actionDone"
android:inputType="textCapCharacters"
android:paddingVertical="16dp"
android:text="@={vm._mbti}"
android:textAppearance="@style/TextAppearance.GoSopt.BodyLarge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_signup_mbti_label" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Expand Down

0 comments on commit a1e8550

Please sign in to comment.