• Chuck Stein

    Chuck Stein

    1 year ago
    Is there any mechanism like
    remember
    but instead of recalculating if dependencies change, it recalculates if a given predicate is true? My use case is I have some UI content within an
    AnimatedVisibility
    block, where
    visible = uiState is InitialUiState
    . (My UI state is a sealed class with subtypes we can call
    InitialUiState
    and
    SecondaryUiState
    .) Some of the UI content I'm animating depends on a property contained within
    InitialUiState
    , but not
    SecondaryUiState
    . So when it's animating out of visibility, my
    uiState
    no longer contains the data needed in order to render the UI. I can wrap the content in
    if (uiState is InitialUiState)
    , but then the content just disappears instead of animating out. My thought is I need to memoize the most recent
    InitialUiState
    value, using something like
    val initialUiState = rememberUnless(uiState is InitialUiState) { uiState as? InitialUiState }
    , so that we can access the data contained within the last
    InitialUiState
    , even when the current value of
    uiState
    is a
    SecondaryUiState
    . In this example it would recalculate on every composition where
    uiState is InitialUiState
    , but "remember" and return the previous calculation otherwise.
    Chuck Stein
    Colton Idle
    +1
    18 replies
    Copy to Clipboard
  • Chris Johnson

    Chris Johnson

    1 year ago
    What's everyone's thoughts on passing in your viewModel to your top level composable VS passing in just your uiState? I'm leaning towards passing in the uiState since it seems that's all you need to preview/test but I was wondering if there's a best practice we should follow and why?
    Chris Johnson
    Colton Idle
    2 replies
    Copy to Clipboard
  • Nick

    Nick

    1 year ago
    If I have a column with several components in it, how do I make one of those components always be at the bottom (specifically a FAB button)
    Nick
    l
    4 replies
    Copy to Clipboard
  • Ashu

    Ashu

    1 year ago
    So this question has been asked like a zillion times, but let me ask it again, what's up with
    androidx.compose.ui.tooling.PreviewActivity is not an Activity subclass or alias
    .?? I am on the latest stable version of everything, • Compose 1.0.1 • AGP 7.0.2 • Kotlin 1.5.21 • Android Studio Arctic Fox Patch 1 ...and still this issue is coming. What's up with that. And how do I fix it.?? Its so annoying. And why does making a duplication Run Configuration of the same just works perfectly fine.??
    Ashu
    a
    6 replies
    Copy to Clipboard
  • s

    Sam

    1 year ago
    Compose noob here, i'm trying to use
    keys
    to avoid recomposition of previously composed ones but can't seem to get it to work. Displaying a list with items and a button to shuffle the list item but all items are composed again (logging via
    SideEffect
    )
    s
    i
    +1
    22 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    1 year ago
    I have a lazy column with a gradient background, and I want the gradient to be the entire height. BUT after I start scrolling I want to gradient to scroll up/off of the screen. Any Ideas on how to implement? I currently have a Box { GradientBackground() LazyColumn() } but the Gradient (of course) doesn't move up. Is there anything Col or LazyCol provide for this sort of thing? Kind of like a "first page background", and then a background for everything below the device height?
    Colton Idle
    Zach Klippenstein (he/him) [MOD]
    +1
    16 replies
    Copy to Clipboard
  • i

    Ink

    1 year ago
    Is it possible to do something like that in the latest version of Compose?
    i
    1 replies
    Copy to Clipboard
  • CRamsan

    CRamsan

    1 year ago
    Hello everyone. Does someone know what will be the plan moving for supporting new versions of the Kotlin compiler? Will Compose always require explicit support for any new compiler version?
    CRamsan
    1 replies
    Copy to Clipboard
  • t

    tad

    1 year ago
    Just to clarify: If I log something during recomposition of the top-level function of my Compose app, and that log occurs every 16 milliseconds, then one of the arguments to the top-level function has "changed" according to Compose?
    t
    Zach Klippenstein (he/him) [MOD]
    9 replies
    Copy to Clipboard
  • z

    zhagnfei

    1 year ago
    i want render diff view with data but when use state it not change like this:
    val state: MutableList<String>? by imageList.observeAsState(mutableListOf())
    if (state.isNullOrEmpty()) {
        feedbackPlaceView(addImgClick)
    } else {
        state?.forEachIndexed { listIndex, s ->
    z
    Zach Klippenstein (he/him) [MOD]
    4 replies
    Copy to Clipboard