Skip to content

Commit

Permalink
#86 refactor : BottomSheet 함수 -> class 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
plashdof committed Nov 26, 2023
1 parent ce4b663 commit ed9835f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.avengers.nibobnebob.presentation.customview

import android.content.Context
import android.view.LayoutInflater
import com.avengers.nibobnebob.R
import com.avengers.nibobnebob.databinding.BottomSheetRestaurantBinding
import com.avengers.nibobnebob.presentation.ui.main.home.model.UiMarkerData
import com.google.android.material.bottomsheet.BottomSheetDialog


class RestaurantBottomSheet(
context: Context,
private val data: UiMarkerData,
private val onClickAddWishRestaurant: (Int, Boolean) -> Boolean,
private val onClickAddMyRestaurant: (Int) -> Unit,
private val onClickGoReview: (Int) -> Unit
): BottomSheetDialog(context) {

private var binding: BottomSheetRestaurantBinding
private var isWishState = data.isInWishList

init{
binding = BottomSheetRestaurantBinding.inflate(LayoutInflater.from(context))
setContentView(binding.root)
binding.item = data
setBottomSheetListener()
}

private fun setBottomSheetListener(){
binding.btnAddMyRestaurant.setOnClickListener {
onClickAddMyRestaurant(data.id)
dismiss()
}

binding.btnAddWishRestaurant.setOnClickListener {
val result = onClickAddWishRestaurant(data.id, data.isInWishList)

if (result) {
isWishState = !isWishState

if (isWishState) {
binding.btnAddWishRestaurant.setBackgroundResource(R.drawable.ic_star_full)
} else {
binding.btnAddWishRestaurant.setBackgroundResource(R.drawable.ic_star_border)
}
}
}

binding.btnGoReview.setOnClickListener {
onClickGoReview(data.id)
dismiss()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.avengers.nibobnebob.NavGraphDirections
import com.avengers.nibobnebob.R
import com.avengers.nibobnebob.databinding.FragmentHomeBinding
import com.avengers.nibobnebob.presentation.base.BaseFragment
import com.avengers.nibobnebob.presentation.customview.RestaurantBottomSheet
import com.avengers.nibobnebob.presentation.ui.main.MainViewModel
import com.avengers.nibobnebob.presentation.ui.main.home.adapter.HomeFilterAdapter
import com.avengers.nibobnebob.presentation.ui.main.home.model.UiMarkerData
import com.avengers.nibobnebob.presentation.util.restaurantSheet
import com.naver.maps.geometry.LatLng
import com.naver.maps.map.LocationTrackingMode
import com.naver.maps.map.MapFragment
Expand Down Expand Up @@ -185,13 +185,14 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),
marker.map = naverMap

marker.setOnClickListener {
restaurantSheet(
val bottomSheet = RestaurantBottomSheet(
context = requireContext(),
data = data,
onClickAddWishRestaurant = ::addWishTest,
onClickAddMyRestaurant = ::addRestaurantTest,
onClickGoReview = ::goReviewTest
).show()
)
bottomSheet.show()

true
}
Expand Down

This file was deleted.

0 comments on commit ed9835f

Please sign in to comment.