Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textIndent still not woring on desktop #2563

Open
PPeanutButter opened this issue Dec 18, 2022 · 3 comments
Open

textIndent still not woring on desktop #2563

PPeanutButter opened this issue Dec 18, 2022 · 3 comments
Labels
bug Something isn't working text

Comments

@PPeanutButter
Copy link

PPeanutButter commented Dec 18, 2022

Text(
                modifier = Modifier
                    .clickable { selected = !selected },
                text = task.files[0].getFileName(),
                fontSize = 20.sp,
                maxLines = 2,
                lineHeight = 24.sp,
                overflow = TextOverflow.Ellipsis,
                fontWeight = FontWeight.Bold,
                style = TextStyle(
                    textIndent = TextIndent(15.sp)
                )
            )

org.jetbrains.compose.ui:ui-text-desktop:1.2.2 (ui-text-desktop-1.2.2.jar)
windows10

it should be fixed by #1733 , but it still not working for me.

--edit

style = TextStyle(
                    textIndent = TextIndent(31.sp)
                )

it works in other place, but not this

Box {
        var selected by remember { mutableStateOf(false) }
        LaunchedEffect(key1 = selected, block = {
            if (onSelected != null)
                onSelected(selected, task)
        })
        Checkbox(
            checked = selected, onCheckedChange = { selected = !selected }, modifier = Modifier
                .wrapContentSize()
                .clickable(interactionSource = MutableInteractionSource(),
                    indication = null, onClick = {})
        )
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .clickable {  }
                .padding(start = 12.dp, end = 12.dp, top = 10.dp, bottom = 12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)
        ) {
            Text(
                modifier = Modifier
                    .clickable { selected = !selected },
                text = task.files[0].getFileName(),
                fontSize = 20.sp,
                maxLines = 2,
                lineHeight = 24.sp,
                overflow = TextOverflow.Ellipsis,
                fontWeight = FontWeight.Bold,
                style = TextStyle(
                    textIndent = TextIndent(31.sp)
                )
            )...

--edit again
when the text has two lines+, it works fine. Only not work with single text long.

@igordmn
Copy link
Collaborator

igordmn commented Dec 19, 2022

Indeed, we have a bug, when the text doesn't have fillMaxWidth(). As a workaround, add it to your text:

            Text(
                modifier = Modifier
                    .fillMaxWidth()
                    .clickable { selected = !selected },
                text = task.files[0].getFileName(),

@igordmn
Copy link
Collaborator

igordmn commented Dec 19, 2022

Reproducer:

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextIndent
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    Column {
        Text(
            modifier = Modifier.fillMaxWidth().border(1.dp, Color.Red),
            text = "Text",
            maxLines = 1,
            softWrap = false,
            style = TextStyle(
                textIndent = TextIndent(15.sp)
            )
        )
        Text(
            modifier = Modifier.border(1.dp, Color.Red),
            text = "Text",
            maxLines = 1,
            softWrap = false,
            style = TextStyle(
                textIndent = TextIndent(15.sp)
            )
        )
        Text(
            modifier = Modifier.fillMaxWidth().border(1.dp, Color.Red),
            text = "Text text text text",
            maxLines = 1,
            softWrap = false,
            style = TextStyle(
                textIndent = TextIndent(15.sp)
            )
        )
        Text(
            modifier = Modifier.border(1.dp, Color.Red),
            text = "Text text text text",
            maxLines = 1,
            softWrap = false,
            style = TextStyle(
                textIndent = TextIndent(15.sp)
            )
        )
    }
}

(Compose 1.2.2)
image

@igordmn igordmn added bug Something isn't working text labels Dec 19, 2022
@PPeanutButter
Copy link
Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working text
Projects
None yet
Development

No branches or pull requests

2 participants