From a204f09385c18b3bf7b60feac4f2177f6905f379 Mon Sep 17 00:00:00 2001 From: Kanzaki Mirai Date: Fri, 6 Nov 2015 15:51:05 -0400 Subject: [PATCH 01/12] Fixed the RCTConvert UIColor failure convertion issue --- RCTRefreshControl.ios.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RCTRefreshControl.ios.js b/RCTRefreshControl.ios.js index efd98be..7582659 100644 --- a/RCTRefreshControl.ios.js +++ b/RCTRefreshControl.ios.js @@ -9,7 +9,8 @@ var { DeviceEventEmitter, NativeModules: { RefreshControl, - } + }, + processColor } = React; /** @@ -30,8 +31,8 @@ var RCTRefreshControl = { configure: function(configs, callback) { var nodeHandle = React.findNodeHandle(configs.node); var options = { - tintColor: configs.tintColor, - activityIndicatorViewColor: configs.activityIndicatorViewColor + tintColor: processColor(configs.tintColor), + activityIndicatorViewColor: processColor(configs.activityIndicatorViewColor) }; RefreshControl.configure(nodeHandle, options, (error) => { @@ -46,4 +47,4 @@ var RCTRefreshControl = { } }; -module.exports = RCTRefreshControl; +module.exports = RCTRefreshControl; \ No newline at end of file From 52235f7e3330f1baa1f9298b3188397c46165c5f Mon Sep 17 00:00:00 2001 From: Kanzaki Mirai Date: Fri, 6 Nov 2015 17:43:14 -0400 Subject: [PATCH 02/12] Added a user friendly wrapper --- .DS_Store | Bin 0 -> 6148 bytes RCTRefreshControl.android.js | 17 ---- ...reshControl.ios.js => RCTRefreshControl.js | 0 index.ios.js | 73 ++++++++++++++++++ package.json | 10 +-- 5 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .DS_Store delete mode 100644 RCTRefreshControl.android.js rename RCTRefreshControl.ios.js => RCTRefreshControl.js (100%) create mode 100644 index.ios.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e79916ee4a9e63165e5955153eabfccddcf2da3 GIT binary patch literal 6148 zcmeHKOHRW;41F$L6tU?NiOuZTA@v4P8!kXO03s<=s3B2563bkROR(S$+=J)wP_+td zDuhsFOZJ;M_9XL0iN^qByeUV(5Ws+{*gK{9M)baFM|#QACrX@Sh6gM$!wU0Gv^)MI z1G;w?xWNRsw7dH^L5*juxt}!_xWWqxj!MQf(f71?98HV5YHV4rABWFW)p=fS)&=l> z|8^PYJMf*Vy8NY?n)%M^M86LgXTTY729AaS)@+r*nW0-}z!`7`whZY1Ay5^wgsoxx zb+PL5;3TQm?dlt>7j_F5-n9yiy@Xye@Jmz!q(8zA*uP0^khjL%GXIv zLJWswhHjk!XJDU!6T2L0{lEUX|KCsYD`&tNI4TCDpHK5Kmy~L2XK`9<1NDxoqH(R^ kHid&&iW#e=_?#Mr{-6V5masLXhvEl;NP`<^;7=L&1nZzl@&Et; literal 0 HcmV?d00001 diff --git a/RCTRefreshControl.android.js b/RCTRefreshControl.android.js deleted file mode 100644 index 6c4716a..0000000 --- a/RCTRefreshControl.android.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Stub of RCTRefreshControl for Android. - * - * @providesModule RCTRefreshControl - * @flow - */ -'use strict'; - -var warning = require('warning'); - -var RCTRefreshControl = { - test: function() { - warning("Not yet implemented for Android."); - } -}; - -module.exports = RCTRefreshControl; diff --git a/RCTRefreshControl.ios.js b/RCTRefreshControl.js similarity index 100% rename from RCTRefreshControl.ios.js rename to RCTRefreshControl.js diff --git a/index.ios.js b/index.ios.js new file mode 100644 index 0000000..74ff239 --- /dev/null +++ b/index.ios.js @@ -0,0 +1,73 @@ +'use strict'; + +import React from 'react-native'; +const { + Component, + StyleSheet, + Text, + View, + ScrollView, + ListView +} = React; + +import RCTRefreshControl from './RCTRefreshControl'; + +let randId = () => (Math.random() + 1).toString(36).substring(7); + +const ELEMENT_ID = randId(); + +var style = StyleSheet.create({ + rootView: { + flex: 1 + } +}); + +let RCTRefreshControlView = {}; + +class RCTRefreshControlScrollView extends Component { + componentDidMount() { + RCTRefreshControl.configure({ + node: this.refs[ELEMENT_ID], + tintColor: this.props.tintColor, + activityIndicatorViewColor: this.props.activityIndicatorViewColor + }, () => { + if (this.props.onRefresh) { + this.props.onRefresh(() => { + RCTRefreshControl.endRefreshing(this.refs[ELEMENT_ID]); + }); + } + }); + } + render() { + return ( + + {this.props.children} + + ); + } +} + +class RCTRefreshControlViewListView extends Component { + componentDidMount() { + RCTRefreshControl.configure({ + node: this.refs[ELEMENT_ID], + tintColor: this.props.tintColor, + activityIndicatorViewColor: this.props.activityIndicatorViewColor + }, () => { + if (this.props.onRefresh) { + this.props.onRefresh(() => { + RCTRefreshControl.endRefreshing(this.refs[ELEMENT_ID]); + }); + } + }); + } + render() { + return ( + + ); + } +} +RCTRefreshControl.ScrollView = RCTRefreshControlScrollView; +RCTRefreshControl.ListView = RCTRefreshControlViewListView; + +module.exports = RCTRefreshControl; \ No newline at end of file diff --git a/package.json b/package.json index ef4fb83..6f131da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-refresh-control", "description": "A pull down to refresh control for react native.", - "version": "2.0.5", + "version": "2.0.6", "keywords": [ "react-component", "react-native", @@ -10,16 +10,16 @@ "control" ], "license": "MIT", - "main": "RCTRefreshControl.ios.js", + "main": "index.ios.js", "repository": { "type": "git", - "url": "git@github.com:Shuangzuan/RCTRefreshControl.git" + "url": "git@github.com:DickyT/RCTRefreshControl.git" }, "author": "Shuangzuan", "maintainers": [ { - "name": "Shuangzuan", - "email": "shuangzuan.he@icloud.com" + "name": "DickyT", + "email": "me@idickyt.com" } ] } From 19e06ee1877b36004c70c7056680b3d635caffe0 Mon Sep 17 00:00:00 2001 From: DickyT | Diqi Zeng Date: Fri, 6 Nov 2015 18:06:42 -0400 Subject: [PATCH 03/12] Update README.md --- README.md | 139 ++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 279c66b..07f4e63 100644 --- a/README.md +++ b/README.md @@ -1,104 +1,97 @@ # RCTRefreshControl +A pull down to refresh control for react native. This project use a native-bridging way to implement the Pull-To-Refresh, absolutely **NO** jetter and lagging compared with those package which implemented using Javascript. -A pull down to refresh control for react native. +This is a **forked** project from [Shuangzuan/RCTRefreshControl](https://github.com/Shuangzuan/RCTRefreshControl). +This project added a more user-friendly way to use this package, and I also fix some bugs of the original project. -## Screen Shot - -![Screen Shot](screen-shot.gif) +![react-refreshcontrol](https://cloud.githubusercontent.com/assets/4535844/11009604/9845be08-84ae-11e5-8fe0-1037c057ce05.gif) ## Installation -1. Run `npm install react-refresh-control --save` in your project directory. +1. Run `npm install DickyT/RCTRefreshControl --save` in your project directory. 2. Drag `RCTRefreshControl.xcodeproj` to your project on Xcode. 3. Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag `libRCTRefreshControl.a` from the Products folder inside the `RCTRefreshControl.xcodeproj`. 4. Add `var RCTRefreshControl = require('react-refresh-control');` to your code. +__I am not going to add a sperate package into npm unless I get the authorization of [Shuangzuan](https://github.com/Shuangzuan)__ + ## Usage +It is very easy to use, just use `RCTRefreshControl.ListView` as the `React.ListView` +or use `RCTRefreshControl.ScrollView` as the `React.ScrollView` + +The simple difference between the `ListView` and `ScrollView` in React Native is that you can pass your `onRefresh` event handler into `RCTRefreshControl.ListView` and `RCTRefreshControl.ScrollView`. + +The event handler below stop the refreshing state of the `ListView` in 2 seconds once the user pull down the `ListView` and triggered the refresh. + +```jsx +var onRefreshHandler = (stopRefreshAnimation) => { + setTimeout(stopRefreshAnimation, 2000); +}; +``` -```javascript +And use like this +```jsx + +``` + +## Sample Code + +**Using fewer lines to implement a Pull-To-Refresh** + +```jsx 'use strict'; -var React = require('react-native'); -var TimerMixin = require('react-timer-mixin'); -var RCTRefreshControl = require('react-refresh-control'); -var { - AppRegistry, - ListView, - ScrollView, - StyleSheet, - Text, - View +import React from 'react-native'; +const { + View, + ListView } = React; -var SCROLLVIEW = 'ScrollView'; -var LISTVIEW = 'ListView'; +import RCTRefreshControl from 'react-refresh-control'; + +class MyApp extends React.Component { + constructor(props) { + super(props); -var RCTRefreshControlDemo = React.createClass({ - mixins: [TimerMixin], - getInitialState: function() { - var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); - return { - dataSource: ds.cloneWithRows(['#484848', '#2F9C0A', '#05A5D1']), + var dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); + this.state = { + dataSource: dataSource.cloneWithRows(['#484848', '#2F9C0A', '#05A5D1']) }; - }, - componentDidMount: function() { - // ScrollView - RCTRefreshControl.configure({ - node: this.refs[SCROLLVIEW], - tintColor: '#05A5D1', - activityIndicatorViewColor: '#05A5D1' - }, () => { - this.setTimeout(() => { - RCTRefreshControl.endRefreshing(this.refs[SCROLLVIEW]); - }, 2000); - }); - - // ListView - RCTRefreshControl.configure({ - node: this.refs[LISTVIEW] - }, () => { - this.setTimeout(() => { - RCTRefreshControl.endRefreshing(this.refs[LISTVIEW]); - }, 2000); - }); - }, - render: function() { + } + onRefresh(stopRefresh) { + console.log(this.state); + setTimeout(stopRefresh, 2000); + } + renderRow(data) { + return ( + + ); + } + render() { return ( - - + + + - - - { - var color = rowData; - return ( - - ); - }} - /> + ); } -}); +} -var styles = StyleSheet.create({ - container: { - flex: 1, - flexDirection: 'row' - } -}); - -AppRegistry.registerComponent('RCTRefreshControlDemo', () => RCTRefreshControlDemo); +React.AppRegistry.registerComponent('RCTRefreshControlDemo', () => RCTRefreshControlDemo); ``` ---- - ## License Available under the MIT license. See the LICENSE file for more informatiion. From 0017d52a10922cb3c05ea3087d2e2641434ea13e Mon Sep 17 00:00:00 2001 From: Kanzaki Mirai Date: Fri, 6 Nov 2015 18:09:32 -0400 Subject: [PATCH 04/12] delete system file --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1e79916ee4a9e63165e5955153eabfccddcf2da3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOHRW;41F$L6tU?NiOuZTA@v4P8!kXO03s<=s3B2563bkROR(S$+=J)wP_+td zDuhsFOZJ;M_9XL0iN^qByeUV(5Ws+{*gK{9M)baFM|#QACrX@Sh6gM$!wU0Gv^)MI z1G;w?xWNRsw7dH^L5*juxt}!_xWWqxj!MQf(f71?98HV5YHV4rABWFW)p=fS)&=l> z|8^PYJMf*Vy8NY?n)%M^M86LgXTTY729AaS)@+r*nW0-}z!`7`whZY1Ay5^wgsoxx zb+PL5;3TQm?dlt>7j_F5-n9yiy@Xye@Jmz!q(8zA*uP0^khjL%GXIv zLJWswhHjk!XJDU!6T2L0{lEUX|KCsYD`&tNI4TCDpHK5Kmy~L2XK`9<1NDxoqH(R^ kHid&&iW#e=_?#Mr{-6V5masLXhvEl;NP`<^;7=L&1nZzl@&Et; From 98542caf4de06838d88d4d9c32c9058ac0c45448 Mon Sep 17 00:00:00 2001 From: DickyT | Diqi Zeng Date: Fri, 6 Nov 2015 22:24:56 -0400 Subject: [PATCH 05/12] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 07f4e63..3740936 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ This project added a more user-friendly way to use this package, and I also fix ## Installation -1. Run `npm install DickyT/RCTRefreshControl --save` in your project directory. +1. Run `npm install react-native-refresh-control --save` in your project directory. 2. Drag `RCTRefreshControl.xcodeproj` to your project on Xcode. 3. Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag `libRCTRefreshControl.a` from the Products folder inside the `RCTRefreshControl.xcodeproj`. -4. Add `var RCTRefreshControl = require('react-refresh-control');` to your code. +4. Add `var RCTRefreshControl = require('react-native-refresh-control');` to your code. -__I am not going to add a sperate package into npm unless I get the authorization of [Shuangzuan](https://github.com/Shuangzuan)__ +__I will yield the package name once [Shuangzuan](https://github.com/Shuangzuan)requests __. ## Usage It is very easy to use, just use `RCTRefreshControl.ListView` as the `React.ListView` From 174b9a84122fbcff9671e091e1bc479ebc0a0cee Mon Sep 17 00:00:00 2001 From: DickyT | Diqi Zeng Date: Sat, 7 Nov 2015 06:00:30 -0400 Subject: [PATCH 06/12] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3740936..75a78a4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # RCTRefreshControl +[![npm version](https://badge.fury.io/js/react-native-refresh-control.svg)](https://badge.fury.io/js/react-native-refresh-control) + A pull down to refresh control for react native. This project use a native-bridging way to implement the Pull-To-Refresh, absolutely **NO** jetter and lagging compared with those package which implemented using Javascript. This is a **forked** project from [Shuangzuan/RCTRefreshControl](https://github.com/Shuangzuan/RCTRefreshControl). From 707617abc9cfa9fa05a03d1f4964feac64eda3b9 Mon Sep 17 00:00:00 2001 From: DickyT | Diqi Zeng Date: Mon, 9 Nov 2015 15:54:38 -0400 Subject: [PATCH 07/12] Typo corrected --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75a78a4..23d69bb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RCTRefreshControl [![npm version](https://badge.fury.io/js/react-native-refresh-control.svg)](https://badge.fury.io/js/react-native-refresh-control) -A pull down to refresh control for react native. This project use a native-bridging way to implement the Pull-To-Refresh, absolutely **NO** jetter and lagging compared with those package which implemented using Javascript. +A pull down to refresh control for react native. This project use a native-bridging way to implement the Pull-To-Refresh, absolutely **NO** jitter and lagging compared with those package which implemented using Javascript. This is a **forked** project from [Shuangzuan/RCTRefreshControl](https://github.com/Shuangzuan/RCTRefreshControl). This project added a more user-friendly way to use this package, and I also fix some bugs of the original project. From 17e00f24a182993358ae12cb2b8ebe3aa8243e5b Mon Sep 17 00:00:00 2001 From: rocman Date: Fri, 8 Jan 2016 13:14:22 +0800 Subject: [PATCH 08/12] makes it compatible with the lastest React Native --- RCTRefreshControl.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RCTRefreshControl.m b/RCTRefreshControl.m index a03a3ba..09b5250 100644 --- a/RCTRefreshControl.m +++ b/RCTRefreshControl.m @@ -5,7 +5,6 @@ #import "RCTBridge.h" #import "RCTConvert.h" #import "RCTScrollView.h" -#import "RCTSparseArray.h" #import "RCTUIManager.h" #import "RCTEventDispatcher.h" @@ -24,7 +23,7 @@ - (dispatch_queue_t)methodQueue { RCT_EXPORT_METHOD(configure:(nonnull NSNumber *)reactTag options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback) { - [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { + [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { UIView *view = viewRegistry[reactTag]; if (!view) { @@ -51,7 +50,7 @@ - (dispatch_queue_t)methodQueue { } RCT_EXPORT_METHOD(beginRefreshing:(nonnull NSNumber *)reactTag) { - [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { + [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { UIView *view = viewRegistry[reactTag]; if (!view) { @@ -70,7 +69,7 @@ - (dispatch_queue_t)methodQueue { } RCT_EXPORT_METHOD(endRefreshing:(nonnull NSNumber *)reactTag) { - [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { + [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { UIView *view = viewRegistry[reactTag]; if (!view) { From 2d7013a029d6aea2a1d5f7017b7b42608c752aeb Mon Sep 17 00:00:00 2001 From: Ian MacLeod Date: Thu, 14 Jan 2016 17:29:02 -0800 Subject: [PATCH 09/12] Expose scrollTo on the ScrollView wrapper --- index.ios.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.ios.js b/index.ios.js index 74ff239..944e105 100644 --- a/index.ios.js +++ b/index.ios.js @@ -45,6 +45,10 @@ class RCTRefreshControlScrollView extends Component { ); } + + scrollTo(...args) { + this.refs[ELEMENT_ID].scrollTo(...args); + } } class RCTRefreshControlViewListView extends Component { @@ -70,4 +74,4 @@ class RCTRefreshControlViewListView extends Component { RCTRefreshControl.ScrollView = RCTRefreshControlScrollView; RCTRefreshControl.ListView = RCTRefreshControlViewListView; -module.exports = RCTRefreshControl; \ No newline at end of file +module.exports = RCTRefreshControl; From 10257be813c728f0300543cabfda6cf9c161e109 Mon Sep 17 00:00:00 2001 From: Ian MacLeod Date: Thu, 14 Jan 2016 17:40:57 -0800 Subject: [PATCH 10/12] Fix package name (for git installs) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f131da..95558fa 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-refresh-control", + "name": "react-native-refresh-control", "description": "A pull down to refresh control for react native.", "version": "2.0.6", "keywords": [ From 96bf682c56ca358ee38b02116a1f35dfe23d961d Mon Sep 17 00:00:00 2001 From: rocman Date: Tue, 26 Jan 2016 11:29:09 +0800 Subject: [PATCH 11/12] .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a105709 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.xcuserstate +project.xcworkspace +xcuserdata +UserInterfaceState.xcuserstate +project.xcworkspace/ +xcuserdata/ +UserInterface.xcuserstate \ No newline at end of file From f46eb767b556632885122094851cb990624b84c7 Mon Sep 17 00:00:00 2001 From: rocman Date: Tue, 26 Jan 2016 14:25:14 +0800 Subject: [PATCH 12/12] Rename the RCTRefreshControl to RCTRresher to avoid naming confliction with the official one in 0.19 of React Native --- RCTRefreshControl.h | 2 +- RCTRefreshControl.js | 10 +++--- RCTRefreshControl.m | 34 ++++++++++----------- RCTRefreshControl.xcodeproj/project.pbxproj | 14 ++++----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/RCTRefreshControl.h b/RCTRefreshControl.h index 8d679c3..fc29cee 100644 --- a/RCTRefreshControl.h +++ b/RCTRefreshControl.h @@ -1,5 +1,5 @@ #import "RCTBridgeModule.h" -@interface RCTRefreshControl : NSObject +@interface RCTRefresher : NSObject @end diff --git a/RCTRefreshControl.js b/RCTRefreshControl.js index 7582659..eed8a49 100644 --- a/RCTRefreshControl.js +++ b/RCTRefreshControl.js @@ -8,7 +8,7 @@ var React = require('react-native'); var { DeviceEventEmitter, NativeModules: { - RefreshControl, + Refresher, }, processColor } = React; @@ -34,8 +34,8 @@ var RCTRefreshControl = { tintColor: processColor(configs.tintColor), activityIndicatorViewColor: processColor(configs.activityIndicatorViewColor) }; - - RefreshControl.configure(nodeHandle, options, (error) => { + + Refresher.configure(nodeHandle, options, (error) => { if (!error) { callbacks[nodeHandle] = callback; } @@ -43,8 +43,8 @@ var RCTRefreshControl = { }, endRefreshing: function(node) { var nodeHandle = React.findNodeHandle(node); - RefreshControl.endRefreshing(nodeHandle); + Refresher.endRefreshing(nodeHandle); } }; -module.exports = RCTRefreshControl; \ No newline at end of file +module.exports = RCTRefreshControl; diff --git a/RCTRefreshControl.m b/RCTRefreshControl.m index 09b5250..86b1256 100644 --- a/RCTRefreshControl.m +++ b/RCTRefreshControl.m @@ -8,7 +8,7 @@ #import "RCTUIManager.h" #import "RCTEventDispatcher.h" -@implementation RCTRefreshControl +@implementation RCTRefresher #pragma mark - @@ -24,44 +24,44 @@ - (dispatch_queue_t)methodQueue { options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback) { [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - + UIView *view = viewRegistry[reactTag]; if (!view) { RCTLogError(@"Cannot find view with tag #%@", reactTag); return; } - + UIScrollView *scrollView = ((RCTScrollView *)view).scrollView; - + ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:scrollView]; refreshControl.tag = [reactTag integerValue]; // Maybe something better - + UIColor *tintColor = options[@"tintColor"]; // TODO: activityIndicatorViewStyle UIColor *activityIndicatorViewColor = options[@"activityIndicatorViewColor"]; - + if (tintColor) refreshControl.tintColor = [RCTConvert UIColor:tintColor]; if (activityIndicatorViewColor) refreshControl.activityIndicatorViewColor = [RCTConvert UIColor:activityIndicatorViewColor]; - + [refreshControl addTarget:self action:@selector(dropViewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged]; - + callback(@[[NSNull null], reactTag]); }]; } RCT_EXPORT_METHOD(beginRefreshing:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - + UIView *view = viewRegistry[reactTag]; if (!view) { RCTLogError(@"Cannot find view with tag #%@", reactTag); return; } - + UIScrollView *scrollView = ((RCTScrollView *)view).scrollView; - + ODRefreshControl *refreshControl = (ODRefreshControl *)[scrollView viewWithTag:[reactTag integerValue]]; - + dispatch_async(dispatch_get_main_queue(), ^{ [refreshControl beginRefreshing]; }); @@ -70,17 +70,17 @@ - (dispatch_queue_t)methodQueue { RCT_EXPORT_METHOD(endRefreshing:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - + UIView *view = viewRegistry[reactTag]; if (!view) { RCTLogError(@"Cannot find view with tag #%@", reactTag); return; } - + UIScrollView *scrollView = ((RCTScrollView *)view).scrollView; - + ODRefreshControl *refreshControl = (ODRefreshControl *)[scrollView viewWithTag:[reactTag integerValue]]; - + dispatch_async(dispatch_get_main_queue(), ^{ [refreshControl endRefreshing]; }); @@ -96,7 +96,7 @@ - (NSDictionary *)constantsToExport { - (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl { [self.bridge.eventDispatcher sendDeviceEventWithName:@"dropViewDidBeginRefreshing" body:@(refreshControl.tag)]; - + /* double delayInSeconds = 3.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); diff --git a/RCTRefreshControl.xcodeproj/project.pbxproj b/RCTRefreshControl.xcodeproj/project.pbxproj index 8f17af8..43d3254 100644 --- a/RCTRefreshControl.xcodeproj/project.pbxproj +++ b/RCTRefreshControl.xcodeproj/project.pbxproj @@ -73,9 +73,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTRefreshControl */ = { + 58B511DA1A9E6C8500147676 /* RCTRefresher */ = { isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTRefreshControl" */; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTRefresher" */; buildPhases = ( 58B511D71A9E6C8500147676 /* Sources */, 58B511D81A9E6C8500147676 /* Frameworks */, @@ -85,7 +85,7 @@ ); dependencies = ( ); - name = RCTRefreshControl; + name = RCTRefresher; productName = RCTDataManager; productReference = 134814201AA4EA6300B7C361 /* libRCTRefreshControl.a */; productType = "com.apple.product-type.library.static"; @@ -116,7 +116,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 58B511DA1A9E6C8500147676 /* RCTRefreshControl */, + 58B511DA1A9E6C8500147676 /* RCTRefresher */, ); }; /* End PBXProject section */ @@ -219,7 +219,7 @@ ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTRefreshControl; + PRODUCT_NAME = RCTRefresher; SKIP_INSTALL = YES; }; name = Debug; @@ -235,7 +235,7 @@ ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTRefreshControl; + PRODUCT_NAME = RCTRefresher; SKIP_INSTALL = YES; }; name = Release; @@ -252,7 +252,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTRefreshControl" */ = { + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTRefresher" */ = { isa = XCConfigurationList; buildConfigurations = ( 58B511F01A9E6C8500147676 /* Debug */,