Skip to content

Commit

Permalink
Add a constant for ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowsky committed Jul 16, 2023
1 parent 2b7cba3 commit 6848342
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.graphics.Matrix
import android.graphics.Path
import android.graphics.RectF
import com.patrykandpatrick.vico.core.component.text.TextComponent
import com.patrykandpatrick.vico.core.constants.ELLIPSIS
import com.patrykandpatrick.vico.core.context.DrawContext
import com.patrykandpatrick.vico.core.extension.ceil
import com.patrykandpatrick.vico.core.extension.centerPoint
Expand Down Expand Up @@ -69,7 +70,7 @@ public open class InsideSliceLabel(
angle = angle.radiansDouble,
)

val minWidth = textComponent.getTextBounds(this, "").width()
val minWidth = textComponent.getTextBounds(this, ELLIPSIS).width()
val textBounds = textComponent.getTextBounds(this, label)

textBounds.offset(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 by Patryk Goworowski and Patrick Michalik.
* Copyright 2023 by Patryk Goworowski and Patrick Michalik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,3 +22,5 @@ package com.patrykandpatrick.vico.core.constants
public const val FULL_DEGREES: Float = 360f

internal const val ERR_REPEATING_COLLECTION_EMPTY = "Cannot get repeated item from empty collection."

internal const val ELLIPSIS: String = ""
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 by Patryk Goworowski and Patrick Michalik.
* Copyright 2023 by Patryk Goworowski and Patrick Michalik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@ package com.patrykandpatrick.vico.core.extension
import android.os.Build
import android.text.Spannable
import android.text.SpannableStringBuilder
import com.patrykandpatrick.vico.core.constants.ELLIPSIS

/**
* An SDK version-dependant compat function for appending text to [SpannableStringBuilder] and setting the span.
Expand Down Expand Up @@ -52,7 +53,7 @@ public fun <T> Iterable<T>.transformToSpannable(
prefix: CharSequence = "",
postfix: CharSequence = "",
limit: Int = -1,
truncated: CharSequence = "…",
truncated: CharSequence = ELLIPSIS,
transform: SpannableStringBuilder.(T) -> Unit,
): Spannable {
val buffer = SpannableStringBuilder()
Expand Down

0 comments on commit 6848342

Please sign in to comment.