• Mehdi Haghgoo

    Mehdi Haghgoo

    2 years ago
    I have noticed some composables have a content field, and they also have a body for content. Should the children composables go in their content field or written in their body? For example surface:
    @Composable
    fun Surface(
        modifier: Modifier = Modifier,
        shape: Shape = RectangleShape,
        color: Color = MaterialTheme.colors.surface,
        contentColor: Color = contentColorFor(color),
        border: Border? = null,
        elevation: Dp = 0.dp,
        content: @Composable () -> Unit
    )
    Mehdi Haghgoo
    a
    +2
    7 replies
    Copy to Clipboard
  • Mehdi Haghgoo

    Mehdi Haghgoo

    2 years ago
    Another question, how to refer to the current composable in a Modifier? For example, trying to change the text value of a Text modifier using a clickable modifier.
    Text(text = "Hello Android!", modifier = Modifier.clickable(onClick =  /*Code to change the text Hello Android */))
    Mehdi Haghgoo
    a
    2 replies
    Copy to Clipboard
  • Adrian Blanco

    Adrian Blanco

    2 years ago
    I've been having some problems with font weights for a while now. It seems like having multiple fonts with different weights in a fontFamily just picks the font with the closest weight and ignores the others. On dev-16 and core-ktx 1.5.0-alpha01 now, and it stopped working properly somewhere around dev-12 or 13.
    Adrian Blanco
    1 replies
    Copy to Clipboard
  • Klaas Kabini

    Klaas Kabini

    2 years ago
    Updated to dev16 today and I cannot do this anymore. Why is mutableStateOf not allowing property delagates anymore? Am i missing something?
    class Position(x: Int, y: Int) {
        var x by mutableStateOf(x)
        var y by mutableStateOf(y)
    }
    Klaas Kabini
    gildor
    +1
    9 replies
    Copy to Clipboard
  • tjohnn

    tjohnn

    2 years ago
    I can't seem to be able to update dev15 and dev16, I have these repositories in place:
    maven(url =  "<https://dl.bintray.com/kotlin/kotlin-eap/>")
    jcenter()
    google()
    tjohnn
    d
    +1
    4 replies
    Copy to Clipboard
  • d

    dam5s

    2 years ago
    Some packages were renamed, maybe check that?
    d
    1 replies
    Copy to Clipboard
  • Neal Sanche

    Neal Sanche

    2 years ago
    I have a small compose example app that I've been updating as the dev releases are made, and dev15 and dev16 have been challenging. Specifically, I'm finding on dev16 with Android Studio 4.2 Canary 7, I can no longer see any previews. The preview window just keeps telling me to compile the app. The app was based off the Empty Compose Activity example initially, and the code compiles. Would be happy to drop the code somewhere if people want it.
    Neal Sanche
    Eric Ampire [MOD]
    +3
    6 replies
    Copy to Clipboard
  • Dominaezzz

    Dominaezzz

    2 years ago
    Can compose be used on arbitrary trees now?
    Dominaezzz
    shikasd
    +1
    16 replies
    Copy to Clipboard
  • Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    I work on an app that has a feature in debug builds where we dump the entire view hierarchy of the main window in certain cases, e.g. for crash reports or manually via a special debug menu. This can be really helpful for figuring out the state of the UI when things go wrong. Is it possible to do this with Compose? What would that look like? One option would be to walk the semantics tree, although I’m not sure that would contain enough information for debugging the UI itself. Another option would be getting access to the root
    LayoutNode
    and walking the node tree, but many Composables just wrap other Composables and don’t have their own LayoutNodes, modifiers are often contributed from multiple composables for a single node, etc, so that’s not ideal either. I’ve seen some work being done for Android Studio tooling around extracting some data about stuff like this by inspecting the slot table directly. Would it be reasonable to request a public API for exposing that parsing in debug builds?
    Zach Klippenstein (he/him) [MOD]
    v
    +2
    12 replies
    Copy to Clipboard
  • Patrick Yin

    Patrick Yin

    2 years ago
    One question about wrapping the classic android view inside of a compose component: See code below, if you click TextView area, it’s not clickable, but if you click the Box’s padding area, it’s clickable. And if replace
    emitView(::TextView)
    with a compose
    Text("")
    , it works well. Is it an intentional behavior? Or there is something wrong?
    @Composable
    fun MarketLabel(text: String) {
    //  Android classic view
      emitView(::TextView) {
        it.text = text
      }
    }
    
    @Composable
    fun SomeThing() {
      Box(
        modifier = Modifier
          .clickable(
            onClick = {
              doingSomething()
            }
          )
          .padding(16.dp)
      ) {
        MarketLabel("Test")
      }
    }
    Patrick Yin
    r
    2 replies
    Copy to Clipboard