Skip to content

Commit

Permalink
feat: 유저 프로필 클릭시, 프로필 상세 뷰로 이동 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
gaeun5744 committed Aug 11, 2024
1 parent 9479b51 commit 2fdb152
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ChatActivity : BaseActivity<ActivityChatBinding>(R.layout.activity_chat),
}

private fun initAdapter() {
adapter = ChatAdapter()
adapter = ChatAdapter(this)
binding.rcvChatDetail.adapter = adapter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ sealed interface ChatUiModel {

data class Other(
val nickName: String,
val profileUrl: String,
val profileUrl: String?,
val message: String,
val time: LocalTime,
val memberId:Long
) : ChatUiModel
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import com.happy.friendogly.databinding.ItemChatComeOutBinding
import com.happy.friendogly.databinding.ItemChatDateBinding
import com.happy.friendogly.databinding.ItemChatMineBinding
import com.happy.friendogly.databinding.ItemChatOtherBinding
import com.happy.friendogly.presentation.ui.chatlist.chat.ChatNavigationAction
import com.happy.friendogly.presentation.ui.chatlist.chat.ChatUiModel

class ChatAdapter : ListAdapter<ChatUiModel, ChatViewHolder>(ChatDiffCallback) {
class ChatAdapter(
private val onMemberClick: ChatNavigationAction
) : ListAdapter<ChatUiModel, ChatViewHolder>(ChatDiffCallback) {
init {
setHasStableIds(true)
}
Expand Down Expand Up @@ -62,7 +65,7 @@ class ChatAdapter : ListAdapter<ChatUiModel, ChatViewHolder>(ChatDiffCallback) {
inflater,
parent,
false,
),
), onMemberClick
)

else -> error("$viewType 잘못된 viewType이 들어왔습니다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.happy.friendogly.databinding.ItemChatComeOutBinding
import com.happy.friendogly.databinding.ItemChatDateBinding
import com.happy.friendogly.databinding.ItemChatMineBinding
import com.happy.friendogly.databinding.ItemChatOtherBinding
import com.happy.friendogly.presentation.ui.chatlist.chat.ChatNavigationAction
import com.happy.friendogly.presentation.ui.chatlist.chat.ChatUiModel
import java.time.format.DateTimeFormatter

Expand Down Expand Up @@ -39,13 +40,16 @@ class MineViewHolder(val binding: ItemChatMineBinding) : ChatViewHolder(binding.
}
}

class OtherViewHolder(val binding: ItemChatOtherBinding) : ChatViewHolder(binding.root) {
class OtherViewHolder(val binding: ItemChatOtherBinding, val onMemberClick:ChatNavigationAction) : ChatViewHolder(binding.root) {
fun bind(item: ChatUiModel.Other) {
binding.tvChatOtherMessage.text = item.message
val timeFormatter =
DateTimeFormatter.ofPattern(itemView.context.getString(R.string.chat_time))
binding.tvChatOtherTime.text = item.time.format(timeFormatter)
binding.tvChatUserNickname.text = item.nickName
binding.profileUrl = item.profileUrl
binding.ivChatUser.setOnClickListener {
onMemberClick.navigateToMemberProfile(item.memberId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ fun Message.Other.toUiModel() =
nickName = name,
message = content,
time = dateTime.toLocalTime(),
profileUrl = profileUrl ?: "",
profileUrl = profileUrl,
memberId = memberId
)
2 changes: 1 addition & 1 deletion android/app/src/main/res/layout/item_chat_other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:layout_marginStart="21dp"
android:layout_marginTop="5dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background"
android:src="@drawable/img_profile_normal"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down

0 comments on commit 2fdb152

Please sign in to comment.