• p

    prat

    1 year ago
    Hi, I'm learning how effect works and trying to understand why
    millis
    value doesn't change when I add a log at A - before Canvas. Without the log or when I add log at B instead,
    millis
    gets updated. Is this an expected behavior?
    @Composable
    fun DrawSomething(
        modifier: Modifier,
        strokeWidth: Float = 8f
    ) {
        val millis = animationTimeMillis()
    
    // A: when adding a Log here, millis.value will stop at 0 and won't draw arc
    // Log.d("DrawSomething", "millis : ${millis.value}")
    
        Canvas(modifier = modifier) {
    
            // B
            // Log.d("DrawSomething", "millis : ${millis.value}")
    
            drawArc(
                color = Color.Green,
                startAngle = 0f,
                sweepAngle = 0f + (millis.value / 360),
                useCenter = false,
                size = Size(100f, 100f),
                style = Stroke(width = strokeWidth)
            )
        }
    }
    @Composable
    fun animationTimeMillis(): State<Long> {
        val millisState = mutableStateOf(0L)
        val lifecycleOwner = AmbientLifecycleOwner.current
        LaunchedEffect(Unit) {
            val startTime = withFrameMillis { it }
            lifecycleOwner.whenStarted {
                while (true) {
                    withFrameMillis { frameTime ->
                        millisState.value = frameTime - startTime
                    }
                }
            }
        }
        return millisState
    }
    p
    Adam Powell
    12 replies
    Copy to Clipboard
  • r

    robnik

    1 year ago
    I'd like to use BottomNavigation where each tab remembers its navigation state. Is this supported with Compose Navigation?
    r
    k
    +1
    3 replies
    Copy to Clipboard
  • Brady Aiello

    Brady Aiello

    1 year ago
    Anyone ever have this issue with bouncing text in a
    TextField
    ? I can resolve it with
    singleLine = true
    , but it still chops off the bottom of the sub-baseline letters. This is in a
    TopAppBar
    in a Scaffold. Thought this might be due to a size constraint on
    TopAppBar
    ? Or maybe just the
    topAppBar
    content parameter in
    Scaffold
    ? Not sure if there's any weird trickiness with
    TextField
    itself.
    Brady Aiello
    Siyamed
    3 replies
    Copy to Clipboard
  • Marcin Środa

    Marcin Środa

    1 year ago
    Has anyone worked on a camera or photo gallery? Looking for photo capture / image selector.
    Marcin Środa
    2 replies
    Copy to Clipboard
  • lewis

    lewis

    1 year ago
    How can I get
    BottomAppBar
    to hide when I scroll down in my
    ScrollableColumn
    ?
    lewis
    1 replies
    Copy to Clipboard
  • t

    tseisel

    1 year ago
    Today I tried Jetpack Compose. While it looks promising, has anyone noticed how long it is to update a composable
    @Preview
    ? It takes almost a minute to render each change, and I'm using a decent laptop. Also, is it required to rebuild project to update preview ?
    t
    z
    +5
    7 replies
    Copy to Clipboard
  • l

    Lilly

    1 year ago
    Is someone aware of a sample app where data is not only retrieved but also send to repository? I'm wondering how to collect all the state in different composable when event is triggered. First thought is to hoist all the state to
    ViewModel
    ...
    l
    b
    +2
    10 replies
    Copy to Clipboard
  • Nana Vong

    Nana Vong

    1 year ago
    When Scaffold bodyContent includes LazyColumn ,sliding becomes very jerky !😫
    Nana Vong
    Shakil Karim
    +1
    3 replies
    Copy to Clipboard
  • s

    Se7eN

    1 year ago
    I have this code and I'm getting this weird bug you can see in the video. The bug goes away when I remove the three Texts for R, G and B values. Here is the code:
    val colors = remember {
        mutableStateListOf(
            mutableStateListOf(Color.Magenta, Color.Blue, Color.Yellow)
        )
    }
    val activeRowIndex = remember { mutableStateOf(0) }
    val activeColumnIndex = remember { mutableStateOf(0) }
    
    ...
    
    Sliders(
        colors[activeRowIndex.value][activeColumnIndex.value],
        onColorChange = { colors[activeRowIndex.value][activeColumnIndex.value] = it }
    )
    @Composable
    fun Sliders(color: Color, onColorChange: (Color) -> Unit) {
        Column {
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "R - ${color.red * 255}")
                Slider(
                    value = color.red,
                    onValueChange = { onColorChange(color.copy(red = it)) }
                )
            }
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "G - ${color.green * 255}")
                Slider(
                    value = color.green,
                    onValueChange = { onColorChange(color.copy(green = it)) }
                )
            }
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "B - ${color.blue * 255}")
                Slider(
                    value = color.blue,
                    onValueChange = { onColorChange(color.copy(blue = it)) }
                )
            }
        }
    }
    s
    tylerwilson
    +1
    4 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    1 year ago
    https://jakewharton.com/a-jetpack-compose-by-any-other-name/ Anyone else here think there should be some sort of name change? 👍 or 👎 Personally, I've talked to people about Jetpack Compose and they find "Jetpack" to be weird. I think I'm only "okay" with it because I've grown used to "jetpack" as a term that we use when talking about android dev. "Jetbrains Compose" for desktop could also be confusing. I think just having Compose (and saying that its available for Android and desktop) is easiest when talking about the UI, and the compiler and runtime could probably just be renamed. Seems like that would be the least amount of friction.
    Colton Idle
    rsktash
    +3
    16 replies
    Copy to Clipboard