Skip to content
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

Make CrossAxisAlignment modifier available for items within LazyList #1288

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Jun 28, 2023

Closes #1265

This only works for Android Views.

(widget.value.parent as? FrameLayout)?.removeAllViews()
widget.value.layoutParams = layoutParams
holder.container.addView(widget.value)
widget.value.applyModifier(widget.modifier)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a bug! FYI @JakeWharton

@@ -25,25 +25,25 @@ import app.cash.redwood.ui.Margin
@LayoutScopeMarker
public interface LazyListScope {
public fun item(
content: @Composable () -> Unit,
content: @Composable LazyItemScope.() -> Unit,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

import app.cash.redwood.layout.api.CrossAxisAlignment
import app.cash.redwood.layout.modifier.Alignment

internal class AlignmentImpl(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a data class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +26 to +27
public fun Modifier.alignment(alignment: CrossAxisAlignment): Modifier =
then(AlignmentImpl(alignment))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make CrossAxisAlignment modifier available for items within LazyList
2 participants