Jan
10/28/2022, 9:02 PMval products by viewModel.productEntryFlow.collectAsState(listOf())
LazyColumn {
items(products) {
Text(it.content + " Done: ${it.doneBy != null}")
}
}
And that kinda works fine when the list itself gets modified (gets new entries etc) but it doesn't work when a single item changes e.g. the "doneBy" property is now null.
If I collect the flow manually I see the changes but not with collectAsState. Can I fix that?. productEntryFlow is a Flow from SQLDelight and as I said manually collecting the flow worksLoney Chou
10/29/2022, 4:52 AMDavide Giuseppe Farella
10/29/2022, 6:53 AMorg.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
…
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:47)
…
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn’t inline method call: CALL ‘public final fun <get-current> (): T of androidx.compose.runtime.CompositionLocal [inline] declared in androidx.compose.runtime.CompositionLocal’ type=android.content.Context origin=GET_PROPERTY
Method: null
File is unknown
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.getMethodNode(SourceCompilerForInline.kt:118)
…
Caused by: java.lang.IllegalStateException: couldn’t find inline method Landroidx/compose/runtime/CompositionLocal;.getCurrent()Ljava/lang/Object;Any idea? I’m already going crazy 😄 Currently, I got a couple of KMP modules and a couple of Android one, but I also tried changing the KMP to plain JVM, without any improvement
xxfast
10/29/2022, 7:44 AMcolorScheme
for Material 3? In Material 2 I used to do
val Colors.alertHigh: Color
@Composable get() =
if (!isSystemInDarkTheme()) Color(0xFFD0011C) else Color(0xFFFF3B2F)
with Material 3 only difference was the Colors
→ ColorScheme
, but as you can see the custom colours tend to stand out from the rest.Jasmin Fajkic
10/29/2022, 7:52 AMErik
10/29/2022, 9:17 PMcopy
the state and pass it to the callback. I've now refactored the callback to not take a state S
, but take a S.() -> S
lambda instead. This leads to lambdas in lambdas everywhere. While it's not a big issue (and Kotlin's last-lambda-argument passing helps a lot here), I wonder:
Is there a different idiomatic Kotlin+compose way to handle this situation? And how would you name the callback? First I had something like onNewState: (S) -> Unit
, but now it's more verbose: onNewStateTransform: S.() -> S
. Any better name suggestions?PHondogo
10/29/2022, 9:22 PMJan Skrasek
10/29/2022, 11:19 PMv79
10/30/2022, 8:38 AMmutableStateOf
in this way...
val totalCost by remember {
mutableStateOf(Field(mutableStateOf("1.01"), validator = CurrencyValidator))
}
Zun
10/30/2022, 1:29 PMtrailingIcon = {
if (enabled) {
Icon(icon, null, Modifier.clickable { // stuff })
} else {
null
}
}
this (with or without the else statement) for example doesn't workagrosner
10/30/2022, 1:55 PMLazyRow
- we want all our items to have the same visible height on screen. (i.e. the smallest visible item grow to fit the other tallest visible item). We cannot have a Row
as that requires measuring all items including offscreen items, and we may have more than 5-10 ui elements. We also dont want to measure offscreen items until they reach visible, then reset the height modifiers on only visible ones if the height is >
the previous value
We currently use an onGloballyPositioned
modifier like so:
onGloballyPositioned {
if (props.rowHeight is RowHeight.MaxHeight) {
minHeightOnMaxHeightChange(with(density) { it.size.height.toDp() })
}
}
we buffer the emission of each item so it only updates in smaller intervals if many are drawn on screen at once. It works in most cases and seems to be as performant as it can be.
we then use a CompositionLocal
to send the value to each item:
val minHeightOnMaxHeight = LocalMaxHeightValue.current
carouselIntervalContent.item.invoke(
this,
info.index,
Modifier.thenIf(props.rowHeight is RowHeight.MaxHeight) {
minHeightOnMaxHeight.takeIf { it > 0.0.dp }?.let {
heightIn(min = it)
} ?: rowHeightModifier
}
)
However, we discover that some kinds of content (depending on their internals) continuously grow until they reach a too large height and crash. Is there a better way to do this?dewildte
10/31/2022, 1:49 AMelye
10/31/2022, 6:47 AMcollectAsStateWithLifecycle
vs collectAsState
? Thanks.PHondogo
10/31/2022, 10:53 AMPHondogo
10/31/2022, 11:23 AMChristian Maier
10/31/2022, 1:30 PMCardDefaults.cardColor(containerColor = ...)
but the thing is: it cannot be the exact same color representation as my Surface color (which is already #FFFFFFFF). If I set either to #FFFFFFFE it's working fine, but I don't like it. Without further research I believe that matching colors (in tone, not just refs) lead to that elevation-overlaying behavior. Is there a way around I'm not aware of?dave08
10/31/2022, 3:14 PMMutableSharedFlow
as a sort of event bus down the composable hierarchy that uses a sealed class with all possible actions callable on the viewModel, and then sending that in the top level composable? Or is it better to just stick to passing up all those onClicks as lambdas...?Pedro Alberto
10/31/2022, 3:41 PMMarko Novakovic
10/31/2022, 4:34 PMText(
text = label,
textAligh = TextAlign.Center,
modifier = Modifier.width(labelWidth),
)
adding textAligh
gives me an error:
None of the following functions can be called with the arguments supplied.
Text(AnnotatedString, Modifier = ..., Color = ..., TextUnit = ..., FontStyle? = ..., FontWeight? = ..., FontFamily? = ..., TextUnit = ..., TextDecoration? = ..., TextAlign? = ..., TextUnit = ..., TextOverflow = ..., Boolean = ..., Int = ..., Map<String, InlineTextContent> = ..., (TextLayoutResult) → Unit = ..., TextStyle = ...) defined in androidx.compose.material3
Text(String, Modifier = ..., Color = ..., TextUnit = ..., FontStyle? = ..., FontWeight? = ..., FontFamily? = ..., TextUnit = ..., TextDecoration? = ..., TextAlign? = ..., TextUnit = ..., TextOverflow = ..., Boolean = ..., Int = ..., (TextLayoutResult) → Unit = ..., TextStyle = ...) defined in androidx.compose.material3
so how am supposed to show the text with textAlign
parameter?myanmarking
10/31/2022, 5:07 PMTolga ÇAĞLAYAN
10/31/2022, 6:05 PMdewildte
10/31/2022, 9:41 PMromainguy
10/31/2022, 9:43 PMChris Sinco [G]
10/31/2022, 10:07 PMKhan
10/31/2022, 10:35 PMchatterInDaSkull
11/01/2022, 12:07 AMTest instrumentation process crashed.
Running it on Compose version 1.3 and Low-resolution MDPI phone, Virtual, API Level 28
Has anyone come across this?
More details in thread🧵kenkyee
11/01/2022, 1:47 AMSushobh
11/01/2022, 2:27 AMmgrazianodecastro
11/01/2022, 3:17 AMPHondogo
11/01/2022, 8:30 AMPHondogo
11/01/2022, 8:30 AMFilip Wiesner
11/01/2022, 8:42 AMAttempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order:,Constraints.maxWidth
,Constraints.maxHeight
,Constraints.minWidth
ifConstraints.minHeight
ismatchHeightConstraintsFirst
(which is the default), orfalse
,Constraints.maxHeight
,Constraints.maxWidth
,Constraints.minHeight
ifConstraints.minWidth
ismatchHeightConstraintsFirst
.true