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

Add fabric support for maintainVisibleContentPosition #32

Merged
merged 4 commits into from
Oct 19, 2022

Conversation

janicduplessis
Copy link

Summary

Changelog

[CATEGORY] [TYPE] - Message

Test Plan

@janicduplessis janicduplessis changed the base branch from 0.69-stable to Expensify-0.70.4 October 13, 2022 03:42
@janicduplessis janicduplessis marked this pull request as ready for review October 13, 2022 03:42
@pull-bot
Copy link

pull-bot commented Oct 13, 2022

Fails
🚫

❗ Base Branch - The base branch for this PR is something other than main or a -stable branch. Are you sure you want to target something other than the main branch?

🚫

📋 Verify Changelog Format - A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • iOS
  • Android
  • JavaScript
  • Internal (for changes that do not need to be called out in the release notes)

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

Generated by 🚫 dangerJS against 5b54bb5

@roryabraham
Copy link

roryabraham commented Oct 13, 2022

This is testing well with just the ScrollView on iOS, not testing well with FlatList on iOS:

RPReplay_Final1665685380.MP4

I wonder if I broke the VirtualizedList {first, last} fix by not porting it over to 0.70.1 properly, or if there's another issue that we haven't seen yet.

BOOL horizontal = _scrollView.contentSize.width > self.frame.size.width;
int minIdx = props.maintainVisibleContentPosition.value().minIndexForVisible;
for (NSUInteger ii = minIdx; ii < _contentView.subviews.count; ++ii) {
// Find the first entirely visible view. This must be done after we update the content offset

Choose a reason for hiding this comment

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

Conceptually, shouldn't this be finding the first entirely visible view before we update the content offset?

Copy link
Author

Choose a reason for hiding this comment

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

This comment was in the original scrollview implementation so I'm not sure what it means. I removed most of it as I think it is confusing.

@@ -12,10 +12,33 @@ public interface UIManagerListener {
/**
* Called right before view updates are dispatched at the end of a batch. This is useful if a
* module needs to add UIBlocks to the queue before it is flushed.
*
* This is called by Paper only.

Choose a reason for hiding this comment

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

NAB for me, but I wonder if when you go to upstream they'll want you to create separate subclasses of UIManagerListener for Paper v.s. Fabric

Choose a reason for hiding this comment

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

Or rather sub-interface ... I'm out of practice with Java but I'm pretty sure interfaces can extend other interfaces? So you'd end up having BaseUIManagerListener and PaperUIManagerListener and FabricUIManagerListener

Copy link
Author

Choose a reason for hiding this comment

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

I think it is the same interface because this is used in an interface that abstracts UIManager and FabricUIManager. See https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java#L110. I also agree that it is probably better as separate interfaces, but might be better to leave as is for now.

@roryabraham
Copy link

Confirmed that the ScrollView example is working as expected on both iOS and Android. Interestingly, the FlatList example works fine with inverted=true, but not with inverted=false. Same on iOS and Android

@janicduplessis
Copy link
Author

Ok it should work now. The problem was because of the loading view that the example has, it should use minIndex of 2 to avoid using that view to maintain visible content position as it will be removed. I think it works in the old arch because react doesn't batch state updates.

Copy link

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

okay, looks good and tests well on iOS and Android, Fabric and Paper. Great work!

@roryabraham roryabraham merged commit cfe7aab into Expensify:Expensify-0.70.4 Oct 19, 2022
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.

3 participants