Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" }

androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.2.1"
androidx-constraintlayout-compose = "androidx.constraintlayout:constraintlayout-compose:1.1.1"

androidx-core = "androidx.core:core-ktx:1.19.0"

androidx-graphics-shapes = "androidx.graphics:graphics-shapes:1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package com.adevinta.spark.divider

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -67,6 +68,14 @@ internal class DividerScreenshot {
label = { TextComposable() },
labelHorizontalAlignment = LabelHorizontalAlignment.Start,
)
// Regression: empty label must not leave stray 16.dp gaps (PR #1208 bug 1)
HorizontalDivider(
label = { Box {} },
)
// Regression: oversized label must not collapse the divider lines (PR #1208 bug 2)
HorizontalDivider(
label = { OverflowTextComposable() },
)

Row {
VerticalDivider(
Expand Down Expand Up @@ -112,3 +121,14 @@ private fun TextComposable(textOverflow: TextOverflow = TextOverflow.Ellipsis) {
text = "label",
)
}

@Composable
private fun OverflowTextComposable() {
Text(
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = SparkTheme.typography.body1,
text = "This label is intentionally very long to verify the divider lines keep their 40dp minimum",
)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The divider seems to not extend like we want...

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions spark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ android {
}

dependencies {
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.constraintlayout.compose)
implementation(libs.androidx.compose.material3)
lintPublish(projects.sparkLint)
lintChecks(libs.slack.lint.compose)
Expand Down
12 changes: 0 additions & 12 deletions spark/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ androidx.annotation:annotation-experimental:1.5.1
androidx.annotation:annotation-jvm:1.10.0
androidx.annotation:annotation:1.10.0
androidx.appcompat:appcompat-resources:1.7.1
androidx.appcompat:appcompat:1.7.1
androidx.arch.core:core-common:2.2.0
androidx.arch.core:core-runtime:2.2.0
androidx.autofill:autofill:1.0.0
Expand Down Expand Up @@ -53,23 +52,14 @@ androidx.compose.ui:ui-util:1.11.3
androidx.compose.ui:ui:1.11.3
androidx.compose:compose-bom:2026.06.00
androidx.concurrent:concurrent-futures:1.1.0
androidx.constraintlayout:constraintlayout-compose-android:1.1.1
androidx.constraintlayout:constraintlayout-compose:1.1.1
androidx.constraintlayout:constraintlayout-core:1.1.1
androidx.constraintlayout:constraintlayout:2.2.1
androidx.core:core-ktx:1.19.0
androidx.core:core-viewtree:1.0.0
androidx.core:core:1.19.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.customview:customview:1.0.0
androidx.documentfile:documentfile:1.1.0
androidx.drawerlayout:drawerlayout:1.0.0
androidx.dynamicanimation:dynamicanimation:1.0.0
androidx.emoji2:emoji2-views-helper:1.4.0
androidx.emoji2:emoji2:1.4.0
androidx.exifinterface:exifinterface:1.4.2
androidx.fragment:fragment:1.5.4
androidx.graphics:graphics-path:1.0.1
androidx.interpolator:interpolator:1.0.0
androidx.legacy:legacy-support-core-utils:1.0.0
Expand Down Expand Up @@ -99,7 +89,6 @@ androidx.navigationevent:navigationevent-compose:1.0.0
androidx.navigationevent:navigationevent:1.0.0
androidx.print:print:1.0.0
androidx.profileinstaller:profileinstaller:1.4.1
androidx.resourceinspection:resourceinspection-annotation:1.0.1
androidx.savedstate:savedstate-android:1.5.0
androidx.savedstate:savedstate-compose-android:1.5.0
androidx.savedstate:savedstate-compose:1.5.0
Expand All @@ -111,7 +100,6 @@ androidx.transition:transition:1.6.0
androidx.vectordrawable:vectordrawable-animated:1.1.0
androidx.vectordrawable:vectordrawable:1.1.0
androidx.versionedparcelable:versionedparcelable:1.1.1
androidx.viewpager:viewpager:1.0.0
androidx.window:window-core-android:1.5.1
androidx.window:window-core:1.5.1
androidx.window:window:1.5.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ package com.adevinta.spark.components.divider
import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ChainStyle
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import androidx.constraintlayout.compose.atLeast
import com.adevinta.spark.PreviewTheme
import com.adevinta.spark.SparkTheme
import com.adevinta.spark.components.spacer.HorizontalSpacer
Expand Down Expand Up @@ -92,45 +93,38 @@ public fun HorizontalDivider(
.fillMaxWidth(),
)
} else {
ConstraintLayout(
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.sparkUsageOverlay()
.fillMaxWidth(),
) {
val (lineLeft, labelBox, lineRight) = createRefs()

createHorizontalChain(lineLeft, labelBox, lineRight, chainStyle = ChainStyle.SpreadInside)

MaterialHorizontalDivider(
color = intent.color(),
modifier = Modifier.constrainAs(lineLeft) {
start.linkTo(parent.start)
end.linkTo(labelBox.start)
centerVerticallyTo(parent)
width = calculateLineWidth(LabelHorizontalAlignment.Start, labelHorizontalAlignment)
modifier = when (labelHorizontalAlignment) {
LabelHorizontalAlignment.Start -> Modifier.width(40.dp)

LabelHorizontalAlignment.Center,
LabelHorizontalAlignment.End,
-> Modifier.weight(1f).widthIn(min = 40.dp)
},
)

Box(
modifier = Modifier
.padding(horizontal = 16.dp)
.constrainAs(labelBox) {
start.linkTo(lineLeft.end)
end.linkTo(lineRight.start)
centerVerticallyTo(parent)
width = Dimension.preferredWrapContent
},
.weight(1f, fill = false)
.padding(horizontal = 16.dp),
) { label() }

MaterialHorizontalDivider(
color = intent.color(),
modifier = Modifier.constrainAs(lineRight) {
start.linkTo(labelBox.end)
end.linkTo(parent.end)
centerVerticallyTo(parent)
width = calculateLineWidth(LabelHorizontalAlignment.End, labelHorizontalAlignment)
},
modifier = when (labelHorizontalAlignment) {
LabelHorizontalAlignment.End -> Modifier.width(40.dp)

LabelHorizontalAlignment.Center,
LabelHorizontalAlignment.Start,
-> Modifier.weight(1f).widthIn(min = 40.dp)
},
)
}
}
Expand Down Expand Up @@ -161,67 +155,43 @@ public fun VerticalDivider(
.fillMaxHeight(),
)
} else {
ConstraintLayout(
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier
.sparkUsageOverlay()
.fillMaxHeight(),
) {
val (lineTop, labelBox, lineBottom) = createRefs()

createVerticalChain(lineTop, labelBox, lineBottom, chainStyle = ChainStyle.SpreadInside)

MaterialVerticalDivider(
color = intent.color(),
modifier = Modifier.constrainAs(lineTop) {
top.linkTo(parent.top)
bottom.linkTo(labelBox.top)
centerHorizontallyTo(parent)
height = calculateLineHeight(LabelVerticalAlignment.Top, labelVerticalAlignment)
modifier = when (labelVerticalAlignment) {
LabelVerticalAlignment.Top -> Modifier.height(40.dp)

LabelVerticalAlignment.Center,
LabelVerticalAlignment.Bottom,
-> Modifier.weight(1f).heightIn(min = 40.dp)
},
)

Box(
modifier = Modifier
.padding(vertical = 16.dp)
.constrainAs(labelBox) {
top.linkTo(lineTop.bottom)
bottom.linkTo(lineBottom.top)
centerHorizontallyTo(parent)
height = Dimension.preferredWrapContent
},
.weight(1f, fill = false)
.padding(vertical = 16.dp),
) { label() }

MaterialVerticalDivider(
color = intent.color(),
modifier = Modifier.constrainAs(lineBottom) {
top.linkTo(labelBox.bottom)
bottom.linkTo(parent.bottom)
centerHorizontallyTo(parent)
height = calculateLineHeight(LabelVerticalAlignment.Bottom, labelVerticalAlignment)
modifier = when (labelVerticalAlignment) {
LabelVerticalAlignment.Bottom -> Modifier.height(40.dp)

LabelVerticalAlignment.Center,
LabelVerticalAlignment.Top,
-> Modifier.weight(1f).heightIn(min = 40.dp)
},
)
}
}
}

private fun calculateLineHeight(
dividerPosition: LabelVerticalAlignment,
labelVerticalAlignment: LabelVerticalAlignment,
): Dimension = if (dividerPosition == labelVerticalAlignment) {
Dimension.value(40.dp)
} else {
Dimension.fillToConstraints.atLeast(40.dp)
}

private fun calculateLineWidth(
dividerPosition: LabelHorizontalAlignment,
labelVerticalAlignment: LabelHorizontalAlignment,
): Dimension = if (dividerPosition == labelVerticalAlignment) {
Dimension.value(40.dp)
} else {
Dimension.fillToConstraints.atLeast(40.dp)
}

@Preview(
group = "Dividers",
name = "Divider",
Expand Down
Loading