From bb5965d5cd6c5459fd59793be501eabc4d53ba9f Mon Sep 17 00:00:00 2001 From: jihyun0v0 Date: Thu, 22 Aug 2024 23:25:23 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[feat]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=EC=97=90=20=EB=82=98=EC=98=A4?= =?UTF-8?q?=EB=8A=94=20dialog=20pop=20up=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/OneButtonCommonDialog.kt | 7 + .../newchallenge/NewChallengeActivity.kt | 18 +- .../res/drawable/ic_challengecreated_120.xml | 234 ++++++++++++++++++ .../challenge/src/main/res/values/strings.xml | 4 + 4 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 feature/challenge/src/main/res/drawable/ic_challengecreated_120.xml diff --git a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt index b107b7f3..331e8643 100644 --- a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt +++ b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt @@ -10,6 +10,7 @@ import androidx.annotation.DrawableRes import androidx.core.view.isGone import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager +import com.hmh.hamyeonham.common.R import com.hmh.hamyeonham.common.context.dialogWidthPercent import com.hmh.hamyeonham.common.databinding.DialogCommonOneButtonBinding import com.hmh.hamyeonham.common.view.setOnSingleClickListener @@ -52,6 +53,7 @@ class OneButtonCommonDialog : DialogFragment() { val description = arguments?.getString(DESCRIPTION) val iconRes = arguments?.getInt(ICON_RES) val confirmButtonText = arguments?.getString(CONFIRM_BUTTON_TEXT, "") + val setBlueButton = arguments?.getBoolean(BLUE_BUTTON, false)?:false with(binding) { tvDialogTitle.text = title @@ -60,6 +62,8 @@ class OneButtonCommonDialog : DialogFragment() { ivDialogIcon.isGone = true } tvConfirmButton.text = confirmButtonText + if(setBlueButton) + tvConfirmButton.setBackgroundResource(R.drawable.shape_blue_purple_button_radius6) } } @@ -82,6 +86,7 @@ class OneButtonCommonDialog : DialogFragment() { const val DESCRIPTION = "description" const val ICON_RES = "iconRes" const val CONFIRM_BUTTON_TEXT = "confirmButtonText" + const val BLUE_BUTTON = "blueButton" fun newInstance( @@ -89,6 +94,7 @@ class OneButtonCommonDialog : DialogFragment() { description: String? = null, @DrawableRes iconRes: Int? = null, confirmButtonText: String, + setBlueButton: Boolean = false ): OneButtonCommonDialog { return OneButtonCommonDialog().apply { arguments = Bundle().apply { @@ -96,6 +102,7 @@ class OneButtonCommonDialog : DialogFragment() { putString(DESCRIPTION, description) iconRes?.let { putInt(ICON_RES, it) } putString(CONFIRM_BUTTON_TEXT, confirmButtonText) + putBoolean(BLUE_BUTTON, setBlueButton) } } } diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt index 874d5f66..a8cc7995 100644 --- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt +++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt @@ -6,7 +6,9 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope +import com.hmh.hamyeonham.common.dialog.OneButtonCommonDialog import com.hmh.hamyeonham.common.view.viewBinding +import com.hmh.hamyeonham.feature.challenge.R import com.hmh.hamyeonham.feature.challenge.databinding.ActivityNewChallengeBinding import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -42,7 +44,7 @@ class NewChallengeActivity : AppCompatActivity() { binding.vpNewChallenge.run { when (currentItem) { FRAGMENT.PERIODSELECTION.position -> currentItem = FRAGMENT.TIMESELECTION.position - FRAGMENT.TIMESELECTION.position -> finishWithResults() + FRAGMENT.TIMESELECTION.position -> showChallengeCreatedDialog() } } } @@ -53,6 +55,20 @@ class NewChallengeActivity : AppCompatActivity() { .launchIn(lifecycleScope) } + private fun showChallengeCreatedDialog() { + OneButtonCommonDialog.newInstance( + title = getString(R.string.dialog_title_challengecreated), + description = getString(R.string.dialog_description_challengecreated), + iconRes = R.drawable.ic_challengecreated_120, + confirmButtonText = getString(R.string.dialog_button_challengecreated), + setBlueButton = true + ).apply { + setConfirmButtonClickListener { + finishWithResults() + } + }.showAllowingStateLoss(supportFragmentManager, OneButtonCommonDialog.TAG) + } + private fun finishWithResults() { val intent = Intent().apply { putExtra(PERIOD, viewModel.state.value.goalDate) diff --git a/feature/challenge/src/main/res/drawable/ic_challengecreated_120.xml b/feature/challenge/src/main/res/drawable/ic_challengecreated_120.xml new file mode 100644 index 00000000..9ab34d95 --- /dev/null +++ b/feature/challenge/src/main/res/drawable/ic_challengecreated_120.xml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/feature/challenge/src/main/res/values/strings.xml b/feature/challenge/src/main/res/values/strings.xml index c032c83b..f5dddc46 100644 --- a/feature/challenge/src/main/res/values/strings.xml +++ b/feature/challenge/src/main/res/values/strings.xml @@ -37,4 +37,8 @@ 목표 사용 시간은 최대 6시간까지 설정할 수 있어요 접기 "\u25B2" 펼치기 "\u25BC" + + 새로운 챌린지 생성 완료! + 별조각을 모아\n블랙홀 탈출에 성공하세요 + 새 챌린지 출발! From 23cefb396e6e127f4a1db430f594603799d288d3 Mon Sep 17 00:00:00 2001 From: jihyun0v0 Date: Thu, 22 Aug 2024 23:43:03 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[fix]:=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20?= =?UTF-8?q?=EB=B6=80=EC=A1=B1=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95,=20TwoButtonCommonDialog?= =?UTF-8?q?=EC=97=90=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hamyeonham/common/dialog/TwoButtonCommonDialog.kt | 8 ++++++++ .../src/main/res/layout/dialog_common_two_button.xml | 11 ++++++++++- .../com/hmh/hamyeonham/feature/main/MainActivity.kt | 10 +++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt index a50bb589..3ec32eb4 100644 --- a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt +++ b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt @@ -6,6 +6,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.annotation.DrawableRes +import androidx.core.view.isGone import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import com.hmh.hamyeonham.common.context.dialogWidthPercent @@ -53,12 +55,16 @@ class TwoButtonCommonDialog : DialogFragment() { private fun initViews() { val title = arguments?.getString(TITLE, "") val description = arguments?.getString(DESCRIPTION) + val iconRes = arguments?.getInt(OneButtonCommonDialog.ICON_RES) val confirmButtonText = arguments?.getString(CONFIRM_BUTTON_TEXT, "") val dismissButtonText = arguments?.getString(DISMISS_BUTTON_TEXT, "") with(binding) { tvDialogTitle.text = title tvDialogDescription.text = description + iconRes?.let { ivDialogIcon.setImageResource(it) } ?: run { + ivDialogIcon.isGone = true + } tvConfirmButton.text = confirmButtonText tvDismissButton.text = dismissButtonText } @@ -92,6 +98,7 @@ class TwoButtonCommonDialog : DialogFragment() { fun newInstance( title: String, description: String? = null, + @DrawableRes iconRes: Int? = null, confirmButtonText: String, dismissButtonText: String ): TwoButtonCommonDialog { @@ -100,6 +107,7 @@ class TwoButtonCommonDialog : DialogFragment() { putString(TITLE, title) putString(DESCRIPTION, description) putString(CONFIRM_BUTTON_TEXT, confirmButtonText) + iconRes?.let { putInt(OneButtonCommonDialog.ICON_RES, it) } putString(DISMISS_BUTTON_TEXT, dismissButtonText) } } diff --git a/core/common/src/main/res/layout/dialog_common_two_button.xml b/core/common/src/main/res/layout/dialog_common_two_button.xml index c93b1577..dfea00e5 100644 --- a/core/common/src/main/res/layout/dialog_common_two_button.xml +++ b/core/common/src/main/res/layout/dialog_common_two_button.xml @@ -42,6 +42,15 @@ app:layout_constraintVertical_bias="0.2" tools:text="챌린지를 등록하면 포인트를 얻을 수 있어요" /> + + Date: Fri, 23 Aug 2024 00:28:18 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[fix]:=20dialog=20xml=EC=88=98=EC=A0=95,=20?= =?UTF-8?q?two=20button=20img=20=3D=20null=EC=9D=B8=20=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/TwoButtonCommonDialog.kt | 13 ++++++++++--- .../main/res/layout/dialog_common_one_button.xml | 3 +-- .../main/res/layout/dialog_common_two_button.xml | 4 +--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt index 3ec32eb4..bb23a2ee 100644 --- a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt +++ b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/TwoButtonCommonDialog.kt @@ -55,15 +55,20 @@ class TwoButtonCommonDialog : DialogFragment() { private fun initViews() { val title = arguments?.getString(TITLE, "") val description = arguments?.getString(DESCRIPTION) - val iconRes = arguments?.getInt(OneButtonCommonDialog.ICON_RES) + val iconRes = arguments?.getInt(OneButtonCommonDialog.ICON_RES, 0) val confirmButtonText = arguments?.getString(CONFIRM_BUTTON_TEXT, "") val dismissButtonText = arguments?.getString(DISMISS_BUTTON_TEXT, "") + val hideIcon = arguments?.getBoolean(HIDE_ICON) ?: false with(binding) { tvDialogTitle.text = title tvDialogDescription.text = description - iconRes?.let { ivDialogIcon.setImageResource(it) } ?: run { + if (hideIcon) ivDialogIcon.isGone = true + else { + iconRes?.let { + ivDialogIcon.setImageResource(it) + } ?: run { ivDialogIcon.isGone = true } } tvConfirmButton.text = confirmButtonText tvDismissButton.text = dismissButtonText @@ -93,6 +98,8 @@ class TwoButtonCommonDialog : DialogFragment() { const val DESCRIPTION = "description" const val CONFIRM_BUTTON_TEXT = "confirmButtonText" const val DISMISS_BUTTON_TEXT = "dismissButtonText" + const val ICON_RES = "iconRes" + const val HIDE_ICON = "hideIcon" fun newInstance( @@ -107,7 +114,7 @@ class TwoButtonCommonDialog : DialogFragment() { putString(TITLE, title) putString(DESCRIPTION, description) putString(CONFIRM_BUTTON_TEXT, confirmButtonText) - iconRes?.let { putInt(OneButtonCommonDialog.ICON_RES, it) } + iconRes?.let { putInt(ICON_RES, it) } ?: run { putBoolean(HIDE_ICON, true) } putString(DISMISS_BUTTON_TEXT, dismissButtonText) } } diff --git a/core/common/src/main/res/layout/dialog_common_one_button.xml b/core/common/src/main/res/layout/dialog_common_one_button.xml index 555a63a2..b7056a67 100644 --- a/core/common/src/main/res/layout/dialog_common_one_button.xml +++ b/core/common/src/main/res/layout/dialog_common_one_button.xml @@ -30,12 +30,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="12dp" - android:layout_marginTop="9dp" + android:layout_marginTop="6dp" android:ellipsize="end" android:gravity="center" android:maxLines="2" android:textAppearance="?textAppearanceBodyMedium" - app:layout_constraintBottom_toTopOf="@+id/tv_confirm_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_dialog_title" diff --git a/core/common/src/main/res/layout/dialog_common_two_button.xml b/core/common/src/main/res/layout/dialog_common_two_button.xml index dfea00e5..2b59e940 100644 --- a/core/common/src/main/res/layout/dialog_common_two_button.xml +++ b/core/common/src/main/res/layout/dialog_common_two_button.xml @@ -29,13 +29,11 @@ android:id="@+id/tv_dialog_description" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginHorizontal="12dp" - android:layout_marginTop="9dp" + android:layout_marginTop="6dp" android:ellipsize="end" android:gravity="center" android:maxLines="2" android:textAppearance="?textAppearanceBodyMedium" - app:layout_constraintBottom_toTopOf="@+id/tv_confirm_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_dialog_title" From 27dd8856e770872b7e6fac873313f17d9e8dbb7d Mon Sep 17 00:00:00 2001 From: jihyun0v0 Date: Fri, 23 Aug 2024 11:43:25 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[fix]:=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt index 331e8643..ab1cebfb 100644 --- a/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt +++ b/core/common/src/main/java/com/hmh/hamyeonham/common/dialog/OneButtonCommonDialog.kt @@ -53,7 +53,7 @@ class OneButtonCommonDialog : DialogFragment() { val description = arguments?.getString(DESCRIPTION) val iconRes = arguments?.getInt(ICON_RES) val confirmButtonText = arguments?.getString(CONFIRM_BUTTON_TEXT, "") - val setBlueButton = arguments?.getBoolean(BLUE_BUTTON, false)?:false + val setBlueButton = arguments?.getBoolean(BLUE_BUTTON, false) ?: false with(binding) { tvDialogTitle.text = title @@ -62,7 +62,7 @@ class OneButtonCommonDialog : DialogFragment() { ivDialogIcon.isGone = true } tvConfirmButton.text = confirmButtonText - if(setBlueButton) + if (setBlueButton) tvConfirmButton.setBackgroundResource(R.drawable.shape_blue_purple_button_radius6) } }