Improved margins for incoming messages chat bubbles

This commit is contained in:
Sylvain Berfini 2021-02-01 15:45:06 +01:00
parent 5ef5564b6d
commit 98fdb56f45
3 changed files with 11 additions and 2 deletions

View file

@ -106,6 +106,13 @@ fun setLeftMargin(view: View, margin: Float) {
view.layoutParams = layoutParams view.layoutParams = layoutParams
} }
@BindingAdapter("android:layout_marginRight")
fun setRightMargin(view: View, margin: Float) {
val layoutParams = view.layoutParams as RelativeLayout.LayoutParams
layoutParams.rightMargin = margin.toInt()
view.layoutParams = layoutParams
}
@BindingAdapter("android:layout_weight") @BindingAdapter("android:layout_weight")
fun setLayoutWeight(view: View, weight: Float) { fun setLayoutWeight(view: View, weight: Float) {
val layoutParams = view.layoutParams as LinearLayout.LayoutParams val layoutParams = view.layoutParams as LinearLayout.LayoutParams

View file

@ -70,7 +70,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@id/time" android:layout_below="@id/time"
android:layout_marginLeft="5dp" android:layout_marginLeft="10dp"
android:gravity="center" android:gravity="center"
app:viewModel="@{viewModel}" app:viewModel="@{viewModel}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
@ -88,7 +88,7 @@
android:layout_toRightOf="@id/avatar" android:layout_toRightOf="@id/avatar"
android:layout_below="@id/time" android:layout_below="@id/time"
android:layout_marginBottom="1dp" android:layout_marginBottom="1dp"
android:layout_marginRight="3dp" android:layout_marginRight="@{viewModel.chatMessage.outgoing ? @dimen/outgoing_chat_message_bubble_right_margin : @dimen/incoming_chat_message_bubble_right_margin}"
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !viewModel.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}" android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !viewModel.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
android:paddingTop="5dp" android:paddingTop="5dp"
android:paddingBottom="5dp"> android:paddingBottom="5dp">

View file

@ -3,6 +3,8 @@
<dimen name="edit_chat_message_bubble_left_margin">10dp</dimen> <dimen name="edit_chat_message_bubble_left_margin">10dp</dimen>
<dimen name="incoming_chat_message_bubble_left_margin">0dp</dimen> <dimen name="incoming_chat_message_bubble_left_margin">0dp</dimen>
<dimen name="outgoing_chat_message_bubble_left_margin">45dp</dimen> <dimen name="outgoing_chat_message_bubble_left_margin">45dp</dimen>
<dimen name="incoming_chat_message_bubble_right_margin">10dp</dimen>
<dimen name="outgoing_chat_message_bubble_right_margin">3dp</dimen>
<dimen name="chat_message_bubble_image_height_big">200dp</dimen> <dimen name="chat_message_bubble_image_height_big">200dp</dimen>
<dimen name="chat_message_bubble_image_height_small">100dp</dimen> <dimen name="chat_message_bubble_image_height_small">100dp</dimen>
<dimen name="video_preview_max_size">200dp</dimen> <dimen name="video_preview_max_size">200dp</dimen>