Skip to content

Commit

Permalink
[feat] : #15 더보기 바텀다이얼로그 셋팅
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed May 19, 2023
1 parent 40cf3ca commit b32417d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.teampome.pome.presentation.friend

//친구 기록 클릭 리스너
interface FriendDetailRecordClickListener {

fun onFriendDetailMoreClick()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,34 @@ import android.widget.Toast
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.teampome.pome.R
import com.teampome.pome.databinding.FragmentFriendBinding
import com.teampome.pome.databinding.PomeCalendarBottomSheetDialogBinding
import com.teampome.pome.databinding.PomeFriendSettingBottomSheetDialogBinding
import com.teampome.pome.databinding.PomeRecordMoreGoalBottomSheetDialogBinding
import com.teampome.pome.util.base.ApiResponse
import com.teampome.pome.util.base.BaseFragment
import com.teampome.pome.util.base.CoroutineErrorHandler
import com.teampome.pome.viewmodel.AddFriendsViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_friend) {
class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_friend), FriendDetailRecordClickListener {

private val viewModel: AddFriendsViewModel by viewModels()

private lateinit var friendGetAdapter: FriendGetAdapter
private lateinit var friendRecordGetAdapter: FriendRecordGetAdapter

private lateinit var pomeFriendSettingBottomSheetDialogBinding : PomeFriendSettingBottomSheetDialogBinding
private lateinit var friendSettingBottomSheetDialog: BottomSheetDialog

override fun initView() {
setUpRecyclerView()
friendRecordSetUpRecyclerView()
getAllFriendRecord()
makeFriendSettingBottomDialog()

//친구 조회
viewModel.getFriend(object : CoroutineErrorHandler{
Expand All @@ -42,6 +50,7 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri
viewModel.getFriendsResponse.observe(viewLifecycleOwner) {
when(it) {
is ApiResponse.Success -> {
hideLoading()
it.data.data?.let { list ->
if(list.isEmpty()) {
binding.friendNotIv.visibility = View.VISIBLE
Expand All @@ -56,9 +65,11 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri
}
}
is ApiResponse.Failure -> {

hideLoading()
}
is ApiResponse.Loading -> {
showLoading()
}
is ApiResponse.Loading -> {}
}
}

Expand Down Expand Up @@ -128,7 +139,7 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri

//친구 기록 조회 RV
private fun friendRecordSetUpRecyclerView(){
friendRecordGetAdapter = FriendRecordGetAdapter()
friendRecordGetAdapter = FriendRecordGetAdapter(this)
binding.friendDetailRv.apply {
// setHasFixedSize(true)
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
Expand All @@ -149,4 +160,27 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri
}
})
}

private fun makeFriendSettingBottomDialog() {
friendSettingBottomSheetDialog = BottomSheetDialog(requireContext())
pomeFriendSettingBottomSheetDialogBinding = PomeFriendSettingBottomSheetDialogBinding.inflate(layoutInflater, null, false)

friendSettingBottomSheetDialog.setContentView(pomeFriendSettingBottomSheetDialogBinding.root)

pomeFriendSettingBottomSheetDialogBinding.apply{
//숨기기
pomeFriendBottomSheetDialogHideTv.setOnClickListener {
friendSettingBottomSheetDialog.dismiss()
}

//신고
pomeFriendBottomSheetDialogReportTv.setOnClickListener {
friendSettingBottomSheetDialog.dismiss()
}
}
}

override fun onFriendDetailMoreClick() {
friendSettingBottomSheetDialog.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import com.teampome.pome.model.response.GetFriendRecord
import com.teampome.pome.model.response.GetFriends

//친구 기록 조회
class FriendRecordGetAdapter : ListAdapter<GetFriendRecord, FriendRecordGetAdapter.FriendGetRecordViewHolder>(BookDiffCallback) {
class FriendRecordGetAdapter(
private val clickListener: FriendDetailRecordClickListener
) : ListAdapter<GetFriendRecord, FriendRecordGetAdapter.FriendGetRecordViewHolder>(BookDiffCallback) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendGetRecordViewHolder {
return FriendGetRecordViewHolder(
clickListener,
ItemFriendDetailCardBinding.inflate(LayoutInflater.from(parent.context), parent, false),
)
}
Expand All @@ -33,11 +36,18 @@ class FriendRecordGetAdapter : ListAdapter<GetFriendRecord, FriendRecordGetAdapt
}

inner class FriendGetRecordViewHolder(
private val friendDetailRecordClickListener: FriendDetailRecordClickListener,
private val binding : ItemFriendDetailCardBinding,
) : RecyclerView.ViewHolder(binding.root){

fun bind(getFriedRecord: GetFriendRecord){
binding.getFriendRecord = getFriedRecord
with(binding) {
getFriendRecord = getFriedRecord

friendDetailMoreSettingIv.setOnClickListener {
friendDetailRecordClickListener.onFriendDetailMoreClick()
}
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_friend_detail_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv"
android:id="@+id/friend_detail_more_setting_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
Expand Down

0 comments on commit b32417d

Please sign in to comment.