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

Compose placeholders #1095

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open

Compose placeholders #1095

wants to merge 6 commits into from

Conversation

planarvoid
Copy link
Contributor

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 of PlaceholderManager 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:

  • If there are new strings that have to be translated, I have added them to the client's strings.xml as a part of the integration PR.

@planarvoid planarvoid self-assigned this Dec 10, 2024
Copy link
Contributor

@AmandaRiu AmandaRiu left a 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>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Non-canonical modifier order

Suggested change
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(
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Non-canonical modifier order

Suggested change
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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Non-canonical modifier order

Suggested change
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 {

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

Successfully merging this pull request may close these issues.

2 participants