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

Move away from using WithConstraints #30

Merged
merged 7 commits into from
Jun 23, 2020
Merged

Move away from using WithConstraints #30

merged 7 commits into from
Jun 23, 2020

Conversation

chrisbanes
Copy link
Contributor

@chrisbanes chrisbanes commented Jun 17, 2020

WithConstraints is not suitable for how we're using it, so we're moving to Modifier.onSizeChanged() (which is based on Modifier.onPositioned). This required some changes to how CoilImage is implemented. While here, I also migrated us to the new launchInComposition() to launch our Coil request.


onCommit(result) {
// Execute the onRequestCompleted callback if we have a new result
result?.also { onRequestCompleted(it) }
Copy link

Choose a reason for hiding this comment

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

Consider running this in the same block as the result = it in the CoilRequestActor callback instead of returning to composition with an onCommit; store the received callback in a MutableState in case it changes and call it from the state value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I'm liking where this has landed 👍. Thanks for the help!

coil/src/main/java/dev/chrisbanes/accompanist/coil/Coil.kt Outdated Show resolved Hide resolved
val requestWidth = constraints.requestWidth.value
val requestHeight = constraints.requestHeight.value
var result by state<RequestResult?> { null }
val callback = mutableStateOf(onRequestCompleted)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this a state? this value is never changed and onRequestCompleted is defined as a param

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 was something @adamp mentioned in #30 (comment)

coil/src/main/java/dev/chrisbanes/accompanist/coil/Coil.kt Outdated Show resolved Hide resolved
Chris Banes added 6 commits June 22, 2020 18:03
WithConstraints is not suitable for how we're using
it, so we're moving to Modifier.onSizeChanged(). This
required some changes to how CoilImage is implemented.

While here we now use the new launchInComposition()
function.
Due to using the wrong key parameter to the outer `remember`. Also
fixed the state which holds the current callback.
@chrisbanes chrisbanes merged commit fd40e9c into main Jun 23, 2020
@chrisbanes chrisbanes deleted the cb/subcomp branch June 23, 2020 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants