Skip to content

Commit

Permalink
Add padding before our first message
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Mar 2, 2022
1 parent b226ab5 commit fc6d743
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/5384.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add top margin before our first message
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import android.widget.RelativeLayout
import android.widget.TextView
import androidx.annotation.IdRes
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import com.airbnb.epoxy.EpoxyAttribute
Expand Down Expand Up @@ -105,6 +106,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
} else {
holder.timeView.isVisible = false
}

holder.additionalTopSpace.isGone = !attributes.informationData.messageLayout.addTopMargin

// Render send state indicator
holder.sendStateImageView.render(attributes.informationData.sendStateDecoration)
holder.eventSendingIndicator.isVisible = attributes.informationData.sendStateDecoration == SendStateDecoration.SENDING_MEDIA
Expand Down Expand Up @@ -154,6 +158,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>

abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) {

val additionalTopSpace by bind<View>(R.id.additionalTopSpace)
val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
val memberNameView by bind<TextView>(R.id.messageMemberNameView)
val timeView by bind<TextView>(R.id.messageTimeView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ sealed interface TimelineMessageLayout : Parcelable {
val layoutRes: Int
val showAvatar: Boolean
val showDisplayName: Boolean
val addTopMargin: Boolean
val showTimestamp: Boolean

@Parcelize
data class Default(override val showAvatar: Boolean,
override val showDisplayName: Boolean,
override val showTimestamp: Boolean,
override val addTopMargin: Boolean = false,
// Keep defaultLayout generated on epoxy items
override val layoutRes: Int = 0) : TimelineMessageLayout

Expand All @@ -38,6 +40,7 @@ sealed interface TimelineMessageLayout : Parcelable {
override val showAvatar: Boolean,
override val showDisplayName: Boolean,
override val showTimestamp: Boolean = true,
override val addTopMargin: Boolean = false,
val isIncoming: Boolean,
val isPseudoBubble: Boolean,
val cornersRadius: CornersRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
TimelineMessageLayout.Bubble(
showAvatar = showInformation && !isSentByMe,
showDisplayName = showInformation && !isSentByMe,
addTopMargin = isFirstFromThisSender && isSentByMe,
isIncoming = !isSentByMe,
cornersRadius = cornersRadius,
isPseudoBubble = messageContent.isPseudoBubble(),
Expand Down
7 changes: 6 additions & 1 deletion vector/src/main/res/layout/view_message_bubble.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@
android:elevation="2dp"
android:padding="2dp"
tools:src="@sample/user_round_avatars" />
<View
android:id="@+id/additionalTopSpace"
android:layout_height="12dp"
android:layout_width="0dp"
android:layout_toEndOf="@id/messageStartGuideline" />

<TextView
android:id="@+id/messageMemberNameView"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="@id/additionalTopSpace"
android:layout_alignParentEnd="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="4dp"
Expand Down

0 comments on commit fc6d743

Please sign in to comment.