SrSouza
05/03/2022, 8:40 PMxxfast
05/04/2022, 2:18 AMmodifier = modifier
.let { if(canBeExpanded) it.clickable { expanded = !expanded } else it }
saket
05/04/2022, 3:19 AMcascade
and would like people to try out its beta: https://github.com/saket/cascade/releases/tag/2.0.0-beta1Jason Ankers
05/04/2022, 7:29 AMrememberSaveable
inside movableContentOf
:
Calling recomposeScope.invalidate()
inside movableContentOf
changes the currentCompositeKeyHash
which breaks rememberSaveable
Daniele Segato
05/04/2022, 9:25 AMLazyRow
and stickyHeader
.
1. If the header is vertically higher than the content the LazyRow
change height when the sticky header item would scroll out of view.
2. if the LazyRow
has contentPadding
this is ignored for the stickyHeader
, I would expect the sticky header to snap in a position that respect content paddding.
are these 2 issues know? should I open 2 but reports?
I assume these 2 issues translates equally with LazyColumn
nitrog42
05/04/2022, 12:51 PMdata class Container(val name: String, val items: List<Item>)
data class Item(val id: Int)
I know how to create a Saver for each (an object, or a list), but I’m not sure how to handle object that contains a listWilliam Reed
05/04/2022, 1:30 PMjasu
05/04/2022, 1:41 PMText()
composable?nitrog42
05/04/2022, 1:57 PMSavedStateHandle.saveable
API, is there an equivalent to
val argArticleId = savedStateHandle.getStateFlow(ArticleArgKey, -1)
that return a State ?
I tried with .saveable(ArticleArgKey)
but it seems the return value is a Bundle instead of a Long... (in my case)Rafael Costa
05/04/2022, 7:05 PMremember
saved state is lost after screen is turned off and on. 🧵Colton Idle
05/04/2022, 8:27 PMZoltan Demant
05/05/2022, 4:33 AMWishnuprathikantam
05/05/2022, 10:41 AMLazyPagingItems<Episodes>
How to use group by with LazyPagingItems? I want to implement a sticky header list here so i would need to convert this to Map<String,List<Episodes>> here. One way i can think of is using the itemSnapshot list, but not sure if it's a good practice. Any help is appreciated. Thanks.Big Chungus
05/05/2022, 11:18 AMSatyam G
05/05/2022, 11:57 AMLandry Norris
05/05/2022, 3:26 PMMatthew Laser
05/05/2022, 3:28 PMandroidx.startup
package in association with compose?Roberto Leinardi
05/05/2022, 4:43 PM@RunWith(AndroidJUnit4::class)
class MainActivityTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun appStartsWithoutCrashing() {
composeTestRule.apply {
// Check Switch
onNodeWithTag(FirstScreen.CONSENT_SWITCH)
.assertIsDisplayed()
.assertIsOff()
.performClick()
.assertIsOn()
// Click accept button
onNodeWithTag(FirstScreen.ACCEPT_BUTTON)
.assertIsDisplayed()
.performClick()
// Thread.sleep(500)
// Check we are inside the second screen
onNodeWithTag(SecondScreen.USERNAME_TEXT_FIELD)
.assertIsDisplayed()
}
}
}
I'm sure that is a timing issue because if I add a Thread.sleep(500)
before the onNodeWithTag(SecondScreen.USERNAME_TEXT_FIELD).assertIsDisplayed()
, the test is successful. But I would like to avoid `Thread.sleep()`s in my code.
Is there a better way to tell the composeTestRule
to wait for the NavHost to load the new content before executing proceeding with the next assertion?
PS
I know that would be better to test the Composables in isolation, but I really need to simulate the user input on the App using Espresso and not only test the Composable behavior.dazza5000
05/05/2022, 7:54 PMmutableStateOf
or a StateFlow
/ LiveData
property from a ViewModel?Slackbot
05/06/2022, 12:24 AMLiangjun Sha
05/06/2022, 2:58 AMLazyColumn
, there is a ConstraintLayout
in the top of it and other items list below the ConstraintLayout
. It works well until I changed the compose version from 1.1.1
to 1.2.0-alpha08
, and now it crashed every single time when I scroll the LazyColumn
.gpaligot
05/06/2022, 8:29 AMtext
property we can call inside the semantics
callback. What is the difference between text
and contentDescription
and why we should use an AnnotatedString
as value? 🤔
Thanks in advance!ste
05/06/2022, 9:43 AMVaios Tsitsonis
05/06/2022, 10:17 AMrsktash
05/06/2022, 10:29 AMMichael Paus
05/06/2022, 11:49 AM2 files found with path 'META-INF/kotlinx_coroutines_core.version'.
Adding a packagingOptions block may help, please refer to
<https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html>
for more information
Besides the fact that the given link is wrong I am wondering what I shall do to get that working again. kotlinx_coroutines_core is used in a thousand places. How can I find the conflicting ones?andrew
05/06/2022, 2:00 PMmattinger
05/06/2022, 4:03 PMvar startBluetoothFlow by remember { mutableStateOf(false) }
LaunchedEffect(key1 = true) {
if (!host.bleManager.isReadyForScanning) {
startBluetoothFlow = true
}
}
if (startBluetoothFlow) {
BluetoothController(
permissionState = permissionState,
bluetooth = host.bleManager,
navHostController = navController,
)
}
The problem is that BluetoothController is getting evaluated multiple timesspierce7
05/06/2022, 4:44 PMImage
, without knowing it’s size, how could I center something on top of the image? I want the the Image
size to dictate the size of the parent Box
. How could I do this in compose?Jorge Domínguez
05/06/2022, 5:08 PMprivate val viewModelState = MutableStateFlow(HomeViewModelState(isLoading = true))
val uiState = viewModelState
.map { it.toUiState() }
.stateIn(
viewModelScope,
SharingStarted.Eagerly,
viewModelState.value.toUiState()
)
My question is, what's the advantage of using stateIn()
here? I would normally do something like:
private val _viewModelState = MutableStateFlow(HomeViewModelState(isLoading = true))
val viewModelState get() = _viewModelState
But looking into the stateIn()
docs there's a mention to increased performance for multiple observers since the upstream flow is instantiataed only once, but what if the flow is collected from a single composable? is there really an advantage there?
I was thinking that each recomposition can be considered as a new observer, in which case I can see how the use of stateIn()
helps, but I'd like to fully understand the implications of its usage and how it's better, so if anyone can shed some light I'd be grateful.Jorge Domínguez
05/06/2022, 5:08 PMprivate val viewModelState = MutableStateFlow(HomeViewModelState(isLoading = true))
val uiState = viewModelState
.map { it.toUiState() }
.stateIn(
viewModelScope,
SharingStarted.Eagerly,
viewModelState.value.toUiState()
)
My question is, what's the advantage of using stateIn()
here? I would normally do something like:
private val _viewModelState = MutableStateFlow(HomeViewModelState(isLoading = true))
val viewModelState get() = _viewModelState
But looking into the stateIn()
docs there's a mention to increased performance for multiple observers since the upstream flow is instantiataed only once, but what if the flow is collected from a single composable? is there really an advantage there?
I was thinking that each recomposition can be considered as a new observer, in which case I can see how the use of stateIn()
helps, but I'd like to fully understand the implications of its usage and how it's better, so if anyone can shed some light I'd be grateful.Adam Powell
05/06/2022, 6:15 PMUiState
, it's something that gets mapped to one, and if you don't have a StateFlow
then you don't have an initial value available, you have to subscribe and wait for it to emit, and in the case of consuming from compose that means you get a frame of empty data before the first item is known.private var viewModelState by mutableStateOf(HomeViewModelState(isLoading = true))
val uiState: UiState
get() = viewModelState.toUiState()
to leverage snapshots instead and skip all of the subscription complexity, since the upstream source of truth is a MutableStateFlow
anyway - a hot data source that doesn't care about subscription awareness in the first place.Jorge Domínguez
05/06/2022, 6:36 PMcollectAsState()
?Adam Powell
05/06/2022, 7:43 PM.collectAsState
is an observer for as long as it remains in composition with the same receiver flow instanceFlow.collect
persists undisturbed across recompositions for as long as the call to .collectAsState
is present in the composition for the same Flow
instanceJorge Domínguez
05/06/2022, 7:51 PM