feat(creator): FanTalk 목록 아이템을 추가한다
This commit is contained in:
@@ -0,0 +1,95 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.ui
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
|
import kr.co.vividnext.sodalive.R
|
||||||
|
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelFantalkBinding
|
||||||
|
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||||
|
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkReplyUiModel
|
||||||
|
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkRightAction
|
||||||
|
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkUiModel
|
||||||
|
|
||||||
|
class CreatorChannelFanTalkAdapter(
|
||||||
|
private val onOwnerMoreClick: (View, CreatorChannelFanTalkUiModel) -> Unit = { _, _ -> },
|
||||||
|
private val onReportClick: (CreatorChannelFanTalkUiModel) -> Unit = { }
|
||||||
|
) : RecyclerView.Adapter<CreatorChannelFanTalkAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
private var items: List<CreatorChannelFanTalkUiModel> = emptyList()
|
||||||
|
|
||||||
|
fun submitItems(items: List<CreatorChannelFanTalkUiModel>) {
|
||||||
|
this.items = items
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return ViewHolder(
|
||||||
|
ItemCreatorChannelFantalkBinding.inflate(LayoutInflater.from(parent.context), parent, false),
|
||||||
|
onOwnerMoreClick,
|
||||||
|
onReportClick
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = items.size
|
||||||
|
|
||||||
|
class ViewHolder(
|
||||||
|
private val binding: ItemCreatorChannelFantalkBinding,
|
||||||
|
private val onOwnerMoreClick: (View, CreatorChannelFanTalkUiModel) -> Unit,
|
||||||
|
private val onReportClick: (CreatorChannelFanTalkUiModel) -> Unit
|
||||||
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
|
fun bind(item: CreatorChannelFanTalkUiModel) = with(binding) {
|
||||||
|
ivCreatorChannelFantalkProfile.loadProfile(item.writerProfileImageUrl)
|
||||||
|
tvCreatorChannelFantalkNickname.text = item.writerNickname
|
||||||
|
tvCreatorChannelFantalkTime.text = item.createdAtText
|
||||||
|
tvCreatorChannelFantalkContent.text = item.content
|
||||||
|
bindRightAction(item)
|
||||||
|
bindReply(item.reply)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ItemCreatorChannelFantalkBinding.bindRightAction(item: CreatorChannelFanTalkUiModel) {
|
||||||
|
when (item.rightAction) {
|
||||||
|
CreatorChannelFanTalkRightAction.Report -> {
|
||||||
|
tvCreatorChannelFantalkReport.isVisible = true
|
||||||
|
tvCreatorChannelFantalkReport.setOnClickListener { onReportClick(item) }
|
||||||
|
ivCreatorChannelFantalkMore.isVisible = false
|
||||||
|
ivCreatorChannelFantalkMore.setOnClickListener(null)
|
||||||
|
}
|
||||||
|
is CreatorChannelFanTalkRightAction.OwnerMore -> {
|
||||||
|
tvCreatorChannelFantalkReport.isVisible = false
|
||||||
|
tvCreatorChannelFantalkReport.setOnClickListener(null)
|
||||||
|
ivCreatorChannelFantalkMore.isVisible = true
|
||||||
|
ivCreatorChannelFantalkMore.setOnClickListener { onOwnerMoreClick(it, item) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ItemCreatorChannelFantalkBinding.bindReply(reply: CreatorChannelFanTalkReplyUiModel?) {
|
||||||
|
val hasReply = reply != null
|
||||||
|
viewCreatorChannelFantalkReplyConnector.isVisible = hasReply
|
||||||
|
layoutCreatorChannelFantalkReply.isVisible = hasReply
|
||||||
|
if (reply == null) return
|
||||||
|
|
||||||
|
ivCreatorChannelFantalkReplyProfile.loadProfile(reply.writerProfileImageUrl)
|
||||||
|
tvCreatorChannelFantalkReplyNickname.text = reply.writerNickname
|
||||||
|
tvCreatorChannelFantalkReplyTime.text = reply.createdAtText
|
||||||
|
tvCreatorChannelFantalkReplyContent.text = reply.content
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun android.widget.ImageView.loadProfile(url: String) {
|
||||||
|
loadUrl(url) {
|
||||||
|
crossfade(true)
|
||||||
|
placeholder(R.drawable.ic_placeholder_profile)
|
||||||
|
error(R.drawable.ic_placeholder_profile)
|
||||||
|
transformations(CircleCropTransformation())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/gray_900" />
|
||||||
|
<corners android:radius="@dimen/radius_14" />
|
||||||
|
</shape>
|
||||||
175
app/src/main/res/layout/item_creator_channel_fantalk.xml
Normal file
175
app/src/main/res/layout/item_creator_channel_fantalk.xml
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="@dimen/spacing_14"
|
||||||
|
android:paddingTop="@dimen/spacing_14">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_creator_channel_fantalk_profile"
|
||||||
|
android:layout_width="42dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:contentDescription="@string/a11y_feed_profile_image"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:src="@drawable/ic_placeholder_profile" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_nickname"
|
||||||
|
style="@style/Typography.Body5"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacing_14"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/barrier_creator_channel_fantalk_action_start"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/iv_creator_channel_fantalk_profile"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/iv_creator_channel_fantalk_profile"
|
||||||
|
tools:text="닉네임" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_time"
|
||||||
|
style="@style/Typography.Body6"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_4"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/gray_500"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tv_creator_channel_fantalk_nickname"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tv_creator_channel_fantalk_nickname"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_creator_channel_fantalk_nickname"
|
||||||
|
tools:text="2분 전" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_report"
|
||||||
|
style="@style/Typography.Body5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:text="@string/creator_channel_fantalk_report"
|
||||||
|
android:textColor="@color/gray_400"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tv_creator_channel_fantalk_nickname" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_creator_channel_fantalk_more"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/ic_new_more"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tv_creator_channel_fantalk_nickname"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
android:id="@+id/barrier_creator_channel_fantalk_action_start"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barrierDirection="start"
|
||||||
|
app:constraint_referenced_ids="tv_creator_channel_fantalk_report,iv_creator_channel_fantalk_more" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_content"
|
||||||
|
style="@style/Typography.Body3"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_12"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tv_creator_channel_fantalk_nickname"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/iv_creator_channel_fantalk_profile"
|
||||||
|
tools:text="팬톡 응원 메시지 내용입니다." />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/view_creator_channel_fantalk_reply_connector"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="@dimen/spacing_14"
|
||||||
|
android:layout_marginTop="@dimen/spacing_14"
|
||||||
|
android:background="@color/gray_800"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tv_creator_channel_fantalk_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_creator_channel_fantalk_content"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_creator_channel_fantalk_reply"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_8"
|
||||||
|
android:background="@drawable/bg_creator_channel_fantalk_reply"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/spacing_14"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tv_creator_channel_fantalk_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/view_creator_channel_fantalk_reply_connector"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_creator_channel_fantalk_reply_profile"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:contentDescription="@string/a11y_feed_profile_image"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:src="@drawable/ic_placeholder_profile" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_reply_nickname"
|
||||||
|
style="@style/Typography.Body5"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacing_8"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
tools:text="크리에이터" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_reply_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_400"
|
||||||
|
tools:text="방금 전" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_creator_channel_fantalk_reply_content"
|
||||||
|
style="@style/Typography.Body6"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_8"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
tools:text="응원 고마워요!" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/view_creator_channel_fantalk_divider"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginTop="@dimen/spacing_14"
|
||||||
|
android:background="@color/gray_800"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/layout_creator_channel_fantalk_reply" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user