From dae543b81eb08c4a23579b5fd828301e292b9112 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 05:45:17 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#76]=20=EA=B5=AC=EB=A7=A4=20=EC=95=BD?= =?UTF-8?q?=EA=B4=80=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/response/AddressInfoDto.kt | 6 ++-- .../entity/response/AddressInfoModel.kt | 2 +- .../buy/finished/BuyFinishedActivity.kt | 2 +- .../presentation/buy/info/BuyInfoActivity.kt | 2 +- .../buy/progress/BuyProgressActivity.kt | 32 ++++++++++++----- .../buy/progress/BuyProgressViewModel.kt | 34 +++++++++++++++++++ .../presentation/detail/OptionAdapter.kt | 2 +- .../presentation/detail/OptionBottomSheet.kt | 1 - .../presentation/detail/OptionViewHolder.kt | 6 ++-- .../sell/info/SellInfoActivity.kt | 2 +- .../main/res/layout/activity_buy_progress.xml | 25 +++++++++----- 11 files changed, 84 insertions(+), 30 deletions(-) diff --git a/data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt b/data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt index df8222ff..a6bcdd52 100644 --- a/data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt +++ b/data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt @@ -12,8 +12,8 @@ data class AddressInfoDto( val zipCode: String? = null, @SerialName("address") val address: String? = null, - @SerialName("phone") - val phone: String? = null, + @SerialName("recipientPhone") + val recipientPhone: String? = null, ) { - fun toModel() = AddressInfoModel(recipient, zipCode, address, phone) + fun toModel() = AddressInfoModel(recipient, zipCode, address, recipientPhone) } diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/AddressInfoModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/AddressInfoModel.kt index 309496c0..847905ca 100644 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/AddressInfoModel.kt +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/AddressInfoModel.kt @@ -4,5 +4,5 @@ data class AddressInfoModel( val recipient: String? = null, val zipCode: String? = null, val address: String? = null, - val phone: String? = null, + val recipientPhone: String? = null, ) diff --git a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt index 09e41e66..0d584e8f 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedActivity.kt @@ -69,7 +69,7 @@ class BuyFinishedActivity : item.addressInfo[0].zipCode, item.addressInfo[0].address, ).breakLines() - tvFinishedDeliveryPhone.text = item.addressInfo[0].phone + tvFinishedDeliveryPhone.text = item.addressInfo[0].recipientPhone tvFinishedTransactionMethod.text = item.paymentInfo[0].method tvFinishedTransactionDate.text = item.paymentInfo[0].completedAt tvFinishedPayMoney.text = item.originPrice.setNumberForm() diff --git a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt index 223e85e1..337a82d0 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoActivity.kt @@ -55,7 +55,7 @@ class BuyInfoActivity : item.addressInfo[0].zipCode, item.addressInfo[0].address, ).breakLines() - tvInfoDeliveryPhone.text = item.addressInfo[0].phone + tvInfoDeliveryPhone.text = item.addressInfo[0].recipientPhone tvInfoTransactionMethod.text = item.paymentInfo[0].method tvInfoTransactionDate.text = item.paymentInfo[0].completedAt tvInfoPayMoney.text = item.originPrice.setNumberForm() diff --git a/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt index 64840ef4..0ee22fee 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt @@ -12,8 +12,10 @@ import co.orange.core.extension.breakLines import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener import co.orange.core.extension.stringOf +import co.orange.core.extension.toPhoneFrom import co.orange.core.extension.toast import co.orange.core.state.UiState +import co.orange.domain.entity.response.AddressInfoModel import co.orange.domain.entity.response.BuyProgressModel import co.orange.presentation.buy.push.BuyPushActivity import co.orange.presentation.setting.delivery.DeliveryActivity @@ -33,6 +35,7 @@ class BuyProgressActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + binding.vm = viewModel initExitBtnListener() initDeliveryChangeBtnListener() initTermBtnListener() @@ -52,10 +55,15 @@ class BuyProgressActivity : } private fun initDeliveryChangeBtnListener() { - binding.btnChangeDelivery.setOnSingleClickListener { - Intent(this, DeliveryActivity::class.java).apply { - startActivity(this) - } + with(binding) { + btnChangeDelivery.setOnSingleClickListener { navigateToAddAddress() } + btnDeliveryAdd.setOnSingleClickListener { navigateToAddAddress() } + } + } + + private fun navigateToAddAddress() { + Intent(this, DeliveryActivity::class.java).apply { + startActivity(this) } } @@ -117,17 +125,23 @@ class BuyProgressActivity : tvConfirmPriceCharge.text = getString(R.string.add_plus, item.charge.setNumberForm()) tvConfirmPriceTotal.text = item.totalPrice.setNumberForm() - if (item.addressInfo.recipient != null) { + } + setAddress(item.addressInfo) + } + + private fun setAddress(address: AddressInfoModel) { + if (address.recipient != null) { + with(binding) { btnDeliveryAdd.isVisible = false layoutDeliveryItem.isVisible = true - tvDeliveryName.text = item.addressInfo.recipient + tvDeliveryName.text = address.recipient tvDeliveryAddress.text = getString( R.string.address_short_format, - item.addressInfo.zipCode, - item.addressInfo.address, + address.zipCode, + address.address, ).breakLines() - tvDeliveryPhone.text = item.addressInfo.phone + tvDeliveryPhone.text = address.recipientPhone?.toPhoneFrom() } } } diff --git a/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt index 6f11f20f..e4a13bd0 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt @@ -1,5 +1,6 @@ package co.orange.presentation.buy.progress +import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import co.orange.core.state.UiState @@ -19,16 +20,49 @@ class BuyProgressViewModel ) : ViewModel() { var productId: String = "" + var isTermAllSelected = MutableLiveData(false) + var isTermServiceSelected = MutableLiveData(false) + var isTermPurchaseSelected = MutableLiveData(false) + var isAddressSelected = false + var isMethodSelected = true + var isCompleted = MutableLiveData(false) + private val _getBuyProgressDataState = MutableStateFlow>(UiState.Empty) val getBuyProgressDataState: StateFlow> = _getBuyProgressDataState + fun checkAllTerm() { + isTermServiceSelected.value = isTermAllSelected.value?.not() + isTermPurchaseSelected.value = isTermAllSelected.value?.not() + isTermAllSelected.value = isTermAllSelected.value?.not() + checkIsCompleted() + } + + fun checkServiceTerm() { + isTermServiceSelected.value = isTermServiceSelected.value?.not() + checkIsCompleted() + } + + fun checkPurchaseTerm() { + isTermPurchaseSelected.value = isTermPurchaseSelected.value?.not() + checkIsCompleted() + } + + private fun checkIsCompleted() { + isTermAllSelected.value = + (isTermServiceSelected.value == true && isTermPurchaseSelected.value == true) + isCompleted.value = + (isTermServiceSelected.value == true && isTermPurchaseSelected.value == true && isAddressSelected && isMethodSelected) + } + fun getBuyProgressDataFromServer() { _getBuyProgressDataState.value = UiState.Loading viewModelScope.launch { // TODO μΆ”ν›„ productId ν™œμš© buyRepository.getBuyProgressData("0110055338") .onSuccess { + isAddressSelected = !it.addressInfo.address.isNullOrEmpty() + checkIsCompleted() _getBuyProgressDataState.value = UiState.Success(it) } .onFailure { diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt index f2cfcaac..a8f34689 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt @@ -8,7 +8,7 @@ import co.orange.domain.entity.response.ProductOptionModel import kr.genti.presentation.databinding.ItemOptionBinding class OptionAdapter( - private val itemClick: (Int, Long, Long) -> Unit, + private val itemClick: (Long, Long) -> Unit, ) : ListAdapter(diffUtil) { override fun onCreateViewHolder( parent: ViewGroup, diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt index f388da06..34e9b54f 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt @@ -80,7 +80,6 @@ class OptionBottomSheet : } private fun initItemClickListener( - position: Int, optionId: Long, optionDetailId: Long, ) { diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt index 21180039..0a226bb5 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt @@ -7,17 +7,15 @@ import kr.genti.presentation.databinding.ItemOptionBinding class OptionViewHolder( val binding: ItemOptionBinding, - private val itemClick: (Int, Long, Long) -> Unit, + private val itemClick: (Long, Long) -> Unit, ) : RecyclerView.ViewHolder(binding.root) { var selectedItemId: Long = -1 - var selectedPosition: Int = -1 fun onBind( item: ProductOptionModel, position: Int, ) { selectedItemId = item.optionId - selectedPosition = position with(binding) { tvOptionItemTitle.text = item.type tvOptionItemTitle.setOnClickListener { @@ -34,6 +32,6 @@ class OptionViewHolder( } private fun initItemClickListener(optionDetailId: Long) { - itemClick(selectedPosition, selectedItemId, optionDetailId) + itemClick(selectedItemId, optionDetailId) } } diff --git a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt index 04e000aa..5ab27f12 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoActivity.kt @@ -55,7 +55,7 @@ class SellInfoActivity : item.addressInfo[0].zipCode, item.addressInfo[0].address, ).breakLines() - tvInfoDeliveryPhone.text = item.addressInfo[0].phone + tvInfoDeliveryPhone.text = item.addressInfo[0].recipientPhone tvInfoTransactionMethod.text = item.paymentInfo[0].method tvInfoTransactionDate.text = item.paymentInfo[0].completedAt tvInfoPayKakao.text = item.originPrice.setNumberForm() diff --git a/presentation/src/main/res/layout/activity_buy_progress.xml b/presentation/src/main/res/layout/activity_buy_progress.xml index e5155abe..4fcaab1c 100644 --- a/presentation/src/main/res/layout/activity_buy_progress.xml +++ b/presentation/src/main/res/layout/activity_buy_progress.xml @@ -5,6 +5,11 @@ + + + + android:src="@{vm.isTermAllSelected ? @drawable/ic_check_circle_filled : @drawable/ic_check_circle_unfilled}" /> + android:src="@{vm.isTermServiceSelected ? @drawable/ic_check_term_selected : @drawable/ic_check_term_unselected}" /> + android:textColor="@{vm.isTermServiceSelected ? @color/black : @color/gray_2}" /> @@ -403,8 +410,9 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:background="@drawable/shape_gray1_line_5_rect" + android:background="@{vm.isTermPurchaseSelected ? @drawable/shape_black_line_5_rect : @drawable/shape_gray1_line_5_rect}" android:gravity="center_vertical" + android:onClick="@{() -> vm.checkPurchaseTerm()}" android:orientation="horizontal" android:padding="11dp" app:layout_constraintEnd_toEndOf="parent" @@ -415,7 +423,7 @@ android:id="@+id/iv_buy_term_purchase" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/sel_check_term" /> + android:src="@{vm.isTermPurchaseSelected ? @drawable/ic_check_term_selected : @drawable/ic_check_term_unselected}" /> + android:textColor="@{vm.isTermPurchaseSelected ? @color/black : @color/gray_2}" /> @@ -459,7 +467,8 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="20dp" android:layout_marginBottom="30dp" - android:background="@drawable/shape_black_fill_10_rect" + android:background="@drawable/sel_btn" + android:enabled="@{vm.isCompleted}" android:gravity="center" android:paddingVertical="15dp" android:text="@string/buy_confirm_tv_title"