From 0baa5e5b3a03d6481b9e5f51d8873b42d9afaae8 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Thu, 13 Jun 2024 22:46:13 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[UI/#9]=20=EC=98=B5=EC=85=98=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=EC=8B=9C=ED=8A=B8=20UI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/DetailOptionBottomSheet.kt | 2 + .../main/res/drawable/ic_check_unselected.xml | 9 ++ .../drawable/shape_gray4_fill_100_rect.xml | 6 + .../drawable/shape_white_fill_top20_rect.xml | 7 + .../res/layout/bottom_sheet_detail_option.xml | 143 ++++++++++++++++++ .../main/res/layout/item_detail_option.xml | 37 +++++ presentation/src/main/res/values/strings.xml | 3 + 7 files changed, 207 insertions(+) create mode 100644 presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt create mode 100644 presentation/src/main/res/drawable/ic_check_unselected.xml create mode 100644 presentation/src/main/res/drawable/shape_gray4_fill_100_rect.xml create mode 100644 presentation/src/main/res/drawable/shape_white_fill_top20_rect.xml create mode 100644 presentation/src/main/res/layout/bottom_sheet_detail_option.xml create mode 100644 presentation/src/main/res/layout/item_detail_option.xml diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt new file mode 100644 index 00000000..d92f62ea --- /dev/null +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt @@ -0,0 +1,2 @@ +package co.orange.presentation.detail + diff --git a/presentation/src/main/res/drawable/ic_check_unselected.xml b/presentation/src/main/res/drawable/ic_check_unselected.xml new file mode 100644 index 00000000..f159ae32 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_check_unselected.xml @@ -0,0 +1,9 @@ + + + diff --git a/presentation/src/main/res/drawable/shape_gray4_fill_100_rect.xml b/presentation/src/main/res/drawable/shape_gray4_fill_100_rect.xml new file mode 100644 index 00000000..54cd92e8 --- /dev/null +++ b/presentation/src/main/res/drawable/shape_gray4_fill_100_rect.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/shape_white_fill_top20_rect.xml b/presentation/src/main/res/drawable/shape_white_fill_top20_rect.xml new file mode 100644 index 00000000..0b47fa4f --- /dev/null +++ b/presentation/src/main/res/drawable/shape_white_fill_top20_rect.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/bottom_sheet_detail_option.xml b/presentation/src/main/res/layout/bottom_sheet_detail_option.xml new file mode 100644 index 00000000..65e80924 --- /dev/null +++ b/presentation/src/main/res/layout/bottom_sheet_detail_option.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_detail_option.xml b/presentation/src/main/res/layout/item_detail_option.xml new file mode 100644 index 00000000..99d2a2ef --- /dev/null +++ b/presentation/src/main/res/layout/item_detail_option.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + \ 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 7eafee7d..ec54e386 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -29,4 +29,7 @@ 이 상품에 대한 자세한 정보를 보고 싶다면? 구매하기 + + 원하는 옵션을 선택해주세요 + *각인 옵션은 사용할 수 없습니다. \ No newline at end of file From aa8ca1a4d45a95493f53a7d500004ec243921866 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Thu, 13 Jun 2024 23:10:21 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[ADD/#9]=20=EC=98=B5=EC=85=98=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=EC=8B=9C=ED=8A=B8=20=EB=B7=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/detail/DetailActivity.kt | 24 ++++++++++--- .../detail/DetailOptionBottomSheet.kt | 34 ++++++++++++++++++ .../res/layout/bottom_sheet_detail_option.xml | 35 ++++++++++++------- 3 files changed, 77 insertions(+), 16 deletions(-) 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 5c0e478f..ae79562e 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt @@ -3,6 +3,7 @@ package co.orange.presentation.detail import android.content.Context import android.content.Intent import android.graphics.Paint +import android.net.Uri import android.os.Bundle import androidx.activity.viewModels import androidx.core.view.isVisible @@ -20,6 +21,9 @@ import kr.genti.presentation.databinding.ActivityDetailBinding @AndroidEntryPoint class DetailActivity : BaseActivity(R.layout.activity_detail) { private val viewModel by viewModels() + + private var detailOptionBottomSheet: DetailOptionBottomSheet? = null + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -38,8 +42,11 @@ class DetailActivity : BaseActivity(R.layout.activity_det } private fun initDetailViewBtnListener() { - // TODO - binding.btnDetailView.setOnSingleClickListener { } + binding.btnDetailView.setOnSingleClickListener { + if (viewModel.mockProduct.infoUrl.isNotEmpty()) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.mockProduct.infoUrl))) + } + } } private fun initLikeBtnListener() { @@ -48,8 +55,10 @@ class DetailActivity : BaseActivity(R.layout.activity_det } private fun initPurchaseBtnListener() { - // TODO - binding.btnPurchase.setOnSingleClickListener { } + binding.btnPurchase.setOnSingleClickListener { + detailOptionBottomSheet = DetailOptionBottomSheet() + detailOptionBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_OPTION) + } } private fun getIntentInfo() { @@ -80,11 +89,18 @@ class DetailActivity : BaseActivity(R.layout.activity_det } } + override fun onDestroy() { + super.onDestroy() + detailOptionBottomSheet = null + } + companion object { private const val EXTRA_PRODUCT_URL = "EXTRA_PRODUCT_URL" private const val EXTRA_ORIGIN_PRICE = "EXTRA_ORIGIN_PRICE" private const val EXTRA_SALE_PRICE = "EXTRA_SALE_PRICE" + private const val BOTTOM_SHEET_OPTION = "BOTTOM_SHEET_OPTION" + @JvmStatic fun createIntent( context: Context, diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt index d92f62ea..744cbb97 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt @@ -1,2 +1,36 @@ package co.orange.presentation.detail +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import kr.genti.core.base.BaseBottomSheet +import kr.genti.core.extension.setOnSingleClickListener +import kr.genti.presentation.R +import kr.genti.presentation.databinding.BottomSheetDetailOptionBinding + +class DetailOptionBottomSheet : + BaseBottomSheet(R.layout.bottom_sheet_detail_option) { + + private val viewModel by activityViewModels() + + override fun onStart() { + super.onStart() + dialog?.window?.setBackgroundDrawableResource(R.color.transparent) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initDetailViewBtnListener() + } + + private fun initDetailViewBtnListener() { + binding.btnDetailView.setOnSingleClickListener { + if (viewModel.mockProduct.infoUrl.isNotEmpty()) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.mockProduct.infoUrl))) + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/res/layout/bottom_sheet_detail_option.xml b/presentation/src/main/res/layout/bottom_sheet_detail_option.xml index 65e80924..296e49c6 100644 --- a/presentation/src/main/res/layout/bottom_sheet_detail_option.xml +++ b/presentation/src/main/res/layout/bottom_sheet_detail_option.xml @@ -9,8 +9,17 @@ + android:layout_height="wrap_content"> + + + app:layout_constraintStart_toStartOf="parent" /> From 7914d2c914759d2bc8725028d38e31194c22225f Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Thu, 13 Jun 2024 23:44:27 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[ADD/#9]=20=EC=98=B5=EC=85=98=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=EC=8B=9C=ED=8A=B8=20recyclerView=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/detail/DetailActivity.kt | 9 +-- .../detail/DetailOptionBottomSheet.kt | 36 ---------- .../presentation/detail/DetailViewModel.kt | 10 ++- .../presentation/detail/OptionAdapter.kt | 38 +++++++++++ .../presentation/detail/OptionBottomSheet.kt | 67 +++++++++++++++++++ .../presentation/detail/OptionViewHolder.kt | 22 ++++++ ...ail_option.xml => bottom_sheet_option.xml} | 4 +- ...item_detail_option.xml => item_option.xml} | 0 8 files changed, 142 insertions(+), 44 deletions(-) delete mode 100644 presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt create mode 100644 presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt create mode 100644 presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt create mode 100644 presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt rename presentation/src/main/res/layout/{bottom_sheet_detail_option.xml => bottom_sheet_option.xml} (98%) rename presentation/src/main/res/layout/{item_detail_option.xml => item_option.xml} (100%) 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 ae79562e..6a189dfd 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailActivity.kt @@ -22,7 +22,7 @@ import kr.genti.presentation.databinding.ActivityDetailBinding class DetailActivity : BaseActivity(R.layout.activity_detail) { private val viewModel by viewModels() - private var detailOptionBottomSheet: DetailOptionBottomSheet? = null + private var optionBottomSheet: OptionBottomSheet? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -56,8 +56,8 @@ class DetailActivity : BaseActivity(R.layout.activity_det private fun initPurchaseBtnListener() { binding.btnPurchase.setOnSingleClickListener { - detailOptionBottomSheet = DetailOptionBottomSheet() - detailOptionBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_OPTION) + optionBottomSheet = OptionBottomSheet() + optionBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_OPTION) } } @@ -91,7 +91,8 @@ class DetailActivity : BaseActivity(R.layout.activity_det override fun onDestroy() { super.onDestroy() - detailOptionBottomSheet = null + + optionBottomSheet = null } companion object { diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt deleted file mode 100644 index 744cbb97..00000000 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailOptionBottomSheet.kt +++ /dev/null @@ -1,36 +0,0 @@ -package co.orange.presentation.detail - -import android.content.Intent -import android.net.Uri -import android.os.Bundle -import android.view.View -import androidx.fragment.app.activityViewModels -import kr.genti.core.base.BaseBottomSheet -import kr.genti.core.extension.setOnSingleClickListener -import kr.genti.presentation.R -import kr.genti.presentation.databinding.BottomSheetDetailOptionBinding - -class DetailOptionBottomSheet : - BaseBottomSheet(R.layout.bottom_sheet_detail_option) { - - private val viewModel by activityViewModels() - - override fun onStart() { - super.onStart() - dialog?.window?.setBackgroundDrawableResource(R.color.transparent) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - initDetailViewBtnListener() - } - - private fun initDetailViewBtnListener() { - binding.btnDetailView.setOnSingleClickListener { - if (viewModel.mockProduct.infoUrl.isNotEmpty()) { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.mockProduct.infoUrl))) - } - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt index c4a68928..686aca64 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt @@ -1,6 +1,7 @@ package co.orange.presentation.detail import androidx.lifecycle.ViewModel +import co.orange.domain.entity.response.OptionModel import co.orange.domain.entity.response.ProductDetailModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -12,7 +13,7 @@ constructor( // private val feedRepository: FeedRepository, ) : ViewModel() { val mockProduct = ProductDetailModel( - "퓨어 오일 퍼퓸 10 ml 긴제목테스트트트트트", + "퓨어 오일 퍼퓸 10ml 입니다 긴제목은 어떻게 될까요? 짧은 것도 이간격", "카테고리", false, true, @@ -20,6 +21,11 @@ constructor( 12, "", 123, - listOf() + listOf( + OptionModel(1,"옵션 1", listOf()), + OptionModel(2,"옵션 2", listOf()), + OptionModel(3,"옵션 3", listOf()), + OptionModel(4,"옵션 4", listOf()) + ) ) } \ No newline at end of file diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt new file mode 100644 index 00000000..189a4ece --- /dev/null +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.kt @@ -0,0 +1,38 @@ +package co.orange.presentation.detail + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.ListAdapter +import co.orange.domain.entity.response.OptionModel +import kr.genti.core.util.ItemDiffCallback +import kr.genti.presentation.databinding.ItemOptionBinding + +class OptionAdapter( + private val itemClick: (Int, Long) -> Unit, +) : ListAdapter(diffUtil) { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OptionViewHolder { + val inflater by lazy { LayoutInflater.from(parent.context) } + val binding: ItemOptionBinding = + ItemOptionBinding.inflate(inflater, parent, false) + return OptionViewHolder(binding, itemClick) + } + + override fun onBindViewHolder(holder: OptionViewHolder, position: Int) { + val item = getItem(position) ?: return + holder.onBind(item, position) + } + + fun addList(newItems: List) { + val currentItems = currentList.toMutableList() + currentItems.addAll(newItems) + submitList(currentItems) + } + + companion object { + private val diffUtil = ItemDiffCallback( + onItemsTheSame = { old, new -> old.optionId == new.optionId }, + onContentsTheSame = { old, new -> old == new }, + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt new file mode 100644 index 00000000..60159b8d --- /dev/null +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.kt @@ -0,0 +1,67 @@ +package co.orange.presentation.detail + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.View +import androidx.fragment.app.activityViewModels +import co.orange.presentation.main.home.HomeProductViewHolder.Companion.OVER_999 +import kr.genti.core.base.BaseBottomSheet +import kr.genti.core.extension.setOnSingleClickListener +import kr.genti.presentation.R +import kr.genti.presentation.databinding.BottomSheetOptionBinding + +class OptionBottomSheet : + BaseBottomSheet(R.layout.bottom_sheet_option) { + + private val viewModel by activityViewModels() + + private var _adapter: OptionAdapter? = null + private val adapter + get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } + + override fun onStart() { + super.onStart() + dialog?.window?.setBackgroundDrawableResource(R.color.transparent) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initDetailViewBtnListener() + initAdapter() + setInterestCount() + setOptionData() + } + + private fun initDetailViewBtnListener() { + binding.btnDetailView.setOnSingleClickListener { + if (viewModel.mockProduct.infoUrl.isNotEmpty()) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.mockProduct.infoUrl))) + } + } + } + + private fun initAdapter() { + _adapter = OptionAdapter( + itemClick = ::initItemClickListener, + ) + binding.rvOption.adapter = adapter + } + + private fun initItemClickListener(position: Int, optionId: Long) { + // TODO + } + + private fun setInterestCount() { + binding.tvOptionLike.text = if (viewModel.mockProduct.interestCount < 1000) { + viewModel.mockProduct.interestCount.toString() + } else { + OVER_999 + } + } + + private fun setOptionData() { + adapter.addList(viewModel.mockProduct.optionList) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt b/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt new file mode 100644 index 00000000..240c81a0 --- /dev/null +++ b/presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.kt @@ -0,0 +1,22 @@ +package co.orange.presentation.detail + +import androidx.recyclerview.widget.RecyclerView +import co.orange.domain.entity.response.OptionModel +import kr.genti.core.extension.setOnSingleClickListener +import kr.genti.presentation.databinding.ItemOptionBinding + +class OptionViewHolder( + val binding: ItemOptionBinding, + private val itemClick: (Int, Long) -> Unit, +) : RecyclerView.ViewHolder(binding.root) { + + fun onBind(item: OptionModel, position: Int) { + // TODO: 수정된 UI 대응 + with(binding) { + tvOptionItemTitle.text = item.type + root.setOnSingleClickListener { + itemClick(position, item.optionId) + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/res/layout/bottom_sheet_detail_option.xml b/presentation/src/main/res/layout/bottom_sheet_option.xml similarity index 98% rename from presentation/src/main/res/layout/bottom_sheet_detail_option.xml rename to presentation/src/main/res/layout/bottom_sheet_option.xml index 296e49c6..be3c0890 100644 --- a/presentation/src/main/res/layout/bottom_sheet_detail_option.xml +++ b/presentation/src/main/res/layout/bottom_sheet_option.xml @@ -9,13 +9,13 @@ + tools:listitem="@layout/item_option" /> Date: Thu, 13 Jun 2024 23:47:27 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[ADD/#9]=20=EC=98=B5=EC=85=98=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=EC=8B=9C=ED=8A=B8=20=EB=91=A5=EA=B7=BC=20=EB=AA=A8?= =?UTF-8?q?=EC=84=9C=EB=A6=AC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/orange/presentation/detail/DetailViewModel.kt | 2 +- presentation/src/main/res/values/styles.xml | 10 ++++++++++ presentation/src/main/res/values/themes.xml | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 presentation/src/main/res/values/styles.xml diff --git a/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt b/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt index 686aca64..a7502ff9 100644 --- a/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt +++ b/presentation/src/main/java/co/orange/presentation/detail/DetailViewModel.kt @@ -13,7 +13,7 @@ constructor( // private val feedRepository: FeedRepository, ) : ViewModel() { val mockProduct = ProductDetailModel( - "퓨어 오일 퍼퓸 10ml 입니다 긴제목은 어떻게 될까요? 짧은 것도 이간격", + "퓨어 오일 퍼퓸 10 ml 긴제목테스트트트트트", "카테고리", false, true, diff --git a/presentation/src/main/res/values/styles.xml b/presentation/src/main/res/values/styles.xml new file mode 100644 index 00000000..166dd24d --- /dev/null +++ b/presentation/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml index e1395fcd..50b7cd58 100644 --- a/presentation/src/main/res/values/themes.xml +++ b/presentation/src/main/res/values/themes.xml @@ -9,6 +9,9 @@ @color/gray_3 + + @style/AppBottomSheetDialogTheme +