From b32417df981fa2c6ddbbf117f5f56e762bb50b88 Mon Sep 17 00:00:00 2001 From: SsongSik Date: Fri, 19 May 2023 17:01:20 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20:=20#15=20=EB=8D=94=EB=B3=B4=EA=B8=B0?= =?UTF-8?q?=20=EB=B0=94=ED=85=80=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=85=8B=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/FriendDetailRecordClickListener.kt | 7 ++++ .../presentation/friend/FriendFragment.kt | 42 +++++++++++++++++-- .../friend/FriendRecordGetAdapter.kt | 14 ++++++- .../res/layout/item_friend_detail_card.xml | 2 +- 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/presentation/friend/FriendDetailRecordClickListener.kt diff --git a/app/src/main/java/com/teampome/pome/presentation/friend/FriendDetailRecordClickListener.kt b/app/src/main/java/com/teampome/pome/presentation/friend/FriendDetailRecordClickListener.kt new file mode 100644 index 00000000..4075d246 --- /dev/null +++ b/app/src/main/java/com/teampome/pome/presentation/friend/FriendDetailRecordClickListener.kt @@ -0,0 +1,7 @@ +package com.teampome.pome.presentation.friend + +//친구 기록 클릭 리스너 +interface FriendDetailRecordClickListener { + + fun onFriendDetailMoreClick() +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/friend/FriendFragment.kt b/app/src/main/java/com/teampome/pome/presentation/friend/FriendFragment.kt index f943a307..d22185cf 100644 --- a/app/src/main/java/com/teampome/pome/presentation/friend/FriendFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/friend/FriendFragment.kt @@ -6,8 +6,12 @@ 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 @@ -15,17 +19,21 @@ import com.teampome.pome.viewmodel.AddFriendsViewModel import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint -class FriendFragment : BaseFragment(R.layout.fragment_friend) { +class FriendFragment : BaseFragment(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{ @@ -42,6 +50,7 @@ class FriendFragment : BaseFragment(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 @@ -56,9 +65,11 @@ class FriendFragment : BaseFragment(R.layout.fragment_fri } } is ApiResponse.Failure -> { - + hideLoading() + } + is ApiResponse.Loading -> { + showLoading() } - is ApiResponse.Loading -> {} } } @@ -128,7 +139,7 @@ class FriendFragment : BaseFragment(R.layout.fragment_fri //친구 기록 조회 RV private fun friendRecordSetUpRecyclerView(){ - friendRecordGetAdapter = FriendRecordGetAdapter() + friendRecordGetAdapter = FriendRecordGetAdapter(this) binding.friendDetailRv.apply { // setHasFixedSize(true) layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) @@ -149,4 +160,27 @@ class FriendFragment : BaseFragment(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() + } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/friend/FriendRecordGetAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/friend/FriendRecordGetAdapter.kt index 1d9b6772..4c5aadc0 100644 --- a/app/src/main/java/com/teampome/pome/presentation/friend/FriendRecordGetAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/friend/FriendRecordGetAdapter.kt @@ -11,10 +11,13 @@ import com.teampome.pome.model.response.GetFriendRecord import com.teampome.pome.model.response.GetFriends //친구 기록 조회 -class FriendRecordGetAdapter : ListAdapter(BookDiffCallback) { +class FriendRecordGetAdapter( + private val clickListener: FriendDetailRecordClickListener +) : ListAdapter(BookDiffCallback) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendGetRecordViewHolder { return FriendGetRecordViewHolder( + clickListener, ItemFriendDetailCardBinding.inflate(LayoutInflater.from(parent.context), parent, false), ) } @@ -33,11 +36,18 @@ class FriendRecordGetAdapter : ListAdapter