-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from NOW-SOPT-APP4-KREAM/feat-view2-xml
[feat] 추천 뷰 구현
- Loading branch information
Showing
68 changed files
with
1,591 additions
and
28 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
app/src/main/java/org/sopt/kream/data/datasource/ProductRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package org.sopt.kream.data.datasource | ||
|
||
import org.sopt.kream.data.model.response.ResponseProductDetailDto | ||
import org.sopt.kream.data.model.response.ResponseRecommendProductDto | ||
import org.sopt.kream.data.model.response.ResponseSearchProductDto | ||
import org.sopt.kream.util.base.BaseResponse | ||
|
||
interface ProductRemoteDataSource { | ||
suspend fun getSearchProduct(findName: String): BaseResponse<ResponseSearchProductDto> | ||
|
||
suspend fun getProductDetail(productId: Int): BaseResponse<ResponseProductDetailDto> | ||
|
||
suspend fun getRecommendProduct(memberId: Int): BaseResponse<ResponseRecommendProductDto> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/sopt/kream/data/mapper/RecommendForYouProductResponseDtoMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.sopt.kream.data.mapper | ||
|
||
import org.sopt.kream.data.model.response.ResponseRecommendProductDto.ResponseForYouProductDto | ||
import org.sopt.kream.domain.model.RecommendForYouProductModel | ||
|
||
fun ResponseForYouProductDto.toRecommendForYouProductModel() = | ||
RecommendForYouProductModel( | ||
thumbnailUrl = this.thumbnailUrl, | ||
brandTitle = this.brandTitle, | ||
engTitle = this.engTitle, | ||
price = this.price, | ||
transactionCount = this.transactionCount, | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/sopt/kream/data/mapper/RecommendJustDroppedProductResponseDtoMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.kream.data.mapper | ||
|
||
import org.sopt.kream.data.model.response.ResponseRecommendProductDto.ResponseJustDroppedProductDto | ||
import org.sopt.kream.domain.model.RecommendJustDroppedProductModel | ||
|
||
fun ResponseJustDroppedProductDto.toRecommendJustDroppedProductModel() = | ||
RecommendJustDroppedProductModel( | ||
thumbnailUrl = this.thumbnailUrl, | ||
brandTitle = this.brandTitle, | ||
engTitle = this.engTitle, | ||
price = this.price, | ||
transactionCount = this.transactionCount, | ||
isScrap = this.isScrap, | ||
isFast = this.isFast, | ||
isFreeDeliver = this.isFreeDeliver, | ||
isSave = this.isSave, | ||
isCoupon = this.isCoupon, | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/sopt/kream/data/mapper/ResponseRecommendProductDtoMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sopt.kream.data.mapper | ||
|
||
import org.sopt.kream.data.model.response.ResponseRecommendProductDto | ||
import org.sopt.kream.domain.model.RecommendProductModel | ||
|
||
fun ResponseRecommendProductDto.toRecommendProductModel() = | ||
RecommendProductModel( | ||
recommendForYouProducts = this.forYouList.map { it.toRecommendForYouProductModel() }, | ||
recommendJustDroppedProducts = this.justDropList.map { it.toRecommendJustDroppedProductModel() }, | ||
) |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/org/sopt/kream/data/model/response/ResponseRecommendProductDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.sopt.kream.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseRecommendProductDto( | ||
@SerialName("forYouList") | ||
val forYouList: List<ResponseForYouProductDto>, | ||
@SerialName("justDropList") | ||
val justDropList: List<ResponseJustDroppedProductDto>, | ||
) { | ||
@Serializable | ||
data class ResponseForYouProductDto( | ||
@SerialName("thumbnailUrl") | ||
val thumbnailUrl: String, | ||
@SerialName("brandTitle") | ||
val brandTitle: String, | ||
@SerialName("engTitle") | ||
val engTitle: String, | ||
@SerialName("price") | ||
val price: String, | ||
@SerialName("transactionCount") | ||
val transactionCount: String, | ||
) | ||
|
||
@Serializable | ||
data class ResponseJustDroppedProductDto( | ||
@SerialName("thumbnailUrl") | ||
val thumbnailUrl: String, | ||
@SerialName("brandTitle") | ||
val brandTitle: String, | ||
@SerialName("engTitle") | ||
val engTitle: String, | ||
@SerialName("price") | ||
val price: String, | ||
@SerialName("transactionCount") | ||
val transactionCount: String, | ||
@SerialName("isScrap") | ||
val isScrap: Boolean, | ||
@SerialName("isFast") | ||
val isFast: Boolean, | ||
@SerialName("isFreeDeliver") | ||
val isFreeDeliver: Boolean, | ||
@SerialName("isSave") | ||
val isSave: Boolean, | ||
@SerialName("isCoupon") | ||
val isCoupon: Boolean, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/kream/domain/model/RecommendForYouProductModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.kream.domain.model | ||
|
||
data class RecommendForYouProductModel( | ||
val thumbnailUrl: String, | ||
val brandTitle: String, | ||
val engTitle: String, | ||
val price: String, | ||
val transactionCount: String, | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/kream/domain/model/RecommendJustDroppedProductModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.sopt.kream.domain.model | ||
|
||
data class RecommendJustDroppedProductModel( | ||
val thumbnailUrl: String, | ||
val brandTitle: String, | ||
val engTitle: String, | ||
val price: String, | ||
val transactionCount: String, | ||
val isScrap: Boolean, | ||
val isFast: Boolean, | ||
val isFreeDeliver: Boolean, | ||
val isSave: Boolean, | ||
val isCoupon: Boolean, | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/org/sopt/kream/domain/model/RecommendProductModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.sopt.kream.domain.model | ||
|
||
data class RecommendProductModel( | ||
val recommendForYouProducts: List<RecommendForYouProductModel>, | ||
val recommendJustDroppedProducts: List<RecommendJustDroppedProductModel>, | ||
) |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/org/sopt/kream/domain/repository/ProductRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package org.sopt.kream.domain.repository | ||
|
||
import org.sopt.kream.domain.model.ProductDetailModel | ||
import org.sopt.kream.domain.model.RecommendProductModel | ||
import org.sopt.kream.domain.model.SearchProductModel | ||
|
||
interface ProductRepository { | ||
suspend fun getSearchProduct(findName: String): Result<SearchProductModel> | ||
|
||
suspend fun getProductDetail(productId: Int): Result<ProductDetailModel> | ||
|
||
suspend fun getRecommendProduct(memberId: Int): Result<RecommendProductModel> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/kream/presentation/model/InstagramModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.sopt.kream.presentation.model | ||
|
||
import androidx.annotation.DrawableRes | ||
|
||
data class InstagramModel( | ||
@DrawableRes val image: Int, | ||
val id: String, | ||
) |
16 changes: 16 additions & 0 deletions
16
...va/org/sopt/kream/presentation/ui/main/home/recommend/RecommendAdvertisementViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.kream.presentation.ui.main.home.recommend | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import org.sopt.kream.databinding.ItemRecommendAdvertisementBinding | ||
|
||
class RecommendAdvertisementViewHolder( | ||
private val binding: ItemRecommendAdvertisementBinding, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind( | ||
item: Int, | ||
) { | ||
with(binding) { | ||
ivRecommendAdvertisement.setImageResource(item) | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../sopt/kream/presentation/ui/main/home/recommend/RecommendAdvertisementViewPagerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.sopt.kream.presentation.ui.main.home.recommend | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.sopt.kream.databinding.ItemRecommendAdvertisementBinding | ||
|
||
class RecommendAdvertisementViewPagerAdapter(private val data: List<Int>) : RecyclerView.Adapter<RecommendAdvertisementViewHolder>() { | ||
private val item = data | ||
|
||
override fun getItemCount(): Int = item.size | ||
|
||
override fun onBindViewHolder( | ||
holder: RecommendAdvertisementViewHolder, | ||
position: Int, | ||
) { | ||
holder.onBind(item[position]) | ||
} | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): RecommendAdvertisementViewHolder { | ||
val binding = ItemRecommendAdvertisementBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return RecommendAdvertisementViewHolder(binding) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ain/java/org/sopt/kream/presentation/ui/main/home/recommend/RecommendCircleMenuAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.sopt.kream.presentation.ui.main.home.recommend | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.sopt.kream.databinding.ItemRecommendCircleMenuBinding | ||
import org.sopt.kream.presentation.ui.type.RecommendCircleMenuType | ||
import kotlin.enums.EnumEntries | ||
|
||
class RecommendCircleMenuAdapter(private val list: EnumEntries<RecommendCircleMenuType>) : RecyclerView.Adapter<RecommendCircleMenuViewHolder>() { | ||
private val item = list | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): RecommendCircleMenuViewHolder { | ||
val binding = ItemRecommendCircleMenuBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return RecommendCircleMenuViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder( | ||
holder: RecommendCircleMenuViewHolder, | ||
position: Int, | ||
) { | ||
holder.onBind(item.get(position)) | ||
} | ||
|
||
override fun getItemCount(): Int = list.size | ||
} |
18 changes: 18 additions & 0 deletions
18
.../java/org/sopt/kream/presentation/ui/main/home/recommend/RecommendCircleMenuViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.kream.presentation.ui.main.home.recommend | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import org.sopt.kream.databinding.ItemRecommendCircleMenuBinding | ||
import org.sopt.kream.presentation.ui.type.RecommendCircleMenuType | ||
|
||
class RecommendCircleMenuViewHolder( | ||
private val binding: ItemRecommendCircleMenuBinding, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind( | ||
item: RecommendCircleMenuType, | ||
) { | ||
with(binding) { | ||
ivCircleMenu.setImageResource(item.image) | ||
tvCircleMenuTitle.setText(item.menu) | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...rc/main/java/org/sopt/kream/presentation/ui/main/home/recommend/RecommendForYouAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.sopt.kream.presentation.ui.main.home.recommend | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import org.sopt.kream.databinding.ItemRecommendForYouProductBinding | ||
import org.sopt.kream.domain.model.RecommendForYouProductModel | ||
import org.sopt.kream.util.view.ItemDiffCallback | ||
|
||
class RecommendForYouAdapter( | ||
private val navigateToProductDetail: (Int) -> Unit, | ||
private val page: Int, | ||
) : ListAdapter< | ||
RecommendForYouProductModel, | ||
RecommendForYouViewHolder, | ||
>( | ||
ItemDiffCallback<RecommendForYouProductModel>( | ||
onContentsTheSame = { old, new -> old == new }, | ||
onItemsTheSame = { old, new -> old.engTitle == new.engTitle }, | ||
), | ||
) { | ||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): RecommendForYouViewHolder = | ||
RecommendForYouViewHolder( | ||
ItemRecommendForYouProductBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false, | ||
), | ||
navigateToProductDetail, | ||
) | ||
|
||
override fun onBindViewHolder( | ||
holder: RecommendForYouViewHolder, | ||
position: Int, | ||
) { | ||
holder.onBind( | ||
recommendForYouProductModel = currentList[page * 6 + position], | ||
position = position, | ||
) | ||
} | ||
} |
Oops, something went wrong.