Adds centering of items with no subtitles
This commit is contained in:
parent
50839c206b
commit
7c1d1c3464
|
@ -19,9 +19,9 @@ package im.vector.app.features.home.room.list
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.Space
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.constraintlayout.widget.ConstraintSet
|
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.airbnb.epoxy.EpoxyAttribute
|
import com.airbnb.epoxy.EpoxyAttribute
|
||||||
|
@ -141,27 +141,11 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
||||||
|
|
||||||
private fun renderForFilteredDisplayMode(holder: Holder) {
|
private fun renderForFilteredDisplayMode(holder: Holder) {
|
||||||
holder.subtitleView.text = subtitle
|
holder.subtitleView.text = subtitle
|
||||||
if (subtitle.isEmpty()) {
|
holder.centerTitle(shouldCenter = subtitle.isEmpty())
|
||||||
holder.centerTitleVertically()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Holder.centerTitleVertically() {
|
private fun Holder.centerTitle(shouldCenter: Boolean) {
|
||||||
removeTitleTopMargin()
|
centerTitleSpace.isVisible = shouldCenter
|
||||||
constrainTitleToParentBottom()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Holder.removeTitleTopMargin() {
|
|
||||||
val layoutParams = titleView.layoutParams as ConstraintLayout.LayoutParams
|
|
||||||
layoutParams.topMargin = 0
|
|
||||||
titleView.layoutParams = layoutParams
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Holder.constrainTitleToParentBottom() {
|
|
||||||
val constraintSet = ConstraintSet()
|
|
||||||
constraintSet.clone(rootView)
|
|
||||||
constraintSet.connect(titleView.id, ConstraintSet.BOTTOM, rootView.id, ConstraintSet.BOTTOM)
|
|
||||||
constraintSet.applyTo(rootView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(holder: Holder) {
|
override fun unbind(holder: Holder) {
|
||||||
|
@ -198,5 +182,6 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
||||||
val roomAvatarFailSendingImageView by bind<ImageView>(R.id.roomAvatarFailSendingImageView)
|
val roomAvatarFailSendingImageView by bind<ImageView>(R.id.roomAvatarFailSendingImageView)
|
||||||
val roomAvatarPresenceImageView by bind<PresenceStateImageView>(R.id.roomAvatarPresenceImageView)
|
val roomAvatarPresenceImageView by bind<PresenceStateImageView>(R.id.roomAvatarPresenceImageView)
|
||||||
val rootView by bind<ConstraintLayout>(R.id.itemRoomLayout)
|
val rootView by bind<ConstraintLayout>(R.id.itemRoomLayout)
|
||||||
|
val centerTitleSpace by bind<Space>(R.id.centerTitleSpace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,13 +112,27 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/roomAvatarContainer"
|
app:layout_constraintTop_toBottomOf="@id/roomAvatarContainer"
|
||||||
tools:layout_marginStart="20dp" />
|
tools:layout_marginStart="20dp" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:id="@+id/topMarginSpace"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:id="@+id/centerTitleSpace"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="15dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/topMarginSpace" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/roomNameView"
|
android:id="@+id/roomNameView"
|
||||||
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_marginStart="@dimen/layout_horizontal_margin"
|
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
@ -130,7 +144,7 @@
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintHorizontal_chainStyle="packed"
|
app:layout_constraintHorizontal_chainStyle="packed"
|
||||||
app:layout_constraintStart_toEndOf="@id/roomAvatarContainer"
|
app:layout_constraintStart_toEndOf="@id/roomAvatarContainer"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/centerTitleSpace"
|
||||||
tools:text="@sample/users.json/data/displayName" />
|
tools:text="@sample/users.json/data/displayName" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
Loading…
Reference in New Issue