Tolriq
05/24/2022, 2:36 PMTypography(defaultFontFamily = Rubik)
Equivalent for M3 ? Or are we supposed to copy paste all the internal token stuff and maintain them when they evolve ?Eko Prasetyo
05/24/2022, 2:48 PMCanvas
, and the second is LazyColumn
(which is scrollable). How to make my Canvas
height the same as my LazyColumn
full (scrollable) height? Or, should I make my Canvas
being item of my LazyColumn
?Daniel Okanin
05/24/2022, 2:48 PMLandry Norris
05/24/2022, 3:08 PMJhonatan Sabadi
05/24/2022, 9:18 PMLazyColumn
inside a NestedScrollView
, it works... But the list does not scroll. Is there a way to make it work?fengdai
05/25/2022, 6:27 AM@Stable
?
The interface is defined like this:
interface SomeState {
val propertyA: NonStableTypeA
val propertyB: NonStableTypeB
}
And in the implementation class, all public properties are backed by MutableState
:
internal class SomeStateImpl: SomeState {
override var propertyA: NonStableTypeA by mutableStateOf(...)
internal set
override var propertyB: NonStableTypeB by mutableStateOf(...)
internal set
}
Satyam G
05/25/2022, 12:48 PMjannis
05/25/2022, 2:47 PMColumn
with two items:
- The first item has a fixed aspect ratio of (e.g. 3:4) and should grow as big as it can until it occupies the full width.
- The second item has a minimum height (e.g. 128dp), but should grow if more space is available
I can solve either of these problems with specifying a weight, but not both:
- Setting a weight for the first item will not let the second item grow if more space is available
- Setting a weight for the second item will let the first item occupy too much space and the second item is not visible anymoreEko Prasetyo
05/25/2022, 2:56 PMDan Peluso
05/25/2022, 3:17 PMandroidx.compose.ui.test
library that I'm looking for advice on. Does performing a click action on a node using onNodeWithTag
actually pass that click to the children of that node? In my example, the node with tag is a composable that applies the fastClickable
modifier on a column (so the entire view is clickable) but the test does not actually click the component with the tag. In the past I've been able to get the click to work, but only by directly accessing the tag on a Button
composable. More code for context in the threadColton Idle
05/25/2022, 4:20 PMJorge Domínguez
05/25/2022, 4:44 PMwhen
statement here bad for performance considering recompositions?
@Composable
private fun ExampleDropdownMenu(
someEnum: SomeEnum,
expanded: Boolean,
items: List<String>,
onDismissRequest: () -> Unit,
) {
DropdownMenu(
expanded = expanded,
onDismissRequest = onDismissRequest
) {
items.forEach() { item ->
DropdownMenuItem(onClick = { ... }) {
Text(
text = when (someEnum) {
SomeEnum.A -> item.formatA()
SomeEnum.B -> item.formatB()
}
)
}
}
}
}
Ji Sungbin
05/25/2022, 5:43 PMcurrentComposer.recomposeScope
return null?
recomposeScope
comes from invalidateStack
, and I thought invalidateStack
would be empty when no referencing state inside. But it wasn’t.
currentRecomposeScope code:
internal val currentRecomposeScope: RecomposeScopeImpl?
get() = invalidateStack.let {
if (childrenComposing == 0 && it.isNotEmpty()) it.peek() else null
}
Test code:
@Composable
private fun Test() {
val recomposeScope = currentRecomposeScope
Box(modifier = Modifier.clickable { recomposeScope.invalidate(); println("Invalidate!") })
}
xxfast
05/26/2022, 1:09 AMfengdai
05/26/2022, 5:32 AMMyState
, which implements the RememberObserver
interface. I do cleanup stuff in onForgotten
and onAbandoned
.
I use remember
to remember the MyState
instance:
val state = remember { MyState() }
And I configure my activity to handle configuration changes automatically in this way in my AndroidManifest.xml:
android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
So the instance will be kept across configuration changes.
When I changed the activity’s orientation, state
was kept, just as I expected. What I didn’t expect is that the MyState
’s onForgotten
method was called. This behavior left my remembered MyState
instance in a wrong state.
Is it a bug?Alexander Maryanovsky
05/26/2022, 8:41 AMString
describing that object, based on its properties, and then I want to display it somewhere in the UI. How should I do that?
I’m thinking of two options:
1. Make the function inline and collectAsState
all the properties it uses.
2. Make the function return a Flow
and then stateIn().collectAsState()
where I want to use it.
What do you think is better? Maybe there are other, better options?Uli Bubenheimer
05/26/2022, 7:11 PM@Composable
fun ModifiedRow(
modifier: Modifier,
columnModifiers: StableImmutableList<Modifier>,
vararg columns: @Composable (Modifier) -> Unit
) = Row(modifier) {
val composableIter: Iterator<(Modifier) -> Unit> = columns.iterator()
columnModifiers.forEach(composableIter.next()::invoke)
}
The Rows are emitted inside a LazyColumn, so I'd like this to be better performing. I want to use this to align header column widths with data column widths.
What I would like to see is inlining all these composables so that they don't get their own recompose scopes, they're all simple lambdas emitting a single Composable each.
I could manually unroll the vararg, since I use this for exactly 15 columns right now, but I'm holding out for something more elegant. I'm guessing that some advanced Compose magic could pull this off (even though it may be overkill compared to the manual unroll approach).nuhkoca
05/26/2022, 10:17 PMwck
05/27/2022, 12:32 AMModifier
as a parameter, apparently fillMaxWidth
is ignored if passed like this.
@Composable
fun TextButton(
modifier: Modifier = Modifier.fillMaxWidth(),
Berkeli Alashov
05/27/2022, 4:35 AM@Composable operator fun invoke
with interfaces - default arguments doesn't work. Is this a bug? Example in threadAlexander Maryanovsky
05/27/2022, 6:20 AMraghunandan
05/27/2022, 9:32 AMmyanmarking
05/27/2022, 3:00 PMChris Fillmore
05/27/2022, 4:48 PMNorbi
05/27/2022, 8:23 PM...
internal class DragTargetInfo {
var isDragging: Boolean by mutableStateOf(false)
...
var draggableComposable by mutableStateOf<(@Composable () -> Unit)?>(null)
...
}
...
internal val LocalDragTargetInfo = compositionLocalOf { DragTargetInfo() }
...
Is this a good pattern for state management?Berkeli Alashov
05/27/2022, 9:40 PMArjan van Wieringen
05/28/2022, 6:06 AMState<T>
variables? So consumers of the library can use this in their composable scopes?
So the actual question is: Does it make sense to put State<T>
inside generic libraries? This creates a dependency on compose runtime, but this is my opinion nothing different than relying on RxJava. And to turn it into something like Flow we only need to use snapshotFlow
I believe.Alexander Maryanovsky
05/28/2022, 9:56 AMtransitionSpec
in AnimatedContent
. Before you ask why I would need that, the animation I’m doing is conditional - in one case I want slideInFromRight with slideOutToLeft, in another case I want slideInFromLeft with slideOutToRight, and in a third case I just want the content to be replaced with no animation. The transitionSpec is defined by a separate function, so in the third case I want it to return “no-animation”.
Is there a built-in function for that, or do I need to do something silly like a fadeIn/Out with 0 duration tween?Mjahangiry75
05/28/2022, 11:28 AMCircularProgressBar
value like this:Ali Khaleqi Yekta
05/28/2022, 6:20 PMAli Khaleqi Yekta
05/28/2022, 6:20 PMLandry Norris
05/29/2022, 12:16 AM