Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
17 changes: 0 additions & 17 deletions RCTRefreshControl.android.js

This file was deleted.

2 changes: 1 addition & 1 deletion RCTRefreshControl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "RCTBridgeModule.h"

@interface RCTRefreshControl : NSObject <RCTBridgeModule>
@interface RCTRefresher : NSObject <RCTBridgeModule>

@end
15 changes: 8 additions & 7 deletions RCTRefreshControl.ios.js → RCTRefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ var React = require('react-native');
var {
DeviceEventEmitter,
NativeModules: {
RefreshControl,
}
Refresher,
},
processColor
} = React;

/**
Expand All @@ -30,19 +31,19 @@ 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) => {

Refresher.configure(nodeHandle, options, (error) => {
if (!error) {
callbacks[nodeHandle] = callback;
}
});
},
endRefreshing: function(node) {
var nodeHandle = React.findNodeHandle(node);
RefreshControl.endRefreshing(nodeHandle);
Refresher.endRefreshing(nodeHandle);
}
};

Expand Down
41 changes: 20 additions & 21 deletions RCTRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
#import "RCTBridge.h"
#import "RCTConvert.h"
#import "RCTScrollView.h"
#import "RCTSparseArray.h"
#import "RCTUIManager.h"
#import "RCTEventDispatcher.h"

@implementation RCTRefreshControl
@implementation RCTRefresher

#pragma mark -

Expand All @@ -24,64 +23,64 @@ - (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) {
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, RCTSparseArray *viewRegistry) {
[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];
});
}];
}

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) {
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];
});
Expand All @@ -97,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);
Expand Down
14 changes: 7 additions & 7 deletions RCTRefreshControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */,
Expand All @@ -85,7 +85,7 @@
);
dependencies = (
);
name = RCTRefreshControl;
name = RCTRefresher;
productName = RCTDataManager;
productReference = 134814201AA4EA6300B7C361 /* libRCTRefreshControl.a */;
productType = "com.apple.product-type.library.static";
Expand Down Expand Up @@ -116,7 +116,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
58B511DA1A9E6C8500147676 /* RCTRefreshControl */,
58B511DA1A9E6C8500147676 /* RCTRefresher */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -219,7 +219,7 @@
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTRefreshControl;
PRODUCT_NAME = RCTRefresher;
SKIP_INSTALL = YES;
};
name = Debug;
Expand All @@ -235,7 +235,7 @@
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTRefreshControl;
PRODUCT_NAME = RCTRefresher;
SKIP_INSTALL = YES;
};
name = Release;
Expand All @@ -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 */,
Expand Down
Loading