Skip to content

Instantly share code, notes, and snippets.

View senneco's full-sized avatar

Yuri Shmakov senneco

View GitHub Profile
@inidamleader
inidamleader / AutoSizeText.kt
Last active May 18, 2024 20:52
Composable function that automatically adjusts the text size to fit within given constraints with optimal performance by using a binary search algorithm
// LAST UPDATE: 18 May 2024 V5: Update to support compose 1.7.0+
package com.inidamleader.ovtracker.util.compose
import android.util.Log
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.BoxWithConstraintsScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle