-
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 #6 from GEON-PPANG/feat-home-view
[feat] 홈 뷰 구현
- Loading branch information
Showing
23 changed files
with
879 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/sopt/geonppang/domain/model/BestBakery.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 com.sopt.geonppang.domain.model | ||
|
||
data class BestBakery( | ||
val bakeryId: Int, | ||
val bakeryName: String, | ||
val firstNearStation: String, | ||
val secondNearStation: String?, | ||
val isBooked: Boolean, | ||
val bookmarkCount: Int, | ||
// TODO image type -> String 으로 수정 | ||
val bakeryImage: Int, | ||
val reviewCount: Int, | ||
val isHACCP: Boolean, | ||
val isVegan: Boolean, | ||
val isNonGMO: Boolean, | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/sopt/geonppang/domain/model/BestReview.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 com.sopt.geonppang.domain.model | ||
|
||
data class BestReview( | ||
val bakeryId: Int, | ||
val bakeryName: String, | ||
val reviewText: String, | ||
val firstReviewChip: String, | ||
val secondReviewChip: String, | ||
val isBooked: Boolean, | ||
val bookmarkCount: Int, | ||
// TODO image type -> String 으로 수정 | ||
val bakeryImage: Int, | ||
val reviewCount: Int, | ||
) |
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
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/sopt/geonppang/presentation/home/BestBakeryAdapter.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,36 @@ | ||
package com.sopt.geonppang.presentation.home | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sopt.geonppang.databinding.ItemHomeBestBakeryBinding | ||
import com.sopt.geonppang.domain.model.BestBakery | ||
import com.sopt.geonppang.util.ItemDiffCallback | ||
|
||
class BestBakeryAdapter : ListAdapter<BestBakery, BestBakeryAdapter.BakeryViewHolder>( | ||
ItemDiffCallback<BestBakery>( | ||
onItemsTheSame = { old, new -> old.bakeryId == new.bakeryId }, | ||
onContentsTheSame = { old, new -> old == new } | ||
) | ||
) { | ||
|
||
class BakeryViewHolder( | ||
private val binding: ItemHomeBestBakeryBinding, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(bakery: BestBakery) { | ||
binding.bakery = bakery | ||
binding.executePendingBindings() | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BakeryViewHolder { | ||
val binding = | ||
ItemHomeBestBakeryBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return BakeryViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: BakeryViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/sopt/geonppang/presentation/home/BestReviewAdapter.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,36 @@ | ||
package com.sopt.geonppang.presentation.home | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sopt.geonppang.databinding.ItemHomeBestReviewBinding | ||
import com.sopt.geonppang.domain.model.BestReview | ||
import com.sopt.geonppang.util.ItemDiffCallback | ||
|
||
class BestReviewAdapter : ListAdapter<BestReview, BestReviewAdapter.ReviewViewHolder>( | ||
ItemDiffCallback<BestReview>( | ||
onItemsTheSame = { old, new -> old.bakeryId == new.bakeryId }, | ||
onContentsTheSame = { old, new -> old == new } | ||
) | ||
) { | ||
|
||
class ReviewViewHolder( | ||
private val binding: ItemHomeBestReviewBinding, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(review: BestReview) { | ||
binding.review = review | ||
binding.executePendingBindings() | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReviewViewHolder { | ||
val binding = | ||
ItemHomeBestReviewBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return ReviewViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ReviewViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/sopt/geonppang/presentation/home/HomeFragment.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,31 @@ | ||
package com.sopt.geonppang.presentation.home | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.viewModels | ||
import com.sopt.geonppang.R | ||
import com.sopt.geonppang.databinding.FragmentHomeBinding | ||
import com.sopt.geonppang.util.binding.BindingFragment | ||
|
||
class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home) { | ||
private val viewModel: HomeViewModel by viewModels() | ||
|
||
lateinit var bestBakeryAdapter: BestBakeryAdapter | ||
lateinit var bestReviewAdapter: BestReviewAdapter | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initLayout() | ||
} | ||
|
||
private fun initLayout() { | ||
bestBakeryAdapter = BestBakeryAdapter() | ||
binding.rvHomeBestBakeryList.adapter = bestBakeryAdapter | ||
bestBakeryAdapter.submitList(viewModel.mockBestBakeryList) | ||
|
||
bestReviewAdapter = BestReviewAdapter() | ||
binding.rvHomeBestReviewList.adapter = bestReviewAdapter | ||
bestReviewAdapter.submitList(viewModel.mockBestReviewList) | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
app/src/main/java/com/sopt/geonppang/presentation/home/HomeViewModel.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,110 @@ | ||
package com.sopt.geonppang.presentation.home | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.sopt.geonppang.R | ||
import com.sopt.geonppang.domain.model.BestBakery | ||
import com.sopt.geonppang.domain.model.BestReview | ||
|
||
class HomeViewModel : ViewModel() { | ||
val mockBestBakeryList = listOf( | ||
BestBakery( | ||
bakeryId = 1, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
firstNearStation = "건대역", | ||
secondNearStation = null, | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 5, | ||
isHACCP = true, | ||
isVegan = true, | ||
isNonGMO = true | ||
), | ||
BestBakery( | ||
bakeryId = 2, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
firstNearStation = "덕소역", | ||
secondNearStation = "구리역", | ||
isBooked = false, | ||
bookmarkCount = 0, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 5, | ||
isHACCP = false, | ||
isVegan = true, | ||
isNonGMO = true | ||
), | ||
BestBakery( | ||
bakeryId = 3, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
firstNearStation = "양정역", | ||
secondNearStation = "하암역", | ||
isBooked = false, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 5, | ||
isHACCP = false, | ||
isVegan = false, | ||
isNonGMO = true | ||
), | ||
BestBakery( | ||
bakeryId = 4, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
firstNearStation = "양원역", | ||
secondNearStation = "후앙역", | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 5, | ||
isHACCP = true, | ||
isVegan = false, | ||
isNonGMO = true | ||
), | ||
) | ||
|
||
val mockBestReviewList = listOf( | ||
BestReview( | ||
bakeryId = 1, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 4, | ||
reviewText = "정말 너무 맛있었어요! 갓 구운빵이 예술이었던 것 같아요오오오오오", | ||
firstReviewChip = "친절해요", | ||
secondReviewChip = "제로웨이스트" | ||
), | ||
BestReview( | ||
bakeryId = 2, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 4, | ||
reviewText = "정말 너무 맛있었어요! 갓 구운빵이 예술이었던 것 같아요오오오오오", | ||
firstReviewChip = "친절해요", | ||
secondReviewChip = "제로웨이스트" | ||
), | ||
BestReview( | ||
bakeryId = 3, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 4, | ||
reviewText = "정말 너무 맛있었어요! 갓 구운빵이 예술이었던 것 같아요오오오오오", | ||
firstReviewChip = "친절해요", | ||
secondReviewChip = "제로웨이스트" | ||
), | ||
BestReview( | ||
bakeryId = 4, | ||
bakeryName = "건대 비건빵아아아아아아", | ||
isBooked = true, | ||
bookmarkCount = 5, | ||
bakeryImage = R.drawable.bread1, | ||
reviewCount = 4, | ||
reviewText = "정말 너무 맛있었어요! 갓 구운빵이 예술이었던 것 같아요오오오오오", | ||
firstReviewChip = "친절해요", | ||
secondReviewChip = "제로웨이스트" | ||
), | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/white"/> | ||
<corners android:radius="5dp" /> | ||
</shape> |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<corners android:radius="43dp" /> | ||
<solid android:color="@color/gray_100" /> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<gradient | ||
android:angle="90" | ||
android:centerColor="#00ffffff" | ||
android:endColor="#00ffffff" | ||
android:startColor="#aa5B5B5B" /> | ||
</shape> |
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 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="34dp" | ||
android:height="34dp" | ||
android:viewportWidth="34" | ||
android:viewportHeight="34"> | ||
<path | ||
android:pathData="M17,17m-17,0a17,17 0,1 1,34 0a17,17 0,1 1,-34 0" | ||
android:fillColor="#FFCFC0"/> | ||
<path | ||
android:strokeWidth="1" | ||
android:pathData="M17.669,21.79L17.669,21.79L21.622,23.566C21.622,23.566 21.622,23.566 21.622,23.566C22.151,23.804 22.75,23.417 22.75,22.836V11.45C22.75,11.008 22.392,10.65 21.95,10.65H12.2C11.758,10.65 11.4,11.008 11.4,11.45V22.836C11.4,23.417 11.999,23.804 12.528,23.566L12.528,23.566L16.481,21.79L16.481,21.79C16.859,21.62 17.291,21.62 17.669,21.79ZM16.747,22.383L16.747,22.383L12.794,24.159C11.835,24.59 10.75,23.888 10.75,22.836V11.45C10.75,10.649 11.399,10 12.2,10H21.95C22.751,10 23.4,10.649 23.4,11.45V22.836C23.4,23.888 22.315,24.59 21.356,24.159C21.356,24.159 21.356,24.159 21.356,24.159L17.403,22.383L17.403,22.383C17.194,22.289 16.956,22.289 16.747,22.383ZM14.5,14.825C14.5,14.646 14.646,14.5 14.825,14.5H19.7C19.879,14.5 20.025,14.646 20.025,14.825C20.025,15.005 19.879,15.15 19.7,15.15H14.825C14.646,15.15 14.5,15.005 14.5,14.825Z" | ||
android:fillColor="#F0683E" | ||
android:strokeColor="#F0683E"/> | ||
</vector> |
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 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="32dp" | ||
android:height="33dp" | ||
android:viewportWidth="32" | ||
android:viewportHeight="33"> | ||
<path | ||
android:pathData="M16,16.5m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0" | ||
android:fillColor="#FAF7F2"/> | ||
<path | ||
android:strokeWidth="1" | ||
android:pathData="M16.572,20.808L16.572,20.808L20.086,22.387C20.593,22.615 21.167,22.244 21.167,21.688V11.567C21.167,11.143 20.823,10.8 20.4,10.8H11.733C11.31,10.8 10.967,11.143 10.967,11.567V21.688C10.967,22.244 11.54,22.615 12.047,22.387L12.047,22.387L15.561,20.808L15.561,20.808C15.883,20.664 16.251,20.664 16.572,20.808ZM15.753,21.234L15.752,21.234L12.239,22.813C11.423,23.179 10.5,22.582 10.5,21.688V11.567C10.5,10.886 11.052,10.333 11.733,10.333H20.4C21.081,10.333 21.633,10.886 21.633,11.567V21.688C21.633,22.582 20.711,23.179 19.895,22.813C19.895,22.813 19.895,22.813 19.895,22.813L16.381,21.234L16.381,21.234C16.181,21.144 15.952,21.144 15.753,21.234ZM13.833,14.567C13.833,14.438 13.938,14.333 14.067,14.333H18.4C18.529,14.333 18.633,14.438 18.633,14.567C18.633,14.696 18.529,14.8 18.4,14.8H14.067C13.938,14.8 13.833,14.696 13.833,14.567Z" | ||
android:fillColor="#CBC8C5" | ||
android:strokeColor="#CBC8C5"/> | ||
</vector> |
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,26 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="26dp" | ||
android:height="26dp" | ||
android:viewportWidth="26" | ||
android:viewportHeight="26"> | ||
<group> | ||
<clip-path | ||
android:pathData="M0,0h26v26h-26z"/> | ||
<path | ||
android:pathData="M13,25.304C19.795,25.304 25.303,19.795 25.303,13C25.303,6.205 19.795,0.697 13,0.697C6.205,0.697 0.696,6.205 0.696,13C0.696,19.795 6.205,25.304 13,25.304Z" | ||
android:strokeWidth="1.5" | ||
android:fillColor="#FAF7F2" | ||
android:strokeColor="#238448"/> | ||
<path | ||
android:pathData="M5.107,21.822L20.429,3.714" | ||
android:strokeWidth="1.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#238448"/> | ||
<path | ||
android:pathData="M22.337,8.357H2.734V17.643H22.337V8.357Z" | ||
android:fillColor="#FAF7F2"/> | ||
<path | ||
android:pathData="M7.876,11.961C7.747,11.487 7.363,11.205 6.803,11.209C5.968,11.205 5.439,11.84 5.439,12.941C5.439,14.05 5.944,14.689 6.803,14.689C7.559,14.689 7.982,14.293 8.002,13.678H6.857V12.698H9.287V13.443C9.287,14.955 8.249,15.864 6.795,15.864C5.172,15.864 4.075,14.751 4.075,12.957C4.075,11.103 5.263,10.033 6.771,10.033C8.08,10.033 9.087,10.829 9.232,11.961H7.876ZM9.982,10.112H11.636L13.101,13.686H13.164L14.63,10.112H16.283V15.786H14.982V12.259H14.935L13.556,15.755H12.709L11.33,12.243H11.283V15.786H9.982V10.112ZM22.355,12.949C22.358,14.818 21.179,15.864 19.659,15.864C18.13,15.864 16.962,14.81 16.962,12.949C16.962,11.076 18.13,10.033 19.659,10.033C21.179,10.033 22.358,11.076 22.355,12.949ZM18.326,12.949C18.326,14.077 18.832,14.689 19.659,14.689C20.489,14.689 20.995,14.077 20.991,12.949C20.995,11.82 20.489,11.205 19.659,11.209C18.832,11.205 18.326,11.82 18.326,12.949Z" | ||
android:fillColor="#238448"/> | ||
</group> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.