diff --git a/Examples/Movies/SearchScreen.js b/Examples/Movies/SearchScreen.js index 3c451fd67..822147516 100644 --- a/Examples/Movies/SearchScreen.js +++ b/Examples/Movies/SearchScreen.js @@ -99,6 +99,15 @@ var SearchScreen = React.createClass({ fetch(this._urlForQueryAndPage(query, 1)) .then((response) => response.json()) + .catch((error) => { + LOADING[query] = false; + resultsCache.dataForQuery[query] = undefined; + + this.setState({ + dataSource: this.getDataSource([]), + isLoading: false, + }); + }) .then((responseData) => { LOADING[query] = false; resultsCache.totalForQuery[query] = responseData.total; @@ -115,15 +124,7 @@ var SearchScreen = React.createClass({ dataSource: this.getDataSource(responseData.movies), }); }) - .catch((error) => { - LOADING[query] = false; - resultsCache.dataForQuery[query] = undefined; - - this.setState({ - dataSource: this.getDataSource([]), - isLoading: false, - }); - }); + .done(); }, hasMore: function(): boolean { @@ -157,6 +158,13 @@ var SearchScreen = React.createClass({ var page = resultsCache.nextPageNumberForQuery[query]; fetch(this._urlForQueryAndPage(query, page)) .then((response) => response.json()) + .catch((error) => { + console.error(error); + LOADING[query] = false; + this.setState({ + isLoadingTail: false, + }); + }) .then((responseData) => { var moviesForQuery = resultsCache.dataForQuery[query].slice(); @@ -182,13 +190,7 @@ var SearchScreen = React.createClass({ dataSource: this.getDataSource(resultsCache.dataForQuery[query]), }); }) - .catch((error) => { - console.error(error); - LOADING[query] = false; - this.setState({ - isLoadingTail: false, - }); - }); + .done(); }, getDataSource: function(movies: Array): ListView.DataSource { diff --git a/Examples/UIExplorer/ActionSheetIOSExample.js b/Examples/UIExplorer/ActionSheetIOSExample.js new file mode 100644 index 000000000..9b164de14 --- /dev/null +++ b/Examples/UIExplorer/ActionSheetIOSExample.js @@ -0,0 +1,112 @@ +/** +* * Copyright 2004-present Facebook. All Rights Reserved. +* */ +'use strict'; + +var React = require('react-native'); +var { + StyleSheet, + Text, + View, +} = React; +var ActionSheetIOS = require('ActionSheetIOS'); +var BUTTONS = [ + 'Button Index: 0', + 'Button Index: 1', + 'Button Index: 2', + 'Destruct', + 'Cancel', +]; +var DESTRUCTIVE_INDEX = 3; +var CANCEL_INDEX = 4; + +var ActionSheetExample = React.createClass({ + getInitialState() { + return { + clicked: 'none', + }; + }, + + render() { + return ( + + + Click to show the ActionSheet + + + Clicked button at index: "{this.state.clicked}" + + + ); + }, + + showActionSheet() { + ActionSheetIOS.showActionSheetWithOptions({ + options: BUTTONS, + cancelButtonIndex: CANCEL_INDEX, + destructiveButtonIndex: DESTRUCTIVE_INDEX, + }, + (buttonIndex) => { + this.setState({ clicked: BUTTONS[buttonIndex] }); + }); + } +}); + +var ShareActionSheetExample = React.createClass({ + getInitialState() { + return { + text: '' + }; + }, + + render() { + return ( + + + Click to show the Share ActionSheet + + + {this.state.text} + + + ); + }, + + showShareActionSheet() { + ActionSheetIOS.showShareActionSheetWithOptions({ + url: 'https://code.facebook.com', + }, + (error) => { + console.error(error); + }, + (success, method) => { + var text; + if (success) { + text = `Shared via ${method}`; + } else { + text = 'You didn\'t share'; + } + this.setState({text}) + }); + } +}); + +var style = StyleSheet.create({ + button: { + marginBottom: 10, + fontWeight: 'bold', + } +}); + +exports.title = 'ActionSheetIOS'; +exports.description = 'Interface to show iOS\' action sheets'; +exports.examples = [ + { + title: 'Show Action Sheet', + render() { return ; } + }, + { + title: 'Show Share Action Sheet', + render() { return ; } + } +]; diff --git a/Examples/UIExplorer/AdSupportIOSExample.js b/Examples/UIExplorer/AdSupportIOSExample.js index 63f3a63eb..a3d720f01 100644 --- a/Examples/UIExplorer/AdSupportIOSExample.js +++ b/Examples/UIExplorer/AdSupportIOSExample.js @@ -29,23 +29,41 @@ var AdSupportIOSExample = React.createClass({ getInitialState: function() { return { deviceID: 'No IDFA yet', + hasAdvertiserTracking: 'unset', }; }, componentDidMount: function() { AdSupportIOS.getAdvertisingId( - this._onSuccess, - this._onFailure + this._onDeviceIDSuccess, + this._onDeviceIDFailure + ); + + AdSupportIOS.getAdvertisingTrackingEnabled( + this._onHasTrackingSuccess, + this._onHasTrackingFailure ); }, - _onSuccess: function(deviceID) { + _onHasTrackingSuccess: function(hasTracking) { + this.setState({ + 'hasAdvertiserTracking': hasTracking, + }); + }, + + _onHasTrackingFailure: function(e) { + this.setState({ + 'hasAdvertiserTracking': 'Error!', + }); + }, + + _onDeviceIDSuccess: function(deviceID) { this.setState({ 'deviceID': deviceID, }); }, - _onFailure: function(e) { + _onDeviceIDFailure: function(e) { this.setState({ 'deviceID': 'Error!', }); @@ -58,6 +76,10 @@ var AdSupportIOSExample = React.createClass({ Advertising ID: {JSON.stringify(this.state.deviceID)} + + Has Advertiser Tracking: + {JSON.stringify(this.state.hasAdvertiserTracking)} + ); } diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index c1f6820cc..f33ddefce 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; + 147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -70,6 +71,13 @@ remoteGlobalIDString = 134814201AA4EA6300B7C361; remoteInfo = RCTGeolocation; }; + 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 134814201AA4EA6300B7C361; + remoteInfo = RCTActionSheet; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -89,6 +97,7 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -103,6 +112,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */, 134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */, 134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */, 1341802C1AA9178B003F314A /* libRCTNetwork.a in Frameworks */, @@ -135,6 +145,7 @@ 1316A21D1AA397F400C0188E /* Libraries */ = { isa = PBXGroup; children = ( + 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */, 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */, 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */, 134A8A201AACED6A00945AAE /* RCTGeolocation.xcodeproj */, @@ -206,6 +217,14 @@ name = UIExplorer; sourceTree = ""; }; + 147CED471AB34F8C00DA3E4C /* Products */ = { + isa = PBXGroup; + children = ( + 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */, + ); + name = Products; + sourceTree = ""; + }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -290,6 +309,10 @@ productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; projectReferences = ( + { + ProductGroup = 147CED471AB34F8C00DA3E4C /* Products */; + ProjectRef = 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */; + }, { ProductGroup = 134454561AAFCAAE003F0779 /* Products */; ProjectRef = 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */; @@ -366,6 +389,13 @@ remoteRef = 134A8A241AACED6A00945AAE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRCTActionSheet.a; + remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index ab8aed798..59653055e 100644 --- a/Examples/UIExplorer/UIExplorerList.js +++ b/Examples/UIExplorer/UIExplorerList.js @@ -43,6 +43,7 @@ var EXAMPLES = [ require('./AppStateIOSExample'), require('./AdSupportIOSExample'), require('./AppStateExample'), + require('./ActionSheetIOSExample'), ]; var UIExplorerList = React.createClass({ diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js new file mode 100644 index 000000000..d4cc84a48 --- /dev/null +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -0,0 +1,49 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule ActionSheetIOS + */ +'use strict'; + +var invariant = require('invariant'); +var RCTActionSheetManager = require('NativeModulesDeprecated').RKActionSheetManager; + +var ActionSheetIOS = { + showActionSheetWithOptions(options, callback) { + invariant( + typeof options === 'object' && options !== null, + 'Options must a valid object' + ); + invariant( + typeof callback === 'function', + 'Must provide a valid callback' + ); + RCTActionSheetManager.showActionSheetWithOptions( + options, + () => {}, // RKActionSheet compatibility hack + callback + ); + }, + + showShareActionSheetWithOptions(options, failureCallback, successCallback) { + invariant( + typeof options === 'object' && options !== null, + 'Options must a valid object' + ); + invariant( + typeof failureCallback === 'function', + 'Must provide a valid failureCallback' + ); + invariant( + typeof successCallback === 'function', + 'Must provide a valid successCallback' + ); + RCTActionSheetManager.showShareActionSheetWithOptions( + options, + failureCallback, + successCallback + ); + } +}; + +module.exports = ActionSheetIOS; diff --git a/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj b/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj new file mode 100644 index 000000000..095c4de35 --- /dev/null +++ b/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj @@ -0,0 +1,250 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 14C644C41AB0DFC900DE3C65 /* RCTActionSheetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 58B511D91A9E6C8500147676 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTActionSheet.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 14C644C11AB0DFC900DE3C65 /* RCTActionSheetManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTActionSheetManager.h; sourceTree = ""; }; + 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTActionSheetManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 58B511D81A9E6C8500147676 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 134814211AA4EA7D00B7C361 /* Products */ = { + isa = PBXGroup; + children = ( + 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */, + ); + name = Products; + sourceTree = ""; + }; + 58B511D21A9E6C8500147676 = { + isa = PBXGroup; + children = ( + 14C644C11AB0DFC900DE3C65 /* RCTActionSheetManager.h */, + 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */, + 134814211AA4EA7D00B7C361 /* Products */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 58B511DA1A9E6C8500147676 /* RCTActionSheet */ = { + isa = PBXNativeTarget; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTActionSheet" */; + buildPhases = ( + 58B511D71A9E6C8500147676 /* Sources */, + 58B511D81A9E6C8500147676 /* Frameworks */, + 58B511D91A9E6C8500147676 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RCTActionSheet; + productName = RCTDataManager; + productReference = 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 58B511D31A9E6C8500147676 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 58B511DA1A9E6C8500147676 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTActionSheet" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 58B511D21A9E6C8500147676; + productRefGroup = 58B511D21A9E6C8500147676; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 58B511DA1A9E6C8500147676 /* RCTActionSheet */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 58B511D71A9E6C8500147676 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14C644C41AB0DFC900DE3C65 /* RCTActionSheetManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 58B511ED1A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 58B511EE1A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 58B511F01A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../ReactKit/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RCTActionSheet; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 58B511F11A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../ReactKit/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RCTActionSheet; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTActionSheet" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511ED1A9E6C8500147676 /* Debug */, + 58B511EE1A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTActionSheet" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511F01A9E6C8500147676 /* Debug */, + 58B511F11A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 58B511D31A9E6C8500147676 /* Project object */; +} diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.h b/Libraries/ActionSheetIOS/RCTActionSheetManager.h new file mode 100644 index 000000000..0ef25b520 --- /dev/null +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.h @@ -0,0 +1,9 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import + +#import "RCTBridge.h" + +@interface RCTActionSheetManager : NSObject + +@end diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m new file mode 100644 index 000000000..2c628e2be --- /dev/null +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -0,0 +1,120 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import "RCTActionSheetManager.h" + +#import "RCTLog.h" + +@interface RCTActionSheetManager() + +@end + +@implementation RCTActionSheetManager { + NSMutableDictionary *_callbacks; +} + +- (instancetype)init +{ + if ((self = [super init])) { + _callbacks = [[NSMutableDictionary alloc] init]; + } + return self; +} + +- (void)showActionSheetWithOptions:(NSDictionary *)options + failureCallback:(RCTResponseSenderBlock)failureCallback + successCallback:(RCTResponseSenderBlock)successCallback +{ + RCT_EXPORT(); + + dispatch_async(dispatch_get_main_queue(), ^{ + UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; + + actionSheet.title = options[@"title"]; + + for (NSString *option in options[@"options"]) { + [actionSheet addButtonWithTitle:option]; + } + + if (options[@"destructiveButtonIndex"]) { + actionSheet.destructiveButtonIndex = [options[@"destructiveButtonIndex"] integerValue]; + } + if (options[@"cancelButtonIndex"]) { + actionSheet.cancelButtonIndex = [options[@"cancelButtonIndex"] integerValue]; + } + + actionSheet.delegate = self; + + _callbacks[keyForInstance(actionSheet)] = successCallback; + + UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window]; + if (appWindow == nil) { + RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); + return; + } + [actionSheet showInView:appWindow]; + }); +} + +- (void)showShareActionSheetWithOptions:(NSDictionary *)options + failureCallback:(RCTResponseSenderBlock)failureCallback + successCallback:(RCTResponseSenderBlock)successCallback +{ + RCT_EXPORT(); + + dispatch_async(dispatch_get_main_queue(), ^{ + NSMutableArray *items = [NSMutableArray array]; + id message = options[@"message"]; + id url = options[@"url"]; + if ([message isKindOfClass:[NSString class]]) { + [items addObject:message]; + } + if ([url isKindOfClass:[NSString class]]) { + [items addObject:[NSURL URLWithString:url]]; + } + if ([items count] == 0) { + failureCallback(@[@"No `url` or `message` to share"]); + return; + } + UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; + UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + if ([share respondsToSelector:@selector(setCompletionWithItemsHandler:)]) { + share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { + if (activityError) { + failureCallback(@[[activityError localizedDescription]]); + } else { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + } + }; + } else { + share.completionHandler = ^(NSString *activityType, BOOL completed) { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + }; + } + [ctrl presentViewController:share animated:YES completion:nil]; + }); +} + +#pragma mark UIActionSheetDelegate Methods + +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +{ + NSString *key = keyForInstance(actionSheet); + RCTResponseSenderBlock callback = _callbacks[key]; + if (callback) { + callback(@[@(buttonIndex)]); + [_callbacks removeObjectForKey:key]; + } else { + RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title); + } + + [[[[UIApplication sharedApplication] delegate] window] makeKeyWindow]; +} + +#pragma mark Private + +static NSString *keyForInstance(id instance) +{ + return [NSString stringWithFormat:@"%p", instance]; +} + +@end diff --git a/Libraries/AdSupport/AdSupportIOS.js b/Libraries/AdSupport/AdSupportIOS.js index 598befd31..c0a081aa4 100644 --- a/Libraries/AdSupport/AdSupportIOS.js +++ b/Libraries/AdSupport/AdSupportIOS.js @@ -11,4 +11,8 @@ module.exports = { getAdvertisingId: function(onSuccess, onFailure) { AdSupport.getAdvertisingId(onSuccess, onFailure); }, + + getAdvertisingTrackingEnabled: function(onSuccess, onFailure) { + AdSupport.getAdvertisingTrackingEnabled(onSuccess, onFailure); + }, }; diff --git a/Libraries/AdSupport/RCTAdSupport.m b/Libraries/AdSupport/RCTAdSupport.m index 3712b1b9b..22ad6aacb 100644 --- a/Libraries/AdSupport/RCTAdSupport.m +++ b/Libraries/AdSupport/RCTAdSupport.m @@ -15,4 +15,16 @@ } } +- (void)getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback withErrorCallback:(RCTResponseSenderBlock)errorCallback +{ + RCT_EXPORT(); + + if ([ASIdentifierManager class]) { + bool hasTracking = [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]; + callback(@[@(hasTracking)]); + } else { + return errorCallback(@[@"as_identifier_unavailable"]); + } +} + @end diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 157cc8e1f..4edfeda81 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -47,17 +47,6 @@ var keyboardDismissModeConstants = { */ var ScrollView = React.createClass({ - - // Only for compatibility with Android which is not yet up to date, - // DO NOT ADD NEW CALL SITES! - statics: { - keyboardDismissMode: { - None: 'none', - Interactive: 'interactive', - OnDrag: 'onDrag', - }, - }, - propTypes: { automaticallyAdjustContentInsets: PropTypes.bool, // true contentInset: EdgeInsetsPropType, // zeros @@ -194,7 +183,7 @@ var ScrollView = React.createClass({ scrollTo: function(destY, destX) { RKUIManager.scrollTo( - ReactIOSTagHandles.rootNodeIDToTag[this._rootNodeID], + this.getNodeHandle(), destX || 0, destY || 0 ); diff --git a/Libraries/Geolocation/Geolocation.ios.js b/Libraries/Geolocation/Geolocation.ios.js index 1b5719212..0e8015335 100644 --- a/Libraries/Geolocation/Geolocation.ios.js +++ b/Libraries/Geolocation/Geolocation.ios.js @@ -6,7 +6,7 @@ 'use strict'; var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTLocationObserver = require('NativeModulesDeprecated').RKLocationObserver; +var RCTLocationObserver = require('NativeModules').RCTLocationObserver; var invariant = require('invariant'); var logError = require('logError'); @@ -34,9 +34,9 @@ var Geolocation = { 'Must provide a valid geo_success callback.' ); RCTLocationObserver.getCurrentPosition( + geo_options || {}, geo_success, - geo_error || logError, - geo_options || {} + geo_error || logError ); }, diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 019653640..c2a2d0ee1 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -180,9 +180,9 @@ static NSDictionary *RCTPositionError(RCTPositionErrorCode code, NSString *msg / }); } -- (void)getCurrentPosition:(RCTResponseSenderBlock)successBlock - withErrorCallback:(RCTResponseSenderBlock)errorBlock - options:(NSDictionary *)optionsJSON +- (void)getCurrentPosition:(NSDictionary *)optionsJSON + withSuccessCallback:(RCTResponseSenderBlock)successBlock + errorCallback:(RCTResponseSenderBlock)errorBlock { RCT_EXPORT(); diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index 422447d46..fda065d4f 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -57,6 +57,8 @@ function setupDocumentShim() { } } +var sourceMapPromise; + function handleErrorWithRedBox(e) { var RKExceptionsManager = require('NativeModules').RKExceptionsManager; var errorToString = require('errorToString'); @@ -73,13 +75,14 @@ function handleErrorWithRedBox(e) { if (RKExceptionsManager) { RKExceptionsManager.reportUnhandledException(e.message, errorToString(e)); if (__DEV__) { - try { - var sourceMapInstance = loadSourceMap(); - var prettyStack = errorToString(e, sourceMapInstance); - RKExceptionsManager.updateExceptionMessage(e.message, prettyStack); - } catch (ee) { - GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + ee.message); - } + (sourceMapPromise = sourceMapPromise || loadSourceMap()) + .then(map => { + var prettyStack = errorToString(e, map); + RKExceptionsManager.updateExceptionMessage(e.message, prettyStack); + }) + .then(null, error => { + GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + error.message); + }); } } } diff --git a/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js b/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js index 076f9fa5c..48fd9d1bf 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js +++ b/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js @@ -2,23 +2,42 @@ * Copyright 2004-present Facebook. All Rights Reserved. * * @providesModule loadSourceMap + * @flow */ 'use strict'; +var Promise = require('Promise'); +var RCTSourceCode = require('NativeModules').RCTSourceCode; var SourceMapConsumer = require('SourceMap').SourceMapConsumer; +var SourceMapURL = require('./source-map-url'); -var sourceMapInstance; +var fetch = require('fetch'); -function loadSourceMap() { - if (sourceMapInstance !== undefined) { - return sourceMapInstance; +function loadSourceMap(): Promise { + return fetchSourceMap() + .then(map => new SourceMapConsumer(map)); +} + +function fetchSourceMap(): Promise { + if (global.RAW_SOURCE_MAP) { + return Promise.resolve(global.RAW_SOURCE_MAP); } - if (!global.RAW_SOURCE_MAP) { - return null; + + if (!RCTSourceCode) { + return Promise.reject(new Error('RCTSourceCode module is not available')); } - sourceMapInstance = new SourceMapConsumer(global.RAW_SOURCE_MAP); - return sourceMapInstance; + + return new Promise(RCTSourceCode.getScriptText) + .then(extractSourceMapURL) + .then(fetch) + .then(response => response.text()) +} + +function extractSourceMapURL({url, text}): string { + var mapURL = SourceMapURL.getFrom(text); + var baseURL = url.match(/(.+:\/\/.*?)\//)[1]; + return baseURL + mapURL; } module.exports = loadSourceMap; diff --git a/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js b/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js new file mode 100644 index 000000000..c3a53f234 --- /dev/null +++ b/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js @@ -0,0 +1,73 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * This is a third-party micro-library grabbed from: + * https://github.com/lydell/source-map-url + * + * @nolint + */ + +(function() { + var define = null; // Hack to make it work with our packager + +// Copyright 2014 Simon Lydell +// X11 (“MIT”) Licensed. (See LICENSE.) + +void (function(root, factory) { + if (typeof define === "function" && define.amd) { + define(factory) + } else if (typeof exports === "object") { + module.exports = factory() + } else { + root.sourceMappingURL = factory() + } +}(this, function() { + + var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/ + + var regex = RegExp( + "(?:" + + "/\\*" + + "(?:\\s*\r?\n(?://)?)?" + + "(?:" + innerRegex.source + ")" + + "\\s*" + + "\\*/" + + "|" + + "//(?:" + innerRegex.source + ")" + + ")" + + "\\s*$" + ) + + return { + + regex: regex, + _innerRegex: innerRegex, + + getFrom: function(code) { + var match = code.match(regex) + return (match ? match[1] || match[2] || "" : null) + }, + + existsIn: function(code) { + return regex.test(code) + }, + + removeFrom: function(code) { + return code.replace(regex, "") + }, + + insertBefore: function(code, string) { + var match = code.match(regex) + if (match) { + return code.slice(0, match.index) + string + code.slice(match.index) + } else { + return code + string + } + } + } + +})); + +/** End of the third-party code */ + +})(); diff --git a/ReactKit/Base/RCTRootView.m b/ReactKit/Base/RCTRootView.m index b21e53e25..5f0698e32 100644 --- a/ReactKit/Base/RCTRootView.m +++ b/ReactKit/Base/RCTRootView.m @@ -8,6 +8,7 @@ #import "RCTKeyCommands.h" #import "RCTLog.h" #import "RCTRedBox.h" +#import "RCTSourceCode.h" #import "RCTTouchHandler.h" #import "RCTUIManager.h" #import "RCTUtils.h" @@ -200,6 +201,10 @@ static Class _globalExecutorClass; } // Success! + RCTSourceCode *sourceCodeModule = _bridge.modules[NSStringFromClass([RCTSourceCode class])]; + sourceCodeModule.scriptURL = _scriptURL; + sourceCodeModule.scriptText = rawText; + [_bridge enqueueApplicationScript:rawText url:_scriptURL onComplete:^(NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [self bundleFinishedLoading:error]; diff --git a/ReactKit/Modules/RCTSourceCode.h b/ReactKit/Modules/RCTSourceCode.h new file mode 100644 index 000000000..3c9df24df --- /dev/null +++ b/ReactKit/Modules/RCTSourceCode.h @@ -0,0 +1,12 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import + +#import "RCTBridgeModule.h" + +@interface RCTSourceCode : NSObject + +@property (nonatomic, copy) NSString *scriptText; +@property (nonatomic, copy) NSURL *scriptURL; + +@end diff --git a/ReactKit/Modules/RCTSourceCode.m b/ReactKit/Modules/RCTSourceCode.m new file mode 100644 index 000000000..b8799378f --- /dev/null +++ b/ReactKit/Modules/RCTSourceCode.m @@ -0,0 +1,21 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import "RCTSourceCode.h" + +#import "RCTAssert.h" +#import "RCTUtils.h" + +@implementation RCTSourceCode + +- (void)getScriptText:(RCTResponseSenderBlock)successCallback failureCallback:(RCTResponseSenderBlock)failureCallback +{ + RCT_EXPORT(); + if (self.scriptText && self.scriptURL) { + successCallback(@[@{@"text": self.scriptText, @"url":[self.scriptURL absoluteString]}]); + } else { + failureCallback(@[RCTMakeError(@"Source code is not available", nil, nil)]); + } + +} + +@end diff --git a/ReactKit/ReactKit.xcodeproj/project.pbxproj b/ReactKit/ReactKit.xcodeproj/project.pbxproj index 73ecaffef..eed3a13e7 100644 --- a/ReactKit/ReactKit.xcodeproj/project.pbxproj +++ b/ReactKit/ReactKit.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 000E6CEB1AB0E980000CDF4D /* RCTSourceCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 000E6CEA1AB0E980000CDF4D /* RCTSourceCode.m */; }; 134FCB361A6D42D900051CC8 /* RCTSparseArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BEE46D1A6D19BC00B5863B /* RCTSparseArray.m */; }; 134FCB3D1A6E7F0800051CC8 /* RCTContextExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 134FCB3A1A6E7F0800051CC8 /* RCTContextExecutor.m */; }; 134FCB3E1A6E7F0800051CC8 /* RCTWebViewExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 134FCB3C1A6E7F0800051CC8 /* RCTWebViewExecutor.m */; }; @@ -42,8 +43,8 @@ 14F484561AABFCE100FDF6B9 /* RCTSliderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F484551AABFCE100FDF6B9 /* RCTSliderManager.m */; }; 58114A161AAE854800E7D092 /* RCTPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A131AAE854800E7D092 /* RCTPicker.m */; }; 58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A151AAE854800E7D092 /* RCTPickerManager.m */; }; - 58C571C11AA56C1900CDF9C8 /* RCTDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */; }; 58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; }; + 58C571C11AA56C1900CDF9C8 /* RCTDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */; }; 830A229E1A66C68A008503DA /* RCTRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 830A229D1A66C68A008503DA /* RCTRootView.m */; }; 830BA4551A8E3BDA00D53203 /* RCTCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 830BA4541A8E3BDA00D53203 /* RCTCache.m */; }; 832348161A77A5AA00B55238 /* Layout.c in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FC71A68125100A75B9A /* Layout.c */; }; @@ -72,6 +73,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 000E6CE91AB0E97F000CDF4D /* RCTSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSourceCode.h; sourceTree = ""; }; + 000E6CEA1AB0E980000CDF4D /* RCTSourceCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSourceCode.m; sourceTree = ""; }; 13442BF21AA90E0B0037E5B0 /* RCTAnimationType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAnimationType.h; sourceTree = ""; }; 13442BF31AA90E0B0037E5B0 /* RCTPointerEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPointerEvents.h; sourceTree = ""; }; 13442BF41AA90E0B0037E5B0 /* RCTViewControllerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTViewControllerProtocol.h; sourceTree = ""; }; @@ -149,10 +152,10 @@ 58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = ""; }; 58114A141AAE854800E7D092 /* RCTPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPickerManager.h; sourceTree = ""; }; 58114A151AAE854800E7D092 /* RCTPickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPickerManager.m; sourceTree = ""; }; - 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePickerManager.m; sourceTree = ""; }; - 58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDatePickerManager.h; sourceTree = ""; }; 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAsyncLocalStorage.m; sourceTree = ""; }; 58114A4F1AAE93D500E7D092 /* RCTAsyncLocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAsyncLocalStorage.h; sourceTree = ""; }; + 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePickerManager.m; sourceTree = ""; }; + 58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDatePickerManager.h; sourceTree = ""; }; 830213F31A654E0800B993E6 /* RCTBridgeModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTBridgeModule.h; sourceTree = ""; }; 830A229C1A66C68A008503DA /* RCTRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootView.h; sourceTree = ""; }; 830A229D1A66C68A008503DA /* RCTRootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootView.m; sourceTree = ""; }; @@ -227,6 +230,8 @@ 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */, 13B07FE91A69327A00A75B9A /* RCTExceptionsManager.h */, 13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */, + 000E6CE91AB0E97F000CDF4D /* RCTSourceCode.h */, + 000E6CEA1AB0E980000CDF4D /* RCTSourceCode.m */, 13723B4E1A82FD3C00F88898 /* RCTStatusBarManager.h */, 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */, 13B07FED1A69327A00A75B9A /* RCTTiming.h */, @@ -440,6 +445,7 @@ buildActionMask = 2147483647; files = ( 13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */, + 000E6CEB1AB0E980000CDF4D /* RCTSourceCode.m in Sources */, 13B0801E1A69489C00A75B9A /* RCTTextField.m in Sources */, 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */, 83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */, diff --git a/ReactKit/Views/RCTMap.m b/ReactKit/Views/RCTMap.m index 09dac2a5b..e0f4d9228 100644 --- a/ReactKit/Views/RCTMap.m +++ b/ReactKit/Views/RCTMap.m @@ -2,6 +2,7 @@ #import "RCTMap.h" +#import "RCTConvert.h" #import "RCTEventDispatcher.h" #import "RCTLog.h" #import "RCTUtils.h" @@ -90,18 +91,9 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; { if (region) { MKCoordinateRegion coordinateRegion = self.region; - if ([region[@"latitude"] isKindOfClass:[NSNumber class]]) { - coordinateRegion.center.latitude = [region[@"latitude"] doubleValue]; - } else { - RCTLogError(@"region must include numeric latitude, got: %@", region); - return; - } - if ([region[@"longitude"] isKindOfClass:[NSNumber class]]) { - coordinateRegion.center.longitude = [region[@"longitude"] doubleValue]; - } else { - RCTLogError(@"region must include numeric longitude, got: %@", region); - return; - } + coordinateRegion.center.latitude = [RCTConvert double:region[@"latitude"]]; + coordinateRegion.center.longitude = [RCTConvert double:region[@"longitude"]]; + if ([region[@"latitudeDelta"] isKindOfClass:[NSNumber class]]) { coordinateRegion.span.latitudeDelta = [region[@"latitudeDelta"] doubleValue]; } diff --git a/ReactKit/Views/RCTMapManager.m b/ReactKit/Views/RCTMapManager.m index 421396a1e..4e4cec164 100644 --- a/ReactKit/Views/RCTMapManager.m +++ b/ReactKit/Views/RCTMapManager.m @@ -60,11 +60,11 @@ RCT_REMAP_VIEW_PROPERTY(region, JSONRegion) - (void)mapView:(RCTMap *)mapView regionDidChangeAnimated:(BOOL)animated { - [self _regionChanged:mapView]; - [self _emitRegionChangeEvent:mapView continuous:NO]; - [mapView.regionChangeObserveTimer invalidate]; mapView.regionChangeObserveTimer = nil; + + [self _regionChanged:mapView]; + [self _emitRegionChangeEvent:mapView continuous:NO]; } #pragma mark Private diff --git a/lint/linterTransform.js b/lint/linterTransform.js index a61fa89a3..6250db80f 100644 --- a/lint/linterTransform.js +++ b/lint/linterTransform.js @@ -47,7 +47,7 @@ function setLinterTransform(transformSource) { eslint.linter.verify = function(text, config, filename, saveState) { var transformedText; try { - transformedText = transformSource(text); + transformedText = transformSource(text, filename); } catch (e) { return [{ severity: 2, diff --git a/website/layout/AutodocsLayout.js b/website/layout/AutodocsLayout.js index 7a1a6dddd..345cfefa6 100644 --- a/website/layout/AutodocsLayout.js +++ b/website/layout/AutodocsLayout.js @@ -100,6 +100,20 @@ var APIDoc = React.createClass({ .join('\n'); }, + renderTypehint: function(typehint) { + try { + var typehint = JSON.parse(typehint); + } catch(e) { + return typehint; + } + + if (typehint.type === 'simple') { + return typehint.value; + } + + return ':(' + JSON.stringify(typehint); + }, + renderMethod: function(method) { return (
@@ -110,15 +124,10 @@ var APIDoc = React.createClass({ {method.name}( {method.params - .map(function(param) { + .map((param) => { var res = param.name; if (param.typehint) { - try { - var typehint = JSON.parse(param.typehint).value; - } catch(e) { - var typehint = param.typehint; - } - res += ': ' + typehint; + res += ': ' + this.renderTypehint(param.typehint); } return res; }) @@ -126,6 +135,9 @@ var APIDoc = React.createClass({ ) + {method.docblock && + {this.removeCommentsFromDocblock(method.docblock)} + }
); }, diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index 44bc6a967..bfaff5f51 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -2,7 +2,7 @@ var docs = require('../react-docgen'); var fs = require('fs'); var path = require('path'); var slugify = require('../core/slugify'); -var jsDocs = require('../jsdocs/jsdocs.js') +var jsDocs = require('../jsdocs/jsdocs.js'); function getNameFromPath(filepath) { var ext = null; @@ -41,7 +41,9 @@ var components = [ '../Libraries/Text/ExpandingText.js', '../Libraries/Image/Image.ios.js', '../Libraries/Components/ListView/ListView.js', + '../Libraries/Components/MapView/MapView.js', '../Libraries/Components/Navigation/NavigatorIOS.ios.js', + '../Libraries/Picker/PickerIOS.ios.js', '../Libraries/Components/ScrollView/ScrollView.js', '../Libraries/Components/Slider/Slider.js', '../Libraries/Components/SwitchIOS/SwitchIOS.ios.js', @@ -55,8 +57,11 @@ var components = [ ]; var apis = [ - '../Libraries/AppRegistry/AppRegistry.js', '../Libraries/Animation/Animation.js', + '../Libraries/AppRegistry/AppRegistry.js', + '../Libraries/AppState/AppState.js', + '../Libraries/AppStateIOS/AppStateIOS.ios.js', + '../Libraries/Storage/AsyncStorage.ios.js', '../Libraries/CameraRoll/CameraRoll.js', '../Libraries/Animation/LayoutAnimation.js', '../Libraries/Utilities/PixelRatio.js',