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" />
+
+
+
+
+
+
+
+
+
+
+
+
-