Skip to content

Commit de1d45e

Browse files
committed
refactor: 소요 시간 UI의 각 View가 앞 부분에 일부 겹치도록 margin 추가
1 parent a708ce0 commit de1d45e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

presentation/src/main/java/com/stop/ui/route/TimeLineContainer.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TimeLineContainer(
3030
private var iconCount: Int? = null
3131
private var textWidth: Int? = null
3232
private var routeCount: Int? = null
33+
private var overlappingWidth: Int? = null
3334

3435
private val density = context.resources.displayMetrics.density
3536

@@ -46,12 +47,13 @@ class TimeLineContainer(
4647
}
4748

4849
iconWidth = convertDpToPixel(9f)
49-
// iconWidth = convertDpToPixel(size) * routes.size
5050
iconCount = count + 1
5151

5252
textWidth = convertDpToPixel(30f)
5353
routeCount = routes.size
5454

55+
overlappingWidth = OVERLAPPING_MARGIN * (routes.size - 1)
56+
5557
doOnLayout {
5658
routes.forEachIndexed { index, route ->
5759
val timeLineItem2Binding = TimeLineItem2Binding.inflate(
@@ -60,8 +62,15 @@ class TimeLineContainer(
6062
false,
6163
).apply {
6264
root.id = View.generateViewId()
65+
if (index != 0) {
66+
val layoutParams = root.layoutParams as MarginLayoutParams
67+
layoutParams.marginStart = -OVERLAPPING_MARGIN
68+
root.requestLayout()
69+
root.layoutParams = layoutParams
70+
}
6371
}
6472

73+
6574
addView(timeLineItem2Binding.root)
6675
setBindingAttribute(timeLineItem2Binding, route, index)
6776
}
@@ -151,12 +160,11 @@ class TimeLineContainer(
151160
val iconCount = iconCount ?: throw IllegalArgumentException("로직이 잘못 되었습니다.")
152161
val textWidth = textWidth ?: throw IllegalArgumentException("로직이 잘못 되었습니다.")
153162
val routeCount = routeCount ?: throw IllegalArgumentException("로직이 잘못 되었습니다.")
154-
163+
val overlappingWidth = overlappingWidth ?: throw IllegalArgumentException("로직이 잘못 되었습니다.")
155164
val extraWidth =
156-
this@TimeLineContainer.width - iconWidth * iconCount - textWidth * routeCount
165+
this@TimeLineContainer.width - iconWidth * iconCount - textWidth * routeCount + overlappingWidth
157166
binding.root.layoutParams.width =
158167
(extraWidth * proportionOfSectionTime).toInt() + iconWidth + textWidth
159-
160168
}
161169

162170
private fun setIdentityColor(binding: TimeLineItem2Binding, route: TransportRoute) {
@@ -177,4 +185,8 @@ class TimeLineContainer(
177185
binding.viewIcon.background = drawable
178186
binding.viewIcon.background.setTintList(null)
179187
}
188+
189+
companion object {
190+
private const val OVERLAPPING_MARGIN = 10
191+
}
180192
}

0 commit comments

Comments
 (0)