Skip to content

Commit

Permalink
[feat] : #15 FriendRecord Emoji Bottom Sheet EmojiList Implement
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Jun 23, 2023
1 parent 7baa68f commit e1dfbca
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.teampome.pome.presentation.friend

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.teampome.pome.util.common.CommonUtil

class BottomEmojiGridSpaceItemDecoration(private val spanCount: Int): RecyclerView.ItemDecoration() {
// 3, 20
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
val position = parent.getChildAdapterPosition(view)

val column = position % spanCount

val spaceInPx = CommonUtil.dpToPx(parent.context, 10)

outRect.top = spaceInPx

if (column == 0) {
outRect.left = spaceInPx
} else if (column == 1) {
outRect.left = spaceInPx
} else if (column == 2) {
outRect.left = spaceInPx
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.teampome.pome.presentation.friend

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.teampome.pome.databinding.ItemBottomEmojiBinding
import com.teampome.pome.model.response.FriendEmotionResponse

class FriendEmotionAdapter(
private var friendEmotionList: List<FriendEmotionResponse>
) : RecyclerView.Adapter<FriendEmotionAdapter.FriendEmotionViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendEmotionViewHolder {
val binding = ItemBottomEmojiBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return FriendEmotionViewHolder(binding)
}

override fun onBindViewHolder(holder: FriendEmotionViewHolder, position: Int) {
holder.bind(friendEmotionList[position])
}

override fun getItemCount(): Int = friendEmotionList.size

fun updateData(newData: List<FriendEmotionResponse>) {
this.friendEmotionList = newData
notifyDataSetChanged()
}

inner class FriendEmotionViewHolder(
private val binding: ItemBottomEmojiBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(friendEmotion: FriendEmotionResponse) {
binding.friendEmotionHappyTv.text = friendEmotion.nickname
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import android.widget.Toast
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager
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.PomeFriendEmotionBottomSheetDialogBinding
import com.teampome.pome.databinding.PomeFriendSettingBottomSheetDialogBinding
import com.teampome.pome.databinding.PomeRecordMoreGoalBottomSheetDialogBinding
import com.teampome.pome.model.response.FriendEmotionResponse
Expand All @@ -31,6 +33,9 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri
private lateinit var pomeFriendSettingBottomSheetDialogBinding : PomeFriendSettingBottomSheetDialogBinding
private lateinit var friendSettingBottomSheetDialog: BottomSheetDialog

private lateinit var pomeFriendEmojiBottomSheetDialogBinding : PomeFriendEmotionBottomSheetDialogBinding
private lateinit var pomeFriendEmojiBottomSheetDialog: BottomSheetDialog

override fun initView() {
setUpRecyclerView()
friendRecordSetUpRecyclerView()
Expand Down Expand Up @@ -209,12 +214,34 @@ class FriendFragment : BaseFragment<FragmentFriendBinding>(R.layout.fragment_fri
}
}

private fun makeFriendEmojiBottomDialog(emojiList : List<FriendEmotionResponse>) {
pomeFriendEmojiBottomSheetDialog = BottomSheetDialog(requireContext())
pomeFriendEmojiBottomSheetDialogBinding = PomeFriendEmotionBottomSheetDialogBinding.inflate(layoutInflater, null, false)

pomeFriendEmojiBottomSheetDialog.setContentView(pomeFriendEmojiBottomSheetDialogBinding.root)

with(pomeFriendEmojiBottomSheetDialogBinding) {
val emojiListSize = emojiList.size
friendDetailAllEmotionTv.text = "전체 ${emojiListSize}"

val gridLayoutManager = GridLayoutManager(context, 3)
val adapter = FriendEmotionAdapter(emojiList)
val decoration = BottomEmojiGridSpaceItemDecoration(3)
friendBottomEmojiRv.apply {
layoutManager = gridLayoutManager
this.adapter = adapter
addItemDecoration(decoration)
}
}
}

override fun onFriendDetailMoreClick(recordId : Int) {
makeFriendSettingBottomDialog(recordId)
friendSettingBottomSheetDialog.show()
}

override fun onFriendDetailEmojiClick(emojiList: List<FriendEmotionResponse>) {

makeFriendEmojiBottomDialog(emojiList)
pomeFriendEmojiBottomSheetDialog.show()
}
}
54 changes: 31 additions & 23 deletions app/src/main/res/layout/item_bottom_emoji.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/friend_emotion_happy_aiv"
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_marginBottom="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:src="@drawable/emoji_mint_fiter_happy" />
<data>

<TextView
android:id="@+id/friend_emotion_happy_tv"
style="@style/Pome.Medium.14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remind_dialog_happy_text"
android:textColor="@color/grey_8"
app:layout_constraintTop_toBottomOf="@+id/friend_emotion_happy_aiv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</data>

</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/friend_emotion_happy_aiv"
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_marginBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/emoji_mint_fiter_happy" />

<TextView
android:id="@+id/friend_emotion_happy_tv"
style="@style/Pome.Medium.14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remind_dialog_happy_text"
android:textColor="@color/grey_8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/friend_emotion_happy_aiv" />

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:id="@+id/pome_friend_emotion_bottom_sheet_dialog_cl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
app:behavior_draggable="true"
app:behavior_hideable="true"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
Expand Down

0 comments on commit e1dfbca

Please sign in to comment.