adjpd
09/22/2021, 10:42 PMModifier.scrollable
and Modifier.horizontalScroll
clip their children differently. Is this a bug? Code in 🧵.adjpd
09/22/2021, 11:25 PMNathan Castlehow
09/23/2021, 4:11 AMTolriq
09/23/2021, 7:52 AMval state by viewModel.state.collectAsState()
Then all the child of that component are recomposed if any child use any property of the state. What would be a proper way to collect a large state but only update sub component on some part of the state.
For example the state contains a media item and a progress state. when only the progress change I only want to recompose the progress bar and not all components that display the media information.Christoffer Niska
09/23/2021, 8:34 AMNapa Ram
09/23/2021, 9:08 AMtheapache64
09/23/2021, 9:45 AM@Stable
and @StableMarker
? 🤔🧵Napa Ram
09/23/2021, 11:44 AMVsevolod Kaganovych
09/23/2021, 2:15 PMval viewmodel: ViewModel = hiltViewModel()
How do I pass a parameter from arguments to constructor?Diego Rodriguez
09/23/2021, 3:00 PMAndroidView
to compose it. Now I need to access that view when the user presses a button to get its state. To simplify, I have an EditText and I need its content when the user presses 'Next'.
How Can I access the state of that view? I know I could build it from scratch using compose, but I have a lot of custom views and plan to migrate them progressively.Zoltan Demant
09/23/2021, 3:24 PMColumn
contains two composables with varying height, how can I make sure the bottom one is always visible, despite the top one sometimes using Modifier.fillMaxHeight
?nglauber
09/23/2021, 3:56 PMLazyColumn
with multiple `item`/`ìtems`. When I navigate to a “detail” screen, and then go back, the scroll position is lost.
Is this the right bug to follow? https://issuetracker.google.com/issues/179397301Napa Ram
09/23/2021, 4:35 PMAhmed Sellami
09/23/2021, 4:48 PMTash
09/23/2021, 6:41 PMMutableState
fields might not be scalable for a system with a lot of tokens. Thinking about possible approaches, esp ones that minimize recompositions as much as possible, such as maintaining a Map<Token, MutableState<Color>>
etc…Would love some suggestions on this 🙏🏼Marko Novakovic
09/23/2021, 8:13 PMFontWeight
and FontSize
?Akram Bensalem
09/23/2021, 8:58 PMAppCompatDelegate.setDefaultNightMode(true)
Because when I use that it's blank and I loose the state of some variables.
But when using just Theme:
val autColors = if (isSystemInDarkTheme()) DarkColorPalette else LightColorPalette
It works great like I want just with one issue is when navigate from screen to another a white flash apears !!!
this happen just with Dark mode.
So anyone here was able to solve this issue ?Eric Boggs
09/23/2021, 9:59 PMtheapache64
09/24/2021, 3:58 AMrajesh
09/24/2021, 4:26 AMK Merle
09/24/2021, 5:30 AMfocusRequester.requestFocus()
does not open the keyboard. Adding a 300ms delay does solve the issue it seems. Anyone faces the same issue and were you able to solve it better? I'd like to avoid delay.
LaunchedEffect(Unit) {
delay(300)
focusRequester.requestFocus()
}
Erlan Amanatov
09/24/2021, 6:00 AMshrinkVertically()
ExitTransition in AnimatedVisibility
?iamthevoid
09/24/2021, 7:23 AMathos
09/24/2021, 10:18 AMpainterResource()
in a composable where the id for the resource is provided as an argument for the composable and ultimately got from a view model's StateFlow
property. The id can be one of several dozen, and it always fails on the same one but only if it comes after another specific one, otherwise everything is fine, maybe I am misusing the API somehow? More details in the thread.myanmarking
09/24/2021, 10:56 AMval error: Color
@Composable get() = if(isSystemInDarkTheme()) error else error2
Zoltan Demant
09/24/2021, 11:36 AMAkram Bensalem
09/24/2021, 11:43 AMescodro
09/24/2021, 12:09 PMAlertDialog
with Jetpack Compose Navigation as a destination?
When using dialog()
, if i add a AlertDialog
in the Composable, the user have to double click outside to dismiss both. And if I don’t use the AlertDialog
then I will have to implement the title, text and buttons to have the same look and feel.
Do you have any suggestions?
Thanks a lot! ❤️Mini
09/24/2021, 12:27 PMclass SomeClass{
val list : SnapshotStateList<Int> = mutableStateListOf(5)
}
val someClass = SomeClass()
snapshotFlow { someClass.list }.onEach { println(it.toString()) }.collectIn(scope)
the onEach block is not executed despite mutating the list
I must instead explicitly do snapshotFlow { someClass.list.toList() }
I am kind of confused why this is the case, and I feel like this must be a pitfall Im likely to run into again. Is this the intended behaviour? Could someone explain why?julioromano
09/24/2021, 1:15 PMjulioromano
09/24/2021, 1:15 PM@Composable
fun SomethingNice(
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier.size(24.dp),
) {
// Something more...
}
}
It is working.
But I was afraid the “default” 24dp modifier would be called after the one passed in via parameter therefore always overriding it. Turns out this is not true. But can’t understand why.Zoltan Demant
09/24/2021, 1:28 PMModifier.defaultMinSize()
Adam Powell
09/24/2021, 1:59 PMmin = max = myRequestedSize.coerceIn(parentSuppliedMin, parentSuppliedMax)
requiredSize
modifiers override parent constraintsjulioromano
09/24/2021, 2:04 PMSomethingNice()
It gets drawn at 24dp as expected.
And if I draw this:
SomethingNice(modifier = Modifier.size(64.dp))
It gets drawn at 64dp. But it is strange to me as in the code it will happen something like:
@Composable
fun SomethingNice() {
Box(
modifier = Modifier.size(64.dp).size(24.dp),
) {
// Something more...
}
}
Shouldn’t the second call to .size(24.dp)
override the first call to .size(64.dp)
?Adam Powell
09/24/2021, 2:28 PM24.coerceIn(64, 64) = 64
size(64.dp)
so it's coerced into the constraints of the upstream parentjulioromano
09/24/2021, 2:31 PMModifier.size(12.dp)
)
In this case we’d have:
24.coerceIn(12, 12) = ?
SomethingNice
it is displayed with 12dp sizemodifier = modifier.size(24.dp)
with modifier = Modifier.size(24.dp).then(modifier)
Solve any issues with sizing I had 🤷Scott Kruse
09/24/2021, 3:52 PMjulioromano
09/24/2021, 3:53 PMAdam Powell
09/24/2021, 6:51 PMmin
and max
size; how big are you?" Modifier.size
narrows those min and max constraints to be as close to the requested value as possible, within the constraints of how it was measured by its immediate parent (whether that parent is another layout modifier or a layout composable)@Composable fun DefaultSizeBox(
modifier: Modifier = Modifier,
content: @Composable BoxScope.() -> Unit
) = Box(modifier.size(24.dp), content = content)
and then call it like this:
DefaultSizeBox(Modifier.size(64.dp)) {
Text("Hello, world")
}
then the final modifier for the Box
created by DefaultSizeBox
is Modifier.size(64.dp).size(24.dp)
.
Measurement then proceeds; let's say the parent of the DefaultSizeBox
measures it with the constraints (min = 0, max = 500)
(simplified to only one dimension here for the sake of this discussion; both width and height each have a min and max).size(64.dp)
. 64 is between 0 and 500, so now the measurement proceeds, but with (min = 64, max = 64)
.size(24.dp)
. 24 is not between 64 and 64; in order to be within that range the constraints are "changed" to (min = 64, max = 64)
. The final box is measured with those constraints, and reports that it is size 64. The "outer" modifier passed to the DefaultSizeBox
call thereby overrode the requested default defined in `DefaultSizeBox`'s implementation.julioromano
09/27/2021, 9:23 AMRafiul Islam
09/28/2021, 11:49 AM.size(24.dp)
. 24 is not between 64 and 64; in order to be within that range the constraints are "changed" to (min = 64, max = 64)
But what happened in this case? 24.coerceIn(12, 12) = ?julioromano
09/28/2021, 11:53 AM= 12
Rafiul Islam
09/28/2021, 11:56 AM