Skip to content

Commit

Permalink
[#30] 로그인 기능 추가 - 닉네임 필드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-223 committed Aug 4, 2022
1 parent f4e5175 commit 8cdda4e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.moyerun.moyeorun_android.login.data.model
data class SignUpRequest(
val idToken: String,
val providerType: String,
val name: String,
val nickName: String,
val gender: String,
val image: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class ProfileEditActivity : AppCompatActivity() {

private val viewModel: ProfileEditViewModel by viewModels()

private val galleryLauncher =
registerForActivityResult(ActivityResultContracts.GetContent()) { imageUri ->
if (imageUri != null) {
viewModel.onImageUrlChanged(imageUri)
} else {
Lg.fw("Cannot get Image Uri from gallery")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityProfileBinding.inflate(layoutInflater)
Expand All @@ -41,19 +50,6 @@ class ProfileEditActivity : AppCompatActivity() {

viewModel.updateData(signUpMetaData, originalProfile)

val galleryLauncher =
registerForActivityResult(ActivityResultContracts.GetContent()) { imageUri ->
if (imageUri != null) {
viewModel.onImageUrlChanged(imageUri)
} else {
Lg.fw("Cannot get Image Uri from gallery")
}
}

binding.edittextProfileName.doAfterTextChanged {
viewModel.onNameChanged(it?.toString().orEmpty())
}

binding.edittextProfileNickname.doAfterTextChanged {
viewModel.onNicknameChanged(it?.toString().orEmpty())
}
Expand Down Expand Up @@ -87,14 +83,6 @@ class ProfileEditActivity : AppCompatActivity() {
}

repeatOnStart {
launch {
viewModel.profileUiModel
.map { it.name }
.distinctUntilChanged()
.collect {
binding.edittextProfileName.setTextIfNew(it)
}
}
launch {
viewModel.profileUiModel
.map { it.nickname }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ class ProfileEditViewModel @Inject constructor(
}
}

fun onNameChanged(name: String) = updateWithValidate {
_profileUiModel.update {
it.copy(name = name)
}
_profileUiModel.value
}

fun onNicknameChanged(nickname: String) = updateWithValidate {
_profileUiModel.update {
it.copy(nickname = nickname)
Expand Down Expand Up @@ -122,15 +115,10 @@ class ProfileEditViewModel @Inject constructor(
}

private fun ProfileUiModel.validate(): Boolean {
return name.validateName()
&& nickname.validateNickname()
return nickname.validateNickname()
&& gender != Gender.NONE
}

private fun String.validateName(): Boolean {
return isNotEmpty()
}

private fun String.validateNickname(): Boolean {
return isNotEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class ProfileUiModel(
val imageUri: Uri = Uri.EMPTY,
val name: String = "",
val nickname: String = "",
val gender: Gender = Gender.NONE
) : Parcelable
Expand All @@ -18,7 +17,6 @@ fun ProfileUiModel.toSignUpRequest(signUpMetaData: SignUpMetaData): SignUpReques
return SignUpRequest(
idToken = signUpMetaData.idToken,
providerType = signUpMetaData.providerType.name,
name = name,
nickName = nickname,
gender = gender.name,
image = "TEST" //TODO: 이미지 Uri 넣기
Expand Down
16 changes: 0 additions & 16 deletions app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@
style="@style/Profile.InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/profile_name" />

<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/edittext_profile_name"
style="@style/Profile.Input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/profile_name"
android:inputType="text" />

<TextView
style="@style/Profile.InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/profile_nickname" />

<androidx.appcompat.widget.AppCompatEditText
Expand Down

0 comments on commit 8cdda4e

Please sign in to comment.