Add padding before our first message

Signed-off-by: sim <git@sgougeon.fr>
This commit is contained in:
sim 2022-03-01 00:26:26 +01:00
parent b226ab5e4b
commit 17d58f24d2
5 changed files with 16 additions and 1 deletions

1
changelog.d/5384.misc Normal file
View File

@ -0,0 +1 @@
Add top margin before our first message

View File

@ -105,6 +105,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
} else { } else {
holder.timeView.isVisible = false holder.timeView.isVisible = false
} }
holder.additionalTopSpace.isVisible = attributes.informationData.messageLayout.addTopMargin
// Render send state indicator // Render send state indicator
holder.sendStateImageView.render(attributes.informationData.sendStateDecoration) holder.sendStateImageView.render(attributes.informationData.sendStateDecoration)
holder.eventSendingIndicator.isVisible = attributes.informationData.sendStateDecoration == SendStateDecoration.SENDING_MEDIA holder.eventSendingIndicator.isVisible = attributes.informationData.sendStateDecoration == SendStateDecoration.SENDING_MEDIA
@ -154,6 +157,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) { 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 avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
val memberNameView by bind<TextView>(R.id.messageMemberNameView) val memberNameView by bind<TextView>(R.id.messageMemberNameView)
val timeView by bind<TextView>(R.id.messageTimeView) val timeView by bind<TextView>(R.id.messageTimeView)

View File

@ -24,12 +24,14 @@ sealed interface TimelineMessageLayout : Parcelable {
val layoutRes: Int val layoutRes: Int
val showAvatar: Boolean val showAvatar: Boolean
val showDisplayName: Boolean val showDisplayName: Boolean
val addTopMargin: Boolean
val showTimestamp: Boolean val showTimestamp: Boolean
@Parcelize @Parcelize
data class Default(override val showAvatar: Boolean, data class Default(override val showAvatar: Boolean,
override val showDisplayName: Boolean, override val showDisplayName: Boolean,
override val showTimestamp: Boolean, override val showTimestamp: Boolean,
override val addTopMargin: Boolean = false,
// Keep defaultLayout generated on epoxy items // Keep defaultLayout generated on epoxy items
override val layoutRes: Int = 0) : TimelineMessageLayout override val layoutRes: Int = 0) : TimelineMessageLayout
@ -38,6 +40,7 @@ sealed interface TimelineMessageLayout : Parcelable {
override val showAvatar: Boolean, override val showAvatar: Boolean,
override val showDisplayName: Boolean, override val showDisplayName: Boolean,
override val showTimestamp: Boolean = true, override val showTimestamp: Boolean = true,
override val addTopMargin: Boolean = false,
val isIncoming: Boolean, val isIncoming: Boolean,
val isPseudoBubble: Boolean, val isPseudoBubble: Boolean,
val cornersRadius: CornersRadius, val cornersRadius: CornersRadius,

View File

@ -118,6 +118,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
TimelineMessageLayout.Bubble( TimelineMessageLayout.Bubble(
showAvatar = showInformation && !isSentByMe, showAvatar = showInformation && !isSentByMe,
showDisplayName = showInformation && !isSentByMe, showDisplayName = showInformation && !isSentByMe,
addTopMargin = isFirstFromThisSender && isSentByMe,
isIncoming = !isSentByMe, isIncoming = !isSentByMe,
cornersRadius = cornersRadius, cornersRadius = cornersRadius,
isPseudoBubble = messageContent.isPseudoBubble(), isPseudoBubble = messageContent.isPseudoBubble(),

View File

@ -26,12 +26,18 @@
android:padding="2dp" android:padding="2dp"
tools:src="@sample/user_round_avatars" /> 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 <TextView
android:id="@+id/messageMemberNameView" android:id="@+id/messageMemberNameView"
style="@style/Widget.Vector.TextView.Subtitle" style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_below="@id/additionalTopSpace"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"