mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Room topic: tweak collapse behaviour some more
One could argue that collapsing is only useful if we have more than 2 lines to hide. Also, @su-ex wants more lines, so let's go for 5+3. Change-Id: I5f3580171d4b1544fd8f91f1de48cea85023b60a
This commit is contained in:
parent
56b84a5201
commit
600674e871
2 changed files with 8 additions and 3 deletions
|
@ -36,6 +36,10 @@ abstract class ExpandableTextItem : VectorEpoxyModel<ExpandableTextItem.Holder>(
|
|||
@EpoxyAttribute
|
||||
var maxLines: Int = 3
|
||||
|
||||
// Number of hidden lines that justify collapsing
|
||||
@EpoxyAttribute
|
||||
var minCollapsedLines: Int = 2
|
||||
|
||||
private var isExpanded = false
|
||||
private var expandedLines = 0
|
||||
|
||||
|
@ -47,7 +51,7 @@ abstract class ExpandableTextItem : VectorEpoxyModel<ExpandableTextItem.Holder>(
|
|||
holder.content.doOnPreDraw {
|
||||
// Allow for displaying maxLines + 1 lines: in this case, the expand button
|
||||
// would reserve just as much space as the expaned text
|
||||
if (holder.content.lineCount > maxLines + 1) {
|
||||
if (holder.content.lineCount > maxLines + minCollapsedLines) {
|
||||
expandedLines = holder.content.lineCount
|
||||
holder.content.maxLines = maxLines
|
||||
|
||||
|
@ -61,7 +65,7 @@ abstract class ExpandableTextItem : VectorEpoxyModel<ExpandableTextItem.Holder>(
|
|||
holder.arrow.isVisible = true
|
||||
} else {
|
||||
holder.arrow.isVisible = false
|
||||
holder.content.maxLines = maxLines + 1
|
||||
holder.content.maxLines = maxLines + minCollapsedLines
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ class RoomProfileController @Inject constructor(
|
|||
expandableTextItem {
|
||||
id("topic")
|
||||
content(it)
|
||||
maxLines(3)
|
||||
maxLines(5)
|
||||
minCollapsedLines(3)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue