-
Notifications
You must be signed in to change notification settings - Fork 117
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
Compose placeholders #1095
base: trunk
Are you sure you want to change the base?
Compose placeholders #1095
Conversation
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.
@planarvoid Tested in the Day One app using a Samsung device and these latest changes work nicely! I made a couple minor code comments for your review. I'm not merging this PR since it looks like it may be waiting for Klym and Danilo as well, but on my end it looks good. 👍🏻
* @param type placeholder type | ||
* @param attributes other attributes passed to the view. For example a `src` for an image. | ||
*/ | ||
suspend override fun insertItem(type: String, vararg attributes: Pair<String, String>) { |
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.
suspend override fun insertItem(type: String, vararg attributes: Pair<String, String>) { | |
override suspend fun insertItem(type: String, vararg attributes: Pair<String, String>) { |
* @param shouldMergeItem this method should return true when the previous type is compatible and should be updated | ||
* @param updateItem function to update current parameters with new params | ||
*/ | ||
suspend override fun insertOrUpdateItem( |
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.
suspend override fun insertOrUpdateItem( | |
override suspend fun insertOrUpdateItem( |
* @param shouldUpdateItem This function should return true if the span can be updated, false if it should be removed | ||
* @param updateItem Function that updates the selected item | ||
*/ | ||
suspend override fun removeOrUpdate(uuid: String, shouldUpdateItem: (Attributes) -> Boolean, updateItem: (currentAttributes: Map<String, String>) -> Map<String, String>): Boolean { |
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.
suspend override fun removeOrUpdate(uuid: String, shouldUpdateItem: (Attributes) -> Boolean, updateItem: (currentAttributes: Map<String, String>) -> Map<String, String>): Boolean { | |
override suspend fun removeOrUpdate(uuid: String, shouldUpdateItem: (Attributes) -> Boolean, updateItem: (currentAttributes: Map<String, String>) -> Map<String, String>): Boolean { |
Fix
In this PR I'm implementing a parallel solution that allows you to draw placeholders in Jetpack Compose instead of Android Views. This is actually more reliable, especially when considering redrawing which was hard to do with AV.
I created the compose placeholder manager from the previous manager and cleaned up things that I think are not necessary with compose. It should be much more straightforward because the compose view should be redrawn when the state changes without any forced redrawns.
This PR is much smaller than it seems because
ViewPlaceholderManager
is just a rename ofPlaceholderManager
so it doesn't need to be reviewed.Test
Test this feature with the related DO PR.
Review
@danilo04
Make sure strings will be translated:
strings.xml
as a part of the integration PR.