Skip to content

Commit

Permalink
Merge pull request #475 from kiwicom/timeline-past-warning-critical-g…
Browse files Browse the repository at this point in the history
…radient-to-success

Timeline: fix going to success from past critical/warning
  • Loading branch information
hrach authored Jun 27, 2023
2 parents 8d94c03 + 41396ca commit 456c83b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
38 changes: 20 additions & 18 deletions ui/src/main/java/kiwi/orbit/compose/ui/controls/Timeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,7 @@ private fun ItemLine(
val width = with(LocalDensity.current) {
20.sp.toDp()
}
if (status in setOf(
TimelineItemStatus.InProgress,
TimelineItemStatus.CurrentSuccess,
TimelineItemStatus.CurrentWarning,
TimelineItemStatus.CurrentCritical,
TimelineItemStatus.Future,
)
) {
if (status in TimelineItemStatusWithDashedBottomLine) {
val color = OrbitTheme.colors.surface.normalAlt
Canvas(modifier = Modifier.width(width)) {
drawLine(
Expand Down Expand Up @@ -308,20 +301,12 @@ private fun ItemLine(
private fun ItemTopLineGradient(
status: TimelineItemStatus,
) {
if (status in setOf(
TimelineItemStatus.PastSuccess,
TimelineItemStatus.InProgress,
TimelineItemStatus.CurrentSuccess,
TimelineItemStatus.Future,
)
) {
if (status in TimelineItemStatusWithGradientTopLine) {
Box {}
return
}

val width = with(LocalDensity.current) {
20.sp.toDp()
}
val width = with(LocalDensity.current) { 20.sp.toDp() }
val color = status.color
val gradient = Brush.linearGradient(colors = listOf(Color.Transparent, color))
Canvas(modifier = Modifier.width(width)) {
Expand All @@ -347,6 +332,19 @@ private val TimelineItemStatus.color: Color
TimelineItemStatus.Future -> OrbitTheme.colors.surface.normalAlt
}

private val TimelineItemStatusWithDashedBottomLine = setOf(
TimelineItemStatus.InProgress,
TimelineItemStatus.CurrentSuccess,
TimelineItemStatus.CurrentWarning,
TimelineItemStatus.CurrentCritical,
TimelineItemStatus.Future,
)

private val TimelineItemStatusWithGradientTopLine = setOf(
TimelineItemStatus.InProgress,
TimelineItemStatus.Future,
)

@OrbitPreviews
@Composable
internal fun TimelinePreview() {
Expand Down Expand Up @@ -413,6 +411,10 @@ internal fun TimelineStatesPreview() {
status = TimelineItemStatus.PastWarning,
title = { Text("Waiting for the airline even more") },
)
TimelineItem(
status = TimelineItemStatus.PastSuccess,
title = { Text("Something good happened") },
)
TimelineItem(
status = TimelineItemStatus.CurrentCritical,
title = { Text("Waiting for the airline, the last one") },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 456c83b

Please sign in to comment.