fix(gift): 선물 상세 상태 표시를 보정한다
This commit is contained in:
@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.v2.gift
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@@ -96,6 +97,8 @@ class GiftDetailActivity : BaseActivity<ActivityGiftDetailBinding>(ActivityGiftD
|
|||||||
updateRecipientForm()
|
updateRecipientForm()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cbTerms.setRequiredLink(::onTermsRequiredClick)
|
||||||
|
cbPrivacy.setRequiredLink(::onPrivacyRequiredClick)
|
||||||
btnPostcodeSearch.setOnClickListener {
|
btnPostcodeSearch.setOnClickListener {
|
||||||
postcodeLauncher.launch(KakaoPostcodeSearchActivity.newIntent(this@GiftDetailActivity))
|
postcodeLauncher.launch(KakaoPostcodeSearchActivity.newIntent(this@GiftDetailActivity))
|
||||||
}
|
}
|
||||||
@@ -128,6 +131,10 @@ class GiftDetailActivity : BaseActivity<ActivityGiftDetailBinding>(ActivityGiftD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onTermsRequiredClick() = openGiftAgreementPage()
|
||||||
|
|
||||||
|
private fun onPrivacyRequiredClick() = openGiftAgreementPage()
|
||||||
|
|
||||||
private fun updateRecipientForm() = with(binding) {
|
private fun updateRecipientForm() = with(binding) {
|
||||||
if (bindingRecipientForm) return
|
if (bindingRecipientForm) return
|
||||||
recipientViewModel.updateForm(
|
recipientViewModel.updateForm(
|
||||||
@@ -263,19 +270,14 @@ class GiftDetailActivity : BaseActivity<ActivityGiftDetailBinding>(ActivityGiftD
|
|||||||
if (received) binding.header.text = ""
|
if (received) binding.header.text = ""
|
||||||
binding.btnBack.isVisible = !received
|
binding.btnBack.isVisible = !received
|
||||||
binding.close.isVisible = received
|
binding.close.isVisible = received
|
||||||
binding.heroChip.bindText(model.hero.chip)
|
val badge = model.hero.badge
|
||||||
binding.heroChip.setTextColor(
|
binding.heroChip.bindText(badge?.label)
|
||||||
getColor(
|
badge?.style?.let { style ->
|
||||||
when {
|
binding.heroChip.setTextColor(getColor(style.textColor))
|
||||||
canceled -> R.color.gray_400
|
binding.heroChip.backgroundTintList = ColorStateList.valueOf(getColor(style.backgroundColor))
|
||||||
undeliverable -> R.color.red_400
|
}
|
||||||
else -> R.color.soda_400
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
binding.heroTitle.bindText(model.hero.title)
|
binding.heroTitle.bindText(model.hero.title)
|
||||||
binding.heroBody.bindText(model.hero.body)
|
binding.heroBody.bindText(model.hero.body)
|
||||||
binding.heroIllustration.isVisible = model.showProgress
|
|
||||||
binding.timeline.isVisible = model.showProgress
|
binding.timeline.isVisible = model.showProgress
|
||||||
timelineAdapter.submitList(model.progressSegments)
|
timelineAdapter.submitList(model.progressSegments)
|
||||||
binding.cancel.isVisible = GiftDetailAction.CANCEL in model.actions
|
binding.cancel.isVisible = GiftDetailAction.CANCEL in model.actions
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package kr.co.vividnext.sodalive.v2.gift
|
package kr.co.vividnext.sodalive.v2.gift
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.R
|
||||||
|
|
||||||
sealed interface GiftDetailText {
|
sealed interface GiftDetailText {
|
||||||
enum class Key : GiftDetailText {
|
enum class Key : GiftDetailText {
|
||||||
RECEIVED_LABEL,
|
RECEIVED_LABEL,
|
||||||
@@ -48,7 +50,27 @@ data class GiftDetailUiModel(
|
|||||||
val received: GiftDetailReceived?
|
val received: GiftDetailReceived?
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GiftDetailHero(val chip: GiftDetailText?, val title: GiftDetailText, val body: GiftDetailText?)
|
data class GiftDetailHero(val chip: GiftDetailText?, val title: GiftDetailText, val body: GiftDetailText?) {
|
||||||
|
val badge: GiftDetailBadge?
|
||||||
|
get() = chip?.let { label ->
|
||||||
|
GiftDetailBadge(
|
||||||
|
label,
|
||||||
|
when (label) {
|
||||||
|
GiftDetailText.Key.UNDELIVERABLE_LABEL -> GiftDetailBadgeStyle.UNDELIVERABLE
|
||||||
|
GiftDetailText.Key.CANCELED_LABEL -> GiftDetailBadgeStyle.CANCELED
|
||||||
|
else -> GiftDetailBadgeStyle.NORMAL
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class GiftDetailBadge(val label: GiftDetailText, val style: GiftDetailBadgeStyle)
|
||||||
|
|
||||||
|
enum class GiftDetailBadgeStyle(val backgroundColor: Int, val textColor: Int) {
|
||||||
|
NORMAL(R.color.white, R.color.black),
|
||||||
|
UNDELIVERABLE(R.color.red_400, R.color.black),
|
||||||
|
CANCELED(R.color.gray_700, R.color.white)
|
||||||
|
}
|
||||||
|
|
||||||
data class GiftDetailInfoRow(val label: Int, val value: GiftDetailText)
|
data class GiftDetailInfoRow(val label: Int, val value: GiftDetailText)
|
||||||
|
|
||||||
|
|||||||
@@ -63,13 +63,6 @@
|
|||||||
android:text="@string/gift_recipient_privacy_notice"
|
android:text="@string/gift_recipient_privacy_notice"
|
||||||
android:textColor="@color/gray_300"
|
android:textColor="@color/gray_300"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
<ImageView
|
|
||||||
android:id="@+id/hero_illustration"
|
|
||||||
android:layout_width="@dimen/spacing_48"
|
|
||||||
android:layout_height="@dimen/spacing_48"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:src="@drawable/ic_gift_inbox_present" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/hero_chip"
|
android:id="@+id/hero_chip"
|
||||||
style="@style/Typography.Body5"
|
style="@style/Typography.Body5"
|
||||||
|
|||||||
@@ -35,6 +35,41 @@ class GiftDetailPresenterTest {
|
|||||||
@After
|
@After
|
||||||
fun tearDown() { TimeZone.setDefault(originalTimeZone) }
|
fun tearDown() { TimeZone.setDefault(originalTimeZone) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `상태 배지는 일반 흰검 전달불가 빨검 취소 회흰 presentation을 선택한다`() {
|
||||||
|
val styles = mapOf(
|
||||||
|
"TRACKING_REGISTERED" to GiftDetailBadgeStyle.NORMAL,
|
||||||
|
"ARRIVED_AT_MAILBOX" to GiftDetailBadgeStyle.NORMAL,
|
||||||
|
"INSPECTION_COMPLETED" to GiftDetailBadgeStyle.NORMAL,
|
||||||
|
"DELIVERED" to GiftDetailBadgeStyle.NORMAL,
|
||||||
|
"UNDELIVERABLE" to GiftDetailBadgeStyle.UNDELIVERABLE,
|
||||||
|
"CANCELED" to GiftDetailBadgeStyle.CANCELED
|
||||||
|
)
|
||||||
|
styles.forEach { (status, style) ->
|
||||||
|
assertEquals(status, style, present(status).hero.badge?.style)
|
||||||
|
}
|
||||||
|
assertEquals(R.color.white, GiftDetailBadgeStyle.NORMAL.backgroundColor)
|
||||||
|
assertEquals(R.color.black, GiftDetailBadgeStyle.NORMAL.textColor)
|
||||||
|
assertEquals(R.color.red_400, GiftDetailBadgeStyle.UNDELIVERABLE.backgroundColor)
|
||||||
|
assertEquals(R.color.black, GiftDetailBadgeStyle.UNDELIVERABLE.textColor)
|
||||||
|
assertEquals(R.color.gray_700, GiftDetailBadgeStyle.CANCELED.backgroundColor)
|
||||||
|
assertEquals(R.color.white, GiftDetailBadgeStyle.CANCELED.textColor)
|
||||||
|
listOf("DELIVERED", "UNDELIVERABLE", "CANCELED").forEach { status ->
|
||||||
|
val hero = GiftDetailPresenter.present(receivedDetail(status)).hero
|
||||||
|
assertEquals(styles.getValue(status), hero.badge?.style)
|
||||||
|
assertEquals(hero.chip, hero.badge?.label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `라벨이 없는 접수 미지원 배송지 입력과 입력완료는 배지 모델이 없다`() {
|
||||||
|
listOf("RECEIVED", "FUTURE").forEach { assertNull(present(it).hero.badge) }
|
||||||
|
assertNull(GiftDetailPresenter.present(receivedDetail(recipientAddressRequired = true)).hero.badge)
|
||||||
|
normalStates.drop(1).dropLast(1).forEach {
|
||||||
|
assertNull(GiftDetailPresenter.present(receivedDetail(it)).hero.badge)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `일곱 상태의 칩 제목 본문을 지역화 키로 매핑한다`() {
|
fun `일곱 상태의 칩 제목 본문을 지역화 키로 매핑한다`() {
|
||||||
val heroes = mapOf(
|
val heroes = mapOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user