CRamsan
02/01/2022, 4:26 AMLazyColumn
and rows of different heights? I have an app where I use LazyColumn
in multiple places for items with different heights and they all work fine except for one screen. In this one screen, trying to scroll UP resets the position and moves the content further down, eventually the user is stuck at the bottom of the list. I have been narrowing down the problem and it seems to repro only when the content has cells of different heights. I tried looking for a bug report bug I could not find anything. I am in the process of trying to narrow down the issue so I can have a demo of it that I can share. But in the meantime I wanted to know if anyone has seen something like this.K Merle
02/01/2022, 7:12 AMLazyColumn
. Only thing I could think of is using remember
, but I'd still would have to use remember
inside LazyColumn
.Kyant
02/01/2022, 8:32 AMZoltan Demant
02/01/2022, 11:27 AMNapa Ram
02/01/2022, 12:33 PMsindrenm
02/01/2022, 2:30 PMweight(1f)
on a RangeSlider
. Am I doing something funny, or is this a bug with the component?
@Preview
@Composable
fun RangeSliderTest() {
var values by remember { mutableStateOf(0f..1f) }
Row(
modifier = Modifier.background(Color.White).fillMaxWidth().padding(16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
Text("0")
RangeSlider(
modifier = Modifier.weight(1f),
values = values,
valueRange = 0f..1f,
onValueChange = { values = it },
)
Text("1")
}
}
Stylianos Gakis
02/01/2022, 4:23 PMColton Idle
02/01/2022, 7:34 PMval focusRequester = FocusRequester()
DisposableEffect(Unit) {
focusRequester.requestFocus()
onDispose { }
}
OutlinedTextField(label = {Text("TODO")}, modifier = Modifier.focusRequester(focusRequester),
Or do I not need a sideEffect?Adam Powell
02/01/2022, 8:43 PMbrabo-hi
02/01/2022, 9:30 PMAlertDialog
on material3
, confirmButton and dismissButton don’t show when getting a scrollable list. But it works on material2
Simon Stahl
02/02/2022, 12:24 AMjulian
02/02/2022, 3:24 AMtestTag
.Colton Idle
02/02/2022, 5:59 AM...
LaunchedEffect(userMessage) {
snackbarHostState.showSnackbar(userMessage.message)
// Once the message is displayed and dismissed, notify the ViewModel.
viewModel.userMessageShown(userMessage.id)
}
...
Is showSnackbar a synchrnous call? i.e. userMessageShown() will be called ONLY after showSnackbar is done/dismissed?Napa Ram
02/02/2022, 6:18 AMRavi
02/02/2022, 12:30 PM1.6.10
, Compose 1.1.0-rc03
and accompanist 0.22.1-rc
, but I got the exception below, plz let me know how to fix it.Arpit Shukla
02/02/2022, 1:36 PMIn some apps, you might have seen ViewModel events being exposed to the UI using Kotlin Channels or other reactive streams. These solutions usually require workarounds such as event wrappers in order to guarantee that events are not lost and that they're consumed only once.
I too (sometimes) use a Channel
to send events from ViewModel to UI as a Flow
which I collect in LaunchedEffect
but I never had to use any
workarounds such as event wrappers in order to guarantee that events are not lost and that they're consumed only onceIt is automatically taken care of while using channels. What exactly did the author mean here?
mattinger
02/02/2022, 2:59 PMperformTextInput
I can no longer match any other elements on the tree. If i use a style from MaterialTheme like body2 it’s fine, but anything else, I get this error:
offset(6) should be less than line limit(0)
java.lang.IndexOutOfBoundsException: offset(6) should be less than line limit(0)
at android.text.TextLine.measure(TextLine.java:353)
at android.text.Layout.getHorizontal(Layout.java:1213)
at android.text.Layout.getHorizontal(Layout.java:1190)
at android.text.Layout.getPrimaryHorizontal(Layout.java:1160)
Code is in threadJunaid
02/02/2022, 3:37 PMkelvinharron
02/02/2022, 3:49 PM<androidx.compose.ui.platform.ComposeView
works, and points to something like:
binding.payButtonLayout.composeButton.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnDetachedFromWindow)
setContent {
MaterialTheme {
Button(onClick = {}) {
Text("My button")
}
}
}
}
I’ve tried using the tools:composableName="androidx.compose.material.ButtonKt"
, <androidx.compose.ui.tooling.ComposeViewAdapter
and even making my own view by inheriting from AbstractComposeView
but still no preview.
Would I be correct in saying that this just isn’t possible to do? Thanks in advance!Stephen Vinouze
02/02/2022, 3:55 PMLandingViewModel
exposing a LandingViewState
data class LandingViewState(
val firstPlayerName: String = "",
val secondPlayerName: String = "",
val canPlay: Boolean = false,
)
I would like the last attribute to be derived from name arguments while only exposing the viewState
– you can see that as a reducer. I haven't been able to find a better pattern than this
@HiltViewModel
class LandingViewModel @Inject constructor() : ViewModel() {
val viewState: LandingViewState by derivedStateOf {
LandingViewState(
firstPlayerName, secondPlayerName, firstPlayerName.isNotEmpty() && secondPlayerName.isNotEmpty()
)
}
var firstPlayerName: String by mutableStateOf("")
var secondPlayerName: String by mutableStateOf("")
}
So I've made the viewState
as a derived state and exposed the other attributes. Ideally, I'd only expose the viewState
as a state and transform the canPlay
on the fly as I'd have done with a reducer. But I can't figure out how to do it with compose mutableStateOf
Lukasz Kalnik
02/02/2022, 4:49 PMMaterialTheme
a separate typography
for a TextButton
? Currently there is only typography.button
. But in our design the regular Button
uses a different text color than a TextButton
.Joseph Hawkes-Cates
02/02/2022, 4:57 PMmyanmarking
02/02/2022, 5:43 PMallan.conda
02/02/2022, 6:32 PMBackend Internal error: Exception during IR lowering
Caused by: java.lang.IllegalStateException: couldn't find inline method Landroidx/compose/runtime/EffectsKt;.rememberCoroutineScope$default
How can I go about fixing this issue? I can’t find a solution from searching here.Matti MK
02/02/2022, 8:46 PMStateFlow
from Compose, the issue is that the state always “restarts” from initial state when switching between screens on bottom nav. This is an issue when the VM has something different than the initial state, as for some reason the Compose local state always restarts from intial state, before getting the updated state from the VM.
On the VM side my flow looks as follows:
public val viewState: StateFlow<ScreenState> = _internalState.stateIn(
clientScope,
SharingStarted.WhileSubscribed(),
ScreenState(showLoading = true)
)
And on my Compose screen collection looks like so:
fun Screen(
viewModel: ViewModel = getViewModel(),
) {
val lifecycleOwner = LocalLifecycleOwner.current
val viewStateFlow = remember(viewModel.viewState, lifecycleOwner) {
viewModel.viewState.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
}
val viewState by viewStateFlow.collectAsState(ViewModel.ScreenState(showLoading = true))
Logger.i { "VM state ${viewModel.viewState.value}" } // 1
Logger.i { " Screen local state is ${viewState}" } // 2
james
02/02/2022, 9:02 PMnavigateUp()
.. at this point the LaunchedEffect block is triggered again. am I misunderstanding it?
code in thread ➡️Bryan Herbst
02/02/2022, 9:45 PMButton:invisible
, which I strongly suspect is the core reason this isn’t working. Digging into TalkBack source, this should only happen when AccessibilityNodeInfo.isVisibleToUser
is false.
• I set some breakpoints in AndroidComposeViewAccessibilityDelegateCompat
, and as best as I can tell the node info has isVisibleToUser
correctly set to true, and I do see the correct role showing up here for the buttons
What are some things that could cause this? I’ve tried replacing my design systems’ buttons with Material buttons, I’ve tried moving the composables out of Fragments and into the Activity, I’ve tried removing all other content in case something else on the screen was confusing TalkBack, all with no success.
I’d love to file a bug, but since I can’t reproduce it outside my application I don’t have much more to provide.Alex C
02/03/2022, 2:08 AMAnand Verma
02/03/2022, 5:03 AMsteelahhh
02/03/2022, 8:48 AMLaunchedEffect
for all of them vs one LaunchedEffect
per flow
See 🧵 for examplesteelahhh
02/03/2022, 8:48 AMLaunchedEffect
for all of them vs one LaunchedEffect
per flow
See 🧵 for exampleLaunchedEffect(Unit) {
someflow
.onEach { /* ... */ }
.launchIn(this)
someflow1
.onEach { /* ... */ }
.launchIn(this)
someflow2
.onEach { /* ... */ }
.launchIn(this)
}
// OR
LaunchedEffect(Unit) {
someflow
.onEach { /* ... */ }
.launchIn(this)
}
LaunchedEffect(Unit) {
someflow1
.onEach { /* ... */ }
.launchIn(this)
}
LaunchedEffect(Unit) {
someflow2
.onEach { /* ... */ }
.launchIn(this)
}
Big Chungus
02/03/2022, 8:54 AMsteelahhh
02/03/2022, 8:56 AMZoltan Demant
02/03/2022, 9:12 AMlaunch{}
inside the LaunchedEffect to collect multiple flows though, but I dont know how that differs from just using multiple LaunchedEffects!myanmarking
02/03/2022, 9:18 AMZoltan Demant
02/03/2022, 9:30 AMlaunch { flow.collect }
👍🏽myanmarking
02/03/2022, 9:30 AMStylianos Gakis
02/03/2022, 12:27 PMlaunchedIn
mentioned here, I feel the obligation to link this https://www.billjings.com/posts/title/avoid-launchin/?up=technical . I really liked it as an idea and I think that it has helped me make some of my code nicer. I still use it myself too, but a tiny bit less.Arjun Achatz
02/03/2022, 1:33 PMmyanmarking
02/03/2022, 2:18 PMStylianos Gakis
02/03/2022, 2:24 PMAdam Powell
02/03/2022, 2:55 PM