From 3f3261ebb173133655deeea8ba3f1d1d4ef4bdf9 Mon Sep 17 00:00:00 2001 From: tutejsy Date: Tue, 24 Sep 2024 19:15:43 +0300 Subject: [PATCH 1/3] fix: fix applying of tintColor and progressViewOffset of RefreshControl component on iOS when newArchitecure enabled --- .../ScrollView/RCTPullToRefreshViewComponentView.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 86f3f578a7aa7e..224ecbebdf76e7 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -49,6 +49,11 @@ - (void)_initializeUIRefreshControl [_refreshControl addTarget:self action:@selector(handleUIControlEventValueChanged) forControlEvents:UIControlEventValueChanged]; + + const auto &concreteProps = static_cast(*_props); + + [_refreshControl setTintColor: RCTUIColorFromSharedColor(concreteProps.tintColor)]; + [_refreshControl setBounds:CGRectMake(_refreshControl.bounds.origin.x, concreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height)]; } #pragma mark - RCTComponentViewProtocol @@ -78,6 +83,14 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & } } + if (newConcreteProps.tintColor != oldConcreteProps.tintColor) { + [_refreshControl setTintColor: RCTUIColorFromSharedColor(newConcreteProps.tintColor)]; + } + + if (newConcreteProps.progressViewOffset != oldConcreteProps.progressViewOffset) { + [_refreshControl setBounds:CGRectMake(_refreshControl.bounds.origin.x, newConcreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height)]; + } + BOOL needsUpdateTitle = NO; if (newConcreteProps.title != oldConcreteProps.title) { From 281d18048a39098a1bbd0cb096c57e85a03a8bc7 Mon Sep 17 00:00:00 2001 From: tutejsy Date: Tue, 24 Sep 2024 22:00:03 +0300 Subject: [PATCH 2/3] inverse progressViewOffset to follow logic on Android, refactor codestyle --- .../ScrollView/RCTPullToRefreshViewComponentView.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 224ecbebdf76e7..1136e15b40ed69 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -51,9 +51,9 @@ - (void)_initializeUIRefreshControl forControlEvents:UIControlEventValueChanged]; const auto &concreteProps = static_cast(*_props); - - [_refreshControl setTintColor: RCTUIColorFromSharedColor(concreteProps.tintColor)]; - [_refreshControl setBounds:CGRectMake(_refreshControl.bounds.origin.x, concreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height)]; + + _refreshControl.tintColor = RCTUIColorFromSharedColor(concreteProps.tintColor); + _refreshControl.bounds = CGRectMake(_refreshControl.bounds.origin.x, -concreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height); } #pragma mark - RCTComponentViewProtocol @@ -84,11 +84,11 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & } if (newConcreteProps.tintColor != oldConcreteProps.tintColor) { - [_refreshControl setTintColor: RCTUIColorFromSharedColor(newConcreteProps.tintColor)]; + _refreshControl.tintColor = RCTUIColorFromSharedColor(newConcreteProps.tintColor); } if (newConcreteProps.progressViewOffset != oldConcreteProps.progressViewOffset) { - [_refreshControl setBounds:CGRectMake(_refreshControl.bounds.origin.x, newConcreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height)]; + _refreshControl.bounds = CGRectMake(_refreshControl.bounds.origin.x, -newConcreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height); } BOOL needsUpdateTitle = NO; From 72b8eb9da2eae1a525b245fd153014177c115f5d Mon Sep 17 00:00:00 2001 From: tutejsy Date: Tue, 24 Sep 2024 22:14:52 +0300 Subject: [PATCH 3/3] refactor: move update of progressViewOffset to _updateProgressViewOffset method --- .../ScrollView/RCTPullToRefreshViewComponentView.mm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 1136e15b40ed69..0e7f22a36f44a9 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -53,7 +53,7 @@ - (void)_initializeUIRefreshControl const auto &concreteProps = static_cast(*_props); _refreshControl.tintColor = RCTUIColorFromSharedColor(concreteProps.tintColor); - _refreshControl.bounds = CGRectMake(_refreshControl.bounds.origin.x, -concreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height); + [self _updateProgressViewOffset: concreteProps.progressViewOffset]; } #pragma mark - RCTComponentViewProtocol @@ -88,7 +88,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & } if (newConcreteProps.progressViewOffset != oldConcreteProps.progressViewOffset) { - _refreshControl.bounds = CGRectMake(_refreshControl.bounds.origin.x, -newConcreteProps.progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height); + [self _updateProgressViewOffset: newConcreteProps.progressViewOffset]; } BOOL needsUpdateTitle = NO; @@ -115,6 +115,11 @@ - (void)handleUIControlEventValueChanged static_cast(*_eventEmitter).onRefresh({}); } +- (void)_updateProgressViewOffset:(Float)progressViewOffset +{ + _refreshControl.bounds = CGRectMake(_refreshControl.bounds.origin.x, -progressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height); +} + - (void)_updateTitle { const auto &concreteProps = static_cast(*_props);