• r

    robnik

    1 year ago
    I'm having trouble seeing how the parts fit together. Eg, I have a
    NavHost(...) { composable(..., arguments = ...) {
    ... inside that I extract at argument (id: String), now I can want to query my Room database, like
    db.getThing(id):Flow<Thing>
    and pass it to a
    @Composable fun ThingView(thing)
    but that DB function is not callable outside of a coroutine context. So... where do I get the coroutine context, and then how to I hook the result obtained within that back to some MutableState that Compose can observe, in ThingView.
    r
    i
    5 replies
    Copy to Clipboard
  • Samir Basnet

    Samir Basnet

    1 year ago
    Will the bug where the list item has ripple animation even while scrolling be fixed in next beta?
    Samir Basnet
    1 replies
    Copy to Clipboard
  • p

    Philip Blandford

    1 year ago
    Struggling to get a chat-like interface behaving correctly - I'm using accompanist-insets to set the padding, but about half the time it shoots the textfield nearly to the top of the screen.
    @Composable
    @Preview
    private fun InsetsTest() {
      val activity = LocalContext.current as Activity
      WindowCompat.setDecorFitsSystemWindows(activity.window, false)
    
      MaterialTheme {
        ProvideWindowInsets {
    
          val text = remember { mutableStateOf("") }
    
          Column(
            Modifier
              .fillMaxSize()
              .background(Color.White)
          ) {
            Box(
              Modifier
                .fillMaxWidth()
                .weight(1f)
                .background(Color.LightGray)
            )
            Column(
              Modifier
                .navigationBarsWithImePadding()
                .background(Color.Yellow)) {
              BasicTextField(
                text.value,
                { text.value = it },
                Modifier
                  .fillMaxWidth()
                  .heightIn(50.dp)
              )
              Box(Modifier.height(50.dp))
            }
          }
        }
      }
    }
    p
    cb
    2 replies
    Copy to Clipboard
  • orangy

    orangy

    1 year ago
    I have a main/detail UI, where user can select an item in the list, and then details are shown in another box. That box has a scrollable layout inside, and everything is working fine, except the scroll state is shared with all the items in the main list. I figured I should inline the
    rememberScrollState
    and provide inputs there (selected item in the main list), but now the scroll is not remembered at all, every switch in main list starts with initial position. How do I make scroll state in detail pane be persisted per item in the main list?
    orangy
    Zach Klippenstein (he/him) [MOD]
    6 replies
    Copy to Clipboard
  • m

    Michal Klimczak

    1 year ago
    Is this a legitimate use of
    LaunchedEffect
    or am I abusing something? I'm trying to detect changes to multiple
    States
    and make a callback out of them.
    @Composable
    fun FooSlider(
        onStartedSelection: () -> Unit,
        onSelected: (value: Float) -> Unit
    ) {
        var sliderPosition by remember { mutableStateOf(0f) }
        val sliderInteractions = remember { MutableInteractionSource() }
        val isDragged by sliderInteractions.collectIsDraggedAsState()
        val isPressed by sliderInteractions.collectIsPressedAsState()
    
        LaunchedEffect(isDragged || isPressed) {
            when {
                isDragged || isPressed -> onStartedSelection()
                else -> onSelected(sliderPosition)
            }
        }
    
        Slider(
            value = sliderPosition,
            onValueChange = { sliderPosition = it },
            interactionSource = sliderInteractions
        )
    
    }
    m
    Zach Klippenstein (he/him) [MOD]
    7 replies
    Copy to Clipboard
  • r

    robnik

    1 year ago
    How do I stop Android Studio from reindenting my entire file just because I autocompleted something in a Composable function? Screenshots in thread...
    r
    Dominaezzz
    +1
    32 replies
    Copy to Clipboard
  • o

    Oleg Tretiakov

    1 year ago
    Hey everyone! Is it possible to measure children at runtime? I'd like to achieve the behavior when visibility of 2nd child of the layout depends on how many lines 1nd child has
    o
    orangy
    2 replies
    Copy to Clipboard
  • YASAN

    YASAN

    1 year ago
    Is there a function or something to change the alpha variable of a
    Color
    ? It is val so cannot be modified. To change it I had to create my custom extension function:
    fun Color.updateAlpha(newAlpha: Float) =
        Color(red = red, blue = blue, green = green, colorSpace = colorSpace, alpha = newAlpha)
    YASAN
    r
    4 replies
    Copy to Clipboard
  • o

    Olivier Patry

    1 year ago
    I struggle to achieve "complex" transition of my entities. I have a list of items, each of them having an "update cause". Depending on it, I have different transition to apply to the item's composable. So, I need to animate several values of different nature at the same time, the animation "spec" depending on "update cause". Both beginning and ending state depends on such state. I have a quick & dirty "working" impl (not smooth anim, not very nice code…) which I try to clean using
    updateTransition
    (doc) without a lot of success so far…
    o
    r
    +3
    78 replies
    Copy to Clipboard
  • Nat Strangerweather

    Nat Strangerweather

    1 year ago
    I have a box with a
    .fillMaxWidth
    modifier. In that box, I have another box and I want it to be the width of the parent box divided by 7. How can I get the width of the parent Box, or that .
    fillMaxWidth
    value?
    Nat Strangerweather
    n
    21 replies
    Copy to Clipboard