Skip to content

Commit

Permalink
[feat]: Add Logout Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kez-lab committed Jan 13, 2024
1 parent 31d26c3 commit b81b477
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import com.hmh.hamyeonham.common.context.dialogWidthPercent
import com.hmh.hamyeonham.common.databinding.DialogCommonTwoButtonBinding
import com.hmh.hamyeonham.common.view.setOnSingleClickListener
Expand Down Expand Up @@ -51,14 +52,13 @@ class TwoButtonCommonDialog : DialogFragment() {

private fun initViews() {
val title = arguments?.getString(TITLE, "")
val description = arguments?.getString(DESCRIPTION, "")
val description = arguments?.getString(DESCRIPTION)
val confirmButtonText = arguments?.getString(CONFIRM_BUTTON_TEXT, "")
val dismissButtonText = arguments?.getString(DISMISS_BUTTON_TEXT, "")

with(binding) {
tvDialogTitle.text = title
tvDialogDescription.text = description

tvConfirmButton.text = confirmButtonText
tvDismissButton.text = dismissButtonText
}
Expand All @@ -75,6 +75,11 @@ class TwoButtonCommonDialog : DialogFragment() {
}
}

fun showAllowingStateLoss(fm: FragmentManager, tag: String = "") {
fm.beginTransaction().add(this, tag)
.commitAllowingStateLoss()
}

companion object {
const val TAG = "TwoButtonCommonDialog"

Expand All @@ -86,7 +91,7 @@ class TwoButtonCommonDialog : DialogFragment() {

fun newInstance(
title: String,
description: String,
description: String? = null,
confirmButtonText: String,
dismissButtonText: String
): TwoButtonCommonDialog {
Expand Down
5 changes: 5 additions & 0 deletions core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="all_okay">확인</string>
<string name="all_cancel">μ·¨μ†Œ</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.core.content.ContextCompat.getColor
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import com.hmh.hamyeonham.common.dialog.TwoButtonCommonDialog
import com.hmh.hamyeonham.common.fragment.viewLifeCycle
import com.hmh.hamyeonham.common.fragment.viewLifeCycleScope
import com.hmh.hamyeonham.common.view.viewBinding
Expand Down Expand Up @@ -40,9 +41,27 @@ class MyPageFragment : Fragment() {
savedInstanceState: Bundle?
) {
super.onViewCreated(view, savedInstanceState)
initViews()
collectMainState()
}

private fun initViews() {
binding.tvLogout.setOnClickListener {
TwoButtonCommonDialog.newInstance(
title = getString(R.string.logout_description),
confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_okay),
dismissButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_cancel)
).apply {
setConfirmButtonClickListener {

}
setDismissButtonClickListener {

}
}.showAllowingStateLoss(childFragmentManager)
}
}

private fun collectMainState() {
activityViewModel.mainState.flowWithLifecycle(viewLifeCycle).onEach {
bindMyPageWithUserInfo(it.userInfo)
Expand Down
4 changes: 2 additions & 2 deletions feature/mypage/src/main/res/layout/fragment_my_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
android:id="@+id/tv_logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="19dp"
android:padding="19dp"
android:text="λ‘œκ·Έμ•„μ›ƒ"
android:textAppearance="?textAppearanceBodyLarge"
android:textColor="?gray3"
Expand All @@ -321,7 +321,7 @@
android:id="@+id/tv_withdrawal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="19dp"
android:padding="19dp"
android:text="νšŒμ›νƒˆν‡΄"
android:textAppearance="?textAppearanceBodyLarge"
android:textColor="?gray3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<resources>
<string name="mypage_title">λ§ˆμ΄νŽ˜μ΄μ§€</string>
<string name = "mypage_point_title">보유 포인트</string>
<string name="mypage_point_unit">P</string>
<string name="mypage_badge_collection">배지 μ»¬λ ‰μ…˜</string>
<string name="mypage_journey">μ§€κΈˆκΉŒμ§€μ˜ μ—¬μ •</string>
<string name="mypage_store">상점</string>
<string name="mypage_info">정보</string>
<string name="mypage_termofuse">μ΄μš©μ•½κ΄€</string>
<string name="mypage_privacy">κ°œμΈμ •λ³΄μ²˜λ¦¬λ°©μΉ¨</string>
</resources>
<resources>
<string name="mypage_title">λ§ˆμ΄νŽ˜μ΄μ§€</string>
<string name="mypage_point_title">보유 포인트</string>
<string name="mypage_point_unit">P</string>
<string name="mypage_badge_collection">배지 μ»¬λ ‰μ…˜</string>
<string name="mypage_journey">μ§€κΈˆκΉŒμ§€μ˜ μ—¬μ •</string>
<string name="mypage_store">상점</string>
<string name="mypage_info">정보</string>
<string name="mypage_termofuse">μ΄μš©μ•½κ΄€</string>
<string name="mypage_privacy">κ°œμΈμ •λ³΄μ²˜λ¦¬λ°©μΉ¨</string>
<string name="logout_description">ν•˜λ©΄ν•¨μ„ λ‘œκ·Έμ•„μ›ƒ ν•˜μ‹œκ² μ–΄μš”?</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
android:background="@drawable/all_next_btn_able"
android:gravity="center"
android:text="@string/all_okay"
android:textColor="?white_text"
android:textAppearance="@style/TextAppearance.Hmh.TitleMedium"
android:textColor="?white_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion feature/onboarding/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<string name="onboarding_done_sing_up_image">celebrate sign up image</string>
<string name="onboarding_done_sing_up_title">νšŒμ›κ°€μž… μ™„λ£Œ</string>
<string name="onboarding_done_sing_up_description">이제 ν•˜λ©΄ν•¨μ—μ„œ λΈ”λž™ν™€ νƒˆμΆœμ„ μœ„ν•œ\n여정을 μ‹œμž‘ν•΄ λ³ΌκΉŒμš”?</string>
<string name="all_okay">확인</string>
<string name="onboarding_select_data_question">ν•˜λ£¨ 평균 νœ΄λŒ€ν°μ„ \nμ–Όλ§ˆλ‚˜ μ‚¬μš©ν•˜μ‹œλ‚˜μš”?</string>
<string name="onboarding_select_data_description">ν•΄λ‹Ή 문항은 μ΅œλŒ€ 2κ°œκΉŒμ§€ 선택할 수 μžˆμ–΄μš”</string>
<string name="success_accessibility_settings">μ ‘κ·Όμ„± ν—ˆμš©μ΄ μŠΉμΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€</string>
Expand Down

0 comments on commit b81b477

Please sign in to comment.