Skip to content
Snippets Groups Projects
Commit 77633f43 authored by Taras's avatar Taras
Browse files

Create DmFooter view

parent f6b2755c
No related branches found
No related tags found
No related merge requests found
package org.futo.circles.view
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import org.futo.circles.core.model.Post
import org.futo.circles.core.model.ReactionsData
import org.futo.circles.databinding.ViewDmFooterBinding
import org.futo.circles.feature.timeline.list.PostOptionsListener
class DmFooterView(
context: Context,
attrs: AttributeSet? = null,
) : ConstraintLayout(context, attrs) {
private val binding =
ViewDmFooterBinding.inflate(LayoutInflater.from(context), this)
private var optionsListener: PostOptionsListener? = null
private var post: Post? = null
fun setData(data: Post, isThread: Boolean) {
post = data
bindReactionsList(data.reactionsData)
}
fun bindPayload(reactions: List<ReactionsData>, isEdited: Boolean, time: Long) {
post = post?.copy(
postInfo = post!!.postInfo.copy(isEdited = isEdited, timestamp = time),
reactionsData = reactions
)
bindReactionsList(reactions)
}
private fun bindReactionsList(reactions: List<ReactionsData>) {
binding.vEmojisList.bindReactionsList(
reactions,
true,
object : ReactionChipClickListener {
override fun onReactionChipClicked(emoji: String, isAddedByMe: Boolean) {
post?.let {
optionsListener?.onEmojiChipClicked(
it.postInfo.roomId,
it.id,
emoji,
isAddedByMe
)
}
}
})
}
fun addEmojiFromPickerLocalUpdate(emoji: String) {
binding.vEmojisList.addEmojiFromPickerLocalUpdate(emoji)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merge 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"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<org.futo.circles.view.EmojiListView
android:id="@+id/vEmojisList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tvTime"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:lines="1"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tvEditedLabel"
tools:text="Jul 17, 6:00 PM" />
<TextView
android:id="@+id/tvEditedLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:paddingStart="4dp"
android:paddingEnd="0dp"
android:text="@string/edited_label"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible" />
</merge>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment