diff --git a/eggs/AndroidNext/src/main/java/com/android_next/egg/AndroidNextTimelineDialog.kt b/eggs/AndroidNext/src/main/java/com/android_next/egg/AndroidNextTimelineDialog.kt index 6ac9b788..fd6abac0 100644 --- a/eggs/AndroidNext/src/main/java/com/android_next/egg/AndroidNextTimelineDialog.kt +++ b/eggs/AndroidNext/src/main/java/com/android_next/egg/AndroidNextTimelineDialog.kt @@ -43,6 +43,7 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.rememberTextMeasurer import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -51,6 +52,7 @@ import com.dede.basic.requireDrawable import com.google.accompanist.drawablepainter.rememberDrawablePainter import kotlinx.coroutines.launch import java.util.Calendar +import kotlin.math.floor import kotlin.math.min internal var androidNextDialogVisible by mutableStateOf(false) @@ -168,6 +170,9 @@ private fun AndroidReleaseTimeline() { .drawWithCache { onDrawWithContent { for (extra in labelExtras) { + val offsetX = size.width * extra.offsetXPercent + val rangeX = size.width * extra.rangeXPercent + val offsetY = size.height * extra.offsetYPercent val textLayout = textMeasurer.measure( text = context.getString(extra.labelRes), style = TextStyle( @@ -175,9 +180,10 @@ private fun AndroidReleaseTimeline() { fontWeight = FontWeight.Bold, fontFamily = FontFamily.SansSerif, ), + constraints = Constraints( + maxWidth = floor(rangeX - offsetX).toInt(), + ) ) - val offsetX = size.width * extra.offsetXPercent - val offsetY = size.height * extra.offsetYPercent drawText( textLayoutResult = textLayout, color = extra.color, diff --git a/eggs/AndroidNext/src/main/java/com/android_next/egg/Datas.kt b/eggs/AndroidNext/src/main/java/com/android_next/egg/Datas.kt index b228e287..fe5d1a96 100644 --- a/eggs/AndroidNext/src/main/java/com/android_next/egg/Datas.kt +++ b/eggs/AndroidNext/src/main/java/com/android_next/egg/Datas.kt @@ -7,14 +7,16 @@ internal data class LabelExtra( @StringRes val labelRes: Int, val color: Color, val offsetXPercent: Float, - val offsetYPercent: Float = 35.2f / 180f, + val offsetYPercent: Float = 35f / 180f, + val rangeXPercent: Float = 1f ) internal val labelExtras = arrayOf( LabelExtra( labelRes = R.string.label_timeline_developer_previews, color = Color(0xFF_54585D), - offsetXPercent = 25f / 789f + offsetXPercent = 24f / 789f, + rangeXPercent = 204f / 789f, ), LabelExtra( labelRes = R.string.label_timeline_beta_release,