Make CrossAxisAlignment modifier available for items within LazyList#1288
Open
Make CrossAxisAlignment modifier available for items within LazyList#1288
CrossAxisAlignment modifier available for items within LazyList#1288Conversation
veyndan
commented
Jun 28, 2023
| (widget.value.parent as? FrameLayout)?.removeAllViews() | ||
| widget.value.layoutParams = layoutParams | ||
| holder.container.addView(widget.value) | ||
| widget.value.applyModifier(widget.modifier) |
Contributor
Author
There was a problem hiding this comment.
This needs to be re-applied if the modifier changes. I tried listening to changes in Items#onModifierUpdated, but it was never called on change.
76b3d70 to
ef8332c
Compare
swankjesse
reviewed
Jun 28, 2023
| public interface LazyListScope { | ||
| public fun item( | ||
| content: @Composable () -> Unit, | ||
| content: @Composable LazyItemScope.() -> Unit, |
swankjesse
reviewed
Jun 28, 2023
| import app.cash.redwood.layout.api.CrossAxisAlignment | ||
| import app.cash.redwood.layout.modifier.Alignment | ||
|
|
||
| internal class AlignmentImpl( |
Contributor
Author
There was a problem hiding this comment.
It's copied generated code from redwood-layout-compose. Ultimately I want to share modifier definitions with redwood-layout, so this is somewhat of a stop gap in the meantime.
swankjesse
approved these changes
Jun 28, 2023
ef8332c to
9bdec48
Compare
veyndan
commented
Jun 30, 2023
Comment on lines
+26
to
+27
| public fun Modifier.alignment(alignment: CrossAxisAlignment): Modifier = | ||
| then(AlignmentImpl(alignment)) |
Contributor
Author
There was a problem hiding this comment.
@colinrtwhite Do you have any ideas on how to convert this to horizontalAlignment/verticalAlignment without introducing a new scope? LazyItemScope is used for more than just scoping modifiers (see LazyListIntervalContent), so I'm a bit hesitant to just have two separate scopes for LazyRow and LazyColumn.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1265
This only works for Android Views.