-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Modifier.flex. #1699
Conversation
redwood-layout-compose/src/commonMain/kotlin/app/cash/redwood/layout/compose/LayoutScopes.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.
How independent are the flex modifiers in HTML? Ie. if I set flex basis does it ignore the value I set for Grow and Shrink?
If they’re fully independent then I don’t like it if flex(1.0)
also sets grow and shrink, because we can also set those modifiers afterwards flex(1.0).grow(0.0)
and the precedence gets really ugly.
If they’re all coupled then maybe we should have one Modifier object with 3 attributes, and offer accelerator APIs to set each of 'em independently? Like we do with margins?
…layout/compose/LayoutScopes.kt Co-authored-by: Jake Wharton <[email protected]>
@swankjesse Yep, data class Flex(
val grow: Double = Unset, // Create an unset constant to avoid replacing previous values.
val shrink: Double = Unset,
val basis: Double = Unset,
)
fun Flex(flex: Double): Flex // Set all 3
Modifier.flex(Flex(1.0)) // Set all 3
Modifier.flex(Flex(grow = 1.0)) // Sets all 3 Also, I've been thinking maybe this property would make more sense named something like Unfortunately, declaring extensions directly on |
Last wins is a pretty common precedence rule. It will be even more obvious once we switch to the trait nomenclature, hopefully. In CSS I've certainly done things like |
Adds support for a new
flex
property toRow
andColumn
. This follows the CSS spec for theflex
property. It's a combination property that setsflex-grow
,flex-shrink
, andflex-basis
all at once. Notably, it's useful for creating equivalently sized nodes along the main axis of a row/column.