Skip to content

Commit

Permalink
Merge pull request #99 from Trendyol/timeLineView/genericMaxLineCount
Browse files Browse the repository at this point in the history
add maxLineCount parameter to TimeLineView and update README.md
  • Loading branch information
edaersu authored Aug 11, 2022
2 parents ab0f9e8 + 08a3e3a commit 2046069
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ComponentVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object ComponentVersions {
const val dialogsVersion = "1.4.0"
const val cardInputViewVersion = "1.2.2"
const val quantityPickerViewVersion = "1.2.5"
const val timelineViewVersion = "1.0.0"
const val timelineViewVersion = "1.0.1"
const val touchDelegatorVersion = "1.0.0"
const val fitOptionMessageView = "1.0.0"
}
3 changes: 2 additions & 1 deletion libraries/timeline-view/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/timeline-view.png" width="240"/>

timelineViewVersion = timeline-view-1.0.0 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
timelineViewVersion = timeline-view-1.0.1 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## TimelineView
TimelineView creates a timeline and shows actions over time
Expand Down Expand Up @@ -42,6 +42,7 @@ To set width you can use `android:layout_width` attribute. To customize more you
| setBorderWidth | borderWidth: Float | To set borderWidth programmatically |
| setTextSize | textSize: Float | To set setTextSize programmatically |
| setLineWidth | lineWidth: Float | To set setLineWidth programmatically |
| setMaxLineCount | maxLineCount: Int | To set setMaxLineCount programmatically |


# Contributors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class TimelineItemViewState(
val borderWidth: Float,
val textSize: Float,
val lineWidth: Float,
val fontFamily: String
val fontFamily: String,
val maxLineCount: Int
) {

fun getOutsideColor(): Int = Color.parseColor(timelineItem.outsideColor)
Expand Down Expand Up @@ -40,6 +41,8 @@ class TimelineItemViewState(
fun getItemWidth(): Float =
dotSize + borderWidth + lineWidth

fun getItemMaxLineCount(): Int = maxLineCount

companion object {
private const val hexColorWhite = "#000000"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class TimelineView : ConstraintLayout {

private var fontFamily: String = ""

private var maxLineCount: Int = 2

private val binding: ViewTimelineBinding = inflate(R.layout.view_timeline)

private var timelineOrientation: TimelineOrientation = TimelineOrientation.HORIZONTAL
Expand Down Expand Up @@ -119,6 +121,10 @@ class TimelineView : ConstraintLayout {
this.timelineOrientation = timelineOrientation
}

fun setMaxLineCount(maxLineCount: Int?) {
this.maxLineCount = maxLineCount ?: 2
}

fun setItems(items: List<TimelineItem>?) {
binding.viewState = TimelineViewState(
timelineOrientation = timelineOrientation,
Expand Down Expand Up @@ -163,7 +169,8 @@ class TimelineView : ConstraintLayout {
borderWidth = borderWidth,
textSize = textSize,
lineWidth = lineWidth,
fontFamily = fontFamily
fontFamily = fontFamily,
maxLineCount = maxLineCount
)
} ?: emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:maxLines="@{itemViewState.getItemMaxLineCount()}"
android:text="@{itemViewState.getText()}"
android:textColor="@{itemViewState.getTextColor()}"
android:textSize="@{itemViewState.textSize}"
Expand Down

0 comments on commit 2046069

Please sign in to comment.