feat(home): 팔로잉 크리에이터와 채팅 카드를 추가한다

This commit is contained in:
2026-06-25 23:33:40 +09:00
parent 11b06d8f9c
commit 34ac433247
4 changed files with 192 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
package kr.co.vividnext.sodalive.v2.main.home.ui
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.v2.main.chat.model.ChatRoomListUiItem
import kr.co.vividnext.sodalive.v2.main.chat.model.formatChatRoomLastMessageTime
class HomeFollowingChatAdapter(
private val onClickItem: (ChatRoomListUiItem) -> Unit = {}
) : RecyclerView.Adapter<HomeFollowingChatAdapter.ChatViewHolder>() {
private var items: List<ChatRoomListUiItem> = emptyList()
fun submitItems(items: List<ChatRoomListUiItem>) {
this.items = items
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChatViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_following_chat, parent, false)
view.layoutParams = RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply { bottomMargin = parent.resources.getDimensionPixelSize(R.dimen.spacing_8) }
return ChatViewHolder(view, onClickItem)
}
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
holder.bind(items[position])
}
override fun getItemCount(): Int = items.size
class ChatViewHolder(
itemView: View,
private val onClickItem: (ChatRoomListUiItem) -> Unit
) : RecyclerView.ViewHolder(itemView) {
private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_following_chat_creator_profile)
private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_following_chat_creator_nickname)
private val messageText = itemView.findViewById<TextView>(R.id.tv_home_following_chat_message)
private val timeText = itemView.findViewById<TextView>(R.id.tv_home_following_chat_time)
fun bind(item: ChatRoomListUiItem) {
profileImage.loadHomeCreatorProfileImage(item.targetImageUrl)
nicknameText.text = item.targetName
messageText.text = item.lastMessage
timeText.text = formatChatRoomLastMessageTime(itemView.context, item.lastMessageAt)
itemView.setOnClickListener { onClickItem(item) }
}
}
}

View File

@@ -0,0 +1,47 @@
package kr.co.vividnext.sodalive.v2.main.home.ui
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingCreatorUiItem
class HomeFollowingCreatorAdapter(
private val onClickItem: (HomeFollowingCreatorUiItem) -> Unit = {}
) : RecyclerView.Adapter<HomeFollowingCreatorAdapter.CreatorViewHolder>() {
private var items: List<HomeFollowingCreatorUiItem> = emptyList()
fun submitItems(items: List<HomeFollowingCreatorUiItem>) {
this.items = items
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreatorViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_following_creator, parent, false)
view.layoutParams = recyclerItemLayoutParams(parent)
return CreatorViewHolder(view, onClickItem)
}
override fun onBindViewHolder(holder: CreatorViewHolder, position: Int) {
holder.bind(items[position])
}
override fun getItemCount(): Int = items.size
class CreatorViewHolder(
itemView: View,
private val onClickItem: (HomeFollowingCreatorUiItem) -> Unit
) : RecyclerView.ViewHolder(itemView) {
private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_following_creator_profile)
private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_following_creator_nickname)
fun bind(item: HomeFollowingCreatorUiItem) {
profileImage.loadHomeCreatorProfileImage(item.creatorProfileImageUrl)
nicknameText.text = item.creatorNickname
itemView.setOnClickListener { onClickItem(item) }
}
}
}

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_feed_card"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/spacing_14">
<ImageView
android:id="@+id/iv_home_following_chat_creator_profile"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/bg_round_corner_999_263238"
android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@drawable/ic_placeholder_profile" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_12"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_home_following_chat_creator_nickname"
style="@style/Typography.Body4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/white"
tools:text="크리에이터 이름" />
<TextView
android:id="@+id/tv_home_following_chat_message"
style="@style/Typography.Body6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_6"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="2"
android:textColor="@color/gray_300"
tools:text="최근 대화 내용이 두 줄까지 노출됩니다." />
</LinearLayout>
<TextView
android:id="@+id/tv_home_following_chat_time"
style="@style/Typography.Body6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_8"
android:includeFontPadding="false"
android:textColor="@color/gray_500"
tools:text="3분 전" />
</LinearLayout>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="76dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_home_following_creator_profile"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/bg_round_corner_999_263238"
android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@drawable/ic_placeholder_profile" />
<TextView
android:id="@+id/tv_home_following_creator_nickname"
style="@style/Typography.Body5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_8"
android:ellipsize="end"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/white"
tools:text="크리에이터" />
</LinearLayout>