diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index f33ddefce..6e214d3b9 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 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 */; }; + D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -78,6 +79,13 @@ remoteGlobalIDString = 134814201AA4EA6300B7C361; remoteInfo = RCTActionSheet; }; + D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; + remoteInfo = RCTVibration; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -98,6 +106,7 @@ 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 = ""; }; + D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../../Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -112,6 +121,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */, 147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */, 134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */, 134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */, @@ -145,6 +155,7 @@ 1316A21D1AA397F400C0188E /* Libraries */ = { isa = PBXGroup; children = ( + D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */, 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */, 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */, 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */, @@ -244,6 +255,14 @@ name = Products; sourceTree = ""; }; + D85B82921AB6D5CE003F4FE2 /* Products */ = { + isa = PBXGroup; + children = ( + D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */, + ); + name = Products; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -333,6 +352,10 @@ ProductGroup = 13417FEB1AA914B8003F314A /* Products */; ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */; }, + { + ProductGroup = D85B82921AB6D5CE003F4FE2 /* Products */; + ProjectRef = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */; + }, { ProductGroup = 13417FFB1AA91531003F314A /* Products */; ProjectRef = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */; @@ -396,6 +419,13 @@ remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRCTVibration.a; + remoteRef = D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index a4f70fbcd..bc46292fd 100644 --- a/Examples/UIExplorer/UIExplorerList.js +++ b/Examples/UIExplorer/UIExplorerList.js @@ -47,6 +47,7 @@ var EXAMPLES = [ require('./AdSupportIOSExample'), require('./AppStateExample'), require('./ActionSheetIOSExample'), + require('./VibrationIOSExample'), ]; var UIExplorerList = React.createClass({ diff --git a/Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m b/Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m index 1a7a70d78..237270f67 100644 --- a/Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m +++ b/Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m @@ -3,7 +3,7 @@ #import #import -#define TIMEOUT_SECONDS 30 +#define TIMEOUT_SECONDS 240 @interface UIExplorerTests : XCTestCase diff --git a/Examples/UIExplorer/VibrationIOSExample.js b/Examples/UIExplorer/VibrationIOSExample.js new file mode 100644 index 000000000..bd768bcbb --- /dev/null +++ b/Examples/UIExplorer/VibrationIOSExample.js @@ -0,0 +1,42 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +'use strict'; + +var React = require('react-native'); +var { + StyleSheet, + View, + Text, + TouchableHighlight, + VibrationIOS +} = React; + +exports.framework = 'React'; +exports.title = 'VibrationIOS'; +exports.description = 'Vibration API for iOS'; +exports.examples = [{ + title: 'VibrationIOS.vibrate()', + render() { + return ( + VibrationIOS.vibrate()}> + + Vibrate + + + ); + }, +}]; + +var styles = StyleSheet.create({ + wrapper: { + borderRadius: 5, + marginBottom: 5, + }, + button: { + backgroundColor: '#eeeeee', + padding: 10, + }, +}); diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index d4cc84a48..5a24f06b0 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -5,8 +5,9 @@ */ 'use strict'; +var { RCTActionSheetManager } = require('NativeModules'); + var invariant = require('invariant'); -var RCTActionSheetManager = require('NativeModulesDeprecated').RKActionSheetManager; var ActionSheetIOS = { showActionSheetWithOptions(options, callback) { diff --git a/Libraries/Animation/AnimationUtils.js b/Libraries/Animation/AnimationUtils.js index cf986abe8..d36e817cf 100644 --- a/Libraries/Animation/AnimationUtils.js +++ b/Libraries/Animation/AnimationUtils.js @@ -8,197 +8,191 @@ type EasingFunction = (t: number) => number; -var b = 0, - c = 1, - d = 1; var defaults = { easeInQuad: function(t) { - return c * (t /= 1) * t + b; + return t * t; }, easeOutQuad: function(t) { - return -c * (t /= d) * (t - 2) + b; + return -t * (t - 2); }, easeInOutQuad: function(t) { - if ((t /= d / 2) < 1) { - return c / 2 * t * t + b; + t = t * 2; + if (t < 1) { + return 0.5 * t * t; } - return -c / 2 * ((--t) * (t - 2) - 1) + b; + return -((t - 1) * (t - 3) - 1) / 2; }, easeInCubic: function(t) { - return c * (t /= d) * t * t + b; + return t * t * t; }, easeOutCubic: function(t) { - return c * ((t = t / d - 1) * t * t + 1) + b; + t -= 1; + return t * t * t + 1; }, easeInOutCubic: function(t) { - if ((t /= d / 2) < 1) { - return c / 2 * t * t * t + b; + t *= 2; + if (t < 1) { + return 0.5 * t * t * t; } - return c / 2 * ((t -= 2) * t * t + 2) + b; + t -= 2; + return (t * t * t + 2) / 2; }, easeInQuart: function(t) { - return c * (t /= d) * t * t * t + b; + return t * t * t * t; }, easeOutQuart: function(t) { - return -c * ((t = t / d - 1) * t * t * t - 1) + b; + t -= 1; + return -(t * t * t * t - 1); }, easeInOutQuart: function(t) { - if ((t /= d / 2) < 1) { - return c / 2 * t * t * t * t + b; + t *= 2; + if (t < 1) { + return 0.5 * t * t * t * t; } - return -c / 2 * ((t -= 2) * t * t * t - 2) + b; + t -= 2; + return -(t * t * t * t - 2) / 2; }, easeInQuint: function(t) { - return c * (t /= d) * t * t * t * t + b; + return t * t * t * t * t; }, easeOutQuint: function(t) { - return c * ((t = t / d - 1) * t * t * t * t + 1) + b; + t -= 1; + return t * t * t * t * t + 1; }, easeInOutQuint: function(t) { - if ((t /= d / 2) < 1) { - return c / 2 * t * t * t * t * t + b; + t *= 2; + if (t < 1) { + return (t * t * t * t * t) / 2; } - return c / 2 * ((t -= 2) * t * t * t * t + 2) + b; + t -= 2; + return (t * t * t * t * t + 2) / 2; }, easeInSine: function(t) { - return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; + return -Math.cos(t * (Math.PI / 2)) + 1; }, easeOutSine: function(t) { - return c * Math.sin(t / d * (Math.PI / 2)) + b; + return Math.sin(t * (Math.PI / 2)); }, easeInOutSine: function(t) { - return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; + return -(Math.cos(Math.PI * t) - 1) / 2; }, easeInExpo: function(t) { - return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b; + return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1)); }, easeOutExpo: function(t) { - return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; + return (t === 1) ? 1 : (-Math.pow(2, -10 * t) + 1); }, easeInOutExpo: function(t) { if (t === 0) { - return b; + return 0; } - if (t === d) { - return b + c; + if (t === 1) { + return 1; } - if ((t /= d / 2) < 1) { - return c / 2 * Math.pow(2, 10 * (t - 1)) + b; + t *= 2; + if (t < 1) { + return 0.5 * Math.pow(2, 10 * (t - 1)); } - return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; + return (-Math.pow(2, -10 * (t - 1)) + 2) / 2; }, easeInCirc: function(t) { - return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b; + return -(Math.sqrt(1 - t * t) - 1); }, easeOutCirc: function(t) { - return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; + t -= 1; + return Math.sqrt(1 - t * t); }, easeInOutCirc: function(t) { - if ((t /= d / 2) < 1) { - return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; + t *= 2; + if (t < 1) { + return -(Math.sqrt(1 - t * t) - 1) / 2; } - return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b; + t -= 2; + return (Math.sqrt(1 - t * t) + 1) / 2; }, easeInElastic: function(t) { var s = 1.70158; - var p = 0; - var a = c; + var p = 0.3; if (t === 0) { - return b; + return 0; } - if ((t /= d) === 1) { - return b + c; + if (t === 1) { + return 1; } - if (!p) { - p = d * 0.3; - } - if (a < Math.abs(c)) { - a = c; - var s = p / 4; - } else { - var s = p / (2 * Math.PI) * Math.asin(c / a); - } - return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; + var s = p / (2 * Math.PI) * Math.asin(1); + t -= 1; + return -(Math.pow(2, 10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); }, easeOutElastic: function(t) { var s = 1.70158; - var p = 0; - var a = c; + var p = 0.3; if (t === 0) { - return b; + return 0; } - if ((t /= d) === 1) { - return b + c; + if (t === 1) { + return 1; } - if (!p) { - p = d * 0.3; - } - if (a < Math.abs(c)) { - a = c; - var s = p / 4; - } else { - var s = p / (2 * Math.PI) * Math.asin(c / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b; + var s = p / (2 * Math.PI) * Math.asin(1); + return Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; }, easeInOutElastic: function(t) { var s = 1.70158; - var p = 0; - var a = c; + var p = 0.3 * 1.5; if (t === 0) { - return b; + return 0; } - if ((t /= d / 2) === 2) { - return b + c; - } - if (!p) { - p = d * (0.3 * 1.5); - } - if (a < Math.abs(c)) { - a = c; - var s = p / 4; - } else { - var s = p / (2 * Math.PI) * Math.asin(c / a); + t *= 2; + if (t === 2) { + return 1; } + var s = p / (2 * Math.PI) * Math.asin(1); if (t < 1) { - return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; + t -= 1; + return -(Math.pow(2, 10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)) / 2; } - return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b; + t -= 1; + return Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) / 2 + 1; }, easeInBack: function(t) { var s = 1.70158; - return c * (t /= d) * t * ((s + 1) * t - s) + b; + return t * t * ((s + 1) * t - s); }, easeOutBack: function(t) { var s = 1.70158; - return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; + t -= 1; + return (t * t * ((s + 1) * t + s) + 1); }, easeInOutBack: function(t) { - var s = 1.70158; - if ((t /= d / 2) < 1) { - return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; + var s = 1.70158 * 1.525; + t *= 2; + if (t < 1) { + return (t * t * ((s + 1) * t - s)) / 2; } - return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b; + t -= 2; + return (t * t * ((s + 1) * t + s) + 2) / 2; }, easeInBounce: function(t) { - return c - this.easeOutBounce(d - t) + b; + return 1 - this.easeOutBounce(1 - t); }, easeOutBounce: function(t) { - if ((t /= d) < (1 / 2.75)) { - return c * (7.5625 * t * t) + b; + if (t < (1 / 2.75)) { + return 7.5625 * t * t; } else if (t < (2 / 2.75)) { - return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b; + t -= 1.5 / 2.75; + return 7.5625 * t * t + 0.75; } else if (t < (2.5 / 2.75)) { - return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b; + t -= 2.25 / 2.75; + return 7.5625 * t * t + 0.9375; } else { - return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b; + t -= 2.625 / 2.75; + return 7.5625 * t * t + 0.984375; } }, easeInOutBounce: function(t) { - if (t < d / 2) { - return this.easeInBounce(t * 2) * 0.5 + b; + if (t < 0.5) { + return this.easeInBounce(t * 2) / 2; } - return this.easeOutBounce(t * 2 - d) * 0.5 + c * 0.5 + b; + return this.easeOutBounce(t * 2 - 1) / 2 + 0.5; }, }; diff --git a/Libraries/Animation/LayoutAnimation.js b/Libraries/Animation/LayoutAnimation.js index 5ce5648b3..a5adc567b 100644 --- a/Libraries/Animation/LayoutAnimation.js +++ b/Libraries/Animation/LayoutAnimation.js @@ -6,7 +6,7 @@ 'use strict'; var PropTypes = require('ReactPropTypes'); -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); var keyMirror = require('keyMirror'); @@ -47,7 +47,7 @@ var configChecker = createStrictShapeTypeChecker({ var LayoutAnimation = { configureNext(config, onAnimationDidEnd, onError) { configChecker({config}, 'config', 'LayoutAnimation.configureNext'); - RKUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); + RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); }, create(duration, type, creationProp) { return { diff --git a/Libraries/Animation/__tests__/AnimationUtils-test.js b/Libraries/Animation/__tests__/AnimationUtils-test.js new file mode 100644 index 000000000..00ca67dab --- /dev/null +++ b/Libraries/Animation/__tests__/AnimationUtils-test.js @@ -0,0 +1,46 @@ +'use strict'; + +jest.autoMockOff(); + +var AnimationUtils = require('AnimationUtils'); + +describe('AnimationUtils', function() { + var DURATION = 300; + + var Samples = { + easeInQuad: [0,0.0030864197530864196,0.012345679012345678,0.027777777777777776,0.04938271604938271,0.0771604938271605,0.1111111111111111,0.15123456790123457,0.19753086419753085,0.25,0.308641975308642,0.37345679012345684,0.4444444444444444,0.5216049382716049,0.6049382716049383,0.6944444444444445,0.7901234567901234,0.8919753086419753,1], + easeOutQuad: [0,0.10802469135802469,0.20987654320987653,0.3055555555555555,0.3950617283950617,0.47839506172839513,0.5555555555555556,0.6265432098765432,0.691358024691358,0.75,0.8024691358024691,0.8487654320987654,0.888888888888889,0.9228395061728394,0.9506172839506174,0.9722222222222221,0.9876543209876543,0.9969135802469136,1], + easeInOutQuad: [0,0.006172839506172839,0.024691358024691357,0.05555555555555555,0.09876543209876543,0.154320987654321,0.2222222222222222,0.30246913580246915,0.3950617283950617,0.5,0.6049382716049383,0.697530864197531,0.7777777777777777,0.845679012345679,0.9012345679012346,0.9444444444444444,0.9753086419753086,0.9938271604938271,1], + easeInCubic: [0,0.00017146776406035664,0.0013717421124828531,0.004629629629629629,0.010973936899862825,0.021433470507544586,0.037037037037037035,0.05881344307270234,0.0877914951989026,0.125,0.1714677640603567,0.22822359396433475,0.2962962962962963,0.37671467764060357,0.4705075445816187,0.5787037037037038,0.7023319615912208,0.8424211248285322,1], + easeOutCubic: [0,0.15757887517146785,0.2976680384087792,0.42129629629629617,0.5294924554183813,0.6232853223593964,0.7037037037037036,0.7717764060356652,0.8285322359396433,0.875,0.9122085048010974,0.9411865569272977,0.9629629629629629,0.9785665294924554,0.9890260631001372,0.9953703703703703,0.9986282578875172,0.9998285322359396,1], + easeInOutCubic: [0,0.0006858710562414266,0.0054869684499314125,0.018518518518518517,0.0438957475994513,0.08573388203017834,0.14814814814814814,0.23525377229080935,0.3511659807956104,0.5,0.6488340192043895,0.7647462277091908,0.8518518518518519,0.9142661179698217,0.9561042524005487,0.9814814814814815,0.9945130315500685,0.9993141289437586,1], + easeInQuart: [0,0.000009525986892242035,0.00015241579027587256,0.0007716049382716049,0.002438652644413961,0.005953741807651274,0.012345679012345678,0.02287189452827313,0.039018442310623375,0.0625,0.09525986892242039,0.1394699740893157,0.19753086419753085,0.2720717116293248,0.3659503124523701,0.48225308641975323,0.624295076969974,0.7956199512269471,1], + easeOutQuart: [0,0.20438004877305294,0.375704923030026,0.5177469135802468,0.6340496875476299,0.7279282883706752,0.802469135802469,0.8605300259106843,0.9047401310775796,0.9375,0.9609815576893767,0.9771281054717269,0.9876543209876543,0.9940462581923487,0.997561347355586,0.9992283950617284,0.9998475842097241,0.9999904740131078,1], + easeInOutQuart: [0,0.00007620789513793628,0.0012193263222069805,0.006172839506172839,0.019509221155311687,0.047629934461210194,0.09876543209876543,0.18297515622618504,0.312147538484987,0.5,0.687852461515013,0.8170248437738151,0.9012345679012346,0.9523700655387898,0.9804907788446883,0.9938271604938271,0.998780673677793,0.999923792104862,1], + easeInQuint: [0,5.292214940134463e-7,0.000016935087808430282,0.00012860082304526747,0.000541922809869769,0.0016538171687920206,0.004115226337448559,0.008894625649883995,0.01734152991583261,0.03125,0.05292214940134466,0.08523165083235959,0.1316872427983539,0.1964962361767346,0.28462802079628785,0.401877572016461,0.5549289573066435,0.75141884282545,1], + easeOutQuint: [0,0.24858115717454998,0.4450710426933565,0.598122427983539,0.7153719792037121,0.8035037638232654,0.868312757201646,0.9147683491676404,0.9470778505986553,0.96875,0.9826584700841674,0.991105374350116,0.9958847736625515,0.998346182831208,0.9994580771901302,0.9998713991769548,0.9999830649121916,0.999999470778506,1], + easeInOutQuint: [0,0.000008467543904215141,0.0002709614049348845,0.0020576131687242796,0.008670764957916305,0.02646107470067233,0.06584362139917695,0.14231401039814393,0.27746447865332174,0.5,0.7225355213466782,0.8576859896018563,0.934156378600823,0.9735389252993276,0.9913292350420837,0.9979423868312757,0.9997290385950651,0.9999915324560957,1], + easeInSine: [0,0.003805301908254455,0.01519224698779198,0.03407417371093169,0.06030737921409157,0.09369221296335006,0.1339745962155613,0.1808479557110082,0.233955556881022,0.2928932188134524,0.35721239031346064,0.42642356364895384,0.4999999999999999,0.5773817382593005,0.6579798566743311,0.7411809548974793,0.8263518223330696,0.9128442572523416,0.9999999999999999], + easeOutSine: [0,0.08715574274765817,0.17364817766693033,0.25881904510252074,0.3420201433256687,0.42261826174069944,0.49999999999999994,0.573576436351046,0.6427876096865393,0.7071067811865475,0.766044443118978,0.8191520442889918,0.8660254037844386,0.9063077870366499,0.9396926207859083,0.9659258262890683,0.984807753012208,0.9961946980917455,1], + easeInOutSine: [0,0.00759612349389599,0.030153689607045786,0.06698729810778065,0.116977778440511,0.17860619515673032,0.24999999999999994,0.32898992833716556,0.4131759111665348,0.49999999999999994,0.5868240888334652,0.6710100716628343,0.7499999999999999,0.8213938048432696,0.883022221559489,0.9330127018922194,0.9698463103929542,0.9924038765061041,1], + easeInExpo: [0,0.0014352875901128893,0.002109491677524035,0.0031003926796253885,0.004556754060844206,0.006697218616039631,0.009843133202303688,0.014466792379488908,0.021262343752724643,0.03125,0.045929202883612456,0.06750373368076916,0.09921256574801243,0.1458161299470146,0.2143109957132682,0.31498026247371835,0.46293735614364506,0.6803950000871883,1], + easeOutExpo: [0,0.31960499991281155,0.5370626438563548,0.6850197375262816,0.7856890042867318,0.8541838700529854,0.9007874342519875,0.9324962663192309,0.9540707971163875,0.96875,0.9787376562472754,0.9855332076205111,0.9901568667976963,0.9933027813839603,0.9954432459391558,0.9968996073203746,0.9978905083224759,0.9985647124098871,1], + easeInOutExpo: [0,0.0010547458387620175,0.002278377030422103,0.004921566601151844,0.010631171876362321,0.022964601441806228,0.049606282874006216,0.1071554978566341,0.23146867807182253,0.5,0.7685313219281775,0.892844502143366,0.9503937171259937,0.9770353985581938,0.9893688281236377,0.9950784333988482,0.9977216229695779,0.998945254161238,1], + easeInCirc: [0,0.0015444024660317135,0.006192010000093506,0.013986702816730645,0.025003956956430873,0.03935464078941209,0.057190958417936644,0.07871533601238889,0.10419358352238339,0.1339745962155614,0.1685205807169019,0.20845517506805522,0.2546440075000701,0.3083389112228482,0.37146063894529113,0.4472292016074334,0.5418771527091488,0.6713289009389102,1], + easeOutCirc: [0,0.3286710990610898,0.45812284729085123,0.5527707983925666,0.6285393610547089,0.6916610887771518,0.7453559924999298,0.7915448249319448,0.8314794192830981,0.8660254037844386,0.8958064164776166,0.9212846639876111,0.9428090415820634,0.9606453592105879,0.9749960430435691,0.9860132971832694,0.9938079899999065,0.9984555975339683,1], + easeInOutCirc: [0,0.003096005000046753,0.012501978478215436,0.028595479208968322,0.052096791761191696,0.08426029035845095,0.12732200375003505,0.18573031947264557,0.2709385763545744,0.5,0.7290614236454256,0.8142696805273546,0.8726779962499649,0.915739709641549,0.9479032082388084,0.9714045207910317,0.9874980215217846,0.9969039949999532,1], + easeInElastic: [0,0.0008570943160003016,0.0020526300563455885,0.0005383775388688477,-0.003807112477441741,-0.005595444524068916,0.0017092421431128787,0.014076838118604966,0.012696991251677569,-0.015625000000000045,-0.045618646044515744,-0.01936028903971309,0.07600123467884114,0.13030605320629246,-0.012461076179381799,-0.29598462833976175,-0.3176868895106366,0.2694906924487451,1], + easeOutElastic: [0,0.7305093075512543,1.3176868895106364,1.2959846283397618,1.0124610761793817,0.8696939467937076,0.9239987653211588,1.019360289039713,1.0456186460445158,1.015625,0.9873030087483224,0.9859231618813951,0.9982907578568871,1.005595444524069,1.0038071124774417,0.9994616224611311,0.9979473699436544,0.9991429056839997,1], + easeInOutElastic: [0,0.0010420781824747765,-0.0003083357248478688,-0.004888288728445655,0.0010292130059457788,0.022895545534212507,-0.0028843488305936938,-0.10707491183281304,0.004488485931276091,0.5,0.995511514068724,1.107074911832813,1.0028843488305939,0.9771044544657875,0.9989707869940542,1.0048882887284456,1.000308335724848,0.9989579218175252,1], + easeInBack: [0,-0.004788556241426612,-0.017301289437585736,-0.0347587962962963,-0.05438167352537723,-0.07339051783264748,-0.08900592592592595,-0.09844849451303156,-0.0989388203017833,-0.08769750000000004,-0.06194513031550073,-0.018902307956104283,0.044210370370370254,0.13017230795610413,0.2417629080932785,0.3817615740740742,0.5529477091906719,0.7581007167352535,0.9999999999999998], + easeOutBack: [2.220446049250313e-16,0.24189928326474652,0.44705229080932807,0.6182384259259258,0.7582370919067215,0.8698276920438959,0.9557896296296297,1.0189023079561044,1.0619451303155008,1.0876975,1.0989388203017834,1.0984484945130315,1.089005925925926,1.0733905178326475,1.0543816735253773,1.0347587962962963,1.0173012894375857,1.0047885562414267,1], + easeInOutBack: [0,-0.01355231550068587,-0.04434668449931412,-0.07758924074074074,-0.09848611796982167,-0.0922434499314129,-0.0440673703703704,0.060835986968449905,0.237260488340192,0.5,0.762739511659808,0.9391640130315503,1.0440673703703702,1.0922434499314129,1.0984861179698218,1.0775892407407408,1.0443466844993141,1.0135523155006858,1], + }; + + Object.keys(Samples).forEach(function(type) { + it('should interpolate ' + type, function() { + expect(AnimationUtils.evaluateEasingFunction(DURATION, type)) + .toEqual(Samples[type]); + }); + }); +}); diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index ca5a7e607..47834936a 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -5,22 +5,17 @@ */ 'use strict'; -var NativeModules = require('NativeModulesDeprecated'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKAppState = NativeModules.RKAppState; -var RKReachability = NativeModules.RKReachability; -var Subscribable = require('Subscribable'); - -var keyMirror = require('keyMirror'); +var NativeModules = require('NativeModules'); +var RCTAppState = NativeModules.RCTAppState; var AppState = { setApplicationIconBadgeNumber: function(number) { - RKAppState.setApplicationIconBadgeNumber(number); + RCTAppState.setApplicationIconBadgeNumber(number); }, getApplicationIconBadgeNumber: function(callback) { - RKAppState.getApplicationIconBadgeNumber(callback); + RCTAppState.getApplicationIconBadgeNumber(callback); }, }; diff --git a/Libraries/AppStateIOS/AppStateIOS.ios.js b/Libraries/AppStateIOS/AppStateIOS.ios.js index 8f03654b5..1f6bca95b 100644 --- a/Libraries/AppStateIOS/AppStateIOS.ios.js +++ b/Libraries/AppStateIOS/AppStateIOS.ios.js @@ -7,7 +7,7 @@ var NativeModules = require('NativeModules'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKAppState = NativeModules.RKAppState; +var RCTAppState = NativeModules.RCTAppState; var logError = require('logError'); @@ -45,7 +45,7 @@ RCTDeviceEventEmitter.addListener( } ); -RKAppState.getCurrentAppState( +RCTAppState.getCurrentAppState( (appStateData) => { AppStateIOS.currentState = appStateData.app_state; }, diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js index 680528575..f8029f8b8 100644 --- a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js +++ b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js @@ -7,10 +7,8 @@ var NativeModules = require('BatchedBridge').RemoteModules; -// Dirty hack to support old (RK) and new (RCT) native module name conventions -Object.keys(NativeModules).forEach((moduleName) => { - var rkModuleName = moduleName.replace(/^RCT/, 'RK'); - NativeModules[rkModuleName] = NativeModules[moduleName]; -}); +var nativeModulePrefixDuplicator = require('nativeModulePrefixDuplicator'); + +nativeModulePrefixDuplicator(NativeModules); module.exports = NativeModules; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js deleted file mode 100644 index 2d83d6f9a..000000000 --- a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule NativeModulesDeprecated - */ -'use strict'; - -var RemoteModulesDeprecated = require('BatchedBridge').RemoteModulesDeprecated; - -// Dirty hack to support old (RK) and new (RCT) native module name conventions -Object.keys(RemoteModulesDeprecated).forEach((moduleName) => { - var rkModuleName = moduleName.replace(/^RCT/, 'RK'); - RemoteModulesDeprecated[rkModuleName] = RemoteModulesDeprecated[moduleName]; -}); - -module.exports = RemoteModulesDeprecated; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js b/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js index 8ec0bd62f..3195e3ee1 100644 --- a/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js +++ b/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js @@ -5,8 +5,8 @@ */ 'use strict'; -var RKPOPAnimationManager = require('NativeModulesDeprecated').RKPOPAnimationManager; -if (!RKPOPAnimationManager) { +var RCTPOPAnimationManager = require('NativeModules').RCTPOPAnimationManager; +if (!RCTPOPAnimationManager) { // POP animation isn't available in the OSS fork - this is a temporary // workaround to enable its availability to be determined at runtime. module.exports = null; @@ -18,45 +18,45 @@ var getObjectValues = require('getObjectValues'); var invariant = require('invariant'); var merge = require('merge'); -var RKTypes = RKPOPAnimationManager.Types; -var RKProperties = RKPOPAnimationManager.Properties; +var RCTTypes = RCTPOPAnimationManager.Types; +var RCTProperties = RCTPOPAnimationManager.Properties; var Properties = { - bounds: RKProperties.bounds, - opacity: RKProperties.opacity, - position: RKProperties.position, - positionX: RKProperties.positionX, - positionY: RKProperties.positionY, - zPosition: RKProperties.zPosition, - rotation: RKProperties.rotation, - rotationX: RKProperties.rotationX, - rotationY: RKProperties.rotationY, - scaleX: RKProperties.scaleX, - scaleXY: RKProperties.scaleXY, - scaleY: RKProperties.scaleY, - shadowColor: RKProperties.shadowColor, - shadowOffset: RKProperties.shadowOffset, - shadowOpacity: RKProperties.shadowOpacity, - shadowRadius: RKProperties.shadowRadius, - size: RKProperties.size, - subscaleXY: RKProperties.subscaleXY, - subtranslationX: RKProperties.subtranslationX, - subtranslationXY: RKProperties.subtranslationXY, - subtranslationY: RKProperties.subtranslationY, - subtranslationZ: RKProperties.subtranslationZ, - translationX: RKProperties.translationX, - translationXY: RKProperties.translationXY, - translationY: RKProperties.translationY, - translationZ: RKProperties.translationZ, + bounds: RCTProperties.bounds, + opacity: RCTProperties.opacity, + position: RCTProperties.position, + positionX: RCTProperties.positionX, + positionY: RCTProperties.positionY, + zPosition: RCTProperties.zPosition, + rotation: RCTProperties.rotation, + rotationX: RCTProperties.rotationX, + rotationY: RCTProperties.rotationY, + scaleX: RCTProperties.scaleX, + scaleXY: RCTProperties.scaleXY, + scaleY: RCTProperties.scaleY, + shadowColor: RCTProperties.shadowColor, + shadowOffset: RCTProperties.shadowOffset, + shadowOpacity: RCTProperties.shadowOpacity, + shadowRadius: RCTProperties.shadowRadius, + size: RCTProperties.size, + subscaleXY: RCTProperties.subscaleXY, + subtranslationX: RCTProperties.subtranslationX, + subtranslationXY: RCTProperties.subtranslationXY, + subtranslationY: RCTProperties.subtranslationY, + subtranslationZ: RCTProperties.subtranslationZ, + translationX: RCTProperties.translationX, + translationXY: RCTProperties.translationXY, + translationY: RCTProperties.translationY, + translationZ: RCTProperties.translationZ, }; var Types = { - decay: RKTypes.decay, - easeIn: RKTypes.easeIn, - easeInEaseOut: RKTypes.easeInEaseOut, - easeOut: RKTypes.easeOut, - linear: RKTypes.linear, - spring: RKTypes.spring, + decay: RCTTypes.decay, + easeIn: RCTTypes.easeIn, + easeInEaseOut: RCTTypes.easeInEaseOut, + easeOut: RCTTypes.easeOut, + linear: RCTTypes.linear, + spring: RCTTypes.spring, }; var POPAnimation = { @@ -98,7 +98,7 @@ var POPAnimation = { ); } - RKPOPAnimationManager.createAnimationInternal(tag, typeName, attrs); + RCTPOPAnimationManager.createAnimationInternal(tag, typeName, attrs); return tag; }, @@ -127,35 +127,35 @@ var POPAnimation = { }, addAnimation: function(nodeHandle, anim, callback) { - RKPOPAnimationManager.addAnimation(nodeHandle, anim, callback); + RCTPOPAnimationManager.addAnimation(nodeHandle, anim, callback); }, removeAnimation: function(nodeHandle, anim) { - RKPOPAnimationManager.removeAnimation(nodeHandle, anim); + RCTPOPAnimationManager.removeAnimation(nodeHandle, anim); }, }; -// Make sure that we correctly propagate RKPOPAnimationManager constants +// Make sure that we correctly propagate RCTPOPAnimationManager constants // to POPAnimation if (__DEV__) { var allProperties = merge( - RKPOPAnimationManager.Properties, - RKPOPAnimationManager.Properties + RCTPOPAnimationManager.Properties, + RCTPOPAnimationManager.Properties ); for (var key in allProperties) { invariant( - POPAnimation.Properties[key] === RKPOPAnimationManager.Properties[key], + POPAnimation.Properties[key] === RCTPOPAnimationManager.Properties[key], 'POPAnimation doesn\'t copy property ' + key + ' correctly' ); } var allTypes = merge( - RKPOPAnimationManager.Types, - RKPOPAnimationManager.Types + RCTPOPAnimationManager.Types, + RCTPOPAnimationManager.Types ); for (var key in allTypes) { invariant( - POPAnimation.Types[key] === RKPOPAnimationManager.Types[key], + POPAnimation.Types[key] === RCTPOPAnimationManager.Types[key], 'POPAnimation doesn\'t copy type ' + key + ' correctly' ); } diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js b/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js new file mode 100644 index 000000000..3621795da --- /dev/null +++ b/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js @@ -0,0 +1,10 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule RCTAlertManager + */ +'use strict'; + +var { RCTAlertManager } = require('NativeModules'); + +module.exports = RCTAlertManager; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js b/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js deleted file mode 100644 index 39d3cbc27..000000000 --- a/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule RKAlertManager - */ -'use strict'; - -var RKAlertManager = require('NativeModulesDeprecated').RKAlertManager; - -module.exports = RKAlertManager; diff --git a/Libraries/BatchedBridge/BatchingImplementation/BatchedBridgeFactory.js b/Libraries/BatchedBridge/BatchingImplementation/BatchedBridgeFactory.js index d6c7f5f3f..a41a13226 100644 --- a/Libraries/BatchedBridge/BatchingImplementation/BatchedBridgeFactory.js +++ b/Libraries/BatchedBridge/BatchingImplementation/BatchedBridgeFactory.js @@ -22,33 +22,6 @@ var MethodTypes = keyMirror({ */ var BatchedBridgeFactory = { MethodTypes: MethodTypes, - /** - * @deprecated: Remove callsites and delete this method. - * - * @param {MessageQueue} messageQueue Message queue that has been created with - * the `moduleConfig` (among others perhaps). - * @param {object} moduleConfig Configuration of module names/method - * names to callback types. - * @return {object} Remote representation of configured module. - */ - _createDeprecatedBridgedModule: function(messageQueue, moduleConfig, moduleName) { - var remoteModule = mapObject(moduleConfig.methods, function(methodConfig, memberName) { - return methodConfig.type === MethodTypes.local ? null : function() { - var lastArg = arguments.length ? arguments[arguments.length - 1] : null; - var hasCB = - typeof lastArg == 'function'; - var args = slice.call(arguments, 0, arguments.length - (hasCB ? 1 : 0)); - var cb = hasCB ? lastArg : null; - return messageQueue.callDeprecated(moduleName, memberName, args, cb); - }; - }); - for (var constName in moduleConfig.constants) { - warning(!remoteModule[constName], 'saw constant and method named %s', constName); - remoteModule[constName] = moduleConfig.constants[constName]; - } - return remoteModule; - }, - /** * @param {MessageQueue} messageQueue Message queue that has been created with * the `moduleConfig` (among others perhaps). @@ -63,14 +36,14 @@ var BatchedBridgeFactory = { var secondLastArg = arguments.length > 1 ? arguments[arguments.length - 2] : null; var hasSuccCB = typeof lastArg === 'function'; var hasErrorCB = typeof secondLastArg === 'function'; - var hasCBs = hasSuccCB; - invariant( - (hasSuccCB && hasErrorCB) || (!hasSuccCB && !hasErrorCB), - 'You must supply error callbacks and success callbacks or neither' + hasErrorCB && invariant( + hasSuccCB, + 'Cannot have a non-function arg after a function arg.' ); - var args = slice.call(arguments, 0, arguments.length - (hasCBs ? 2 : 0)); - var onSucc = hasCBs ? lastArg : null; - var onFail = hasCBs ? secondLastArg : null; + var numCBs = (hasSuccCB ? 1 : 0) + (hasErrorCB ? 1 : 0); + var args = slice.call(arguments, 0, arguments.length - numCBs); + var onSucc = hasSuccCB ? lastArg : null; + var onFail = hasErrorCB ? secondLastArg : null; return messageQueue.call(moduleName, memberName, args, onFail, onSucc); }; }); @@ -92,8 +65,6 @@ var BatchedBridgeFactory = { invokeCallbackAndReturnFlushedQueue: messageQueue.invokeCallbackAndReturnFlushedQueue.bind(messageQueue), flushedQueue: messageQueue.flushedQueue.bind(messageQueue), - // These deprecated modules do not accept an error callback. - RemoteModulesDeprecated: mapObject(modulesConfig, this._createDeprecatedBridgedModule.bind(this, messageQueue)), RemoteModules: mapObject(modulesConfig, this._createBridgedModule.bind(this, messageQueue)), setLoggingEnabled: messageQueue.setLoggingEnabled.bind(messageQueue), getLoggedOutgoingItems: messageQueue.getLoggedOutgoingItems.bind(messageQueue), diff --git a/Libraries/CameraRoll/CameraRoll.js b/Libraries/CameraRoll/CameraRoll.js index 54295fc52..d97fa8ce2 100644 --- a/Libraries/CameraRoll/CameraRoll.js +++ b/Libraries/CameraRoll/CameraRoll.js @@ -6,7 +6,7 @@ 'use strict'; var ReactPropTypes = require('ReactPropTypes'); -var RKCameraRollManager = require('NativeModules').RKCameraRollManager; +var RCTCameraRollManager = require('NativeModules').RCTCameraRollManager; var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); var deepFreezeAndThrowOnMutationInDev = @@ -98,7 +98,7 @@ class CameraRoll { typeof tag === 'string', 'CameraRoll.saveImageWithTag tag must be a valid string.' ); - RKCameraRollManager.saveImageWithTag( + RCTCameraRollManager.saveImageWithTag( tag, (imageTag) => { successCallback && successCallback(imageTag); @@ -140,7 +140,7 @@ class CameraRoll { callback(response); }; } - RKCameraRollManager.getPhotos(params, metaCallback, errorCallback); + RCTCameraRollManager.getPhotos(params, metaCallback, errorCallback); } } diff --git a/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js b/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js index df762c5ee..c494e031c 100644 --- a/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js +++ b/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js @@ -53,7 +53,7 @@ var ActivityIndicatorIOS = React.createClass({ render: function() { var style = styles.sizeSmall; - var NativeConstants = NativeModules.RKUIManager.UIActivityIndicatorView.Constants; + var NativeConstants = NativeModules.RCTUIManager.UIActivityIndicatorView.Constants; var activityIndicatorViewStyle = NativeConstants.StyleWhite; if (this.props.size === 'large') { style = styles.sizeLarge; diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index b4a6d5bb1..c45672d65 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule DatePickerIOS * - * This is a controlled component version of RKDatePickerIOS + * This is a controlled component version of RCTDatePickerIOS */ 'use strict'; @@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); var React = require('React'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKDatePickerIOSConsts = require('NativeModules').RKUIManager.RCTDatePicker.Constants; +var RCTDatePickerIOSConsts = require('NativeModules').RCTUIManager.RCTDatePicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); @@ -65,7 +65,7 @@ var DatePickerIOS = React.createClass({ * * Valid modes on iOS are: 'date', 'time', 'datetime'. */ - mode: PropTypes.oneOf(Object.keys(RKDatePickerIOSConsts.DatePickerModes)), + mode: PropTypes.oneOf(Object.keys(RCTDatePickerIOSConsts.DatePickerModes)), /** * The interval at which minutes can be selected. @@ -111,7 +111,7 @@ var DatePickerIOS = React.createClass({ var props = this.props; return ( - + ); }, }); @@ -70,12 +70,12 @@ var NavigatorTransitionerIOS = React.createClass({ /** * Think of `` as simply a component that renders an - * `RKNavigator`, and moves the `RKNavigator`'s `requestedTopOfStack` pointer - * forward and backward. The `RKNavigator` interprets changes in + * `RCTNavigator`, and moves the `RCTNavigator`'s `requestedTopOfStack` pointer + * forward and backward. The `RCTNavigator` interprets changes in * `requestedTopOfStack` to be pushes and pops of children that are rendered. * `` always ensures that whenever the `requestedTopOfStack` * pointer is moved, that we've also rendered enough children so that the - * `RKNavigator` can carry out the push/pop with those children. + * `RCTNavigator` can carry out the push/pop with those children. * `` also removes children that will no longer be needed * (after the pop of a child has been fully completed/animated out). */ @@ -496,7 +496,7 @@ var NavigatorIOS = React.createClass({ return ( - - + ); }, diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 4221722bd..b8f4c96c6 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -6,14 +6,14 @@ 'use strict'; var NativeModules = require('NativeModules'); -var NativeModulesDeprecated = require('NativeModulesDeprecated'); +var NativeModules = require('NativeModules'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var Subscribable = require('Subscribable'); var TextInputState = require('TextInputState'); -var RKUIManager = NativeModules.RKUIManager; -var RKUIManagerDeprecated = NativeModulesDeprecated.RKUIManager; -var RKScrollViewConsts = RKUIManager.RCTScrollView.Constants; +var RCTUIManager = NativeModules.RCTUIManager; +var RCTUIManagerDeprecated = NativeModules.RCTUIManager; +var RCTScrollViewConsts = RCTUIManager.RCTScrollView.Constants; var warning = require('warning'); @@ -99,7 +99,7 @@ var IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16; var ScrollResponderMixin = { mixins: [Subscribable.Mixin], - statics: RKScrollViewConsts, + statics: RCTScrollViewConsts, scrollResponderMixinGetInitialState: function() { return { isTouching: false, @@ -336,7 +336,7 @@ var ScrollResponderMixin = { * can also be used to quickly scroll to any element we want to focus */ scrollResponderScrollTo: function(offsetX, offsetY) { - RKUIManagerDeprecated.scrollTo(this.getNodeHandle(), offsetX, offsetY); + RCTUIManagerDeprecated.scrollTo(this.getNodeHandle(), offsetX, offsetY); }, /** @@ -344,7 +344,7 @@ var ScrollResponderMixin = { * @param {object} rect Should have shape {x, y, w, h} */ scrollResponderZoomTo: function(rect) { - RKUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect); + RCTUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect); }, /** @@ -354,7 +354,7 @@ var ScrollResponderMixin = { */ scrollResponderScrollNativeHandleToKeyboard: function(nodeHandle, additionalOffset) { this.additionalScrollOffset = additionalOffset || 0; - RKUIManager.measureLayout( + RCTUIManager.measureLayout( nodeHandle, this.getNodeHandle(), this.scrollResponderTextInputFocusError, diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 4edfeda81..804b6f578 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -8,12 +8,12 @@ var EdgeInsetsPropType = require('EdgeInsetsPropType'); var Platform = require('Platform'); var PointPropType = require('PointPropType'); -var RCTScrollView = require('NativeModules').RKUIManager.RCTScrollView; +var RCTScrollView = require('NativeModules').RCTUIManager.RCTScrollView; var RCTScrollViewConsts = RCTScrollView.Constants; var React = require('React'); var ReactIOSTagHandles = require('ReactIOSTagHandles'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKUIManager = require('NativeModulesDeprecated').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; var ScrollResponder = require('ScrollResponder'); var StyleSheet = require('StyleSheet'); var StyleSheetPropType = require('StyleSheetPropType'); @@ -182,7 +182,7 @@ var ScrollView = React.createClass({ }, scrollTo: function(destY, destX) { - RKUIManager.scrollTo( + RCTUIManager.scrollTo( this.getNodeHandle(), destX || 0, destY || 0 diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index 80f631c45..a0be43066 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -60,7 +60,7 @@ var Slider = React.createClass({ render: function() { return ( - resp.network_reachability, - * RKReachability.getCurrentReachability + * RCTReachability.getCurrentReachability * ); * * var myComponent = React.createClass({ diff --git a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js b/Libraries/Components/SwitchIOS/SwitchIOS.ios.js index 391b4da3a..15c0af5aa 100644 --- a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js +++ b/Libraries/Components/SwitchIOS/SwitchIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule SwitchIOS * - * This is a controlled component version of RKSwitch. + * This is a controlled component version of RCTSwitch. */ 'use strict'; @@ -80,7 +80,7 @@ var SwitchIOS = React.createClass({ render: function() { return ( - + {this.props.children} - + ); } }); @@ -31,6 +31,6 @@ var config = { validAttributes: ReactIOSViewAttributes.UIView, uiViewClassName: 'RCTTabBar', }; -var RKTabBar = createReactIOSNativeComponentClass(config); +var RCTTabBar = createReactIOSNativeComponentClass(config); module.exports = TabBarIOS; diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 763be7438..70333d54e 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -58,7 +58,7 @@ var TabBarItemIOS = React.createClass({ } return ( - {tabContents} - + ); } }); @@ -80,7 +80,7 @@ var styles = StyleSheet.create({ } }); -var RKTabBarItem = createReactIOSNativeComponentClass({ +var RCTTabBarItem = createReactIOSNativeComponentClass({ validAttributes: merge(ReactIOSViewAttributes.UIView, { title: true, icon: true, diff --git a/Libraries/Components/TextInput/TextInput.ios.js b/Libraries/Components/TextInput/TextInput.ios.js index e04ed88ee..21ad49f53 100644 --- a/Libraries/Components/TextInput/TextInput.ios.js +++ b/Libraries/Components/TextInput/TextInput.ios.js @@ -8,7 +8,7 @@ var DocumentSelectionState = require('DocumentSelectionState'); var EventEmitter = require('EventEmitter'); var NativeMethodsMixin = require('NativeMethodsMixin'); -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; var PropTypes = require('ReactPropTypes'); var React = require('React'); var ReactChildren = require('ReactChildren'); @@ -25,10 +25,10 @@ var getObjectValues = require('getObjectValues'); var invariant = require('invariant'); var merge = require('merge'); -var autoCapitalizeConsts = RKUIManager.UIText.AutocapitalizationType; -var clearButtonModeConsts = RKUIManager.UITextField.clearButtonMode; +var autoCapitalizeConsts = RCTUIManager.UIText.AutocapitalizationType; +var clearButtonModeConsts = RCTUIManager.UITextField.clearButtonMode; -var RKTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { +var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { autoCorrect: true, autoCapitalize: true, color: true, @@ -42,7 +42,7 @@ var RKTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { text: true, }); -var RKTextFieldAttributes = merge(RKTextViewAttributes, { +var RCTTextFieldAttributes = merge(RCTTextViewAttributes, { caretHidden: true, enabled: true, clearButtonMode: true, @@ -198,7 +198,7 @@ var TextInput = React.createClass({ viewConfig: { uiViewClassName: 'RCTTextField', - validAttributes: RKTextFieldAttributes, + validAttributes: RCTTextFieldAttributes, }, isFocused: function() { @@ -309,7 +309,7 @@ var TextInput = React.createClass({ } } textContainer = - ; + return ; }, }); -var RKView = createReactIOSNativeComponentClass({ - validAttributes: ReactIOSViewAttributes.RKView, +var RCTView = createReactIOSNativeComponentClass({ + validAttributes: ReactIOSViewAttributes.RCTView, uiViewClassName: 'RCTView', }); -RKView.propTypes = View.propTypes; +RCTView.propTypes = View.propTypes; -var ViewToExport = RKView; +var ViewToExport = RCTView; if (__DEV__) { ViewToExport = View; } diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 8190258ae..d153ebe92 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -16,9 +16,9 @@ var keyMirror = require('keyMirror'); var merge = require('merge'); var PropTypes = React.PropTypes; -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; -var RK_WEBVIEW_REF = 'webview'; +var RCT_WEBVIEW_REF = 'webview'; var WebViewState = keyMirror({ IDLE: null, @@ -81,7 +81,7 @@ var WebView = React.createClass({ var webView = { var prettyStack = errorToString(e, map); - RKExceptionsManager.updateExceptionMessage(e.message, prettyStack); + RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack); }) .then(null, error => { GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + error.message); @@ -95,7 +95,7 @@ function setupRedBoxErrorHandler() { /** * Sets up a set of window environment wrappers that ensure that the * BatchedBridge is flushed after each tick. In both the case of the - * `UIWebView` based `RKJavaScriptCaller` and `RKContextCaller`, we + * `UIWebView` based `RCTJavaScriptCaller` and `RCTContextCaller`, we * implement our own custom timing bridge that should be immune to * unexplainably dropped timing signals. */ @@ -115,7 +115,7 @@ function setupTimers() { } function setupAlert() { - var RKAlertManager = require('RKAlertManager'); + var { RCTAlertManager } = require('NativeModules'); if (!GLOBAL.alert) { GLOBAL.alert = function(text) { var alertOpts = { @@ -123,7 +123,7 @@ function setupAlert() { message: '' + text, buttons: [{'cancel': 'Okay'}], }; - RKAlertManager.alertWithArgs(alertOpts, null); + RCTAlertManager.alertWithArgs(alertOpts, null); }; } } diff --git a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js index 13297ef00..1b25e00c1 100644 --- a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js +++ b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js @@ -7,7 +7,7 @@ // Note that the module JSTimers is split into two in order to solve a cycle // in dependencies. NativeModules > BatchedBridge > MessageQueue > JSTimersExecution -var RKTiming = require('NativeModules').RKTiming; +var RCTTiming = require('NativeModules').RCTTiming; var JSTimersExecution = require('JSTimersExecution'); /** @@ -43,7 +43,7 @@ var JSTimers = { return func.apply(undefined, args); }; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setTimeout; - RKTiming.createTimer(newID, duration, Date.now(), /** recurring */ false); + RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ false); return newID; }, @@ -60,7 +60,7 @@ var JSTimers = { return func.apply(undefined, args); }; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval; - RKTiming.createTimer(newID, duration, Date.now(), /** recurring */ true); + RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ true); return newID; }, @@ -90,7 +90,7 @@ var JSTimers = { JSTimersExecution.timerIDs[freeIndex] = newID; JSTimersExecution.callbacks[freeIndex] = func; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.requestAnimationFrame; - RKTiming.createTimer(newID, 0, Date.now(), /** recurring */ false); + RCTTiming.createTimer(newID, 0, Date.now(), /** recurring */ false); return newID; }, @@ -126,7 +126,7 @@ var JSTimers = { if (index !== -1) { JSTimersExecution._clearIndex(index); if (JSTimersExecution.types[index] !== JSTimersExecution.Type.setImmediate) { - RKTiming.deleteTimer(timerID); + RCTTiming.deleteTimer(timerID); } } }, diff --git a/Libraries/Network/NetInfo.js b/Libraries/Network/NetInfo.js index 59c29cb07..671b064a2 100644 --- a/Libraries/Network/NetInfo.js +++ b/Libraries/Network/NetInfo.js @@ -8,7 +8,7 @@ var NativeModules = require('NativeModules'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKReachability = NativeModules.RKReachability; +var RCTReachability = NativeModules.RCTReachability; var DEVICE_REACHABILITY_EVENT = 'reachabilityDidChange'; @@ -49,7 +49,7 @@ type ChangeEventName = $Enum<{ var NetInfo = {}; -if (RKReachability) { +if (RCTReachability) { var _reachabilitySubscriptions = {}; NetInfo.reachabilityIOS = { @@ -78,7 +78,7 @@ if (RKReachability) { fetch: function(): Promise { return new Promise((resolve, reject) => { - RKReachability.getCurrentReachability( + RCTReachability.getCurrentReachability( (resp) => { resolve(resp.network_reachability); }, diff --git a/Libraries/Network/XMLHttpRequest.ios.js b/Libraries/Network/XMLHttpRequest.ios.js index 042cbe4b9..b747d0bed 100644 --- a/Libraries/Network/XMLHttpRequest.ios.js +++ b/Libraries/Network/XMLHttpRequest.ios.js @@ -6,7 +6,7 @@ */ 'use strict'; -var RKDataManager = require('NativeModulesDeprecated').RKDataManager; +var RCTDataManager = require('NativeModules').RCTDataManager; var crc32 = require('crc32'); @@ -91,7 +91,7 @@ class XMLHttpRequest { } this._sent = true; - RKDataManager.queryData( + RCTDataManager.queryData( 'http', JSON.stringify({ method: this._method, diff --git a/Libraries/Picker/PickerIOS.android.js b/Libraries/Picker/PickerIOS.android.js index 72cc87a75..51103157a 100644 --- a/Libraries/Picker/PickerIOS.android.js +++ b/Libraries/Picker/PickerIOS.android.js @@ -3,7 +3,7 @@ * * @providesModule PickerIOS * - * This is a controlled component version of RKPickerIOS + * This is a controlled component version of RCTPickerIOS */ 'use strict'; diff --git a/Libraries/Picker/PickerIOS.ios.js b/Libraries/Picker/PickerIOS.ios.js index 04559a700..c2d1c2241 100644 --- a/Libraries/Picker/PickerIOS.ios.js +++ b/Libraries/Picker/PickerIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule PickerIOS * - * This is a controlled component version of RKPickerIOS + * This is a controlled component version of RCTPickerIOS */ 'use strict'; @@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var React = require('React'); var ReactChildren = require('ReactChildren'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKPickerIOSConsts = require('NativeModules').RKUIManager.RCTPicker.Constants; +var RCTPickerIOSConsts = require('NativeModules').RCTUIManager.RCTPicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); @@ -37,7 +37,7 @@ var PickerIOS = React.createClass({ this.setState(this._stateFromProps(nextProps)); }, - // Translate PickerIOS prop and children into stuff that RKPickerIOS understands. + // Translate PickerIOS prop and children into stuff that RCTPickerIOS understands. _stateFromProps: function(props) { var selectedIndex = 0; var items = []; @@ -53,7 +53,7 @@ var PickerIOS = React.createClass({ render: function() { return ( - , rootTag diff --git a/Libraries/Storage/AsyncStorage.ios.js b/Libraries/Storage/AsyncStorage.ios.js index a29288f36..754e59cb1 100644 --- a/Libraries/Storage/AsyncStorage.ios.js +++ b/Libraries/Storage/AsyncStorage.ios.js @@ -6,12 +6,12 @@ */ 'use strict'; -var NativeModules = require('NativeModulesDeprecated'); -var RKAsyncLocalStorage = NativeModules.RKAsyncLocalStorage; -var RKAsyncRocksDBStorage = NativeModules.RKAsyncRocksDBStorage; +var NativeModules = require('NativeModules'); +var RCTAsyncLocalStorage = NativeModules.RCTAsyncLocalStorage; +var RCTAsyncRocksDBStorage = NativeModules.RCTAsyncRocksDBStorage; // We use RocksDB if available. -var RKAsyncStorage = RKAsyncRocksDBStorage || RKAsyncLocalStorage; +var RCTAsyncStorage = RCTAsyncRocksDBStorage || RCTAsyncLocalStorage; /** * AsyncStorage is a simple, asynchronous, persistent, global, key-value storage @@ -33,7 +33,7 @@ var AsyncStorage = { key: string, callback: (error: ?Error, result: ?string) => void ): void { - RKAsyncStorage.multiGet([key], function(errors, result) { + RCTAsyncStorage.multiGet([key], function(errors, result) { // Unpack result to get value from [[key,value]] var value = (result && result[0] && result[0][1]) ? result[0][1] : null; callback((errors && convertError(errors[0])) || null, value); @@ -49,7 +49,7 @@ var AsyncStorage = { value: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiSet([[key,value]], function(errors) { + RCTAsyncStorage.multiSet([[key,value]], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -58,7 +58,7 @@ var AsyncStorage = { key: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiRemove([key], function(errors) { + RCTAsyncStorage.multiRemove([key], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -73,7 +73,7 @@ var AsyncStorage = { value: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiMerge([[key,value]], function(errors) { + RCTAsyncStorage.multiMerge([[key,value]], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -84,7 +84,7 @@ var AsyncStorage = { * own keys instead. */ clear: function(callback: ?(error: ?Error) => void) { - RKAsyncStorage.clear(function(error) { + RCTAsyncStorage.clear(function(error) { callback && callback(convertError(error)); }); }, @@ -93,7 +93,7 @@ var AsyncStorage = { * Gets *all* keys known to the system, for all callers, libraries, etc. */ getAllKeys: function(callback: (error: ?Error) => void) { - RKAsyncStorage.getAllKeys(function(error, keys) { + RCTAsyncStorage.getAllKeys(function(error, keys) { callback(convertError(error), keys); }); }, @@ -118,7 +118,7 @@ var AsyncStorage = { keys: Array, callback: (errors: ?Array, result: ?Array>) => void ): void { - RKAsyncStorage.multiGet(keys, function(errors, result) { + RCTAsyncStorage.multiGet(keys, function(errors, result) { callback( (errors && errors.map((error) => convertError(error))) || null, result @@ -136,7 +136,7 @@ var AsyncStorage = { keyValuePairs: Array>, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiSet(keyValuePairs, function(errors) { + RCTAsyncStorage.multiSet(keyValuePairs, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -150,7 +150,7 @@ var AsyncStorage = { keys: Array, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiRemove(keys, function(errors) { + RCTAsyncStorage.multiRemove(keys, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -167,7 +167,7 @@ var AsyncStorage = { keyValuePairs: Array>, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiMerge(keyValuePairs, function(errors) { + RCTAsyncStorage.multiMerge(keyValuePairs, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -176,7 +176,7 @@ var AsyncStorage = { }; // Not all native implementations support merge. -if (!RKAsyncStorage.multiMerge) { +if (!RCTAsyncStorage.multiMerge) { delete AsyncStorage.mergeItem; delete AsyncStorage.multiMerge; } diff --git a/Libraries/StyleSheet/StyleSheet.js b/Libraries/StyleSheet/StyleSheet.js index cca0f87da..ec771e332 100644 --- a/Libraries/StyleSheet/StyleSheet.js +++ b/Libraries/StyleSheet/StyleSheet.js @@ -5,19 +5,15 @@ */ 'use strict'; -var ImageStylePropTypes = require('ImageStylePropTypes'); -var ReactPropTypeLocations = require('ReactPropTypeLocations'); var StyleSheetRegistry = require('StyleSheetRegistry'); -var TextStylePropTypes = require('TextStylePropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); - -var invariant = require('invariant'); +var StyleSheetValidation = require('StyleSheetValidation'); /** * A StyleSheet is an abstraction similar to CSS StyleSheets * * Create a new StyleSheet: * + * ``` * var styles = StyleSheet.create({ * container: { * borderRadius: 4, @@ -31,21 +27,26 @@ var invariant = require('invariant'); * activeTitle: { * color: 'red', * }, - * }) + * }); + * ``` * * Use a StyleSheet: * + * ``` * * * + * ``` * * Code quality: + * * - By moving styles away from the render function, you're making the code * code easier to understand. * - Naming the styles is a good way to add meaning to the low level components * in the render function. * * Performance: + * * - Making a stylesheet from a style object makes it possible to refer to it * by ID instead of creating a new style object every time. * - It also allows to send the style only once through the bridge. All @@ -55,66 +56,11 @@ class StyleSheet { static create(obj) { var result = {}; for (var key in obj) { - StyleSheet.validateStyle(key, obj); + StyleSheetValidation.validateStyle(key, obj); result[key] = StyleSheetRegistry.registerStyle(obj[key]); } return result; } - - static validateStyleProp(prop, style, caller) { - if (!__DEV__) { - return; - } - if (allStylePropTypes[prop] === undefined) { - var message1 = '"' + prop + '" is not a valid style property.'; - var message2 = '\nValid style props: ' + - JSON.stringify(Object.keys(allStylePropTypes), null, ' '); - styleError(message1, style, caller, message2); - } - var error = allStylePropTypes[prop]( - style, - prop, - caller, - ReactPropTypeLocations.prop - ); - if (error) { - styleError(error.message, style, caller); - } - } - - static validateStyle(name, styles) { - if (!__DEV__) { - return; - } - for (var prop in styles[name]) { - StyleSheet.validateStyleProp(prop, styles[name], 'StyleSheet ' + name); - } - } - - static addValidStylePropTypes(stylePropTypes) { - for (var key in stylePropTypes) { - invariant( - allStylePropTypes[key] === undefined || - allStylePropTypes[key] === stylePropTypes[key], - 'Attemped to redefine existing style prop type "' + key + '".' - ); - allStylePropTypes[key] = stylePropTypes[key]; - } - } } -var styleError = function(message1, style, caller, message2) { - invariant( - false, - message1 + '\n' + (caller || '<>') + ': ' + - JSON.stringify(style, null, ' ') + (message2 || '') - ); -}; - -var allStylePropTypes = {}; - -StyleSheet.addValidStylePropTypes(ImageStylePropTypes); -StyleSheet.addValidStylePropTypes(TextStylePropTypes); -StyleSheet.addValidStylePropTypes(ViewStylePropTypes); - module.exports = StyleSheet; diff --git a/Libraries/StyleSheet/StyleSheetValidation.js b/Libraries/StyleSheet/StyleSheetValidation.js new file mode 100644 index 000000000..694f11d5a --- /dev/null +++ b/Libraries/StyleSheet/StyleSheetValidation.js @@ -0,0 +1,72 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule StyleSheetValidation + */ +'use strict'; + +var ImageStylePropTypes = require('ImageStylePropTypes'); +var ReactPropTypeLocations = require('ReactPropTypeLocations'); +var TextStylePropTypes = require('TextStylePropTypes'); +var ViewStylePropTypes = require('ViewStylePropTypes'); + +var invariant = require('invariant'); + +class StyleSheetValidation { + static validateStyleProp(prop, style, caller) { + if (!__DEV__) { + return; + } + if (allStylePropTypes[prop] === undefined) { + var message1 = '"' + prop + '" is not a valid style property.'; + var message2 = '\nValid style props: ' + + JSON.stringify(Object.keys(allStylePropTypes), null, ' '); + styleError(message1, style, caller, message2); + } + var error = allStylePropTypes[prop]( + style, + prop, + caller, + ReactPropTypeLocations.prop + ); + if (error) { + styleError(error.message, style, caller); + } + } + + static validateStyle(name, styles) { + if (!__DEV__) { + return; + } + for (var prop in styles[name]) { + StyleSheetValidation.validateStyleProp(prop, styles[name], 'StyleSheet ' + name); + } + } + + static addValidStylePropTypes(stylePropTypes) { + for (var key in stylePropTypes) { + invariant( + allStylePropTypes[key] === undefined || + allStylePropTypes[key] === stylePropTypes[key], + 'Attemped to redefine existing style prop type "' + key + '".' + ); + allStylePropTypes[key] = stylePropTypes[key]; + } + } +} + +var styleError = function(message1, style, caller, message2) { + invariant( + false, + message1 + '\n' + (caller || '<>') + ': ' + + JSON.stringify(style, null, ' ') + (message2 || '') + ); +}; + +var allStylePropTypes = {}; + +StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes); +StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes); +StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes); + +module.exports = StyleSheetValidation; diff --git a/Libraries/Text/RCTTextManager.m b/Libraries/Text/RCTTextManager.m index 80f350fea..2a0ed3db7 100644 --- a/Libraries/Text/RCTTextManager.m +++ b/Libraries/Text/RCTTextManager.m @@ -23,6 +23,8 @@ return [[RCTShadowText alloc] init]; } +#pragma mark - View properties + RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor) RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText) { @@ -34,6 +36,8 @@ RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText) view.lineBreakMode = truncationMode; } +#pragma mark - Shadow properties + RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowText) { view.textBackgroundColor = json ? [RCTConvert UIColor:json] : defaultView.textBackgroundColor; diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 6171ecbde..5d4efcd5c 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -184,12 +184,12 @@ var Text = React.createClass({ props.onResponderMove = this.handleResponderMove; props.onResponderRelease = this.handleResponderRelease; props.onResponderTerminate = this.handleResponderTerminate; - return ; + return ; }, }); var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; -var RKText = createReactIOSNativeComponentClass(viewConfig); +var RCTText = createReactIOSNativeComponentClass(viewConfig); module.exports = Text; diff --git a/Libraries/Utilities/AlertIOS.js b/Libraries/Utilities/AlertIOS.js index ee0bb2d0b..bbbdc8981 100644 --- a/Libraries/Utilities/AlertIOS.js +++ b/Libraries/Utilities/AlertIOS.js @@ -6,9 +6,7 @@ */ 'use strict'; -var NativeModules = require('NativeModulesDeprecated'); - -var RCTAlertManager = NativeModules.RCTAlertManager; +var { RCTAlertManager } = require('NativeModules'); var DEFAULT_BUTTON_TEXT = 'OK'; var DEFAULT_BUTTON = { diff --git a/Libraries/Utilities/Dimensions.js b/Libraries/Utilities/Dimensions.js index 97e8d2d01..d33515799 100644 --- a/Libraries/Utilities/Dimensions.js +++ b/Libraries/Utilities/Dimensions.js @@ -9,7 +9,7 @@ var NativeModules = require('NativeModules'); var invariant = require('invariant'); -var dimensions = NativeModules.RKUIManager.Dimensions; +var dimensions = NativeModules.RCTUIManager.Dimensions; class Dimensions { /** diff --git a/Libraries/Utilities/MessageQueue.js b/Libraries/Utilities/MessageQueue.js index c5cba0525..1a487d56f 100644 --- a/Libraries/Utilities/MessageQueue.js +++ b/Libraries/Utilities/MessageQueue.js @@ -415,28 +415,6 @@ var MessageQueueMixin = { return ret; }, - callDeprecated: function(moduleName, methodName, params, cb, scope) { - invariant( - !cb || typeof cb === 'function', - 'Last argument (callback) must be function' - ); - // Store callback _before_ sending the request, just in case the MailBox - // returns the response in a blocking manner - if (cb) { - this._storeCallbacksInCurrentThread(null, cb, scope, this._POOLED_CBIDS); - params.push(this._POOLED_CBIDS.successCallbackID); - } - var moduleID = this._remoteModuleNameToModuleID[moduleName]; - if (moduleID === undefined || moduleID === null) { - throw new Error('Unrecognized module name:' + moduleName); - } - var methodID = this._remoteModuleNameToMethodNameToID[moduleName][methodName]; - if (methodID === undefined || moduleID === null) { - throw new Error('Unrecognized method name:' + methodName); - } - this._pushRequestToOutgoingItems(moduleID, methodID, params); - }, - call: function(moduleName, methodName, params, onFail, onSucc, scope) { invariant( (!onFail || typeof onFail === 'function') && @@ -445,9 +423,9 @@ var MessageQueueMixin = { ); // Store callback _before_ sending the request, just in case the MailBox // returns the response in a blocking manner. - if (onFail || onSucc) { + if (onSucc) { this._storeCallbacksInCurrentThread(onFail, onSucc, scope, this._POOLED_CBIDS); - params.push(this._POOLED_CBIDS.errorCallbackID); + onFail && params.push(this._POOLED_CBIDS.errorCallbackID); params.push(this._POOLED_CBIDS.successCallbackID); } var moduleID = this._remoteModuleNameToModuleID[moduleName]; diff --git a/Libraries/Utilities/nativeModulePrefixDuplicator.js b/Libraries/Utilities/nativeModulePrefixDuplicator.js new file mode 100644 index 000000000..fb2951612 --- /dev/null +++ b/Libraries/Utilities/nativeModulePrefixDuplicator.js @@ -0,0 +1,25 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule nativeModulePrefixDuplicator + */ +'use strict'; + +// Dirty hack to support old (RK) and new (RCT) native module name conventions +function nativeModulePrefixDuplicator(modules) { + Object.keys(modules).forEach((moduleName) => { + var rkModuleName = moduleName.replace(/^RCT/, 'RK'); + var rctModuleName = moduleName.replace(/^RK/, 'RCT'); + if (rkModuleName !== rctModuleName) { + if (modules[rkModuleName] && modules[rctModuleName]) { + throw new Error( + 'Module cannot be registered as both RCT and RK: ' + moduleName + ); + } + modules[rkModuleName] = modules[moduleName]; + modules[rctModuleName] = modules[moduleName]; + } + }); +} + +module.exports = nativeModulePrefixDuplicator; diff --git a/Libraries/Vibration/RCTVibration.h b/Libraries/Vibration/RCTVibration.h new file mode 100644 index 000000000..fe499acee --- /dev/null +++ b/Libraries/Vibration/RCTVibration.h @@ -0,0 +1,7 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import "RCTBridgeModule.h" + +@interface RCTVibration : NSObject + +@end diff --git a/Libraries/Vibration/RCTVibration.m b/Libraries/Vibration/RCTVibration.m new file mode 100644 index 000000000..e0e8e63be --- /dev/null +++ b/Libraries/Vibration/RCTVibration.m @@ -0,0 +1,15 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import "RCTVibration.h" + +#import + +@implementation RCTVibration + +- (void)vibrate +{ + RCT_EXPORT(); + AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); +} + +@end diff --git a/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj b/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj new file mode 100644 index 000000000..efd86976e --- /dev/null +++ b/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj @@ -0,0 +1,248 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 832C819C1AAF6E1A007FA2F7 /* RCTVibration.m in Sources */ = {isa = PBXBuildFile; fileRef = 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 832C817E1AAF6DEF007FA2F7 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVibration.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 832C819A1AAF6E1A007FA2F7 /* RCTVibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVibration.h; sourceTree = ""; }; + 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVibration.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 832C817D1AAF6DEF007FA2F7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 832C81771AAF6DEF007FA2F7 = { + isa = PBXGroup; + children = ( + 832C819A1AAF6E1A007FA2F7 /* RCTVibration.h */, + 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */, + 832C81811AAF6DEF007FA2F7 /* Products */, + ); + sourceTree = ""; + }; + 832C81811AAF6DEF007FA2F7 /* Products */ = { + isa = PBXGroup; + children = ( + 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 832C817F1AAF6DEF007FA2F7 /* RCTVibration */ = { + isa = PBXNativeTarget; + buildConfigurationList = 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTVibration" */; + buildPhases = ( + 832C817C1AAF6DEF007FA2F7 /* Sources */, + 832C817D1AAF6DEF007FA2F7 /* Frameworks */, + 832C817E1AAF6DEF007FA2F7 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RCTVibration; + productName = RCTVibration; + productReference = 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 832C81781AAF6DEF007FA2F7 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0620; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 832C817F1AAF6DEF007FA2F7 = { + CreatedOnToolsVersion = 6.2; + }; + }; + }; + buildConfigurationList = 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTVibration" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 832C81771AAF6DEF007FA2F7; + productRefGroup = 832C81811AAF6DEF007FA2F7 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 832C817F1AAF6DEF007FA2F7 /* RCTVibration */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 832C817C1AAF6DEF007FA2F7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 832C819C1AAF6E1A007FA2F7 /* RCTVibration.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 832C81921AAF6DF0007FA2F7 /* 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; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../ReactKit/**", + ); + IPHONEOS_DEPLOYMENT_TARGET = 8.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 832C81931AAF6DF0007FA2F7 /* 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 = NO; + 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; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../ReactKit/**", + ); + IPHONEOS_DEPLOYMENT_TARGET = 8.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 832C81951AAF6DF0007FA2F7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 832C81961AAF6DF0007FA2F7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTVibration" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 832C81921AAF6DF0007FA2F7 /* Debug */, + 832C81931AAF6DF0007FA2F7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTVibration" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 832C81951AAF6DF0007FA2F7 /* Debug */, + 832C81961AAF6DF0007FA2F7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 832C81781AAF6DEF007FA2F7 /* Project object */; +} diff --git a/Libraries/Vibration/VibrationIOS.android.js b/Libraries/Vibration/VibrationIOS.android.js new file mode 100644 index 000000000..0828d35c1 --- /dev/null +++ b/Libraries/Vibration/VibrationIOS.android.js @@ -0,0 +1,18 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * Stub of VibrationIOS for Android. + * + * @providesModule VibrationIOS + */ +'use strict'; + +var warning = require('warning'); + +var VibrationIOS = { + vibrate: function() { + warning('VibrationIOS is not supported on this platform!'); + } +}; + +module.exports = VibrationIOS; diff --git a/Libraries/Vibration/VibrationIOS.ios.js b/Libraries/Vibration/VibrationIOS.ios.js new file mode 100644 index 000000000..054d6c81e --- /dev/null +++ b/Libraries/Vibration/VibrationIOS.ios.js @@ -0,0 +1,32 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule VibrationIOS + */ +'use strict'; + +var {RCTVibration} = require('NativeModules'); +var invariant = require('invariant'); + +/** + * The Vibration API is exposed at `VibrationIOS.vibrate()`. On iOS, calling this + * function will trigger a one second vibration. The vibration is asynchronous + * so this method will return immediately. + * + * There will be no effect on devices that do not support Vibration, eg. the iOS + * simulator. + * + * Vibration patterns are currently unsupported. + */ + +var VibrationIOS = { + vibrate: function() { + invariant( + arguments[0] === undefined, + 'Vibration patterns not supported.' + ); + RCTVibration.vibrate(); + } +}; + +module.exports = VibrationIOS; diff --git a/Libraries/react-native/react-native.js b/Libraries/react-native/react-native.js index 5e164b5fc..cda4a3014 100644 --- a/Libraries/react-native/react-native.js +++ b/Libraries/react-native/react-native.js @@ -38,6 +38,7 @@ var ReactNative = { TouchableHighlight: require('TouchableHighlight'), TouchableOpacity: require('TouchableOpacity'), TouchableWithoutFeedback: require('TouchableWithoutFeedback'), + VibrationIOS: require('VibrationIOS'), View: require('View'), WebView: require('WebView'), invariant: require('invariant'), diff --git a/ReactKit/Base/RCTConvert.h b/ReactKit/Base/RCTConvert.h index d4baaf19a..3c1afaad7 100644 --- a/ReactKit/Base/RCTConvert.h +++ b/ReactKit/Base/RCTConvert.h @@ -36,6 +36,7 @@ + (NSTextAlignment)NSTextAlignment:(id)json; + (NSWritingDirection)NSWritingDirection:(id)json; ++ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json; + (UIKeyboardType)UIKeyboardType:(id)json; + (CGFloat)CGFloat:(id)json; diff --git a/ReactKit/Base/RCTRedBox.m b/ReactKit/Base/RCTRedBox.m index 1d037cd4f..1c70394fd 100644 --- a/ReactKit/Base/RCTRedBox.m +++ b/ReactKit/Base/RCTRedBox.m @@ -85,10 +85,9 @@ - (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack showIfHidden:(BOOL)shouldShow { - _lastStackTrace = stack; - _lastErrorMessage = message; - if (self.hidden && shouldShow) { + _lastStackTrace = stack; + _lastErrorMessage = message; _cachedMessageCell = [self reuseCell:nil forErrorMessage:message]; [_stackTraceTableView reloadData]; diff --git a/ReactKit/Modules/RCTUIManager.m b/ReactKit/Modules/RCTUIManager.m index 98b10dfa0..93090e2c1 100644 --- a/ReactKit/Modules/RCTUIManager.m +++ b/ReactKit/Modules/RCTUIManager.m @@ -718,7 +718,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView } RCTShadowView *shadowView = [manager shadowView]; - shadowView.moduleName = viewName; + shadowView.viewName = viewName; shadowView.reactTag = reactTag; RCTSetShadowViewProps(props, shadowView, _defaultShadowViews[viewName], manager); _shadowViewRegistry[shadowView.reactTag] = shadowView; @@ -973,8 +973,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; CGRect layoutRect = [RCTConvert CGRect:rect]; - for (int ii = 0; ii < [childShadowViews count]; ii++) { - RCTShadowView *childShadowView = [childShadowViews objectAtIndex:ii]; + [childShadowViews enumerateObjectsUsingBlock:^(RCTShadowView *childShadowView, NSUInteger idx, BOOL *stop) { CGRect childLayout = [RCTShadowView measureLayout:childShadowView relativeTo:shadowView]; if (CGRectIsNull(childLayout)) { RCTLogError(@"View %@ (tag #%@) is not a decendant of %@ (tag #%@)", @@ -992,7 +991,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView topOffset <= layoutRect.origin.y + layoutRect.size.height && topOffset + height >= layoutRect.origin.y) { // This view is within the layout rect - NSDictionary *result = @{@"index": @(ii), + NSDictionary *result = @{@"index": @(idx), @"left": @(leftOffset), @"top": @(topOffset), @"width": @(width), @@ -1000,7 +999,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView [results addObject:result]; } - } + }]; callback(@[results]); } diff --git a/ReactKit/Views/RCTShadowView.h b/ReactKit/Views/RCTShadowView.h index f869ca614..3b961fac6 100644 --- a/ReactKit/Views/RCTShadowView.h +++ b/ReactKit/Views/RCTShadowView.h @@ -2,8 +2,8 @@ #import -#import "Layout.h" -#import "RCTUIManager.h" +#import "../Layout/Layout.h" + #import "RCTViewNodeProtocol.h" @class RCTSparseArray; @@ -31,7 +31,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); @property (nonatomic, weak, readonly) RCTShadowView *superview; @property (nonatomic, assign, readonly) css_node_t *cssNode; -@property (nonatomic, copy) NSString *moduleName; +@property (nonatomic, copy) NSString *viewName; @property (nonatomic, assign) BOOL isBGColorExplicitlySet; // Used to propagate to children @property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children @property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle; @@ -54,6 +54,9 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); */ @property (nonatomic, assign) CGFloat top; @property (nonatomic, assign) CGFloat left; +@property (nonatomic, assign) CGFloat bottom; +@property (nonatomic, assign) CGFloat right; + @property (nonatomic, assign) CGFloat width; @property (nonatomic, assign) CGFloat height; @property (nonatomic, assign) CGRect frame; @@ -66,8 +69,8 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); */ @property (nonatomic, assign) CGFloat borderTop; @property (nonatomic, assign) CGFloat borderLeft; -@property (nonatomic, assign) CGFloat borderWidth; -@property (nonatomic, assign) CGFloat borderHeight; +@property (nonatomic, assign) CGFloat borderBottom; +@property (nonatomic, assign) CGFloat borderRight; - (void)setBorderWidth:(CGFloat)value; diff --git a/ReactKit/Views/RCTShadowView.m b/ReactKit/Views/RCTShadowView.m index 62d38249e..d28495b4c 100644 --- a/ReactKit/Views/RCTShadowView.m +++ b/ReactKit/Views/RCTShadowView.m @@ -44,7 +44,7 @@ typedef enum { static void RCTPrint(void *context) { RCTShadowView *shadowView = (__bridge RCTShadowView *)context; - printf("%s(%zd), ", [[shadowView moduleName] UTF8String], [[shadowView reactTag] integerValue]); + printf("%s(%zd), ", shadowView.viewName.UTF8String, shadowView.reactTag.integerValue); } static css_node_t *RCTGetChild(void *context, int i) @@ -132,12 +132,13 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st RCTRoundPixelValue(absolutePosition.y + node->layout.position[CSS_TOP] + node->layout.dimensions[CSS_HEIGHT]) }; - CGRect frame = { + CGRect frame = {{ RCTRoundPixelValue(node->layout.position[CSS_LEFT]), RCTRoundPixelValue(node->layout.position[CSS_TOP]), + }, { RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x), RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y) - }; + }}; if (!CGRectEqualToRect(frame, _frame)) { _frame = frame; diff --git a/ReactKit/Views/RCTTextFieldManager.m b/ReactKit/Views/RCTTextFieldManager.m index 40a46e100..9576935b9 100644 --- a/ReactKit/Views/RCTTextFieldManager.m +++ b/ReactKit/Views/RCTTextFieldManager.m @@ -2,6 +2,7 @@ #import "RCTTextFieldManager.h" +#import "RCTBridge.h" #import "RCTConvert.h" #import "RCTShadowView.h" #import "RCTSparseArray.h" @@ -16,20 +17,24 @@ RCT_EXPORT_VIEW_PROPERTY(caretHidden) RCT_EXPORT_VIEW_PROPERTY(autoCorrect) -RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType) RCT_EXPORT_VIEW_PROPERTY(enabled) RCT_EXPORT_VIEW_PROPERTY(placeholder) RCT_EXPORT_VIEW_PROPERTY(text) RCT_EXPORT_VIEW_PROPERTY(clearButtonMode) RCT_EXPORT_VIEW_PROPERTY(keyboardType) RCT_REMAP_VIEW_PROPERTY(color, textColor) +RCT_CUSTOM_VIEW_PROPERTY(autoCapitalize, RCTTextField) +{ + view.autocapitalizationType = json ? [RCTConvert UITextAutocapitalizationType:json] + : defaultView.autocapitalizationType; +} RCT_CUSTOM_VIEW_PROPERTY(fontSize, RCTTextField) { view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)]; } RCT_CUSTOM_VIEW_PROPERTY(fontWeight, RCTTextField) { - view.font = [RCTConvert UIFont:view.font withWeight:json]; // TODO + view.font = [RCTConvert UIFont:view.font withWeight:json]; // TODO: default value } RCT_CUSTOM_VIEW_PROPERTY(fontFamily, RCTTextField) { diff --git a/ReactKit/Views/RCTViewManager.m b/ReactKit/Views/RCTViewManager.m index 011f66f24..151f72cfe 100644 --- a/ReactKit/Views/RCTViewManager.m +++ b/ReactKit/Views/RCTViewManager.m @@ -62,7 +62,7 @@ return nil; } -// View properties +#pragma mark - View properties RCT_EXPORT_VIEW_PROPERTY(accessibilityLabel) RCT_EXPORT_VIEW_PROPERTY(hidden) @@ -110,7 +110,7 @@ RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTView) } } -// ShadowView properties +#pragma mark - ShadowView properties RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowView) {