Skip to content

Commit

Permalink
#34 [feat] 홈 화면 기능 구현
Browse files Browse the repository at this point in the history
#34 [feat] 홈 화면 기능 구현
  • Loading branch information
NaZe0320 authored Feb 5, 2024
2 parents a4af0a6 + d41a4dc commit cbba922
Show file tree
Hide file tree
Showing 42 changed files with 792 additions and 438 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
id ("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
}

android {
Expand Down Expand Up @@ -77,7 +78,7 @@ dependencies {
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation ("androidx.collection:collection-ktx:1.3.0")
implementation ("androidx.collection:collection-ktx:1.4.0")
implementation ("androidx.navigation:navigation-runtime-ktx:2.7.6")
implementation ("androidx.navigation:navigation-fragment-ktx:2.7.6")
implementation ("androidx.navigation:navigation-ui-ktx:2.7.6")
Expand All @@ -86,10 +87,12 @@ dependencies {
implementation ("com.github.bumptech.glide:glide:4.11.0")
annotationProcessor ("com.github.bumptech.glide:compiler:4.11.0")

implementation ("androidx.camera:camera-core:1.4.0-alpha03")
implementation ("androidx.camera:camera-camera2:1.4.0-alpha03")
implementation ("androidx.camera:camera-lifecycle:1.4.0-alpha03")
implementation ("androidx.camera:camera-view:1.4.0-alpha03")
implementation ("androidx.camera:camera-core:1.4.0-alpha04")
implementation ("androidx.camera:camera-camera2:1.4.0-alpha04")
implementation ("androidx.camera:camera-lifecycle:1.4.0-alpha04")
implementation ("androidx.camera:camera-view:1.4.0-alpha04")

implementation ("com.journeyapps:zxing-android-embedded:4.3.0")

implementation ("com.google.android.gms:play-services-maps:18.2.0")
}
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
android:theme="@style/Theme.Coumo"
android:hardwareAccelerated="true"
tools:targetApi="31">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${GOOGLE_MAPS_API_KEY}" />

<activity
android:name=".presentation.activity.MainActivity"
android:exported="true">
Expand All @@ -26,6 +31,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.umc.coumo.data.remote.model.request

data class RequestLocationModel(
val longitude: Double = 127.028194,
val latitude: Double = 37.498085
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.coumo.data.remote.model.response

data class ResponsePopularStoreModel(
val storeId: Int,
val name: String,
val location: String,
val description: String,
val storeImage: String
)
5 changes: 0 additions & 5 deletions app/src/main/java/com/umc/coumo/domain/model/DummyModel.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.umc.coumo.domain.model

import android.net.Uri

data class ImageViewPagerModel(
val image: Uri,
) {
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/umc/coumo/domain/model/MenuModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
11 changes: 11 additions & 0 deletions app/src/main/java/com/umc/coumo/domain/model/StoreInfoItemModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.umc.coumo.domain.model

import android.net.Uri

data class StoreInfoItemModel(
val id : Int,
val image: Uri? = null,
val name: String,
val address: String,
val description: String,
)
14 changes: 9 additions & 5 deletions app/src/main/java/com/umc/coumo/domain/model/StoreInfoModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package com.umc.coumo.domain.model
import android.net.Uri

data class StoreInfoModel(
val id : Int,
val image: Uri? = null,
val name: String,
val address: String,
val content: String,
)
val description: String,
val location: String,
val longitude: Double,
val latitude: Double,
val image: List<Uri>?,
val coupon: CouponModel,
val menuList: List<MenuModel>,
) {
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/umc/coumo/domain/type/CategoryType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.umc.coumo.domain.type

enum class CategoryType(val title: String) {
CAFE("카페/디저트"),
RETAIL1("리테일"),
FOOD("요식업"),
RETAIL2("리테일"),
BEAUTY("뷰티/살롱"),
CLASS("학원/클래스"),
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/umc/coumo/domain/type/Status.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.coumo.domain.type

enum class Status {
SUCCESS,
ERROR,
LOADING
}
57 changes: 45 additions & 12 deletions app/src/main/java/com/umc/coumo/domain/viewmodel/HomeViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.umc.coumo.domain.viewmodel

import android.net.Uri
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.StoreCouponCountModel
import com.umc.coumo.domain.model.StoreInfoModel
import com.umc.coumo.domain.type.CategoryType
import com.umc.coumo.domain.type.DetailTabType
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
Expand All @@ -14,25 +19,53 @@ class HomeViewModel @Inject constructor(): ViewModel() {
private val _currentTab = MutableLiveData(DetailTabType.INFO)
val currentTab: LiveData<DetailTabType> get() = _currentTab

private val _menuList = MutableLiveData<List<MenuModel>>()
val menuList: LiveData<List<MenuModel>> get() = _menuList
private val _storeData = MutableLiveData<StoreInfoModel>()
val storeData: LiveData<StoreInfoModel> get() = _storeData

//카테고리
private val _category = MutableLiveData<CategoryType>(CategoryType.CAFE)
val category: LiveData<CategoryType> get() = _category

//근처 매장 리스트
private val _nearStoreList = MutableLiveData<List<StoreCouponCountModel>>()
val nearStoreList: LiveData<List<StoreCouponCountModel>> get() = _nearStoreList

//인기 매장 리스트
private val _popularStoreList = MutableLiveData<List<StoreCouponCountModel>>()
val popularStoreList: LiveData<List<StoreCouponCountModel>> get() = _popularStoreList

init {
testData()
}

fun changeTab(tab: DetailTabType) {
_currentTab.value = tab
}

fun selectCategory(category: CategoryType) {
_category.value = category
//리스트 요청
}

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 = "양떼띠 로스터리는 2017년에 오픈한 강남의 유명 카페입니다. 강남역 직장인들을 위해 평일 오전 7시~9시에\n" +
"아메리카노 2000원 이벤트를 진행 중입니다.",
location = "가게 위치 정보",
longitude = 127.02629637,
latitude = 37.500075,
image = listOf(Uri.parse(""),
),
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class MainViewModel @Inject constructor(): ViewModel() {
private val _currentPageIndex = MutableLiveData<TabType>(TabType.HOME)
val currentPageIndex: LiveData<TabType> get() = _currentPageIndex



fun changePageIndex(type: TabType) {
_currentPageIndex.value = type
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.umc.coumo.presentation.adapter

import android.content.Context
import android.net.Uri
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.umc.coumo.databinding.ItemImageViewpagerBinding
import com.umc.coumo.utils.ItemDiffCallback

class ImageViewPagerAdapter(val context: Context): ListAdapter<Uri, RecyclerView.ViewHolder>(
ItemDiffCallback<Uri>(
onContentsTheSame = {old, new -> old == new},
onItemsTheSame = {old, new -> old == new}
)
){
inner class ItemViewHolder(
private val binding: ItemImageViewpagerBinding
): RecyclerView.ViewHolder(binding.root) {
fun bind(item: Uri) {
binding.item = item
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val inflater = LayoutInflater.from(parent.context)
return ItemViewHolder(ItemImageViewpagerBinding.inflate(inflater, parent, false))
}

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val item = getItem(position)

when (holder) {
is ItemViewHolder -> {
holder.bind(item)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MenuAdapter(
): ListAdapter<MenuModel, RecyclerView.ViewHolder>(
ItemDiffCallback<MenuModel>(
onContentsTheSame = {old, new -> old == new},
onItemsTheSame = {old, new -> old.id == new.id}
onItemsTheSame = {old, new -> old.name == new.name}
)
) {
companion object {
Expand Down Expand Up @@ -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)
}
}
}

Expand All @@ -68,10 +62,6 @@ companion object {
): RecyclerView.ViewHolder(binding.root) {
fun bind(item: MenuModel) {
binding.item = item

itemView.setOnClickListener {
listener?.onItemClick(item.id)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.umc.coumo.databinding.ItemStoreCouponCountBinding
import com.umc.coumo.databinding.ItemStoreInfoBinding
import com.umc.coumo.domain.model.StoreCouponCountModel
import com.umc.coumo.domain.model.StoreInfoModel
import com.umc.coumo.utils.ItemDiffCallback

class StoreCouponCountAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.umc.coumo.databinding.ItemStoreInfoBinding
import com.umc.coumo.domain.model.StoreInfoModel
import com.umc.coumo.domain.model.StoreInfoItemModel
import com.umc.coumo.utils.ItemDiffCallback

class StoreInfoAdapter(

): ListAdapter<StoreInfoModel, RecyclerView.ViewHolder>(
ItemDiffCallback<StoreInfoModel>(
): ListAdapter<StoreInfoItemModel, RecyclerView.ViewHolder>(
ItemDiffCallback<StoreInfoItemModel>(
onContentsTheSame = {old, new -> old == new},
onItemsTheSame = {old, new -> old.id == new.id}
)
Expand All @@ -35,7 +35,7 @@ class StoreInfoAdapter(
inner class StoreInfoViewHolder(
private val binding: ItemStoreInfoBinding
): RecyclerView.ViewHolder(binding.root) {
fun bind(item: StoreInfoModel) {
fun bind(item: StoreInfoItemModel) {
binding.item = item

itemView.setOnClickListener {
Expand Down
Loading

0 comments on commit cbba922

Please sign in to comment.