Skip to content

Commit

Permalink
fix timelineview
Browse files Browse the repository at this point in the history
  • Loading branch information
edanur.ersu committed Jul 27, 2023
1 parent 3815fa8 commit b23262f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
1 change: 0 additions & 1 deletion libraries/timeline-view-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ val timelineItems = listOf(
| elevation | Int | To set elevation |
| color | Color | To set color |
| alpha | Float | To set alpha of shadow |
| radius | Float | To set radius |

#### Item Types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.trendyol.uicomponents.timelineviewcompose

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -32,7 +31,6 @@ internal fun TimelinePoint(
shape = CircleShape,
ambientColor = pointShadowConfig.color.copy(alpha = pointShadowConfig.alpha),
)
.padding(horizontal = pointShadowConfig.radius.dp)
} else {
Modifier
}
Expand Down Expand Up @@ -88,7 +86,6 @@ private fun TimelinePointPreview() {
elevation = 7,
color = Color.Black,
alpha = 0.6f,
radius = 1.5f
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.trendyol.uicomponents.timelineviewcompose.model.PointLayoutId
import com.trendyol.uicomponents.timelineviewcompose.model.TextLayoutId
import com.trendyol.uicomponents.timelineviewcompose.model.TimelineItem
import com.trendyol.uicomponents.timelineviewcompose.model.TimelineOrientation
import com.trendyol.uicomponents.timelineviewcompose.model.getHorizontalConstraintSet
import com.trendyol.uicomponents.timelineviewcompose.model.getHorizontalWithIndexConstraintSet

@Composable
internal fun HorizontalTimelineWithIndexTextItem(
Expand All @@ -38,7 +38,7 @@ internal fun HorizontalTimelineWithIndexTextItem(
val itemWidth =item.pointConfig.getSizeWithBorder() + customLineWidth

ConstraintLayout(
constraintSet = getHorizontalConstraintSet(item.contentMargin),
constraintSet = getHorizontalWithIndexConstraintSet(item.contentMargin, itemWidth),
modifier = modifier
.width(customLineWidth)
) {
Expand Down Expand Up @@ -69,7 +69,7 @@ internal fun HorizontalTimelineWithIndexTextItem(
config = item.lineConfig,
orientation = TimelineOrientation.HORIZONTAL,
modifier = Modifier.layoutId(LineLayoutId),
customLineWidth = customLineWidth
customLineWidth = customLineWidth - item.pointConfig.borderWidth
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.trendyol.uicomponents.timelineviewcompose.model

import androidx.compose.ui.unit.Dp
import androidx.constraintlayout.compose.ConstraintSet
import androidx.constraintlayout.compose.Dimension

internal const val PointLayoutId = "point"
internal const val LineLayoutId = "line"
Expand All @@ -13,7 +14,6 @@ internal fun getHorizontalConstraintSet(marginFromPoint: Dp): ConstraintSet {
val point = createRefFor(PointLayoutId)
val text = createRefFor(TextLayoutId)
val line = createRefFor(LineLayoutId)
val indexText = createRefFor(IndexTextLayoutId)

constrain(point) {
start.linkTo(parent.start)
Expand All @@ -29,11 +29,6 @@ internal fun getHorizontalConstraintSet(marginFromPoint: Dp): ConstraintSet {
centerVerticallyTo(point)
start.linkTo(point.end)
}

constrain(indexText) {
centerHorizontallyTo(point)
centerVerticallyTo(point)
}
}
}

Expand Down Expand Up @@ -62,6 +57,39 @@ internal fun getVerticalConstraintSet(marginFromPoint: Dp): ConstraintSet {
end.linkTo(point.end)
}

constrain(indexText) {
centerHorizontallyTo(point)
centerVerticallyTo(point)
}
}
}

internal fun getHorizontalWithIndexConstraintSet(
marginFromPoint: Dp,
itemWidth: Dp
): ConstraintSet {
return ConstraintSet {
val point = createRefFor(PointLayoutId)
val text = createRefFor(TextLayoutId)
val line = createRefFor(LineLayoutId)
val indexText = createRefFor(IndexTextLayoutId)

constrain(point) {
start.linkTo(parent.start)
top.linkTo(parent.top)
}

constrain(text) {
centerHorizontallyTo(point)
top.linkTo(point.bottom, marginFromPoint)
width = Dimension.value(itemWidth)
}

constrain(line) {
centerVerticallyTo(point)
start.linkTo(point.end)
}

constrain(indexText) {
centerHorizontallyTo(point)
centerVerticallyTo(point)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ data class PointShadowConfig(
val elevation: Int,
val color: Color,
val alpha: Float,
val radius: Float,
)
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ internal object TimelineViewItemProvider {
insideColor = colorWhite
),
text = "Kredi ile Öde",
textStyle = TextStyle(color = Color.Gray, fontSize = 10.sp),
textStyle = TextStyle(
fontFamily = FontFamily.Default,
fontSize = 12.sp,
color = Color.Gray
),
indexTextStyle = TextStyle(color = Color.Gray),
lineConfig = LineConfig(color = colorGray),
)
Expand All @@ -161,7 +165,11 @@ internal object TimelineViewItemProvider {
insideColor = colorWhite
),
text = "Sms Onayı",
textStyle = TextStyle(color = Color.Gray, fontSize = 10.sp),
textStyle = TextStyle(
fontFamily = FontFamily.Default,
fontSize = 12.sp,
color = Color.Gray
),
indexTextStyle = TextStyle(color = Color.Gray),
lineConfig = LineConfig(color = colorGray),
)
Expand All @@ -174,14 +182,17 @@ internal object TimelineViewItemProvider {
animation = if (pointAnimationEnabled) PointAnimation(startDelay = 2000) else null
),
text = "Kredi Teklifleri",
textStyle = TextStyle(color = colorGreen, fontSize = 10.sp),
textStyle = TextStyle(
fontFamily = FontFamily.Default,
fontSize = 12.sp,
color = colorGreen
),
lineConfig = LineConfig(color = colorGray),
indexTextStyle = TextStyle(color = Color.White),
pointShadowConfig = PointShadowConfig(
elevation = 7,
color = Color.Black,
alpha = 0.6f,
radius = 1.5f
)
)

Expand All @@ -191,8 +202,12 @@ internal object TimelineViewItemProvider {
outSideColor = colorGray,
insideColor = colorWhite
),
text = "Banka Onayı Onayı",
textStyle = TextStyle(color = Color.Gray, fontSize = 10.sp),
text = "Banka Onayı",
textStyle = TextStyle(
fontFamily = FontFamily.Default,
fontSize = 12.sp,
color = Color.Gray
),
indexTextStyle = TextStyle(color = Color.Gray),
lineConfig = getLineConfig(colorGray)
)
Expand Down

0 comments on commit b23262f

Please sign in to comment.