Bluesky app fork with some witchin' additions 💫

Properly patch React Native to fix iOS `RefreshControl` bug (#5605)

authored by hailey.at and committed by

GitHub 9802ebe2 09caf327

+63 -17
+63 -17
patches/react-native+0.74.1.patch
··· 38 38 39 39 - (void)reactBlur 40 40 diff --git a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.h b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.h 41 - index e9b330f..1ecdf0a 100644 41 + index e9b330f..ec5f58c 100644 42 42 --- a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.h 43 43 +++ b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.h 44 - @@ -16,4 +16,6 @@ 44 + @@ -15,5 +15,8 @@ 45 + @property (nonatomic, copy) NSString *title; 45 46 @property (nonatomic, copy) RCTDirectEventBlock onRefresh; 46 47 @property (nonatomic, weak) UIScrollView *scrollView; 48 + +@property (nonatomic, copy) UIColor *customTintColor; 49 + + 50 + +- (void)forwarderBeginRefreshing; 47 51 48 - +- (void)forwarderBeginRefreshing; 49 - + 50 52 @end 51 53 diff --git a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.m b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.m 52 - index b09e653..f93cb46 100644 54 + index b09e653..288e60c 100644 53 55 --- a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.m 54 56 +++ b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControl.m 55 - @@ -198,9 +198,53 @@ - (void)refreshControlValueChanged 56 - [self setCurrentRefreshingState:super.refreshing]; 57 - _refreshingProgrammatically = NO; 57 + @@ -22,6 +22,7 @@ @implementation RCTRefreshControl { 58 + NSString *_title; 59 + UIColor *_titleColor; 60 + CGFloat _progressViewOffset; 61 + + UIColor *_customTintColor; 62 + } 58 63 59 - + if (@available(iOS 17.4, *)) { 60 - + if (_currentRefreshingState) { 61 - + UIImpactFeedbackGenerator *feedbackGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight]; 62 - + [feedbackGenerator prepare]; 63 - + [feedbackGenerator impactOccurred]; 64 - + } 65 - + } 64 + - (instancetype)init 65 + @@ -56,6 +57,12 @@ - (void)layoutSubviews 66 + _isInitialRender = false; 67 + } 68 + 69 + +- (void)didMoveToSuperview 70 + +{ 71 + + [super didMoveToSuperview]; 72 + + [self setTintColor:_customTintColor]; 73 + +} 66 74 + 67 - if (_onRefresh) { 68 - _onRefresh(nil); 75 + - (void)beginRefreshingProgrammatically 76 + { 77 + UInt64 beginRefreshingTimestamp = _currentRefreshingStateTimestamp; 78 + @@ -203,4 +210,58 @@ - (void)refreshControlValueChanged 69 79 } 70 80 } 71 81 82 + +- (void)setCustomTintColor:(UIColor *)customTintColor 83 + +{ 84 + + _customTintColor = customTintColor; 85 + + [self setTintColor:customTintColor]; 86 + +} 87 + + 88 + +// Fix for https://github.com/facebook/react-native/issues/43388 89 + +// A bug in iOS 17.4 causes the haptic to not play when refreshing if the tintColor 90 + +// is set before the refresh control gets added to the scrollview. We'll call this 91 + +// function whenever the superview changes. We'll also call it if the value of customTintColor 92 + +// changes. 93 + +- (void)setTintColor:(UIColor *)tintColor 94 + +{ 95 + + if ([self.superview isKindOfClass:[UIScrollView class]] && self.tintColor != tintColor) { 96 + + [super setTintColor:tintColor]; 97 + + } 98 + +} 99 + + 72 100 +/* 73 101 + This method is used by Bluesky's ExpoScrollForwarder. This allows other React Native 74 102 + libraries to perform a refresh of a scrollview and access the refresh control's onRefresh ··· 106 134 +} 107 135 + 108 136 @end 137 + diff --git a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControlManager.m b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControlManager.m 138 + index 40aaf9c..1c60164 100644 139 + --- a/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControlManager.m 140 + +++ b/node_modules/react-native/React/Views/RefreshControl/RCTRefreshControlManager.m 141 + @@ -22,11 +22,12 @@ - (UIView *)view 142 + 143 + RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock) 144 + RCT_EXPORT_VIEW_PROPERTY(refreshing, BOOL) 145 + -RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) 146 + RCT_EXPORT_VIEW_PROPERTY(title, NSString) 147 + RCT_EXPORT_VIEW_PROPERTY(titleColor, UIColor) 148 + RCT_EXPORT_VIEW_PROPERTY(progressViewOffset, CGFloat) 149 + 150 + +RCT_REMAP_VIEW_PROPERTY(tintColor, customTintColor, UIColor) 151 + + 152 + RCT_EXPORT_METHOD(setNativeRefreshing : (nonnull NSNumber *)viewTag toRefreshing : (BOOL)refreshing) 153 + { 154 + [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) { 109 155 diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java 110 156 index 5f5e1ab..aac00b6 100644 111 157 --- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java