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..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 @@ -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/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..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 @@ -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,21 @@ class TwoButtonCommonDialog : DialogFragment() { private fun initViews() { val title = arguments?.getString(TITLE, "") val description = arguments?.getString(DESCRIPTION) + 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 + if (hideIcon) + ivDialogIcon.isGone = true + else { + iconRes?.let { + ivDialogIcon.setImageResource(it) + } ?: run { ivDialogIcon.isGone = true } + } tvConfirmButton.text = confirmButtonText tvDismissButton.text = dismissButtonText } @@ -87,11 +98,14 @@ 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( title: String, description: String? = null, + @DrawableRes iconRes: Int? = null, confirmButtonText: String, dismissButtonText: String ): TwoButtonCommonDialog { @@ -100,6 +114,7 @@ class TwoButtonCommonDialog : DialogFragment() { putString(TITLE, title) putString(DESCRIPTION, description) putString(CONFIRM_BUTTON_TEXT, confirmButtonText) + 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 c93b1577..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,19 +29,26 @@ 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" app:layout_constraintVertical_bias="0.2" tools:text="챌린지를 등록하면 포인트를 얻을 수 있어요" /> + + currentItem = FRAGMENT.TIMESELECTION.position - FRAGMENT.TIMESELECTION.position -> finishWithResults() + FRAGMENT.TIMESELECTION.position -> showChallengeCreatedDialog() } } } @@ -63,6 +65,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블랙홀 탈출에 성공하세요 + 새 챌린지 출발! diff --git a/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt b/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt index 3f503495..3a484024 100644 --- a/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt +++ b/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt @@ -111,15 +111,20 @@ class MainActivity : AppCompatActivity() { } private fun showPointLackDialog() { - OneButtonCommonDialog.newInstance( + TwoButtonCommonDialog.newInstance( title = getString(R.string.dialog_title_point_lack), description = getString(R.string.dialog_description_point_lack), iconRes = R.drawable.ic_point_lack, - confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.no), + confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_okay), + dismissButtonText = getString(R.string.dialog_button_charge_point) ).apply { setConfirmButtonClickListener { dismiss() } + setDismissButtonClickListener { + val intent = navigationProvider.toStore() + startActivity(intent) + } }.showAllowingStateLoss(supportFragmentManager, OneButtonCommonDialog.TAG) } @@ -139,7 +144,6 @@ class MainActivity : AppCompatActivity() { if (!allPermissionIsGranted()) { startActivity(navigationProvider.toPermission()) } - checkPowerManagerPermission() }