From 8cdda4e90ee55353d2069fa2a942c97179c6cca6 Mon Sep 17 00:00:00 2001 From: winter223 Date: Fri, 5 Aug 2022 00:22:15 +0900 Subject: [PATCH] =?UTF-8?q?[#30]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20=EB=8B=89=EB=84=A4?= =?UTF-8?q?=EC=9E=84=20=ED=95=84=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../login/data/model/SignUpRequest.kt | 1 - .../profile/ui/ProfileEditActivity.kt | 30 ++++++------------- .../profile/ui/ProfileEditViewModel.kt | 14 +-------- .../profile/ui/ProfileUiModel.kt | 2 -- app/src/main/res/layout/activity_profile.xml | 16 ---------- 5 files changed, 10 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/com/moyerun/moyeorun_android/login/data/model/SignUpRequest.kt b/app/src/main/java/com/moyerun/moyeorun_android/login/data/model/SignUpRequest.kt index 3e93656..0790c40 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/login/data/model/SignUpRequest.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/login/data/model/SignUpRequest.kt @@ -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 diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditActivity.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditActivity.kt index bfabcbe..f1367d0 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditActivity.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditActivity.kt @@ -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) @@ -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()) } @@ -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 } diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditViewModel.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditViewModel.kt index 24b1b37..873f5f7 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditViewModel.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileEditViewModel.kt @@ -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) @@ -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() } diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileUiModel.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileUiModel.kt index 14c7f9f..1d10c14 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileUiModel.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ui/ProfileUiModel.kt @@ -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 @@ -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 넣기 diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 11cb7ae..12891b8 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -49,22 +49,6 @@ style="@style/Profile.InputLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/profile_name" /> - - - -