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 iOS support for progressViewOffset on RefreshControl #30117

Closed

Conversation

Taylor123
Copy link
Contributor

Summary

fix #10718

Add progressViewOffset support to RefreshControl in iOS for better feature parity with Android.

Changelog

[iOS] [Fix] - Add progressViewOffset support to RefreshControl in iOS for better feature parity with Android.

Test Plan

Tested locally

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2020
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Oct 7, 2020
@pull-bot
Copy link

pull-bot commented Oct 7, 2020

Messages
📖

📋 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 448decc

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: fd9787e

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,385,801 0
android hermes armeabi-v7a 7,013,117 0
android hermes x86 7,828,013 0
android hermes x86_64 7,717,499 0
android jsc arm64-v8a 9,532,102 0
android jsc armeabi-v7a 9,147,130 0
android jsc x86 9,396,778 0
android jsc x86_64 9,978,488 0

Base commit: fd9787e

@@ -160,6 +163,11 @@ - (void)setCurrentRefreshingState:(BOOL)refreshing
_currentRefreshingStateTimestamp = _currentRefreshingStateClock++;
}

- (void)setProgressViewOffset:(float)offset
{
_progressViewOffset = offset / UIScreen.mainScreen.scale;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed? Isn't offset already in points?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the scaling, the offset using CGRectOffset didn't match up with the android progressViewOffset

@sammy-SC
Copy link
Contributor

Hello @Taylor123,

thank you for the PR.

Could you post a screenshot where we can see the effect of progressViewOffset property? Is layoutSubviews called when progressViewOffset is updated? If not, could we use transformation to translate the view?

Do you think we should add the use of progressViewOffset to RNTester, it currently isn't there.

Also the documentation will need to be updated here: https://github.com/facebook/react-native-website/blob/master/docs/refreshcontrol.md

@kelset kelset added the Needs: Docs Website PR To encourage the authors to create a website PR for documentation. label Oct 12, 2020
@Taylor123
Copy link
Contributor Author

Could you post a screenshot where we can see the effect of progressViewOffset property? Is layoutSubviews called when progressViewOffset is updated? If not, could we use transformation to translate the view?

layoutSubviews is not called when progressViewOffset is updated. It's called on mount and on scroll events.

I don't have much time to dedicate to this at the moment (maybe I will in the near future). I tried quickly reimplementing with transform, but can't get the transform to work. Not sure if there is some quirk with the UIControl in the scrollview or what.

Tried this as well as updating the transform in layoutSubviews to no effect.

- (void)setProgressViewOffset:(float)offset
{
	self.transform = CGAffineTransformMakeTranslation(0, offset);
}

If i can find the time to figure out why the transform isn't working, then i'll post a screenshot with an updated PR.

@davidbiedenbach
Copy link
Contributor

@Taylor123 Are you still working on this? Are you open to me taking up the mantle?

I've tried self.transform as well, and of course in this case the offset needs to be negated, but there seems to be some other view that ends up occluding or clipping the RefreshControl. I've had much more luck with adapting your original solution - I extracted the bit that sets the offset frame into a helper function, and I've identified a few places where it needs to be called (mostly because the parent class's methods occasionally re-calculate the frame).

I'm happy to either provide a patch, or open up a new PR, but I'm using it now in a production app and it was just validated by our QA.

cc @sammy-SC

@Taylor123
Copy link
Contributor Author

@davidbiedenbach feel free to contribute however is easiest to you! My requirements changed, so I no longer needed the fix for this. Glad you were able to get a better fix. If you open up a new PR, just tag me here so i can close this one

@davidbiedenbach
Copy link
Contributor

@Taylor123 @sammy-SC New PR is here: #30737

Thanks!

@github-actions
Copy link

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 11, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Needs: Docs Website PR To encourage the authors to create a website PR for documentation. Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offsetting RefreshControl on iOS via progressViewOffset
8 participants