From 4ed596f982e8e1b2a37bcc12a12f83a86e1bbdaf Mon Sep 17 00:00:00 2001 From: winter223 Date: Tue, 26 Apr 2022 23:56:08 +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 - 이미지 선택 다이얼로그 추가 --- .../common/dialog/RoundDialogFragment.kt | 2 +- .../profile/ProfileEditActivity.kt | 17 +++++-- .../ProfileImageSelectDialogFragment.kt | 50 +++++++++++++++++++ .../layout/dialog_profile_image_select.xml | 38 ++++++++++++++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/styles_dialog.xml | 6 +++ 6 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileImageSelectDialogFragment.kt create mode 100644 app/src/main/res/layout/dialog_profile_image_select.xml diff --git a/app/src/main/java/com/moyerun/moyeorun_android/common/dialog/RoundDialogFragment.kt b/app/src/main/java/com/moyerun/moyeorun_android/common/dialog/RoundDialogFragment.kt index 24c4ab4..b0d7d9d 100644 --- a/app/src/main/java/com/moyerun/moyeorun_android/common/dialog/RoundDialogFragment.kt +++ b/app/src/main/java/com/moyerun/moyeorun_android/common/dialog/RoundDialogFragment.kt @@ -9,7 +9,7 @@ import android.view.Window import androidx.fragment.app.DialogFragment import com.moyerun.moyeorun_android.common.extension.isActivityDestroyed -open class RoundDialogFragment : DialogFragment() { +abstract class RoundDialogFragment : DialogFragment() { private var dismissOnPause = false 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 d3b5f50..73de13e 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 @@ -8,9 +8,7 @@ import android.widget.EditText import androidx.activity.viewModels import androidx.core.widget.doAfterTextChanged import com.moyerun.moyeorun_android.R -import com.moyerun.moyeorun_android.common.extension.repeatOnStart -import com.moyerun.moyeorun_android.common.extension.setDrawableEnd -import com.moyerun.moyeorun_android.common.extension.setTextIfNew +import com.moyerun.moyeorun_android.common.extension.* import com.moyerun.moyeorun_android.databinding.ActivityProfileBinding import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collect @@ -49,6 +47,19 @@ class ProfileEditActivity : AppCompatActivity() { viewModel.onNicknameChanged(it?.toString().orEmpty()) } + binding.badgeimageviewProfileImage.setOnDebounceClickListener { + showAllowingStateLoss("selectImage") { + ProfileImageSelectDialogFragment.getInstance( + onGalleryClick = { + // Todo : 갤러리 선택 화면 + }, + onDefaultImagesClick = { + // Todo : 기본 이미지 선택 화면 + } + ) + } + } + repeatOnStart { launch { viewModel.profileUiModel diff --git a/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileImageSelectDialogFragment.kt b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileImageSelectDialogFragment.kt new file mode 100644 index 0000000..ab2ea6e --- /dev/null +++ b/app/src/main/java/com/moyerun/moyeorun_android/profile/ProfileImageSelectDialogFragment.kt @@ -0,0 +1,50 @@ +package com.moyerun.moyeorun_android.profile + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.moyerun.moyeorun_android.common.dialog.RoundDialogFragment +import com.moyerun.moyeorun_android.common.extension.setOnDebounceClickListener +import com.moyerun.moyeorun_android.databinding.DialogProfileImageSelectBinding + +class ProfileImageSelectDialogFragment : RoundDialogFragment() { + + private var onGalleryClick: () -> Unit = {} + private var onDefaultImagesClick: () -> Unit = {} + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return DialogProfileImageSelectBinding.inflate(inflater, container, false).root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val binding = DialogProfileImageSelectBinding.bind(view) + + binding.buttonImageSelectGallery.setOnDebounceClickListener { + onGalleryClick.invoke() + dismissAllowingStateLoss() + } + + binding.buttonImageSelectDefault.setOnDebounceClickListener { + onDefaultImagesClick.invoke() + dismissAllowingStateLoss() + } + } + + companion object { + fun getInstance( + onGalleryClick: () -> Unit, + onDefaultImagesClick: () -> Unit + ): ProfileImageSelectDialogFragment { + return ProfileImageSelectDialogFragment().apply { + this.onGalleryClick = onGalleryClick + this.onDefaultImagesClick = onDefaultImagesClick + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_profile_image_select.xml b/app/src/main/res/layout/dialog_profile_image_select.xml new file mode 100644 index 0000000..a34e39d --- /dev/null +++ b/app/src/main/res/layout/dialog_profile_image_select.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2322876..1cd8c22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,5 +14,7 @@ 이름 닉네임 + 갤러리에서 선택 + 기본 이미지에서 선택 \ No newline at end of file diff --git a/app/src/main/res/values/styles_dialog.xml b/app/src/main/res/values/styles_dialog.xml index 55a64cf..61c771f 100644 --- a/app/src/main/res/values/styles_dialog.xml +++ b/app/src/main/res/values/styles_dialog.xml @@ -27,6 +27,12 @@ 0dp 21dp 16dp + @android:color/transparent + + +