Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add padding before first own message #5384

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -105,6 +105,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
} else {
holder.timeView.isVisible = false
}

holder.additionalTopSpace.isVisible = 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 +157,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
8 changes: 7 additions & 1 deletion vector/src/main/res/layout/view_message_bubble.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@
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