From d95ed2a042cc2ab8f90d84e834fbfa97d4ab7484 Mon Sep 17 00:00:00 2001 From: NaZe0320 Date: Sun, 4 Feb 2024 00:52:52 +0900 Subject: [PATCH] =?UTF-8?q?[feat/#34]:=20=EA=B0=80=EA=B2=8C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=ED=99=94=EB=A9=B4=20DataBindi?= =?UTF-8?q?ng=20=EC=97=B0=EA=B2=B0=20=EB=B0=8F=20StoreInfoModel=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/umc/coumo/domain/model/MenuModel.kt | 3 +- .../umc/coumo/domain/model/StoreInfoModel.kt | 13 +++++++- .../coumo/domain/viewmodel/HomeViewModel.kt | 31 ++++++++++++++----- .../coumo/presentation/adapter/MenuAdapter.kt | 12 +------ .../fragment/HomeDetailInfoFragment.kt | 4 +-- .../main/res/drawable/shape_rect_round_12.xml | 4 +++ .../main/res/layout/fragment_home_detail.xml | 4 +-- .../res/layout/fragment_home_detail_info.xml | 6 ++-- app/src/main/res/layout/item_menu.xml | 2 +- app/src/main/res/layout/item_menu_detail.xml | 4 +-- 10 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 app/src/main/res/drawable/shape_rect_round_12.xml diff --git a/app/src/main/java/com/umc/coumo/domain/model/MenuModel.kt b/app/src/main/java/com/umc/coumo/domain/model/MenuModel.kt index 8051a66..ebbf37b 100644 --- a/app/src/main/java/com/umc/coumo/domain/model/MenuModel.kt +++ b/app/src/main/java/com/umc/coumo/domain/model/MenuModel.kt @@ -3,9 +3,8 @@ package com.umc.coumo.domain.model import android.net.Uri data class MenuModel( - val id: Int, val name: String, - val content: String, + val description: String, val image: Uri? = null, val isNew: Boolean = false ) \ No newline at end of file diff --git a/app/src/main/java/com/umc/coumo/domain/model/StoreInfoModel.kt b/app/src/main/java/com/umc/coumo/domain/model/StoreInfoModel.kt index 125e3e2..2868f8d 100644 --- a/app/src/main/java/com/umc/coumo/domain/model/StoreInfoModel.kt +++ b/app/src/main/java/com/umc/coumo/domain/model/StoreInfoModel.kt @@ -1,4 +1,15 @@ package com.umc.coumo.domain.model -class StoreInfoModel { +import android.net.Uri + +data class StoreInfoModel( + val name: String, + val description: String, + val location: String, + val longitude: Double, + val latitude: Double, + val image: List?, + val coupon: CouponModel, + val menuList: List, +) { } \ No newline at end of file diff --git a/app/src/main/java/com/umc/coumo/domain/viewmodel/HomeViewModel.kt b/app/src/main/java/com/umc/coumo/domain/viewmodel/HomeViewModel.kt index 3d65db3..0821eae 100644 --- a/app/src/main/java/com/umc/coumo/domain/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/com/umc/coumo/domain/viewmodel/HomeViewModel.kt @@ -3,7 +3,9 @@ package com.umc.coumo.domain.viewmodel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import com.umc.coumo.domain.model.CouponModel import com.umc.coumo.domain.model.MenuModel +import com.umc.coumo.domain.model.StoreInfoModel import com.umc.coumo.domain.type.DetailTabType import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -17,6 +19,9 @@ class HomeViewModel @Inject constructor(): ViewModel() { private val _menuList = MutableLiveData>() val menuList: LiveData> get() = _menuList + private val _storeData = MutableLiveData() + val storeData: LiveData get() = _storeData + init { testData() } @@ -25,14 +30,26 @@ class HomeViewModel @Inject constructor(): ViewModel() { _currentTab.value = tab } + fun loadStoreData() { + // TODO( API 에서 데이터 가져오기 ) + testData() + } + private fun testData() { - val list = listOf( - MenuModel(id = 0, name = "아이스 바닐라 라떼", content = "Tall: 4,800\nGrande: 6,800\nTrenta: 6,800"), - MenuModel(id = 1, name = "아이스 바닐라 라떼2", content = "Tall: 4,800\nGrande: 6,800\nTrenta: 6,800", isNew = true), - MenuModel(id = 2, name = "아이스 바닐라 라떼3", content = "Tall: 4,800\nGrande: 6,800\nTrenta: 6,800",), - MenuModel(id = 3, name = "아이스 바닐라 라떼4", content = "Tall: 4,800\nGrande: 6,800\nTrenta: 6,800",), - MenuModel(id = 4, name = "아이스 바닐라 라떼5", content = "Tall: 4,800\nGrande: 6,800\nTrenta: 6,800",), + _storeData.value = StoreInfoModel( + name = "가게 이름", + description = "가게 정보", + location = "가게 위치 정보", + longitude = 126.12, + latitude = 36.12, + image = null, + coupon = CouponModel("?",1,"1",1,null), + menuList = listOf( + MenuModel("메뉴 이름1","메뉴 정보1"), + MenuModel("메뉴 이름2","메뉴 정보2", isNew = true), + MenuModel("메뉴 이름3","메뉴 정보3"), + MenuModel("메뉴 이름4","메뉴 정보4"), + ) ) - _menuList.value = list } } \ No newline at end of file diff --git a/app/src/main/java/com/umc/coumo/presentation/adapter/MenuAdapter.kt b/app/src/main/java/com/umc/coumo/presentation/adapter/MenuAdapter.kt index 6b030cc..484605d 100644 --- a/app/src/main/java/com/umc/coumo/presentation/adapter/MenuAdapter.kt +++ b/app/src/main/java/com/umc/coumo/presentation/adapter/MenuAdapter.kt @@ -15,7 +15,7 @@ class MenuAdapter( ): ListAdapter( ItemDiffCallback( onContentsTheSame = {old, new -> old == new}, - onItemsTheSame = {old, new -> old.id == new.id} + onItemsTheSame = {old, new -> old.name == new.name} ) ) { companion object { @@ -49,17 +49,11 @@ companion object { } } - - inner class MenuViewHolder( private val binding: ItemMenuBinding ): RecyclerView.ViewHolder(binding.root) { fun bind(item: MenuModel) { binding.item = item - - itemView.setOnClickListener { - listener?.onItemClick(item.id) - } } } @@ -68,10 +62,6 @@ companion object { ): RecyclerView.ViewHolder(binding.root) { fun bind(item: MenuModel) { binding.item = item - - itemView.setOnClickListener { - listener?.onItemClick(item.id) - } } } diff --git a/app/src/main/java/com/umc/coumo/presentation/fragment/HomeDetailInfoFragment.kt b/app/src/main/java/com/umc/coumo/presentation/fragment/HomeDetailInfoFragment.kt index 4662bdc..2ea900e 100644 --- a/app/src/main/java/com/umc/coumo/presentation/fragment/HomeDetailInfoFragment.kt +++ b/app/src/main/java/com/umc/coumo/presentation/fragment/HomeDetailInfoFragment.kt @@ -39,9 +39,9 @@ class HomeDetailInfoFragment: BindingFragmentNoneBackPress + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_detail.xml b/app/src/main/res/layout/fragment_home_detail.xml index db59ca5..4834f59 100644 --- a/app/src/main/res/layout/fragment_home_detail.xml +++ b/app/src/main/res/layout/fragment_home_detail.xml @@ -48,7 +48,7 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/horizontal_padding" android:layout_marginTop="24dp" - android:text="앙떼띠 로스터리 (강남점)" + android:text="@{viewModel.storeData.name}" android:textSize="24sp" android:textColor="@color/font_text" android:fontFamily="@font/pretendard_700" @@ -64,7 +64,7 @@ android:paddingVertical="6dp" android:background="@drawable/shape_rect_side_round" android:backgroundTint="#E4D9F8" - android:text="쿠모로 4개 모았어요!" + android:text="@{@string/coupon_format(viewModel.storeData.coupon.stampCount)}" android:textSize="12sp" android:textColor="#4E4E4E" android:fontFamily="@font/pretendard_600" diff --git a/app/src/main/res/layout/fragment_home_detail_info.xml b/app/src/main/res/layout/fragment_home_detail_info.xml index 24e35bb..146d9e4 100644 --- a/app/src/main/res/layout/fragment_home_detail_info.xml +++ b/app/src/main/res/layout/fragment_home_detail_info.xml @@ -3,7 +3,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - +