Hide the icon area if there is no icon to display
This commit is contained in:
parent
056b9df65e
commit
b78f1dbb93
@ -44,6 +44,9 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
|
|||||||
@DrawableRes
|
@DrawableRes
|
||||||
var iconRes: Int = 0
|
var iconRes: Int = 0
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var showIcon = true
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var text: String? = null
|
var text: String? = null
|
||||||
|
|
||||||
@ -80,6 +83,7 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
|
|||||||
} else {
|
} else {
|
||||||
ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary)
|
ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary)
|
||||||
}
|
}
|
||||||
|
holder.icon.isVisible = showIcon
|
||||||
holder.icon.setImageResource(iconRes)
|
holder.icon.setImageResource(iconRes)
|
||||||
ImageViewCompat.setImageTintList(holder.icon, ColorStateList.valueOf(tintColor))
|
ImageViewCompat.setImageTintList(holder.icon, ColorStateList.valueOf(tintColor))
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
|
@ -48,8 +48,11 @@ abstract class BottomSheetGenericController<State : BottomSheetGenericState, Act
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Actions
|
// Actions
|
||||||
getActions(state).forEach { action ->
|
val actions = getActions(state)
|
||||||
|
val showIcons = actions.any { it.iconResId > 0 }
|
||||||
|
actions.forEach { action ->
|
||||||
action.toBottomSheetItem()
|
action.toBottomSheetItem()
|
||||||
|
.showIcon(showIcons)
|
||||||
.listener(View.OnClickListener { listener?.didSelectAction(action) })
|
.listener(View.OnClickListener { listener?.didSelectAction(action) })
|
||||||
.addTo(this)
|
.addTo(this)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
android:paddingEnd="@dimen/layout_horizontal_margin"
|
android:paddingEnd="@dimen/layout_horizontal_margin"
|
||||||
android:paddingBottom="8dp">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<!-- Used for sub items -->
|
||||||
<Space
|
<Space
|
||||||
android:id="@+id/actionStartSpace"
|
android:id="@+id/actionStartSpace"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
@ -25,37 +26,44 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/actionIcon"
|
android:id="@+id/actionIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="26dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="26dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_toEndOf="@id/actionStartSpace"
|
android:layout_toEndOf="@id/actionStartSpace"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/actionTitleContainer"
|
||||||
app:layout_constraintStart_toEndOf="@+id/actionStartSpace"
|
app:layout_constraintStart_toEndOf="@+id/actionStartSpace"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@drawable/ic_room_actions_notifications_all"
|
|
||||||
app:tint="?riotx_text_secondary"
|
app:tint="?riotx_text_secondary"
|
||||||
tools:ignore="MissingPrefix" />
|
tools:ignore="MissingPrefix"
|
||||||
|
tools:src="@drawable/ic_room_actions_notifications_all" />
|
||||||
|
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:id="@+id/actionTitle"
|
android:id="@+id/actionTitleContainer"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="40dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:drawablePadding="16dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:textColor="?riotx_text_secondary"
|
|
||||||
android:textSize="17sp"
|
|
||||||
app:layout_constrainedWidth="true"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/actionSelected"
|
app:layout_constraintEnd_toStartOf="@+id/actionSelected"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintStart_toEndOf="@id/actionIcon"
|
||||||
app:layout_constraintStart_toEndOf="@id/actionStartSpace"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:text="zbla azjazjaz s sdkqdskdsqk kqsdkdqsk kdqsksqdk" />
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/actionTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="?riotx_text_secondary"
|
||||||
|
android:textSize="17sp"
|
||||||
|
tools:drawableEnd="@drawable/ic_material_expand_more_black"
|
||||||
|
tools:drawableTint="?riotx_text_secondary"
|
||||||
|
tools:text="kdqsksqdk" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/actionSelected"
|
android:id="@+id/actionSelected"
|
||||||
@ -66,9 +74,8 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:visibility="visible"
|
|
||||||
app:tint="@color/riotx_accent"
|
app:tint="@color/riotx_accent"
|
||||||
tools:ignore="MissingPrefix" />
|
tools:ignore="MissingPrefix"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user