Mehdi Haghgoo
05/18/2022, 7:29 AMSlackbot
05/18/2022, 8:03 AMAlexander Maryanovsky
05/18/2022, 8:15 AMMichał Diner
05/18/2022, 9:09 AMFatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f08024a
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
at android.content.res.Resources.getValue(Resources.java:1316)
at androidx.compose.ui.res.PainterResources_androidKt.painterResource(PainterResources_androidKt.java:61)
at x.x.x.presentation.x.ComposableSingletons$xKt$lambda-1$1.invoke(x.kt:66)
at x.x.x.presentation.x.ComposableSingletons$xKt$lambda-1$1.invoke(x.kt:40)
It’s a simple usage of Image with painterResource
.
Any ideas? 😬Slackbot
05/18/2022, 12:58 PMBrian Norman
05/18/2022, 1:03 PMModifier.clip()
like:
val preferBottomContentShape = GenericShape { size, _ ->
moveTo(0f, size.height - desiredHeightPx)
lineTo(size.width, size.height - desiredHeightPx)
lineTo(size.width, size.height)
lineTo(0f, size.height)
}
But the issue there is that there is left over whitespace from the background where the top of that image used to beAfzal Najam
05/18/2022, 5:41 PMcalculateWindowSizeClass
equivalent for non-activities? We’re using a fair bit of AbstractComposeViews
, leveraging interop capabilities and so activity instance isn’t available without casting the Context
👀
Is this not enough? Or does rememberWidthSizeClass provide something else that this doesn’t?
@Composable
fun getWidthSizeClass(): WidthSizeClass {
val configuration = LocalConfiguration.current
val windowDpSize = configuration.screenWidthDp.dp
return when {
windowDpSize < 600.dp -> WidthSizeClass.COMPACT
windowDpSize < 840.dp -> WidthSizeClass.MEDIUM
else -> WidthSizeClass.EXPANDED
}
}
allan.conda
05/18/2022, 6:09 PMHorizontalPager
immediately composes adjacent pages other than the current page?
I don’t want my LaunchedEffect
to run if the page is not visible yet, or is it expected that I check for pagerState.currentPage
?Fanilog
05/18/2022, 6:44 PM//TOP level composable of the app
with(LocalLifecycleOwner.current) {
lifecycleScope.launch {
navigationManager.navigationEvents
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
.collect { navigationDirection ->
//Listening to navigation event
navController.navigate()...
}
}
Or should I do it in LaunchEffect ? Since Compose function can execute in any order, I wanted to avoid to have it a LaunchEffect and use a replay parameter of a Flow. (eg: Sending a event before the collection,)Manojna Chintapalli
05/18/2022, 7:28 PMSterling Albury
05/18/2022, 7:52 PMRow(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
leftHandContent(
Modifier
.wrapContentWidth()
)
Text(
modifier = Modifier
.wrapContentWidth()
.align(CenterVertically)
.weight(1F, fill = true),
text = appBarTitle,
color = topBarPrimaryColor,
fontWeight = FontWeight.Bold,
fontSize = 22.sp,
textAlign = TextAlign.Center
)
rightHandContent(
Modifier
.wrapContentWidth()
)
}
I would like the Text to be in the center of the bar but also be constrained by the left and right hand content. If one of the content items is missing, then I'd still like the text to be centered in the row. Considering a couple of options here. I briefly tried using a Box and using the align modifiers for the content items, but the text wasn't getting constrained like i wanted and got some overlap with the contents. trying to not use the constraint layout. Was looking at a custom layout and using some vertical baselines but not very familiar with using those objects. Any thoughts?brabo-hi
05/18/2022, 9:03 PMText()
fengdai
05/19/2022, 5:10 AMallan.conda
05/19/2022, 6:59 AMRene Win
05/19/2022, 9:01 AM@Composable
fun Home(navController: NavController) {
Column(
modifier = Modifier.testTag("hometag")
) {
Text("home1")
Text("home2")
Button(onClick = {
navController.navigate("detail",
)
}) {
Text("NEXT")
}
}
}
@Composable
fun Detail(navController: NavController) {
Column(
modifier = Modifier
.testTag("detailTag")
) {
Text("detail1")
Text("detail2")
Text("detail3")
}
}
Is there something I can do against that behaviour? Thanks in advance!Fanilog
05/19/2022, 9:30 AMval lifecycleOwner = LocalLifecycleOwner.current
LaunchedEffect(key1 = lifecycleOwner) {
launch {
and
val lifecycleOwner = LocalLifecycleOwner.current
remember(key1 = lifecycleOwner) {
with(lifecycleOwner) {
lifecycleScope.launch {
?dimsuz
05/19/2022, 12:53 PMFunkyMuse
05/19/2022, 1:24 PMcontext (Composable)
Rajat Singh Jasrotia
05/19/2022, 3:12 PMHamza GATTAL
05/19/2022, 3:17 PMmcpiroman
05/19/2022, 3:37 PMfixed
, so it should be inferred as stable. Can I somehow make it became stable?Francescos
05/19/2022, 4:50 PMNavBackStackEntry.savedStateHandle
is a complete different object from the SavedStateHandle
object injected from Hilt in the corresponding route ViewModel
?mattinger
05/19/2022, 4:57 PMonNode
type functions. As a side note, it works in an espresso test, just not robolectric.Chris Fillmore
05/19/2022, 6:33 PMcentroid
https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.i[…]olean,kotlin.Function4)
Are the centroid coordinates relative to the display? The window? Something else?will also provide centroid of all the pointers that are down.onGesture
Landry Norris
05/19/2022, 9:25 PMZoltan Demant
05/20/2022, 4:22 AMFatal Exception: java.lang.IllegalArgumentException: end cannot negative. [end: -1]
since one of the recent compose (alpha/beta) releases?Eko Prasetyo
05/20/2022, 4:28 AMzt
05/20/2022, 4:31 AMJan Skrasek
05/20/2022, 7:02 AMcontent
and having it as the last one, or
• make that slot rather named by its function and sort slots differently?
The second option seems more suitable, but only if there is another non slot argument as the last one, otherwise it would expose the last slot as trailing lambda, which is not good. What do you think?Stylianos Gakis
05/20/2022, 7:03 AMviewModel.uiState.userMessages
inside the LaunchedEffect, but with no mechanism to ensure that this only happens when the app is in the foreground. Wouldn’t this mean that if I were to press home on my device, and right as I do that a message appears, this would trigger normally, and I would miss that message.
On the contrary, in the View version, we’re using the repeatOnLifecycle
API to make this work correctly.
Maybe this has to do something with the fact that we’re using a State<T>
object inside the VM in that sample instead of a [State]Flow
and there’s some interaction I don’t understand, but I still think this would happen in the background even with that approach.
p.s. I really wish the docs followed the more “common” pattern of having a StateFlow inside the VM instead. Or at least show how you’d have to approach this problem with both State
and StateFlow
in the VM.Stylianos Gakis
05/20/2022, 7:03 AMviewModel.uiState.userMessages
inside the LaunchedEffect, but with no mechanism to ensure that this only happens when the app is in the foreground. Wouldn’t this mean that if I were to press home on my device, and right as I do that a message appears, this would trigger normally, and I would miss that message.
On the contrary, in the View version, we’re using the repeatOnLifecycle
API to make this work correctly.
Maybe this has to do something with the fact that we’re using a State<T>
object inside the VM in that sample instead of a [State]Flow
and there’s some interaction I don’t understand, but I still think this would happen in the background even with that approach.
p.s. I really wish the docs followed the more “common” pattern of having a StateFlow inside the VM instead. Or at least show how you’d have to approach this problem with both State
and StateFlow
in the VM..collectAsState()
extension on StateFlow
. There’s very few cases where I’d purposefully allow the state to be collected in the background (they exist, but by default I want the rememberStateWithLifecycle
approach).Colton Idle
05/25/2022, 1:54 PMManuel Vivo
05/30/2022, 8:49 AMStylianos Gakis
05/30/2022, 9:20 AMManuel Vivo
05/30/2022, 10:19 AMStylianos Gakis
05/30/2022, 10:24 AMColton Idle
06/02/2022, 9:13 AMStylianos Gakis
06/02/2022, 9:41 AMcollectAsState
vs collectAsStateWithLifecycle
problem, since that one is not out yet I guess they are not going to be talking about it yet.
In fact, in the last snippet, the compose and View alternatives are not functionally equivalent since one reads the state in the background as well while the View alternative uses repeatOnLifecycle as one should.
I hope that once the collectAsStateWithLifecycle
hits alpha/beta this article will be updated and all future ones will take it into consideration.
A good article nonetheless, I read it before and it was a nice read.