Improve focusedEvent rendering when sender information are displayed.
This commit is contained in:
parent
31946a98ad
commit
174b1a4888
1 changed files with 21 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ import androidx.compose.ui.draw.drawWithCache
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.geometry.Size
|
import androidx.compose.ui.geometry.Size
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.features.messages.impl.timeline.TimelineEvents
|
import io.element.android.features.messages.impl.timeline.TimelineEvents
|
||||||
|
|
@ -58,7 +59,12 @@ internal fun TimelineItemRow(
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val backgroundModifier = if (timelineItem.isEvent(focusedEventId)) {
|
val backgroundModifier = if (timelineItem.isEvent(focusedEventId)) {
|
||||||
Modifier.focusedEvent()
|
val focusedEventOffset = if ((timelineItem as? TimelineItem.Event)?.showSenderInformation == true) {
|
||||||
|
14.dp
|
||||||
|
} else {
|
||||||
|
2.dp
|
||||||
|
}
|
||||||
|
Modifier.focusedEvent(focusedEventOffset)
|
||||||
} else {
|
} else {
|
||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
|
|
@ -130,18 +136,28 @@ internal fun TimelineItemRow(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun Modifier.focusedEvent(): Modifier {
|
private fun Modifier.focusedEvent(
|
||||||
|
focusedEventOffset: Dp
|
||||||
|
): Modifier {
|
||||||
val highlightedLineColor = ElementTheme.colors.textActionAccent
|
val highlightedLineColor = ElementTheme.colors.textActionAccent
|
||||||
val gradientColors = listOf(
|
val gradientColors = listOf(
|
||||||
ElementTheme.colors.highlightedMessageBackgroundColor,
|
ElementTheme.colors.highlightedMessageBackgroundColor,
|
||||||
ElementTheme.materialColors.background
|
ElementTheme.materialColors.background
|
||||||
)
|
)
|
||||||
val verticalOffset = 2.dp.toPx()
|
val verticalOffset = focusedEventOffset.toPx()
|
||||||
return drawWithCache {
|
return drawWithCache {
|
||||||
val brush = Brush.verticalGradient(gradientColors)
|
val brush = Brush.verticalGradient(gradientColors)
|
||||||
onDrawBehind {
|
onDrawBehind {
|
||||||
drawRect(brush, topLeft = Offset(0f, verticalOffset), size = Size(size.width, size.height * 0.7f))
|
drawRect(
|
||||||
drawLine(highlightedLineColor, start = Offset(0f, verticalOffset), end = Offset(size.width, verticalOffset))
|
brush,
|
||||||
|
topLeft = Offset(0f, verticalOffset),
|
||||||
|
size = Size(size.width, size.height * 0.7f)
|
||||||
|
)
|
||||||
|
drawLine(
|
||||||
|
highlightedLineColor,
|
||||||
|
start = Offset(0f, verticalOffset),
|
||||||
|
end = Offset(size.width, verticalOffset)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}.padding(top = 4.dp)
|
}.padding(top = 4.dp)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue