From 25f3567574186b61ef28352d1204f98760adae87 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Fri, 1 Dec 2023 16:49:54 +0900 Subject: [PATCH 01/23] =?UTF-8?q?[feat]=20#26=20=EB=A7=A4=EC=9E=A5=20?= =?UTF-8?q?=EA=B2=80=EC=83=89,=20=EB=A7=A4=EC=9E=A5=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EB=B7=B0=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shopDetail/ShopDetailActivity.kt | 18 ++++++++++++------ .../shopDetail/ShopDetailViewModel.kt | 6 +----- .../store/PopularStoreActivity.kt | 15 ++++++++++++++- .../presentation/store/PopularStoreAdapter.kt | 19 +++++++++---------- .../store/PopularStoreViewHolder.kt | 18 ++++++++++++++++++ 5 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreViewHolder.kt diff --git a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt index dc50285..8b5a468 100644 --- a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt +++ b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt @@ -18,9 +18,10 @@ import org.sopt.tabling.R import org.sopt.tabling.databinding.ActivityShopDetailBinding import org.sopt.tabling.domain.model.Reserve import org.sopt.tabling.domain.model.ShopDetail +import org.sopt.tabling.presentation.common.ViewModelFactory import org.sopt.tabling.presentation.reserve.ReserveBottomSheetDialogFragment import org.sopt.tabling.presentation.reserve.ReserveDialog -import org.sopt.tabling.presentation.common.ViewModelFactory +import org.sopt.tabling.presentation.store.PopularStoreActivity.Companion.SHOP_ID import org.sopt.tabling.presentation.type.StarType import org.sopt.tabling.util.UiState import org.sopt.tabling.util.binding.BindingActivity @@ -34,11 +35,14 @@ class ShopDetailActivity : private lateinit var shopDetailShopImgAdapter: ShopDetailShopImgAdapter private lateinit var shopDetailMenuListAdapter: ShopDetailMenuListAdapter private lateinit var shopDetailRecentReviewAdapter: ShopDetailRecentReviewAdapter + private var shopId: Long = -1 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding.shopDetailViewModel = shopDetailViewModel + shopId = intent.getLongExtra(SHOP_ID, -1) + initLayout() collectData() } @@ -54,6 +58,8 @@ class ShopDetailActivity : } private fun initLayout() { + shopDetailViewModel.getShopDetail(shopId) + initAppBar() initTabLayout() initNestedScrollView() @@ -181,12 +187,12 @@ class ShopDetailActivity : setTvShopDetailShopImgPageText(FIRST_POSITION) binding.vpShopDetailShopImg.registerOnPageChangeCallback(object : - ViewPager2.OnPageChangeCallback() { - override fun onPageSelected(position: Int) { - super.onPageSelected(position) - setTvShopDetailShopImgPageText(position) - } + ViewPager2.OnPageChangeCallback() { + override fun onPageSelected(position: Int) { + super.onPageSelected(position) + setTvShopDetailShopImgPageText(position) } + } ) } diff --git a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailViewModel.kt b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailViewModel.kt index 8e24a38..df5b369 100644 --- a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailViewModel.kt +++ b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailViewModel.kt @@ -15,11 +15,7 @@ class ShopDetailViewModel( private val _getShopDetailState = MutableStateFlow>(UiState.Empty) val getShopDetailState = _getShopDetailState.asStateFlow() - init { - getShopDetail() - } - - private fun getShopDetail(shopId: Long = 2) { + fun getShopDetail(shopId: Long) { viewModelScope.launch { _getShopDetailState.value = UiState.Loading shopDetailRepository.getShopDetail(shopId).onSuccess { shopDetail -> diff --git a/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreActivity.kt b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreActivity.kt index 6833c85..1696aee 100644 --- a/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreActivity.kt +++ b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreActivity.kt @@ -1,9 +1,11 @@ package org.sopt.tabling.presentation.store +import android.content.Intent import android.os.Bundle import androidx.activity.viewModels import org.sopt.tabling.R import org.sopt.tabling.databinding.ActivityPopularStoreBinding +import org.sopt.tabling.presentation.shopDetail.ShopDetailActivity import org.sopt.tabling.util.binding.BindingActivity class PopularStoreActivity : @@ -21,7 +23,7 @@ class PopularStoreActivity : } private fun initAdapter() { - popularStoreAdapter = PopularStoreAdapter(this) + popularStoreAdapter = PopularStoreAdapter(this, ::moveToShopDetail) binding.rvPopularStore.adapter = popularStoreAdapter } @@ -30,4 +32,15 @@ class PopularStoreActivity : popularStoreAdapter.setStoreList(storeList) } } + + private fun moveToShopDetail(shopId: Long) { + Intent(this@PopularStoreActivity, ShopDetailActivity::class.java).apply { + putExtra(SHOP_ID, shopId) + startActivity(this) + } + } + + companion object { + const val SHOP_ID = "shopId" + } } diff --git a/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreAdapter.kt b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreAdapter.kt index ae3ac60..46f8722 100644 --- a/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreAdapter.kt +++ b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreAdapter.kt @@ -7,20 +7,19 @@ import androidx.recyclerview.widget.RecyclerView import org.sopt.tabling.data.model.response.ResponsePopularStoreDto import org.sopt.tabling.databinding.ItemPopularStoreBinding -class PopularStoreAdapter(context: Context) : - RecyclerView.Adapter() { +class PopularStoreAdapter( + private val context: Context, + private val moveToShopDetail: (Long) -> Unit +) : + RecyclerView.Adapter() { private val inflater by lazy { LayoutInflater.from(context) } private var storeList = listOf() - inner class PopularStoreViewHolder(val binding: ItemPopularStoreBinding) : - RecyclerView.ViewHolder(binding.root) { - fun onBind(storeData: ResponsePopularStoreDto.StoreData) { - binding.storeData = storeData - } - } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PopularStoreViewHolder { - return PopularStoreViewHolder(ItemPopularStoreBinding.inflate(inflater, parent, false)) + return PopularStoreViewHolder( + ItemPopularStoreBinding.inflate(inflater, parent, false), + moveToShopDetail + ) } override fun getItemCount() = storeList.size diff --git a/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreViewHolder.kt b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreViewHolder.kt new file mode 100644 index 0000000..ab10fa5 --- /dev/null +++ b/app/src/main/java/org/sopt/tabling/presentation/store/PopularStoreViewHolder.kt @@ -0,0 +1,18 @@ +package org.sopt.tabling.presentation.store + +import androidx.recyclerview.widget.RecyclerView +import org.sopt.tabling.data.model.response.ResponsePopularStoreDto +import org.sopt.tabling.databinding.ItemPopularStoreBinding + +class PopularStoreViewHolder( + private val binding: ItemPopularStoreBinding, + private val moveToShopDetail: (Long) -> Unit +) : + RecyclerView.ViewHolder(binding.root) { + fun onBind(storeData: ResponsePopularStoreDto.StoreData) { + binding.storeData = storeData + binding.root.setOnClickListener { + moveToShopDetail(storeData.shopId.toLong()) + } + } +} From 1a9bddc6af300d93292a66631e523b3ceb7e0819 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Fri, 1 Dec 2023 16:57:44 +0900 Subject: [PATCH 02/23] =?UTF-8?q?[chore]=20#26=20=EB=A7=A4=EC=9E=A5=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EB=A9=94=EB=89=B4=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=ED=85=9C=20=EB=A9=94=EB=89=B4=20=EC=9D=B4=EB=A6=84=201?= =?UTF-8?q?=EC=A4=84=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/item_shop_detail_menu.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/layout/item_shop_detail_menu.xml b/app/src/main/res/layout/item_shop_detail_menu.xml index 4a9d1f2..e09ed0b 100644 --- a/app/src/main/res/layout/item_shop_detail_menu.xml +++ b/app/src/main/res/layout/item_shop_detail_menu.xml @@ -22,6 +22,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="6dp" + android:ellipsize="end" + android:maxLines="1" android:textAppearance="@style/TextAppearance.Body2.Regular" android:textColor="@color/gray_800" app:layout_constraintEnd_toEndOf="@id/iv_item_shop_detail_menu_img" From ac51e6d0bc08d26f0e34411776ca88b9882fd2f6 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Fri, 1 Dec 2023 17:00:57 +0900 Subject: [PATCH 03/23] =?UTF-8?q?[feat]=20#26=20=EB=A7=A4=EC=9E=A5=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EB=92=A4=EB=A1=9C=EA=B0=80=EA=B8=B0=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabling/presentation/shopDetail/ShopDetailActivity.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt index 8b5a468..1c8d9a1 100644 --- a/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt +++ b/app/src/main/java/org/sopt/tabling/presentation/shopDetail/ShopDetailActivity.kt @@ -44,6 +44,7 @@ class ShopDetailActivity : shopId = intent.getLongExtra(SHOP_ID, -1) initLayout() + addListeners() collectData() } @@ -65,6 +66,12 @@ class ShopDetailActivity : initNestedScrollView() } + private fun addListeners() { + binding.ivShopDetailBack.setOnClickListener { + finish() + } + } + private fun collectData() { shopDetailViewModel.getShopDetailState.flowWithLifecycle(lifecycle).onEach { uiState -> when (uiState) { From 909f4a597f95492121988e3b607ba491118e0ed2 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Fri, 1 Dec 2023 17:11:54 +0900 Subject: [PATCH 04/23] =?UTF-8?q?[chore]=20#26=20chip=20=ED=8C=A8=EB=94=A9?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/view_detail_btn.xml | 4 ++-- app/src/main/res/values/themes.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/layout/view_detail_btn.xml b/app/src/main/res/layout/view_detail_btn.xml index 09d29a9..756a8ae 100644 --- a/app/src/main/res/layout/view_detail_btn.xml +++ b/app/src/main/res/layout/view_detail_btn.xml @@ -10,7 +10,7 @@ android:id="@+id/tv_detail_btn" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginVertical="7dp" + android:layout_marginVertical="10dp" android:layout_marginStart="@dimen/spacing12" android:textAppearance="@style/TextAppearance.Body2.SemiBold" android:textColor="@color/gray_400" @@ -23,7 +23,7 @@ android:id="@+id/iv_detail_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="8dp" + android:layout_marginEnd="10dp" android:src="@drawable/ic_chevron_gray_600_12" app:layout_constraintBottom_toBottomOf="@+id/tv_detail_btn" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 04aaf9c..731a47b 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -97,7 +97,7 @@