Skip to content

Commit

Permalink
Merge pull request #263 from BCSDLab/fix/store-detail
Browse files Browse the repository at this point in the history
[Fix] Store Detail 이슈 해결
  • Loading branch information
ThirFir authored May 10, 2024
2 parents eea05cc + add09cb commit 96739e9
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.bumptech.glide.Glide
import com.google.android.material.tabs.TabLayoutMediator
import `in`.koreatech.koin.R
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.appbar.AppBarBase
import `in`.koreatech.koin.core.constant.AnalyticsConstant
import `in`.koreatech.koin.core.toast.ToastUtil
import `in`.koreatech.koin.core.util.dataBinding
Expand Down Expand Up @@ -76,6 +77,12 @@ class StoreDetailActivity : KoinNavigationDrawerActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.koinBaseAppbar.setOnClickListener {
when (it.id) {
AppBarBase.getLeftButtonId() -> onBackPressed()
AppBarBase.getRightButtonId() -> toggleNavigationDrawer()
}
}
binding.storeDetailViewPager.adapter = storeDetailViewpagerAdapter
binding.storeDetailCallButton.setOnClickListener {
showCallDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class StoreDetailMenuRecyclerAdapter :

fun setCategory(category: String?) {
(binding as StoreDetailMenuHeaderBinding).textViewHeaderTitle.text = category
binding.imageViewHeaderIcon.setImageResource(
binding.imageViewHeaderIcon.setBackgroundResource(

when (category) {

"추천메뉴" -> R.drawable.ic_recommend
"메인메뉴" -> R.drawable.ic_represent
"세트메뉴" -> R.drawable.ic_set
"사이드메뉴" -> R.drawable.ic_side
"추천 메뉴" -> R.drawable.ic_recommend
"메인 메뉴" -> R.drawable.ic_represent
"세트 메뉴" -> R.drawable.ic_set
"사이드 메뉴" -> R.drawable.ic_side
else -> R.drawable.ic_represent
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package `in`.koreatech.koin.ui.store.fragment

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import `in`.koreatech.koin.R
import `in`.koreatech.koin.databinding.FragmentStoreDetailMenuBinding
import `in`.koreatech.koin.domain.model.store.ShopMenus
Expand All @@ -24,14 +22,18 @@ class StoreDetailMenuFragment : Fragment() {
private val binding: FragmentStoreDetailMenuBinding get() = _binding!!
private val viewModel by activityViewModels<StoreDetailViewModel>()

private val storeMenuAdapter: MutableList<StoreDetailMenuRecyclerAdapter> =
List(4) { StoreDetailMenuRecyclerAdapter() }.toMutableList()
private val storeRecommendMenuAdapter = StoreDetailMenuRecyclerAdapter()
private val storeMainMenuAdapter = StoreDetailMenuRecyclerAdapter()
private val storeSetMenuAdapter = StoreDetailMenuRecyclerAdapter()
private val storeSideMenuAdapter = StoreDetailMenuRecyclerAdapter()

private var selectedCategory: String = "추천 메뉴"

private val storeDetailActivityContract =
registerForActivityResult(StoreDetailActivityContract()) {
}

private val storeRecyclerAdapter = StoreRecyclerAdapter().apply {
private val storeRandomRecyclerAdapter = StoreRecyclerAdapter().apply {
setOnItemClickListener {
storeDetailActivityContract.launch(it.uid)
requireActivity().finish()
Expand All @@ -55,14 +57,12 @@ class StoreDetailMenuFragment : Fragment() {
}

private fun initViews() {
repeat(4) {
storeMenuAdapter.add(StoreDetailMenuRecyclerAdapter())
}
binding.storeDetailRecommendRecyclerview.adapter = storeMenuAdapter[0]
binding.storeDetailMainRecyclerview.adapter = storeMenuAdapter[1]
binding.storeDetailSetRecyclerview.adapter = storeMenuAdapter[2]
binding.storeDetailSideRecyclerview.adapter = storeMenuAdapter[3]
binding.storeRandomRecyclerView.adapter = storeRecyclerAdapter
binding.storeDetailRecommendRecyclerview.adapter = storeRecommendMenuAdapter
binding.storeDetailMainRecyclerview.adapter = storeMainMenuAdapter
binding.storeDetailSetRecyclerview.adapter = storeSetMenuAdapter
binding.storeDetailSideRecyclerview.adapter = storeSideMenuAdapter
binding.storeRandomRecyclerView.adapter = storeRandomRecyclerAdapter

}

@SuppressLint("ResourceAsColor")
Expand Down Expand Up @@ -94,44 +94,136 @@ class StoreDetailMenuFragment : Fragment() {
)
}
}
storeMenuAdapter[index].submitList(
list
)

when(category.name){
"추천 메뉴" -> {
binding.storeDetailRecommendRecyclerview.visibility = View.VISIBLE
storeRecommendMenuAdapter.submitList(list)
binding.storeDetailRecommendMenuButton.setOnClickListener {
binding.storeDetailMenuNestedScrollView.smoothScrollTo(0, binding.storeDetailRecommendRecyclerview.top)
setUnselectedCategoryButtonStyle(selectedCategory)
selectedCategory = "추천 메뉴"
setSelectedCategoryButtonStyle(selectedCategory)
}
}
"메인 메뉴" -> {
binding.storeDetailMainRecyclerview.visibility = View.VISIBLE
storeMainMenuAdapter.submitList(list)
binding.storeDetailMainMenuButton.setOnClickListener {
binding.storeDetailMenuNestedScrollView.smoothScrollTo(0, binding.storeDetailMainRecyclerview.top)
setUnselectedCategoryButtonStyle(selectedCategory)
selectedCategory = "메인 메뉴"
setSelectedCategoryButtonStyle(selectedCategory)
}
}
"세트 메뉴" -> {
binding.storeDetailSetRecyclerview.visibility = View.VISIBLE
storeSetMenuAdapter.submitList(list)
binding.storeDetailSetMenuButton.setOnClickListener {
binding.storeDetailMenuNestedScrollView.smoothScrollTo(0, binding.storeDetailSetRecyclerview.top)
setUnselectedCategoryButtonStyle(selectedCategory)
selectedCategory = "세트 메뉴"
setSelectedCategoryButtonStyle(selectedCategory)
}
}
"사이드 메뉴" -> {
binding.storeDetailSideRecyclerview.visibility = View.VISIBLE
storeSideMenuAdapter.submitList(list)
binding.storeDetailSideMenuButton.setOnClickListener {
binding.storeDetailMenuNestedScrollView.smoothScrollTo(0, binding.storeDetailSideRecyclerview.top)
setUnselectedCategoryButtonStyle(selectedCategory)
selectedCategory = "사이드 메뉴"
setSelectedCategoryButtonStyle(selectedCategory)
}
}
}
}
}
}
observeLiveData(viewModel.recommendStores) {
if (it != null) {
storeRecyclerAdapter.submitList(it)
storeRandomRecyclerAdapter.submitList(it)
}
}
observeLiveData(viewModel.categories) {
if (it.menuCategories != null) {
viewModel.categories.value?.menuCategories?.forEachIndexed { index, category ->
if(binding.storeDetailMainMenuTextView.text == category.name){
binding.storeDetailMainMenuButton.strokeColor= ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailMainMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
else if(binding.storeDetailSetMenuTextView.text == category.name){
binding.storeDetailSetMenuButton.strokeColor= ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailSetMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
else if (binding.storeDetailSideMenuTextView.text == category.name){
binding.storeDetailSideMenuButton.strokeColor = ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailSideMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
else{
binding.storeDetailRecommendMenuButton.strokeColor= ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailRecommendMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
when(category.name) {
binding.storeDetailMainMenuTextView.text -> {
binding.storeDetailMainMenuButton.strokeColor = ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailMainMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
binding.storeDetailSetMenuTextView.text -> {
binding.storeDetailSetMenuButton.strokeColor = ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailSetMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
binding.storeDetailSideMenuTextView.text -> {
binding.storeDetailSideMenuButton.strokeColor = ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailSideMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
else -> {
binding.storeDetailRecommendMenuButton.strokeColor = ContextCompat.getColor(requireContext(), R.color.gray15)
binding.storeDetailRecommendMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
}
}


storeMenuAdapter[index].setCategory(category.name)
when(category.name){
"추천 메뉴" -> storeRecommendMenuAdapter.setCategory(category.name)
"메인 메뉴" -> storeMainMenuAdapter.setCategory(category.name)
"세트 메뉴" -> storeSetMenuAdapter.setCategory(category.name)
"사이드 메뉴" -> storeSideMenuAdapter.setCategory(category.name)
}
}
}
}
}
}
private fun setSelectedCategoryButtonStyle(name: String) {
when(name) {
"추천 메뉴" -> {
binding.storeDetailRecommendMenuButton.strokeWidth = 0
binding.storeDetailRecommendMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
binding.storeDetailRecommendMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
}
"메인 메뉴" -> {
binding.storeDetailMainMenuButton.strokeWidth = 0
binding.storeDetailMainMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
binding.storeDetailMainMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
}
"세트 메뉴" -> {
binding.storeDetailSetMenuButton.strokeWidth = 0
binding.storeDetailSetMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
binding.storeDetailSetMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
}
"사이드 메뉴" -> {
binding.storeDetailSideMenuButton.strokeWidth = 0
binding.storeDetailSideMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
binding.storeDetailSideMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
}
}
}
private fun setUnselectedCategoryButtonStyle(name: String) {
when(name) {
"추천 메뉴" -> {
binding.storeDetailRecommendMenuButton.strokeWidth = 1
binding.storeDetailRecommendMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
binding.storeDetailRecommendMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
}
"메인 메뉴" -> {
binding.storeDetailMainMenuButton.strokeWidth = 1
binding.storeDetailMainMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
binding.storeDetailMainMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
}
"세트 메뉴" -> {
binding.storeDetailSetMenuButton.strokeWidth = 1
binding.storeDetailSetMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
binding.storeDetailSetMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
}
"사이드 메뉴" -> {
binding.storeDetailSideMenuButton.strokeWidth = 1
binding.storeDetailSideMenuTextView.setTextColor(ContextCompat.getColor(requireContext(), R.color.gray10))
binding.storeDetailSideMenuButton.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
}
}

}
}
Loading

0 comments on commit 96739e9

Please sign in to comment.