UI: fix the font size auto scaling for ArmFeaturesVisualizer
This commit is contained in:
parent
480d774b0c
commit
d5220549b6
|
|
@ -3,6 +3,7 @@ package com.example.llama.ui.components
|
||||||
import android.llama.cpp.ArmFeature
|
import android.llama.cpp.ArmFeature
|
||||||
import android.llama.cpp.ArmFeaturesMapper.DisplayItem
|
import android.llama.cpp.ArmFeaturesMapper.DisplayItem
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.text.TextAutoSize
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
||||||
import androidx.compose.material3.SegmentedButton
|
import androidx.compose.material3.SegmentedButton
|
||||||
|
|
@ -19,6 +20,7 @@ import kotlin.math.sqrt
|
||||||
@Composable
|
@Composable
|
||||||
fun ArmFeaturesVisualizer(
|
fun ArmFeaturesVisualizer(
|
||||||
supportedFeatures: List<DisplayItem>,
|
supportedFeatures: List<DisplayItem>,
|
||||||
|
autoSizeMinScaling: Float = 0.5f,
|
||||||
onFeatureClick: ((ArmFeature) -> Unit)? = null
|
onFeatureClick: ((ArmFeature) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
// Segmented Button Row for Features
|
// Segmented Button Row for Features
|
||||||
|
|
@ -40,7 +42,12 @@ fun ArmFeaturesVisualizer(
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = item.feature.displayName,
|
text = item.feature.displayName,
|
||||||
|
autoSize = TextAutoSize.StepBased(
|
||||||
|
minFontSize = MaterialTheme.typography.labelSmall.fontSize * autoSizeMinScaling,
|
||||||
|
maxFontSize = MaterialTheme.typography.labelSmall.fontSize
|
||||||
|
),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
maxLines = 1,
|
||||||
fontWeight = if (item.isSupported) {
|
fontWeight = if (item.isSupported) {
|
||||||
FontWeight.Medium
|
FontWeight.Medium
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue