Colton Idle
11/04/2021, 6:34 AMSololo
11/04/2021, 6:54 AMSteffen Funke
11/04/2021, 6:56 AM@Immutable
to work correctly for me - why do my list items recompose, when changing only a isLoading
flag of my UI-State?
👉 Code in 🧵elect
11/04/2021, 10:32 AMelect
11/04/2021, 12:32 PMallan.conda
11/04/2021, 1:16 PMBradleycorn
11/04/2021, 2:03 PMjulioromano
11/04/2021, 3:33 PMhiltViewModel()
is the only “easy” way to get dagger-managed objects from within a @Composable
function. Are there any alternatives?
2) In a non 100% compose app (where we can’t just disable all configuration changes in the manifest) any operation running inside a rememberCoroutineScope()
will be interrupted during a configuration change. In these cases we need to resort to the `ViewModel`’s viewModelScope
. Are there any alternatives?
Any insight on the topic is very much appreciated!Alex
11/04/2021, 3:40 PMrsktash
11/04/2021, 3:59 PMif(state.loading) {
ShowLoading()
} else {
LazyColumn{}
}
Jaime
11/04/2021, 4:09 PMprivate val _marketStatusIsClosed = MutableStateFlow(MarketStatusUiState())
val marketStatusClosed: StateFlow<MarketStatusUiState> get() = _marketStatusIsClosed
Composable
val marketStatusState by rememberFlowWithLifecycle(tickerDetailViewModel.marketStatusClosed)
.collectAsState(MarketStatusUiState())
this is the code that is always running even though it is not visible to the user
if (!marketStatusState.isLoading) {
Log.e("BuyInSharesScreen", "$marketStatusState")
if (marketStatusState.isMarketClose) {
} else {
open another composable
}
}
the new composable (screen) is being opened many times, and it is already closing so I do the navigation
currentBackStackEntry?.arguments?.putParcelable(CREATE_ORDER_INFO, operation)
navigate(Screens.BuyStockConfirmationScreen.route)
Tash
11/04/2021, 4:43 PMMatti MK
11/04/2021, 5:41 PMArpit Shukla
11/04/2021, 6:45 PMColton Idle
11/04/2021, 7:35 PMvar theValue by remember { mutableStateOf(false) }
val doSomething = { theValue = !theValue }
Row(modifier = Modifier.clickable { doSomething() }, verticalAlignment = CenterVertically) {
Text(text = "Show this: ")
Checkbox(checked = theValue, onCheckedChange = { doSomething() })
}
or is there something else to have the touch ripples not be independent depending if you click on the row vs the checkbox.Colton Idle
11/04/2021, 11:09 PMColton Idle
11/04/2021, 11:48 PMSteffen Funke
11/05/2021, 7:23 AMLazyColumn
inside a ComposeView
, both wrapped in a View based BottomNavigation
container hierarchy.
Goal: I need to pass outside View based events, e.g. onTabItemReselected
, from containing BottomNavigationView
to the compose hierarchy, to let my LazyList
scroll up, as the current tab is reselected.
My cumbersome, but working approach now looks like this, I am wondering if there are better ways, to avoid those ViewModel round turns, only to dispatch the scrollToTop
- Event
Thanks - 👉 Code in thread🧵Vsevolod Kaganovych
11/05/2021, 9:25 AMfabio.carballo
11/05/2021, 10:16 AMAdrian Tappe
11/05/2021, 10:20 AMfun format(number: Int): String
it uses then is side-effect free.
Where would you use it with Compose? In the ViewModel and expose the State as String or in Compose?
I intuitively would expose the number as state - and see the formatting as part of transforming the state to UI - so put it into the Compose part.
How would you then get this class in Compose - if for performance reasons I’d usually inject it as @Singleton
or @Reusable
via dagger?Ink
11/05/2021, 11:43 AMRuben Quadros
11/05/2021, 2:04 PMjava.lang.IllegalArgumentException: Key was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item
. I am sure all the keys are unique and I even logged them to be sure. Also this happens when items are rapidly added to lazy column.
Please find the sample code in the threadZoltan Demant
11/05/2021, 2:41 PMfabio.carballo
11/05/2021, 3:18 PMRow {
Text()
Checkbox(selected)
}
How can I guarantee that the Row
gets the correct semantics
of selected
that inside the material.Checkbox
? Is there a way it can inherit that status from the "children" ?rsktash
11/05/2021, 3:51 PMArchie
11/05/2021, 3:58 PMsaket
11/06/2021, 6:38 AMjava.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions.setUseIR(boolean)'
AmrJyniat
11/06/2021, 9:08 AMPaddingValues
class? there is no <http://paddingValues.top|paddingValues.top>
getter!Zoltan Demant
11/06/2021, 10:21 AMZoltan Demant
11/06/2021, 10:21 AMfun removeFromWindow() {
manager.removeView(this)
}
e.g. Removing the view from the window should happen after the animation finishes. Similar but reverse story when adding the view.
My code thus far has a mutableState<Boolean> which indicates whether the view should be attached, but there are no start/end listeners so I dont know where to go from there.Csaba Kozák
11/06/2021, 10:51 AManimatable.animateTo(…)
then it will suspend until the animation is done. In the next line, you can set the state to remove the view.Zoltan Demant
11/06/2021, 11:00 AMvar wasVisible by remember {
mutableStateOf(false)
}
LaunchedEffect(visible) {
if (!wasVisible) {
// addToWindow
}
val animatable = Animatable(
initialValue = if (wasVisible) 1f else 0f
)
animatable.animateTo(
targetValue = if (visible) 1f else 0f
)
if (!visible) {
// removeFromWindow
}
wasVisible = visible
}
Csaba Kozák
11/06/2021, 11:08 AMZoltan Demant
11/06/2021, 11:20 AM