From d430f0a8312b692871195cc72e2cdfbf45eb1188 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 01:53:30 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[FIX/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=95=BD=EA=B4=80=20=EA=B5=AC=EC=84=B1=EC=9A=94=EC=86=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/activity_buy_confirm.xml | 48 +++++-------------- presentation/src/main/res/values/strings.xml | 2 + 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/presentation/src/main/res/layout/activity_buy_confirm.xml b/presentation/src/main/res/layout/activity_buy_confirm.xml index 45db86fd..5f211c8f 100644 --- a/presentation/src/main/res/layout/activity_buy_confirm.xml +++ b/presentation/src/main/res/layout/activity_buy_confirm.xml @@ -293,7 +293,7 @@ + android:text="@string/confirm_term_tv_first" + android:textColor="@color/gray_2" /> + app:layout_constraintTop_toBottomOf="@id/btn_term_service"> - - - - - - - - + android:text="@string/confirm_term_tv_second" + android:textColor="@color/gray_2" /> @@ -380,7 +356,7 @@ android:layout_height="50dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/btn_term_third" /> + app:layout_constraintTop_toBottomOf="@id/btn_term_purchase" /> diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index d483850b..d67debdf 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -132,6 +132,8 @@ 수수료 결제 금액 아래 약관에 전체동의해요 + 서비스 이용 약관 (필수) + 딴지 구매 가이드 (필수) 판매하기 상품명 카카오톡 선물하기 가격 From 3f6f7123d439a6eb3d580d5f5cd50ffdc39d9253 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 02:07:44 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[FIX/#76]=20=EA=B5=AC=EB=A7=A4,=20?= =?UTF-8?q?=ED=8C=90=EB=A7=A4=20=EC=A7=84=ED=96=89=EB=B7=B0=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 ++-- .../BuyProgressActivity.kt} | 16 ++++++++-------- .../BuyProgressViewModel.kt} | 4 ++-- .../orange/presentation/detail/DetailActivity.kt | 4 ++-- .../presentation/detail/OptionBottomSheet.kt | 4 ++-- .../presentation/main/home/SellProductDialog.kt | 4 ++-- .../SellProgressActivity.kt} | 12 ++++++------ .../SellProgressViewModel.kt} | 4 ++-- ...buy_confirm.xml => activity_buy_progress.xml} | 0 ...ll_confirm.xml => activity_sell_progress.xml} | 0 10 files changed, 26 insertions(+), 26 deletions(-) rename presentation/src/main/java/co/orange/presentation/buy/{confirm/BuyConfirmActivity.kt => progress/BuyProgressActivity.kt} (83%) rename presentation/src/main/java/co/orange/presentation/buy/{confirm/BuyConfirmViewModel.kt => progress/BuyProgressViewModel.kt} (93%) rename presentation/src/main/java/co/orange/presentation/sell/{confirm/SellConfirmActivity.kt => progress/SellProgressActivity.kt} (86%) rename presentation/src/main/java/co/orange/presentation/sell/{confirm/SellConfirmViewModel.kt => progress/SellProgressViewModel.kt} (87%) rename presentation/src/main/res/layout/{activity_buy_confirm.xml => activity_buy_progress.xml} (100%) rename presentation/src/main/res/layout/{activity_sell_confirm.xml => activity_sell_progress.xml} (100%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2976150a..e547ba90 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,7 +38,7 @@ android:screenOrientation="portrait" /> @@ -83,7 +83,7 @@ android:screenOrientation="portrait" /> diff --git a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt similarity index 83% rename from presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt rename to presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt index 31194d6f..d2be1d26 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressActivity.kt @@ -1,4 +1,4 @@ -package co.orange.presentation.buy.confirm +package co.orange.presentation.buy.progress import android.content.Context import android.content.Intent @@ -12,11 +12,12 @@ import co.orange.presentation.buy.push.BuyPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R -import kr.genti.presentation.databinding.ActivityBuyConfirmBinding +import kr.genti.presentation.databinding.ActivityBuyProgressBinding @AndroidEntryPoint -class BuyConfirmActivity : BaseActivity(R.layout.activity_buy_confirm) { - private val viewModel by viewModels() +class BuyProgressActivity : + BaseActivity(R.layout.activity_buy_progress) { + private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -41,9 +42,8 @@ class BuyConfirmActivity : BaseActivity(R.layout.acti private fun initTermBtnListener() { // TODO binding.btnTermAll.setOnSingleClickListener { } - binding.btnTermFirst.setOnSingleClickListener { } - binding.btnTermSecond.setOnSingleClickListener { } - binding.btnTermThird.setOnSingleClickListener { } + binding.btnTermService.setOnSingleClickListener { } + binding.btnTermPurchase.setOnSingleClickListener { } } private fun initConfirmBtnListener() { @@ -81,7 +81,7 @@ class BuyConfirmActivity : BaseActivity(R.layout.acti context: Context, productId: String, ): Intent = - Intent(context, BuyConfirmActivity::class.java).apply { + Intent(context, BuyProgressActivity::class.java).apply { putExtra(EXTRA_PRODUCT_ID, productId) } } diff --git a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmViewModel.kt b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt similarity index 93% rename from presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmViewModel.kt rename to presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt index 9764621a..bb066cb6 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/confirm/BuyConfirmViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/progress/BuyProgressViewModel.kt @@ -1,4 +1,4 @@ -package co.orange.presentation.buy.confirm +package co.orange.presentation.buy.progress import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.AddressInfoModel @@ -7,7 +7,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel -class BuyConfirmViewModel +class BuyProgressViewModel @Inject constructor( // private val feedRepository: FeedRepository, diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt index 6dee150a..ce784fd0 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt @@ -20,7 +20,7 @@ import co.orange.core.extension.toast import co.orange.core.state.UiState import co.orange.domain.entity.response.ProductDetailModel import co.orange.presentation.auth.login.LoginActivity -import co.orange.presentation.buy.confirm.BuyConfirmActivity +import co.orange.presentation.buy.progress.BuyProgressActivity import coil.load import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay @@ -78,7 +78,7 @@ class DetailActivity : BaseActivity(R.layout.activity_det return@setOnSingleClickListener } if (viewModel.optionList.isEmpty()) { - BuyConfirmActivity.createIntent( + BuyProgressActivity.createIntent( this, viewModel.productId, ).apply { startActivity(this) } 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 ee9445b8..f388da06 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt @@ -10,7 +10,7 @@ import androidx.lifecycle.lifecycleScope import co.orange.core.base.BaseBottomSheet import co.orange.core.extension.setOnSingleClickListener import co.orange.core.extension.setOverThousand -import co.orange.presentation.buy.confirm.BuyConfirmActivity +import co.orange.presentation.buy.progress.BuyProgressActivity import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -56,7 +56,7 @@ class OptionBottomSheet : private fun initPurchaseBtnListener() { binding.btnPurchase.setOnSingleClickListener { // TODO 버튼 활성화 설정 - BuyConfirmActivity.createIntent( + BuyProgressActivity.createIntent( requireContext(), viewModel.productId, ).apply { diff --git a/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt b/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt index cfb399a9..e216bcd8 100644 --- a/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt +++ b/presentation/src/main/java/co/orange/presentation/main/home/SellProductDialog.kt @@ -6,7 +6,7 @@ import android.view.WindowManager import androidx.fragment.app.activityViewModels import co.orange.core.base.BaseDialog import co.orange.core.extension.setOnSingleClickListener -import co.orange.presentation.sell.confirm.SellConfirmActivity +import co.orange.presentation.sell.progress.SellProgressActivity import coil.load import kr.genti.presentation.R import kr.genti.presentation.databinding.DialogSellProductBinding @@ -45,7 +45,7 @@ class SellProductDialog : private fun initConfirmBtnListener() { binding.btnSubmit.setOnSingleClickListener { // TODO intent값 수정 - SellConfirmActivity.createIntent(requireContext(), -1).apply { + SellProgressActivity.createIntent(requireContext(), -1).apply { startActivity(this) } dismiss() diff --git a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressActivity.kt similarity index 86% rename from presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt rename to presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressActivity.kt index dbde2836..fb144b75 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressActivity.kt @@ -1,4 +1,4 @@ -package co.orange.presentation.sell.confirm +package co.orange.presentation.sell.progress import android.content.Context import android.content.Intent @@ -12,12 +12,12 @@ import co.orange.presentation.sell.push.SellPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R -import kr.genti.presentation.databinding.ActivitySellConfirmBinding +import kr.genti.presentation.databinding.ActivitySellProgressBinding @AndroidEntryPoint -class SellConfirmActivity : - BaseActivity(R.layout.activity_sell_confirm) { - private val viewModel by viewModels() +class SellProgressActivity : + BaseActivity(R.layout.activity_sell_progress) { + private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -78,7 +78,7 @@ class SellConfirmActivity : context: Context, productId: Long, ): Intent = - Intent(context, SellConfirmActivity::class.java).apply { + Intent(context, SellProgressActivity::class.java).apply { putExtra(EXTRA_PRODUCT_ID, productId) } } diff --git a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmViewModel.kt b/presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressViewModel.kt similarity index 87% rename from presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmViewModel.kt rename to presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressViewModel.kt index 2f4b4b3b..5b228538 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/confirm/SellConfirmViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/progress/SellProgressViewModel.kt @@ -1,4 +1,4 @@ -package co.orange.presentation.sell.confirm +package co.orange.presentation.sell.progress import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.SellProductModel @@ -6,7 +6,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel -class SellConfirmViewModel +class SellProgressViewModel @Inject constructor( // private val feedRepository: FeedRepository, diff --git a/presentation/src/main/res/layout/activity_buy_confirm.xml b/presentation/src/main/res/layout/activity_buy_progress.xml similarity index 100% rename from presentation/src/main/res/layout/activity_buy_confirm.xml rename to presentation/src/main/res/layout/activity_buy_progress.xml diff --git a/presentation/src/main/res/layout/activity_sell_confirm.xml b/presentation/src/main/res/layout/activity_sell_progress.xml similarity index 100% rename from presentation/src/main/res/layout/activity_sell_confirm.xml rename to presentation/src/main/res/layout/activity_sell_progress.xml From f743ca7c31c6692a9d1dc0eec2214a1a8ba325bd Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 02:31:15 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[ADD/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=ED=99=95=EC=9D=B8=20API=20domain=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/entity/response/BuyInfoModel.kt | 8 +++++++- .../{BuyDetailModel.kt => BuyProgressModel.kt} | 11 +++-------- .../domain/entity/response/SellDetailModel.kt | 18 ------------------ .../domain/entity/response/SellInfoModel.kt | 11 +++++++++++ .../entity/response/SellProgressModel.kt | 7 +++++++ .../orange/domain/repository/BuyRepository.kt | 7 +++++++ .../buy/finished/BuyFinishedActivity.kt | 4 ++-- .../buy/finished/BuyFinishedViewModel.kt | 4 ++-- .../presentation/buy/info/BuyInfoActivity.kt | 4 ++-- .../presentation/buy/info/BuyInfoViewModel.kt | 4 ++-- .../buy/progress/BuyProgressActivity.kt | 4 ++-- .../buy/progress/BuyProgressViewModel.kt | 4 ++-- .../sell/finished/SellFinishedActivity.kt | 4 ++-- .../sell/finished/SellFinishedViewModel.kt | 4 ++-- .../presentation/sell/info/SellInfoActivity.kt | 4 ++-- .../sell/info/SellInfoViewModel.kt | 4 ++-- 16 files changed, 55 insertions(+), 47 deletions(-) rename domain/src/main/kotlin/co/orange/domain/entity/response/{BuyDetailModel.kt => BuyProgressModel.kt} (53%) delete mode 100644 domain/src/main/kotlin/co/orange/domain/entity/response/SellDetailModel.kt create mode 100644 domain/src/main/kotlin/co/orange/domain/entity/response/SellProgressModel.kt create mode 100644 domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyInfoModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyInfoModel.kt index 42404921..c35109cb 100644 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyInfoModel.kt +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyInfoModel.kt @@ -1,11 +1,17 @@ package co.orange.domain.entity.response +import co.orange.domain.enums.OrderStatus + data class BuyInfoModel( + val orderId: String, + val orderStatus: OrderStatus, val productName: String, val imgUrl: String, val originPrice: Int, + val sellerNickname: String, val addressInfo: List, + val paymentInfo: List, val discountPrice: Int, val charge: Int, val totalPrice: Int, -) \ No newline at end of file +) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyDetailModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt similarity index 53% rename from domain/src/main/kotlin/co/orange/domain/entity/response/BuyDetailModel.kt rename to domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt index b38662e8..d2c7af44 100644 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyDetailModel.kt +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt @@ -1,17 +1,12 @@ package co.orange.domain.entity.response -import co.orange.domain.enums.OrderStatus - -data class BuyDetailModel( - val orderId: String, - val orderStatus: OrderStatus, +data class BuyProgressModel( + val itemId: String, val productName: String, val imgUrl: String, val originPrice: Int, - val sellerNickname: String, val addressInfo: List, - val paymentInfo: List, val discountPrice: Int, val charge: Int, val totalPrice: Int, -) \ No newline at end of file +) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/SellDetailModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/SellDetailModel.kt deleted file mode 100644 index a4cce85f..00000000 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/SellDetailModel.kt +++ /dev/null @@ -1,18 +0,0 @@ -package co.orange.domain.entity.response - -import co.orange.domain.enums.ItemStatus -import co.orange.domain.enums.OrderStatus - -data class SellDetailModel( - val itemId: String, - val itemStatus: ItemStatus, - val productName: String, - val imgUrl: String, - val originPrice: Int, - val salePrice: Int, - val orderId: String, - val orderStatus: OrderStatus, - val buyerNickname: String, - val addressInfo: List, - val paymentInfo: List, -) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/SellInfoModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/SellInfoModel.kt index e307709f..dc8dccc1 100644 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/SellInfoModel.kt +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/SellInfoModel.kt @@ -1,7 +1,18 @@ package co.orange.domain.entity.response +import co.orange.domain.enums.ItemStatus +import co.orange.domain.enums.OrderStatus + data class SellInfoModel( val itemId: String, + val itemStatus: ItemStatus, val productName: String, + val imgUrl: String, val originPrice: Int, + val salePrice: Int, + val orderId: String, + val orderStatus: OrderStatus, + val buyerNickname: String, + val addressInfo: List, + val paymentInfo: List, ) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/SellProgressModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/SellProgressModel.kt new file mode 100644 index 00000000..154e67ab --- /dev/null +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/SellProgressModel.kt @@ -0,0 +1,7 @@ +package co.orange.domain.entity.response + +data class SellProgressModel( + val itemId: String, + val productName: String, + val originPrice: Int, +) diff --git a/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt b/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt new file mode 100644 index 00000000..64e9626f --- /dev/null +++ b/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt @@ -0,0 +1,7 @@ +package co.orange.domain.repository + +import co.orange.domain.entity.response.BuyProgressModel + +interface BuyRepository { + suspend fun getButProgressData(productId: String): Result +} 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 c15b43a2..09e41e66 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 @@ -8,7 +8,7 @@ import co.orange.core.base.BaseActivity import co.orange.core.extension.breakLines import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener -import co.orange.domain.entity.response.BuyDetailModel +import co.orange.domain.entity.response.BuyInfoModel import co.orange.presentation.buy.info.BuyInfoActivity import co.orange.presentation.main.MainActivity import coil.load @@ -55,7 +55,7 @@ class BuyFinishedActivity : viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() } - private fun setIntentUi(item: BuyDetailModel) { + private fun setIntentUi(item: BuyInfoModel) { with(binding) { tvFinishedTransaction.text = getString(R.string.transaction_id, item.orderId).breakLines() diff --git a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedViewModel.kt b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedViewModel.kt index 01aed439..d71b202f 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/finished/BuyFinishedViewModel.kt @@ -2,7 +2,7 @@ package co.orange.presentation.buy.finished import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.AddressInfoModel -import co.orange.domain.entity.response.BuyDetailModel +import co.orange.domain.entity.response.BuyInfoModel import co.orange.domain.entity.response.PaymentInfoModel import co.orange.domain.enums.OrderStatus import dagger.hilt.android.lifecycle.HiltViewModel @@ -17,7 +17,7 @@ class BuyFinishedViewModel var productId: String = "" val mockBuyInfo = - BuyDetailModel( + BuyInfoModel( "123e4567-e89b-12d3-a456-426614174000", OrderStatus.ORDER_PLACED, "상품이름은 한줄로만 보여줄거에야야야야야야", 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 4b396a18..223e85e1 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 @@ -8,7 +8,7 @@ import co.orange.core.base.BaseActivity import co.orange.core.extension.breakLines import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener -import co.orange.domain.entity.response.BuyDetailModel +import co.orange.domain.entity.response.BuyInfoModel import coil.load import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R @@ -41,7 +41,7 @@ class BuyInfoActivity : viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() } - private fun setIntentUi(item: BuyDetailModel) { + private fun setIntentUi(item: BuyInfoModel) { with(binding) { tvInfoTransaction.text = getString(R.string.transaction_id, item.orderId).breakLines() ivInfoProduct.load(item.imgUrl) diff --git a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoViewModel.kt b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoViewModel.kt index 147e9660..0cd6cdd6 100644 --- a/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/buy/info/BuyInfoViewModel.kt @@ -2,7 +2,7 @@ package co.orange.presentation.buy.info import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.AddressInfoModel -import co.orange.domain.entity.response.BuyDetailModel +import co.orange.domain.entity.response.BuyInfoModel import co.orange.domain.entity.response.PaymentInfoModel import co.orange.domain.enums.OrderStatus import dagger.hilt.android.lifecycle.HiltViewModel @@ -17,7 +17,7 @@ class BuyInfoViewModel var productId: String = "" val mockBuyInfo = - BuyDetailModel( + BuyInfoModel( "123e4567-e89b-12d3-a456-426614174000", OrderStatus.ORDER_PLACED, "상품이름은 한줄로만 보여줄거에야야야야야야", 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 d2be1d26..e34356cf 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 @@ -7,7 +7,7 @@ import androidx.activity.viewModels import co.orange.core.base.BaseActivity import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener -import co.orange.domain.entity.response.BuyInfoModel +import co.orange.domain.entity.response.BuyProgressModel import co.orange.presentation.buy.push.BuyPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint @@ -59,7 +59,7 @@ class BuyProgressActivity : viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() } - private fun setIntentUi(item: BuyInfoModel) { + private fun setIntentUi(item: BuyProgressModel) { with(binding) { tvConfirmProductName.text = item.productName ivConfirmProduct.load(item.imgUrl) 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 bb066cb6..2e36d3fc 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 @@ -2,7 +2,7 @@ package co.orange.presentation.buy.progress import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.AddressInfoModel -import co.orange.domain.entity.response.BuyInfoModel +import co.orange.domain.entity.response.BuyProgressModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -15,7 +15,7 @@ class BuyProgressViewModel var productId: String = "" val mockBuyInfo = - BuyInfoModel( + BuyProgressModel( "상품이름은 한줄로만 보여줄거에야야야야야야", "https://github.com/Marchbreeze/Marchbreeze/assets/97405341/cd2c0454-92b4-41e7-ae2f-319f83e2426f", 24000, diff --git a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt index d0791fa2..b8eae451 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedActivity.kt @@ -7,7 +7,7 @@ import androidx.activity.viewModels import co.orange.core.base.BaseActivity import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener -import co.orange.domain.entity.response.SellInfoModel +import co.orange.domain.entity.response.SellProgressModel import co.orange.presentation.main.MainActivity import co.orange.presentation.sell.info.SellInfoActivity import coil.load @@ -58,7 +58,7 @@ class SellFinishedActivity : viewModel.itemId = intent.getLongExtra(EXTRA_ITEM_ID, -1) } - private fun setIntentUi(item: SellInfoModel) { + private fun setIntentUi(item: SellProgressModel) { with(binding) { // TODO 이미지 설정 ivFinishedItem.load(R.drawable.mock_img_product) diff --git a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedViewModel.kt b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedViewModel.kt index 92b5e20c..8258d06e 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/finished/SellFinishedViewModel.kt @@ -1,7 +1,7 @@ package co.orange.presentation.sell.finished import androidx.lifecycle.ViewModel -import co.orange.domain.entity.response.SellInfoModel +import co.orange.domain.entity.response.SellProgressModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -14,7 +14,7 @@ class SellFinishedViewModel var itemId: Long = -1 val mockSellInfo = - SellInfoModel( + SellProgressModel( "123e4567-e89b-12d3-a456-426614174000", "딴지 키링 세트", 9000, 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 5b796d56..04e000aa 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 @@ -8,7 +8,7 @@ import co.orange.core.base.BaseActivity import co.orange.core.extension.breakLines import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener -import co.orange.domain.entity.response.SellDetailModel +import co.orange.domain.entity.response.SellInfoModel import coil.load import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R @@ -41,7 +41,7 @@ class SellInfoActivity : viewModel.productId = intent.getLongExtra(EXTRA_PRODUCT_ID, -1) } - private fun setIntentUi(item: SellDetailModel) { + private fun setIntentUi(item: SellInfoModel) { with(binding) { tvInfoTransaction.text = getString(R.string.transaction_id, item.orderId).breakLines() ivInfoProduct.load(item.imgUrl) diff --git a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoViewModel.kt b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoViewModel.kt index 5df78515..abcdbe7e 100644 --- a/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/sell/info/SellInfoViewModel.kt @@ -3,7 +3,7 @@ package co.orange.presentation.sell.info import androidx.lifecycle.ViewModel import co.orange.domain.entity.response.AddressInfoModel import co.orange.domain.entity.response.PaymentInfoModel -import co.orange.domain.entity.response.SellDetailModel +import co.orange.domain.entity.response.SellInfoModel import co.orange.domain.enums.ItemStatus import co.orange.domain.enums.OrderStatus import dagger.hilt.android.lifecycle.HiltViewModel @@ -18,7 +18,7 @@ class SellInfoViewModel var productId: Long = -1 val mockSellInfo = - SellDetailModel( + SellInfoModel( "1", ItemStatus.ON_SALE, "상품이름은 한줄로만 보여줄거에야야야야야야", From d0bb063c271e803b155342310ca0d7e362ba16c6 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 02:38:12 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[ADD/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=ED=99=95=EC=9D=B8=20API=20data=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orange/data/dataSource/BuyDataSource.kt | 8 ++++ .../data/dataSourceImpl/BuyDataSourceImpl.kt | 15 ++++++++ .../data/dto/response/AddressInfoDto.kt | 19 ++++++++++ .../data/dto/response/BuyProgressDto.kt | 37 +++++++++++++++++++ .../data/repositoryImpl/BuyRepositoryImpl.kt | 17 +++++++++ .../java/co/orange/data/service/BuyService.kt | 13 +++++++ .../orange/domain/repository/BuyRepository.kt | 2 +- 7 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 data/src/main/java/co/orange/data/dataSource/BuyDataSource.kt create mode 100644 data/src/main/java/co/orange/data/dataSourceImpl/BuyDataSourceImpl.kt create mode 100644 data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt create mode 100644 data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt create mode 100644 data/src/main/java/co/orange/data/repositoryImpl/BuyRepositoryImpl.kt create mode 100644 data/src/main/java/co/orange/data/service/BuyService.kt diff --git a/data/src/main/java/co/orange/data/dataSource/BuyDataSource.kt b/data/src/main/java/co/orange/data/dataSource/BuyDataSource.kt new file mode 100644 index 00000000..ef435f91 --- /dev/null +++ b/data/src/main/java/co/orange/data/dataSource/BuyDataSource.kt @@ -0,0 +1,8 @@ +package co.orange.data.dataSource + +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.response.BuyProgressDto + +interface BuyDataSource { + suspend fun getBuyProgressData(productId: String): BaseResponse +} diff --git a/data/src/main/java/co/orange/data/dataSourceImpl/BuyDataSourceImpl.kt b/data/src/main/java/co/orange/data/dataSourceImpl/BuyDataSourceImpl.kt new file mode 100644 index 00000000..ef2fa7f5 --- /dev/null +++ b/data/src/main/java/co/orange/data/dataSourceImpl/BuyDataSourceImpl.kt @@ -0,0 +1,15 @@ +package co.orange.data.dataSourceImpl + +import co.orange.data.dataSource.BuyDataSource +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.response.BuyProgressDto +import co.orange.data.service.BuyService +import javax.inject.Inject + +data class BuyDataSourceImpl + @Inject + constructor( + private val buyService: BuyService, + ) : BuyDataSource { + override suspend fun getBuyProgressData(productId: String): BaseResponse = buyService.getBuyProgressData(productId) + } 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 new file mode 100644 index 00000000..08294637 --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/response/AddressInfoDto.kt @@ -0,0 +1,19 @@ +package co.orange.data.dto.response + +import co.orange.domain.entity.response.AddressInfoModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class AddressInfoDto( + @SerialName("recipient") + val recipient: String, + @SerialName("zipCode") + val zipCode: String, + @SerialName("address") + val address: String, + @SerialName("phone") + val phone: String, +) { + fun toModel() = AddressInfoModel(recipient, zipCode, address, phone) +} diff --git a/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt b/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt new file mode 100644 index 00000000..8e7de0a5 --- /dev/null +++ b/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt @@ -0,0 +1,37 @@ +package co.orange.data.dto.response + +import co.orange.domain.entity.response.BuyProgressModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BuyProgressDto( + @SerialName("itemId") + val itemId: String, + @SerialName("productName") + val productName: String, + @SerialName("imgUrl") + val imgUrl: String, + @SerialName("originPrice") + val originPrice: Int, + @SerialName("addressInfo") + val addressInfo: List, + @SerialName("discountPrice") + val discountPrice: Int, + @SerialName("charge") + val charge: Int, + @SerialName("totalPrice") + val totalPrice: Int, +) { + fun toModel() = + BuyProgressModel( + itemId, + productName, + imgUrl, + originPrice, + addressInfo.map { it.toModel() }, + discountPrice, + charge, + totalPrice, + ) +} diff --git a/data/src/main/java/co/orange/data/repositoryImpl/BuyRepositoryImpl.kt b/data/src/main/java/co/orange/data/repositoryImpl/BuyRepositoryImpl.kt new file mode 100644 index 00000000..a27b650b --- /dev/null +++ b/data/src/main/java/co/orange/data/repositoryImpl/BuyRepositoryImpl.kt @@ -0,0 +1,17 @@ +package co.orange.data.repositoryImpl + +import co.orange.data.dataSource.BuyDataSource +import co.orange.domain.entity.response.BuyProgressModel +import co.orange.domain.repository.BuyRepository +import javax.inject.Inject + +class BuyRepositoryImpl + @Inject + constructor( + private val buyDataSource: BuyDataSource, + ) : BuyRepository { + override suspend fun getBuyProgressData(productId: String): Result = + runCatching { + buyDataSource.getBuyProgressData(productId).data.toModel() + } + } diff --git a/data/src/main/java/co/orange/data/service/BuyService.kt b/data/src/main/java/co/orange/data/service/BuyService.kt new file mode 100644 index 00000000..879f3572 --- /dev/null +++ b/data/src/main/java/co/orange/data/service/BuyService.kt @@ -0,0 +1,13 @@ +package co.orange.data.service + +import co.orange.data.dto.BaseResponse +import co.orange.data.dto.response.BuyProgressDto +import retrofit2.http.GET +import retrofit2.http.Path + +interface BuyService { + @GET("/api/v1/order/product/{id}") + suspend fun getBuyProgressData( + @Path("id") productId: String, + ): BaseResponse +} diff --git a/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt b/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt index 64e9626f..eb540e3d 100644 --- a/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt +++ b/domain/src/main/kotlin/co/orange/domain/repository/BuyRepository.kt @@ -3,5 +3,5 @@ package co.orange.domain.repository import co.orange.domain.entity.response.BuyProgressModel interface BuyRepository { - suspend fun getButProgressData(productId: String): Result + suspend fun getBuyProgressData(productId: String): Result } From 569477a2c7ced17709ac7063769bc2b3506f8543 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 02:50:16 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[ADD/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=ED=99=95=EC=9D=B8=20API=20di=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/co/orange/ddanzi/di/module/DataSourceModule.kt | 6 ++++++ .../java/co/orange/ddanzi/di/module/RepositoryModule.kt | 6 ++++++ .../java/co/orange/ddanzi/di/module/ServiceModule.kt | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/co/orange/ddanzi/di/module/DataSourceModule.kt b/app/src/main/java/co/orange/ddanzi/di/module/DataSourceModule.kt index b28370f3..dd6019ef 100644 --- a/app/src/main/java/co/orange/ddanzi/di/module/DataSourceModule.kt +++ b/app/src/main/java/co/orange/ddanzi/di/module/DataSourceModule.kt @@ -1,6 +1,7 @@ package co.orange.ddanzi.di.module import co.orange.data.dataSource.AuthDataSource +import co.orange.data.dataSource.BuyDataSource import co.orange.data.dataSource.DeviceDataSource import co.orange.data.dataSource.HomeDataSource import co.orange.data.dataSource.IamportDataSource @@ -9,6 +10,7 @@ import co.orange.data.dataSource.ProfileDataSource import co.orange.data.dataSource.SearchDataSource import co.orange.data.dataSource.SettingDataSource import co.orange.data.dataSourceImpl.AuthDataSourceImpl +import co.orange.data.dataSourceImpl.BuyDataSourceImpl import co.orange.data.dataSourceImpl.DeviceDataSourceImpl import co.orange.data.dataSourceImpl.HomeDataSourceImpl import co.orange.data.dataSourceImpl.IamportDataSourceImpl @@ -41,6 +43,10 @@ object DataSourceModule { @Singleton fun provideSearchDataSource(searchDataSourceImpl: SearchDataSourceImpl): SearchDataSource = searchDataSourceImpl + @Provides + @Singleton + fun provideBuyDataSource(buyDataSourceImpl: BuyDataSourceImpl): BuyDataSource = buyDataSourceImpl + @Provides @Singleton fun provideProfileDataSource(profileDataSourceImpl: ProfileDataSourceImpl): ProfileDataSource = profileDataSourceImpl diff --git a/app/src/main/java/co/orange/ddanzi/di/module/RepositoryModule.kt b/app/src/main/java/co/orange/ddanzi/di/module/RepositoryModule.kt index fb7e0c69..02ab132e 100644 --- a/app/src/main/java/co/orange/ddanzi/di/module/RepositoryModule.kt +++ b/app/src/main/java/co/orange/ddanzi/di/module/RepositoryModule.kt @@ -1,6 +1,7 @@ package co.orange.ddanzi.di.module import co.orange.data.repositoryImpl.AuthRepositoryImpl +import co.orange.data.repositoryImpl.BuyRepositoryImpl import co.orange.data.repositoryImpl.DeviceRepositoryImpl import co.orange.data.repositoryImpl.HomeRepositoryImpl import co.orange.data.repositoryImpl.IamportRepositoryImpl @@ -9,6 +10,7 @@ import co.orange.data.repositoryImpl.ProfileRepositoryImpl import co.orange.data.repositoryImpl.SearchRepositoryImpl import co.orange.data.repositoryImpl.SettingRepositoryImpl import co.orange.domain.repository.AuthRepository +import co.orange.domain.repository.BuyRepository import co.orange.domain.repository.DeviceRepository import co.orange.domain.repository.HomeRepository import co.orange.domain.repository.IamportRepository @@ -41,6 +43,10 @@ object RepositoryModule { @Singleton fun provideSearchRepository(searchRepositoryImpl: SearchRepositoryImpl): SearchRepository = searchRepositoryImpl + @Provides + @Singleton + fun provideBuyRepository(buyRepositoryImpl: BuyRepositoryImpl): BuyRepository = buyRepositoryImpl + @Provides @Singleton fun provideProfileRepository(profileRepositoryImpl: ProfileRepositoryImpl): ProfileRepository = profileRepositoryImpl diff --git a/app/src/main/java/co/orange/ddanzi/di/module/ServiceModule.kt b/app/src/main/java/co/orange/ddanzi/di/module/ServiceModule.kt index 0b5817fc..ce1327b1 100644 --- a/app/src/main/java/co/orange/ddanzi/di/module/ServiceModule.kt +++ b/app/src/main/java/co/orange/ddanzi/di/module/ServiceModule.kt @@ -1,6 +1,7 @@ package co.orange.ddanzi.di.module import co.orange.data.service.AuthService +import co.orange.data.service.BuyService import co.orange.data.service.DeviceService import co.orange.data.service.HomeService import co.orange.data.service.IamportService @@ -33,7 +34,7 @@ object ServiceModule { @Provides @Singleton - fun provideDetailService( + fun provideDeviceService( @RetrofitQualifier.DEVICE retrofit: Retrofit, ): DeviceService = retrofit.create(DeviceService::class.java) @@ -43,6 +44,12 @@ object ServiceModule { @RetrofitQualifier.JWT retrofit: Retrofit, ): SearchService = retrofit.create(SearchService::class.java) + @Provides + @Singleton + fun provideBuyService( + @RetrofitQualifier.JWT retrofit: Retrofit, + ): BuyService = retrofit.create(BuyService::class.java) + @Provides @Singleton fun provideProfileService( From 515387fedf157a729090b01c8d79ab470cde28a0 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 03:04:46 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[FEAT/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=ED=99=95=EC=9D=B8=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buy/progress/BuyProgressActivity.kt | 43 +++++++++++++++++-- .../buy/progress/BuyProgressViewModel.kt | 43 +++++++++++-------- 2 files changed, 63 insertions(+), 23 deletions(-) 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 e34356cf..b20d9200 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 @@ -4,13 +4,21 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import androidx.lifecycle.flowWithLifecycle +import androidx.lifecycle.lifecycleScope import co.orange.core.base.BaseActivity import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener +import co.orange.core.extension.stringOf +import co.orange.core.extension.toast +import co.orange.core.state.UiState import co.orange.domain.entity.response.BuyProgressModel import co.orange.presentation.buy.push.BuyPushActivity import coil.load import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityBuyProgressBinding @@ -27,7 +35,14 @@ class BuyProgressActivity : initTermBtnListener() initConfirmBtnListener() getIntentInfo() - setIntentUi(viewModel.mockBuyInfo) + observeGetBuyProgressDataState() + } + + override fun onResume() { + super.onResume() + + // TODO 추후 주소지 비교 후 호출 + viewModel.getBuyProgressDataFromServer() } private fun initExitBtnListener() { @@ -35,8 +50,11 @@ class BuyProgressActivity : } private fun initDeliveryChangeBtnListener() { - // TODO - binding.btnChangeDelivery.setOnSingleClickListener { } + binding.btnChangeDelivery.setOnSingleClickListener { + BuyPushActivity.createIntent(this, viewModel.productId).apply { + startActivity(this) + } + } } private fun initTermBtnListener() { @@ -57,9 +75,26 @@ class BuyProgressActivity : private fun getIntentInfo() { viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() + viewModel.getBuyProgressDataFromServer() + } + + private fun observeGetBuyProgressDataState() { + viewModel.getBuyProgressDataState.flowWithLifecycle(lifecycle).distinctUntilChanged() + .onEach { state -> + when (state) { + is UiState.Success -> setBuyProgressUi(state.data) + + is UiState.Failure -> { + toast(stringOf(R.string.error_msg)) + finish() + } + + else -> return@onEach + } + }.launchIn(lifecycleScope) } - private fun setIntentUi(item: BuyProgressModel) { + private fun setBuyProgressUi(item: BuyProgressModel) { with(binding) { tvConfirmProductName.text = item.productName ivConfirmProduct.load(item.imgUrl) 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 2e36d3fc..6f11f20f 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,34 +1,39 @@ package co.orange.presentation.buy.progress import androidx.lifecycle.ViewModel -import co.orange.domain.entity.response.AddressInfoModel +import androidx.lifecycle.viewModelScope +import co.orange.core.state.UiState import co.orange.domain.entity.response.BuyProgressModel +import co.orange.domain.repository.BuyRepository import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class BuyProgressViewModel @Inject constructor( - // private val feedRepository: FeedRepository, + private val buyRepository: BuyRepository, ) : ViewModel() { var productId: String = "" - val mockBuyInfo = - BuyProgressModel( - "상품이름은 한줄로만 보여줄거에야야야야야야", - "https://github.com/Marchbreeze/Marchbreeze/assets/97405341/cd2c0454-92b4-41e7-ae2f-319f83e2426f", - 24000, - listOf( - AddressInfoModel( - "김상호", - "04567", - "서울특벌시 성동구 성수이로 137 107동 903호", - "010-3259-0327", - ), - ), - 3000, - 350, - 21350, - ) + private val _getBuyProgressDataState = + MutableStateFlow>(UiState.Empty) + val getBuyProgressDataState: StateFlow> = _getBuyProgressDataState + + fun getBuyProgressDataFromServer() { + _getBuyProgressDataState.value = UiState.Loading + viewModelScope.launch { + // TODO 추후 productId 활용 + buyRepository.getBuyProgressData("0110055338") + .onSuccess { + _getBuyProgressDataState.value = UiState.Success(it) + } + .onFailure { + _getBuyProgressDataState.value = UiState.Failure(it.message.toString()) + } + } + } } From edb1cd55bbbe1fc650b2d31b177de5ebc0a34991 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 04:58:28 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[FIX/#76]=20address=20info=20nullable=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/co/orange/data/dto/response/AddressInfoDto.kt | 8 ++++---- .../java/co/orange/data/dto/response/BuyProgressDto.kt | 4 ++-- .../orange/domain/entity/response/AddressInfoModel.kt | 10 +++++----- .../orange/domain/entity/response/BuyProgressModel.kt | 2 +- 4 files changed, 12 insertions(+), 12 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 08294637..df8222ff 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 @@ -7,13 +7,13 @@ import kotlinx.serialization.Serializable @Serializable data class AddressInfoDto( @SerialName("recipient") - val recipient: String, + val recipient: String? = null, @SerialName("zipCode") - val zipCode: String, + val zipCode: String? = null, @SerialName("address") - val address: String, + val address: String? = null, @SerialName("phone") - val phone: String, + val phone: String? = null, ) { fun toModel() = AddressInfoModel(recipient, zipCode, address, phone) } diff --git a/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt b/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt index 8e7de0a5..3f35234d 100644 --- a/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt +++ b/data/src/main/java/co/orange/data/dto/response/BuyProgressDto.kt @@ -15,7 +15,7 @@ data class BuyProgressDto( @SerialName("originPrice") val originPrice: Int, @SerialName("addressInfo") - val addressInfo: List, + val addressInfo: AddressInfoDto, @SerialName("discountPrice") val discountPrice: Int, @SerialName("charge") @@ -29,7 +29,7 @@ data class BuyProgressDto( productName, imgUrl, originPrice, - addressInfo.map { it.toModel() }, + addressInfo.toModel(), discountPrice, charge, totalPrice, 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 cbcecb88..309496c0 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 @@ -1,8 +1,8 @@ package co.orange.domain.entity.response data class AddressInfoModel( - val recipient: String, - val zipCode: String, - val address: String, - val phone: String -) \ No newline at end of file + val recipient: String? = null, + val zipCode: String? = null, + val address: String? = null, + val phone: String? = null, +) diff --git a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt index d2c7af44..0b840b48 100644 --- a/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt +++ b/domain/src/main/kotlin/co/orange/domain/entity/response/BuyProgressModel.kt @@ -5,7 +5,7 @@ data class BuyProgressModel( val productName: String, val imgUrl: String, val originPrice: Int, - val addressInfo: List, + val addressInfo: AddressInfoModel, val discountPrice: Int, val charge: Int, val totalPrice: Int, From e979c110c7ba12c425b3f5f502e2b24d7b6f108e Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 05:08:04 +0900 Subject: [PATCH 08/10] =?UTF-8?q?[FIX/#76]=20=EA=B5=AC=EB=A7=A4=EB=B7=B0?= =?UTF-8?q?=20=ED=99=94=EB=A9=B4=20=EA=B5=AC=EC=84=B1=20=EC=8B=9C=EC=A0=90?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buy/progress/BuyProgressActivity.kt | 13 +++++++------ .../src/main/res/layout/activity_buy_progress.xml | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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 b20d9200..6832b5b3 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 @@ -14,6 +14,7 @@ import co.orange.core.extension.toast import co.orange.core.state.UiState import co.orange.domain.entity.response.BuyProgressModel import co.orange.presentation.buy.push.BuyPushActivity +import co.orange.presentation.setting.delivery.DeliveryActivity import coil.load import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.distinctUntilChanged @@ -34,15 +35,13 @@ class BuyProgressActivity : initDeliveryChangeBtnListener() initTermBtnListener() initConfirmBtnListener() - getIntentInfo() observeGetBuyProgressDataState() } override fun onResume() { super.onResume() - // TODO 추후 주소지 비교 후 호출 - viewModel.getBuyProgressDataFromServer() + getIntentInfo() } private fun initExitBtnListener() { @@ -51,7 +50,7 @@ class BuyProgressActivity : private fun initDeliveryChangeBtnListener() { binding.btnChangeDelivery.setOnSingleClickListener { - BuyPushActivity.createIntent(this, viewModel.productId).apply { + Intent(this, DeliveryActivity::class.java).apply { startActivity(this) } } @@ -74,8 +73,10 @@ class BuyProgressActivity : } private fun getIntentInfo() { - viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() - viewModel.getBuyProgressDataFromServer() + with(viewModel) { + if (productId.isEmpty()) productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty() + getBuyProgressDataFromServer() + } } private fun observeGetBuyProgressDataState() { diff --git a/presentation/src/main/res/layout/activity_buy_progress.xml b/presentation/src/main/res/layout/activity_buy_progress.xml index 5f211c8f..9753d5ca 100644 --- a/presentation/src/main/res/layout/activity_buy_progress.xml +++ b/presentation/src/main/res/layout/activity_buy_progress.xml @@ -36,12 +36,12 @@ android:id="@+id/btn_exit" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:padding="12dp" android:src="@drawable/ic_exit" - app:layout_constraintBottom_toBottomOf="@id/tv_confirm_title" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="@id/tv_confirm_title" /> + app:layout_constraintTop_toTopOf="parent" /> From 63da2557de18672b2d81d02dde7b3b74f0f8a82c Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 05:19:13 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[ADD/#76]=20=EA=B5=AC=EB=A7=A4=EB=B7=B0?= =?UTF-8?q?=20=EB=B0=B0=EC=86=A1=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buy/progress/BuyProgressActivity.kt | 23 ++++ .../main/res/layout/activity_buy_progress.xml | 104 ++++++++++++++++-- .../src/main/res/layout/activity_delivery.xml | 6 +- presentation/src/main/res/values/strings.xml | 1 + 4 files changed, 125 insertions(+), 9 deletions(-) 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 6832b5b3..64840ef4 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 @@ -4,9 +4,11 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.viewModels +import androidx.core.view.isVisible import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import co.orange.core.base.BaseActivity +import co.orange.core.extension.breakLines import co.orange.core.extension.setNumberForm import co.orange.core.extension.setOnSingleClickListener import co.orange.core.extension.stringOf @@ -34,6 +36,7 @@ class BuyProgressActivity : initExitBtnListener() initDeliveryChangeBtnListener() initTermBtnListener() + initTermDetailBtnListener() initConfirmBtnListener() observeGetBuyProgressDataState() } @@ -63,6 +66,14 @@ class BuyProgressActivity : binding.btnTermPurchase.setOnSingleClickListener { } } + private fun initTermDetailBtnListener() { + // TODO + with(binding) { + btnTermServiceDetail.setOnSingleClickListener { } + btnTermPurchaseDetail.setOnSingleClickListener { } + } + } + private fun initConfirmBtnListener() { binding.btnConfirmPurchase.setOnSingleClickListener { // TODO 구매 요청 서버통신 이후 @@ -106,6 +117,18 @@ class BuyProgressActivity : tvConfirmPriceCharge.text = getString(R.string.add_plus, item.charge.setNumberForm()) tvConfirmPriceTotal.text = item.totalPrice.setNumberForm() + if (item.addressInfo.recipient != null) { + btnDeliveryAdd.isVisible = false + layoutDeliveryItem.isVisible = true + tvDeliveryName.text = item.addressInfo.recipient + tvDeliveryAddress.text = + getString( + R.string.address_short_format, + item.addressInfo.zipCode, + item.addressInfo.address, + ).breakLines() + tvDeliveryPhone.text = item.addressInfo.phone + } } } diff --git a/presentation/src/main/res/layout/activity_buy_progress.xml b/presentation/src/main/res/layout/activity_buy_progress.xml index 9753d5ca..e5155abe 100644 --- a/presentation/src/main/res/layout/activity_buy_progress.xml +++ b/presentation/src/main/res/layout/activity_buy_progress.xml @@ -132,15 +132,79 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@id/tv_confirm_delivery_title" /> - + app:layout_constraintTop_toBottomOf="@id/tv_confirm_delivery_title"> + + + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/layout_confirm_delivery" /> + + + + + app:layout_constraintTop_toBottomOf="@id/border_delivery" + tools:visibility="visible"> + app:layout_constraintTop_toBottomOf="@id/border_delivery" + tools:visibility="gone" /> \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index d67debdf..a5e3bb80 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -66,6 +66,7 @@ 상세 내역 보러가기 거래 번호 %s + (%s) %s (%s) %s %s 구매 상세 From dae543b81eb08c4a23579b5fd828301e292b9112 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 19 Aug 2024 05:45:17 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[FEAT/#76]=20=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=95=BD=EA=B4=80=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=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"