From 3d4b20d1114104246e5a6c3512c04b9bb18f24f4 Mon Sep 17 00:00:00 2001 From: winter223 Date: Sat, 30 Apr 2022 15:14:26 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 성별 선택 기능 추가 - 바뀐 디자인 가이드 소폭 적용 --- .../profile/ProfileEditActivity.kt | 31 +++++++++++- .../profile/ProfileEditViewModel.kt | 6 +++ .../profile/ProfileUiModel.kt | 8 +++- .../main/res/drawable/gender_background.xml | 9 ++++ .../drawable/gender_background_checked.xml | 6 +++ .../main/res/drawable/gender_button_man.xml | 10 ++++ .../drawable/gender_button_man_checked.xml | 10 ++++ .../main/res/drawable/gender_button_woman.xml | 10 ++++ .../drawable/gender_button_woman_checked.xml | 10 ++++ app/src/main/res/drawable/ic_gender_man.xml | 16 +++++++ .../main/res/drawable/ic_gender_man_white.xml | 16 +++++++ app/src/main/res/drawable/ic_gender_woman.xml | 16 +++++++ .../res/drawable/ic_gender_woman_white.xml | 16 +++++++ .../main/res/drawable/round_background_12.xml | 13 ++--- .../main/res/drawable/selector_gender_man.xml | 5 ++ .../res/drawable/selector_gender_woman.xml | 5 ++ .../drawable/toolbar_divider_background.xml | 15 ++++++ app/src/main/res/layout/activity_profile.xml | 48 +++++++++++++++++-- app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/styles_button.xml | 4 ++ app/src/main/res/values/styles_edittext.xml | 1 - app/src/main/res/values/styles_textview.xml | 9 ++++ app/src/main/res/values/styles_toolbar.xml | 5 ++ 24 files changed, 257 insertions(+), 16 deletions(-) create mode 100644 app/src/main/res/drawable/gender_background.xml create mode 100644 app/src/main/res/drawable/gender_background_checked.xml create mode 100644 app/src/main/res/drawable/gender_button_man.xml create mode 100644 app/src/main/res/drawable/gender_button_man_checked.xml create mode 100644 app/src/main/res/drawable/gender_button_woman.xml create mode 100644 app/src/main/res/drawable/gender_button_woman_checked.xml create mode 100644 app/src/main/res/drawable/ic_gender_man.xml create mode 100644 app/src/main/res/drawable/ic_gender_man_white.xml create mode 100644 app/src/main/res/drawable/ic_gender_woman.xml create mode 100644 app/src/main/res/drawable/ic_gender_woman_white.xml create mode 100644 app/src/main/res/drawable/selector_gender_man.xml create mode 100644 app/src/main/res/drawable/selector_gender_woman.xml create mode 100644 app/src/main/res/drawable/toolbar_divider_background.xml create mode 100644 app/src/main/res/values/styles_textview.xml diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditActivity.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditActivity.kt index e041025..20f1f6f 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditActivity.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.widget.EditText +import android.widget.RadioButton import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity @@ -72,6 +73,15 @@ class ProfileEditActivity : AppCompatActivity() { } } + binding.radiogroupProfileGender.setOnCheckedChangeListener { _, checkedId -> + val gender = when (checkedId) { + R.id.radiobutton_profile_man -> Gender.MAN + R.id.radiobutton_profile_woman -> Gender.WOMAN + else -> Gender.NONE + } + viewModel.onGenderChanged(gender) + } + binding.buttonProfileConfirm.setOnDebounceClickListener { if (isNewProfile) { viewModel.signUp() @@ -103,6 +113,18 @@ class ProfileEditActivity : AppCompatActivity() { binding.badgeimageviewProfileImage.setBigCircleImgSrc(it) } } + launch { + viewModel.profileUiModel + .map { it.gender } + .distinctUntilChanged() + .collect { + when (it) { + Gender.MAN -> binding.radiobuttonProfileMan.setCheckIfNew(true) + Gender.WOMAN -> binding.radiobuttonProfileWoman.setCheckIfNew(true) + Gender.NONE -> binding.radiogroupProfileGender.clearCheck() + } + } + } } observeEvent(viewModel.profileEvent) { @@ -115,7 +137,7 @@ class ProfileEditActivity : AppCompatActivity() { when (it.error) { ProfileError.WRONG_ACCESS -> { Lg.fw("Wrong access. signUpMetadata: $signUpMetaData, originProfile: $originalProfile") - toast("잘못된 접근입니다.") + toast(getString(R.string.profile_toast_wrong_access)) finish() } } @@ -140,6 +162,13 @@ class ProfileEditActivity : AppCompatActivity() { setTextIfNew(text) } + private fun RadioButton.setCheckIfNew(check: Boolean) { + val oldValue = isChecked + if (oldValue != check) { + isChecked = check + } + } + companion object { private const val EXTRA_PROFILE_UI_MODEL = "profileUiModel" private const val EXTRA_SIGN_UP_META_DATA = "signUpMetaData" diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditViewModel.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditViewModel.kt index 0ce6825..21d8c70 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditViewModel.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileEditViewModel.kt @@ -59,6 +59,12 @@ class ProfileEditViewModel: ViewModel() { } } + fun onGenderChanged(gender: Gender) { + _profileUiModel.update { + it.copy(gender = gender) + } + } + fun signUp() { // Todo: 회원가입 API 호출 Lg.d("SignUp : ${profileUiModel.value}, $signUpMetaData") diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileUiModel.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileUiModel.kt index 8ebb5a4..9294a26 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileUiModel.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileUiModel.kt @@ -2,13 +2,15 @@ package com.moyerun.moyeorun_android.profile import android.net.Uri import android.os.Parcelable +import androidx.annotation.IdRes import kotlinx.parcelize.Parcelize @Parcelize data class ProfileUiModel( val imageUri: Uri = Uri.EMPTY, val name: String = "", - val nickname: String = "" + val nickname: String = "", + val gender: Gender = Gender.NONE ): Parcelable sealed class ProfileEvent { @@ -18,4 +20,8 @@ sealed class ProfileEvent { enum class ProfileError { WRONG_ACCESS +} + +enum class Gender { + MAN, WOMAN, NONE } \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_background.xml b/app/src/main/res/drawable/gender_background.xml new file mode 100644 index 0000000..9a187a5 --- /dev/null +++ b/app/src/main/res/drawable/gender_background.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_background_checked.xml b/app/src/main/res/drawable/gender_background_checked.xml new file mode 100644 index 0000000..9503dee --- /dev/null +++ b/app/src/main/res/drawable/gender_background_checked.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_button_man.xml b/app/src/main/res/drawable/gender_button_man.xml new file mode 100644 index 0000000..7aaffa5 --- /dev/null +++ b/app/src/main/res/drawable/gender_button_man.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_button_man_checked.xml b/app/src/main/res/drawable/gender_button_man_checked.xml new file mode 100644 index 0000000..1238092 --- /dev/null +++ b/app/src/main/res/drawable/gender_button_man_checked.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_button_woman.xml b/app/src/main/res/drawable/gender_button_woman.xml new file mode 100644 index 0000000..1b3c591 --- /dev/null +++ b/app/src/main/res/drawable/gender_button_woman.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gender_button_woman_checked.xml b/app/src/main/res/drawable/gender_button_woman_checked.xml new file mode 100644 index 0000000..1c8be3a --- /dev/null +++ b/app/src/main/res/drawable/gender_button_woman_checked.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_gender_man.xml b/app/src/main/res/drawable/ic_gender_man.xml new file mode 100644 index 0000000..95fc05c --- /dev/null +++ b/app/src/main/res/drawable/ic_gender_man.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/drawable/ic_gender_man_white.xml b/app/src/main/res/drawable/ic_gender_man_white.xml new file mode 100644 index 0000000..71745b9 --- /dev/null +++ b/app/src/main/res/drawable/ic_gender_man_white.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/drawable/ic_gender_woman.xml b/app/src/main/res/drawable/ic_gender_woman.xml new file mode 100644 index 0000000..1c22bb6 --- /dev/null +++ b/app/src/main/res/drawable/ic_gender_woman.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/drawable/ic_gender_woman_white.xml b/app/src/main/res/drawable/ic_gender_woman_white.xml new file mode 100644 index 0000000..87715ff --- /dev/null +++ b/app/src/main/res/drawable/ic_gender_woman_white.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/drawable/round_background_12.xml b/app/src/main/res/drawable/round_background_12.xml index cfb6cbf..06b257f 100644 --- a/app/src/main/res/drawable/round_background_12.xml +++ b/app/src/main/res/drawable/round_background_12.xml @@ -1,9 +1,6 @@ - - - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_gender_man.xml b/app/src/main/res/drawable/selector_gender_man.xml new file mode 100644 index 0000000..3dd0ff1 --- /dev/null +++ b/app/src/main/res/drawable/selector_gender_man.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_gender_woman.xml b/app/src/main/res/drawable/selector_gender_woman.xml new file mode 100644 index 0000000..136e3c9 --- /dev/null +++ b/app/src/main/res/drawable/selector_gender_woman.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/toolbar_divider_background.xml b/app/src/main/res/drawable/toolbar_divider_background.xml new file mode 100644 index 0000000..3a8ba01 --- /dev/null +++ b/app/src/main/res/drawable/toolbar_divider_background.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 8cb96a0..0c40403 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -8,7 +8,7 @@ @@ -60,6 +61,7 @@ android:inputType="text" /> + + + + + + + + + + + + -