Skip to content

Commit

Permalink
Harmonize AutoSizeTextField.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobodemann authored and Mario Bodemann committed May 13, 2024
1 parent f548542 commit abc3230
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.font.createFontFamilyResolver
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import de.berlindroid.zeapp.zeui.zetheme.ZeBlack
Expand All @@ -29,26 +28,22 @@ private const val TEXT_SCALE_REDUCTION_INTERVAL = 0.7f
fun AutoSizeTextField(
modifier: Modifier = Modifier,
value: String,
fontSize: TextUnit = 24.sp,
lineHeight: TextUnit = 36.sp,
onValueChange: (String) -> Unit,
supportingText: @Composable () -> Unit,
label: @Composable () -> Unit = { },
trailingIcon: @Composable () -> Unit,
placeholder: @Composable () -> Unit,
fontWeight: FontWeight = FontWeight.SemiBold,
textAlign: TextAlign = TextAlign.Center,
isError: Boolean = false,
) {
BoxWithConstraints(modifier = modifier.fillMaxWidth()) {
var shrunkFontSize = fontSize
var shrunkFontSize = 20.sp
val calculateIntrinsics = @Composable {
ParagraphIntrinsics(
text = value,
style = TextStyle(
fontSize = shrunkFontSize,
fontWeight = fontWeight,
lineHeight = lineHeight,
fontWeight = FontWeight.Normal,
lineHeight = 36.sp,
),
density = LocalDensity.current,
fontFamilyResolver = createFontFamilyResolver(LocalContext.current),
Expand All @@ -73,9 +68,9 @@ fun AutoSizeTextField(
onValueChange = { onValueChange(it) },
textStyle = TextStyle(
fontSize = shrunkFontSize,
fontWeight = fontWeight,
lineHeight = lineHeight,
textAlign = textAlign,
fontWeight = FontWeight.Normal,
lineHeight = 36.sp,
textAlign = TextAlign.Start,
),
label = label,
singleLine = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package de.berlindroid.zeapp
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Icon
import android.net.Uri
import android.os.Bundle
import androidx.activity.ComponentActivity
Expand Down Expand Up @@ -36,7 +35,6 @@ import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.ThumbUp
Expand Down Expand Up @@ -84,7 +82,6 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -702,7 +699,6 @@ private fun BadgeConfigEditor(

AutoSizeTextField(
value = "$value",
fontSize = 18.sp,
isError = !error[key].isNullOrEmpty(),
onValueChange = { updated ->
if (updated != value) {
Expand All @@ -713,8 +709,6 @@ private fun BadgeConfigEditor(
}
},
label = { Text(text = key) },
textAlign = TextAlign.Start,
fontWeight = FontWeight.Normal,
supportingText = {
Text(text = error.getOrDefault(key, ""))
},
Expand Down

0 comments on commit abc3230

Please sign in to comment.