diff --git a/.flowconfig b/.flowconfig index 7e5099c58..c4265b9b2 100644 --- a/.flowconfig +++ b/.flowconfig @@ -18,9 +18,6 @@ # Ignore jest .*/react-native/node_modules/jest-cli/.* -# Ignore website -.*/website/.* - [include] [libs] diff --git a/Examples/2048/2048.xcodeproj/project.pbxproj b/Examples/2048/2048.xcodeproj/project.pbxproj index 696d9331d..bf1fb02aa 100644 --- a/Examples/2048/2048.xcodeproj/project.pbxproj +++ b/Examples/2048/2048.xcodeproj/project.pbxproj @@ -12,8 +12,8 @@ 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 */; }; + 1461632D1AC3E23900C2F5AD /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1461632C1AC3E22900C2F5AD /* libReact.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; - 8323482C1A77B59500B55238 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832348291A77B50100B55238 /* libReactKit.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -24,6 +24,13 @@ remoteGlobalIDString = 134814201AA4EA6300B7C361; remoteInfo = RCTAnimation; }; + 1461632B1AC3E22900C2F5AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146163271AC3E22900C2F5AD /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; @@ -31,13 +38,6 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; - 832348281A77B50100B55238 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 834D32361A76971A00F38302 /* ReactKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -49,8 +49,8 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = 2048/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = 2048/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = 2048/main.m; sourceTree = ""; }; + 146163271AC3E22900C2F5AD /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; - 834D32361A76971A00F38302 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,8 +58,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1461632D1AC3E23900C2F5AD /* libReact.a in Frameworks */, 13ACB6741AC2117000FF4204 /* libRCTAnimation.a in Frameworks */, - 8323482C1A77B59500B55238 /* libReactKit.a in Frameworks */, 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -88,10 +88,18 @@ name = 2048; sourceTree = ""; }; + 146163281AC3E22900C2F5AD /* Products */ = { + isa = PBXGroup; + children = ( + 1461632C1AC3E22900C2F5AD /* libReact.a */, + ); + name = Products; + sourceTree = ""; + }; 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( - 834D32361A76971A00F38302 /* ReactKit.xcodeproj */, + 146163271AC3E22900C2F5AD /* React.xcodeproj */, 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 13ACB66C1AC2113500FF4204 /* RCTAnimation.xcodeproj */, ); @@ -106,14 +114,6 @@ name = Products; sourceTree = ""; }; - 832348241A77B50100B55238 /* Products */ = { - isa = PBXGroup; - children = ( - 832348291A77B50100B55238 /* libReactKit.a */, - ); - name = Products; - sourceTree = ""; - }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -181,8 +181,8 @@ ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; }, { - ProductGroup = 832348241A77B50100B55238 /* Products */; - ProjectRef = 834D32361A76971A00F38302 /* ReactKit.xcodeproj */; + ProductGroup = 146163281AC3E22900C2F5AD /* Products */; + ProjectRef = 146163271AC3E22900C2F5AD /* React.xcodeproj */; }, ); projectRoot = ""; @@ -200,6 +200,13 @@ remoteRef = 13ACB6701AC2113600FF4204 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 1461632C1AC3E22900C2F5AD /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 1461632B1AC3E22900C2F5AD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -207,13 +214,6 @@ remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 832348291A77B50100B55238 /* libReactKit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReactKit.a; - remoteRef = 832348281A77B50100B55238 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -257,6 +257,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; @@ -268,6 +273,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; @@ -312,7 +322,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -352,7 +362,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Examples/Movies/Movies.xcodeproj/project.pbxproj b/Examples/Movies/Movies.xcodeproj/project.pbxproj index 8dfb1be4e..29eaf91c4 100644 --- a/Examples/Movies/Movies.xcodeproj/project.pbxproj +++ b/Examples/Movies/Movies.xcodeproj/project.pbxproj @@ -14,8 +14,8 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 140D9B661AC36C42004F25EE /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14312D241AC3654D00CDC950 /* libRCTLinking.a */; }; + 14A2D4421AC3E43800CC738A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14A2D4411AC3E41A00CC738A /* libReact.a */; }; 58C5726B1AA6239E00CDF9C8 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C5725B1AA6236500CDF9C8 /* libRCTText.a */; }; - 58C5726C1AA623A200CDF9C8 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C572681AA6236600CDF9C8 /* libReactKit.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -40,6 +40,13 @@ remoteGlobalIDString = 134814201AA4EA6300B7C361; remoteInfo = RCTLinking; }; + 14A2D4401AC3E41A00CC738A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 14A2D43C1AC3E41A00CC738A /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; 58C5725A1AA6236500CDF9C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 587650F61A9EB120008B8F17 /* RCTText.xcodeproj */; @@ -47,13 +54,6 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; - 58C572671AA6236600CDF9C8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 587650F91A9EB120008B8F17 /* ReactKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -67,8 +67,8 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Movies/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Movies/main.m; sourceTree = ""; }; 14312D1E1AC3654D00CDC950 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../../Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = ""; }; + 14A2D43C1AC3E41A00CC738A /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = ""; }; 587650F61A9EB120008B8F17 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = SOURCE_ROOT; }; - 587650F91A9EB120008B8F17 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -76,11 +76,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 14A2D4421AC3E43800CC738A /* libReact.a in Frameworks */, 140D9B661AC36C42004F25EE /* libRCTLinking.a in Frameworks */, 1341801E1AA91750003F314A /* libRCTNetwork.a in Frameworks */, 13442C061AA90EA00037E5B0 /* libRCTImage.a in Frameworks */, 58C5726B1AA6239E00CDF9C8 /* libRCTText.a in Frameworks */, - 58C5726C1AA623A200CDF9C8 /* libReactKit.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -124,14 +124,22 @@ name = Products; sourceTree = ""; }; + 14A2D43D1AC3E41A00CC738A /* Products */ = { + isa = PBXGroup; + children = ( + 14A2D4411AC3E41A00CC738A /* libReact.a */, + ); + name = Products; + sourceTree = ""; + }; 58C571FC1AA6124500CDF9C8 /* Libraries */ = { isa = PBXGroup; children = ( + 14A2D43C1AC3E41A00CC738A /* React.xcodeproj */, 14312D1E1AC3654D00CDC950 /* RCTLinking.xcodeproj */, 134180151AA91740003F314A /* RCTNetwork.xcodeproj */, 13442C001AA90E7D0037E5B0 /* RCTImage.xcodeproj */, 587650F61A9EB120008B8F17 /* RCTText.xcodeproj */, - 587650F91A9EB120008B8F17 /* ReactKit.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -144,14 +152,6 @@ name = Products; sourceTree = ""; }; - 58C5725C1AA6236500CDF9C8 /* Products */ = { - isa = PBXGroup; - children = ( - 58C572681AA6236600CDF9C8 /* libReactKit.a */, - ); - name = Products; - sourceTree = ""; - }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -227,8 +227,8 @@ ProjectRef = 587650F61A9EB120008B8F17 /* RCTText.xcodeproj */; }, { - ProductGroup = 58C5725C1AA6236500CDF9C8 /* Products */; - ProjectRef = 587650F91A9EB120008B8F17 /* ReactKit.xcodeproj */; + ProductGroup = 14A2D43D1AC3E41A00CC738A /* Products */; + ProjectRef = 14A2D43C1AC3E41A00CC738A /* React.xcodeproj */; }, ); projectRoot = ""; @@ -260,6 +260,13 @@ remoteRef = 14312D231AC3654D00CDC950 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 14A2D4411AC3E41A00CC738A /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 14A2D4401AC3E41A00CC738A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 58C5725B1AA6236500CDF9C8 /* libRCTText.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -267,13 +274,6 @@ remoteRef = 58C5725A1AA6236500CDF9C8 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 58C572681AA6236600CDF9C8 /* libReactKit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReactKit.a; - remoteRef = 58C572671AA6236600CDF9C8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -320,7 +320,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -338,7 +338,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -386,7 +386,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -426,7 +426,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj b/Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj index ba0c1d97b..76c7963c0 100644 --- a/Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj +++ b/Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj @@ -19,8 +19,8 @@ 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 */; }; + 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; - 8323482C1A77B59500B55238 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832348291A77B50100B55238 /* libReactKit.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -73,6 +73,13 @@ remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; remoteInfo = RCTVibration; }; + 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; @@ -80,13 +87,6 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; - 832348281A77B50100B55238 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 834D32361A76971A00F38302 /* ReactKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -105,8 +105,8 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = iOS/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = iOS/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = iOS/main.m; sourceTree = ""; }; + 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; - 834D32361A76971A00F38302 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -115,6 +115,7 @@ buildActionMask = 2147483647; files = ( 00481BEA1AC0C89D00671115 /* libicucore.dylib in Frameworks */, + 146834051AC3E58100842450 /* libReact.a in Frameworks */, 00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */, 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */, @@ -122,7 +123,6 @@ 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, - 8323482C1A77B59500B55238 /* libReactKit.a in Frameworks */, 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -199,10 +199,18 @@ name = SampleApp; sourceTree = ""; }; + 146834001AC3E56700842450 /* Products */ = { + isa = PBXGroup; + children = ( + 146834041AC3E56700842450 /* libReact.a */, + ); + name = Products; + sourceTree = ""; + }; 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( - 834D32361A76971A00F38302 /* ReactKit.xcodeproj */, + 146833FF1AC3E56700842450 /* React.xcodeproj */, 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */, @@ -224,14 +232,6 @@ name = Products; sourceTree = ""; }; - 832348241A77B50100B55238 /* Products */ = { - isa = PBXGroup; - children = ( - 832348291A77B50100B55238 /* libReactKit.a */, - ); - name = Products; - sourceTree = ""; - }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -323,8 +323,8 @@ ProjectRef = 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */; }, { - ProductGroup = 832348241A77B50100B55238 /* Products */; - ProjectRef = 834D32361A76971A00F38302 /* ReactKit.xcodeproj */; + ProductGroup = 146834001AC3E56700842450 /* Products */; + ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, ); projectRoot = ""; @@ -384,6 +384,13 @@ remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 146834041AC3E56700842450 /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -391,13 +398,6 @@ remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 832348291A77B50100B55238 /* libReactKit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReactKit.a; - remoteRef = 832348281A77B50100B55238 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -441,6 +441,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; @@ -452,6 +457,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; @@ -496,7 +506,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -536,7 +546,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj b/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj index 48b484437..c1333f78b 100644 --- a/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj +++ b/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj @@ -12,7 +12,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 */; }; - 58C572501AA6229900CDF9C8 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C572471AA6224300CDF9C8 /* libReactKit.a */; }; + 144C5F691AC3E5E300B004E7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 144C5F681AC3E5D800B004E7 /* libReact.a */; }; 58C572511AA6229D00CDF9C8 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C5724D1AA6224400CDF9C8 /* libRCTText.a */; }; /* End PBXBuildFile section */ @@ -24,12 +24,12 @@ remoteGlobalIDString = 58B5115D1A9E6B3D00147676; remoteInfo = RCTImage; }; - 58C572461AA6224300CDF9C8 /* PBXContainerItemProxy */ = { + 144C5F671AC3E5D800B004E7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 587650E31A9EB0DF008B8F17 /* ReactKit.xcodeproj */; + containerPortal = 144C5F631AC3E5D800B004E7 /* React.xcodeproj */; proxyType = 2; remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; + remoteInfo = React; }; 58C5724C1AA6224400CDF9C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -49,8 +49,8 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = TicTacToe/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = TicTacToe/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = TicTacToe/main.m; sourceTree = ""; }; + 144C5F631AC3E5D800B004E7 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = ""; }; 587650DA1A9EB0DB008B8F17 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; - 587650E31A9EB0DF008B8F17 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,8 +58,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 144C5F691AC3E5E300B004E7 /* libReact.a in Frameworks */, 1341803E1AA91802003F314A /* libRCTImage.a in Frameworks */, - 58C572501AA6229900CDF9C8 /* libReactKit.a in Frameworks */, 58C572511AA6229D00CDF9C8 /* libRCTText.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -88,24 +88,24 @@ name = TicTacToe; sourceTree = ""; }; + 144C5F641AC3E5D800B004E7 /* Products */ = { + isa = PBXGroup; + children = ( + 144C5F681AC3E5D800B004E7 /* libReact.a */, + ); + name = Products; + sourceTree = ""; + }; 58C572071AA6126D00CDF9C8 /* Libraries */ = { isa = PBXGroup; children = ( + 144C5F631AC3E5D800B004E7 /* React.xcodeproj */, 134180381AA917ED003F314A /* RCTImage.xcodeproj */, 587650DA1A9EB0DB008B8F17 /* RCTText.xcodeproj */, - 587650E31A9EB0DF008B8F17 /* ReactKit.xcodeproj */, ); name = Libraries; sourceTree = ""; }; - 58C572411AA6224300CDF9C8 /* Products */ = { - isa = PBXGroup; - children = ( - 58C572471AA6224300CDF9C8 /* libReactKit.a */, - ); - name = Products; - sourceTree = ""; - }; 58C572481AA6224300CDF9C8 /* Products */ = { isa = PBXGroup; children = ( @@ -181,8 +181,8 @@ ProjectRef = 587650DA1A9EB0DB008B8F17 /* RCTText.xcodeproj */; }, { - ProductGroup = 58C572411AA6224300CDF9C8 /* Products */; - ProjectRef = 587650E31A9EB0DF008B8F17 /* ReactKit.xcodeproj */; + ProductGroup = 144C5F641AC3E5D800B004E7 /* Products */; + ProjectRef = 144C5F631AC3E5D800B004E7 /* React.xcodeproj */; }, ); projectRoot = ""; @@ -200,11 +200,11 @@ remoteRef = 1341803C1AA917ED003F314A /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 58C572471AA6224300CDF9C8 /* libReactKit.a */ = { + 144C5F681AC3E5D800B004E7 /* libReact.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = libReactKit.a; - remoteRef = 58C572461AA6224300CDF9C8 /* PBXContainerItemProxy */; + path = libReact.a; + remoteRef = 144C5F671AC3E5D800B004E7 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 58C5724D1AA6224400CDF9C8 /* libRCTText.a */ = { @@ -257,6 +257,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -269,6 +274,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -314,7 +324,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -354,7 +364,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Examples/UIExplorer/BorderExample.js b/Examples/UIExplorer/BorderExample.js new file mode 100644 index 000000000..668e77880 --- /dev/null +++ b/Examples/UIExplorer/BorderExample.js @@ -0,0 +1,90 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +'use strict'; + +var React = require('react-native'); +var { + StyleSheet, + View +} = React; + +var styles = StyleSheet.create({ + box: { + width: 100, + height: 100, + }, + border1: { + borderWidth: 10, + borderColor: 'brown', + }, + borderRadius: { + borderWidth: 10, + borderRadius: 10, + borderColor: 'cyan', + }, + border2: { + borderWidth: 10, + borderTopColor: 'red', + borderRightColor: 'yellow', + borderBottomColor: 'green', + borderLeftColor: 'blue', + }, + border3: { + borderColor: 'purple', + borderTopWidth: 10, + borderRightWidth: 20, + borderBottomWidth: 30, + borderLeftWidth: 40, + }, + border4: { + borderTopWidth: 10, + borderTopColor: 'red', + borderRightWidth: 20, + borderRightColor: 'yellow', + borderBottomWidth: 30, + borderBottomColor: 'green', + borderLeftWidth: 40, + borderLeftColor: 'blue', + }, +}); + +exports.title = 'Border'; +exports.description = 'View borders'; +exports.examples = [ + { + title: 'Equal-Width / Same-Color', + description: 'borderWidth & borderColor', + render() { + return ; + } + }, + { + title: 'Equal-Width / Same-Color', + description: 'borderWidth & borderColor', + render() { + return ; + } + }, + { + title: 'Equal-Width Borders', + description: 'borderWidth & border*Color', + render() { + return ; + } + }, + { + title: 'Same-Color Borders', + description: 'border*Width & borderColor', + render() { + return ; + } + }, + { + title: 'Custom Borders', + description: 'border*Width & border*Color', + render() { + return ; + } + }, +]; diff --git a/Examples/UIExplorer/ReactNavigator/BreadcrumbNavSample.js b/Examples/UIExplorer/Navigator/BreadcrumbNavSample.js similarity index 78% rename from Examples/UIExplorer/ReactNavigator/BreadcrumbNavSample.js rename to Examples/UIExplorer/Navigator/BreadcrumbNavSample.js index 17be12f8d..0734dff41 100644 --- a/Examples/UIExplorer/ReactNavigator/BreadcrumbNavSample.js +++ b/Examples/UIExplorer/Navigator/BreadcrumbNavSample.js @@ -1,20 +1,23 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. * - * @providesModule BreadcrumbNavSample + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; -var BreadcrumbNavigationBar = require('BreadcrumbNavigationBar'); -var ReactNavigator = require('ReactNavigator'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var ScrollView = require('ScrollView'); -var TabBarItemIOS = require('TabBarItemIOS'); -var TabBarIOS = require('TabBarIOS'); -var Text = require('Text'); -var TouchableBounce = require('TouchableBounce'); -var View = require('View'); +var React = require('react-native'); +var { + Navigator, + ScrollView, + StyleSheet, + TabBarIOS, + Text, + View, + TouchableHighlight, +} = React; var SAMPLE_TEXT = 'Top Pushes. Middle Replaces. Bottom Pops.'; @@ -43,28 +46,28 @@ var SampleNavigationBarRouteMapper = { }, titleContentForRoute: function(route, navigator) { return ( - navigator.push(_getRandomRoute())}> {route.title} - + ); }, iconForRoute: function(route, navigator) { var onPress = navigator.popToRoute.bind(navigator, route); return ( - + - + ); }, separatorForRoute: function(route, navigator) { return ( - + - + ); } }; @@ -76,49 +79,49 @@ var renderScene = function(route, navigator) { return ( - request push soon - - + {content} - - + {content} - - + {content} - - + {content} - - + {content} - - + request pop soon - - + Immediate set two routes - - + pop to top soon - + ); @@ -180,41 +183,41 @@ var BreadcrumbNavSample = React.createClass({ }; return ( - - } /> - - + - ReactNavigator.SceneConfigs.FloatFromBottom} + Navigator.SceneConfigs.FloatFromBottom} debugOverlay={false} style={[styles.appContainer]} initialRoute={initialRoute} renderScene={renderScene} navigationBar={ - } /> - + ); }, diff --git a/Examples/UIExplorer/ReactNavigator/JumpingNavSample.js b/Examples/UIExplorer/Navigator/JumpingNavSample.js similarity index 79% rename from Examples/UIExplorer/ReactNavigator/JumpingNavSample.js rename to Examples/UIExplorer/Navigator/JumpingNavSample.js index fd44f7384..fa3d72b0d 100644 --- a/Examples/UIExplorer/ReactNavigator/JumpingNavSample.js +++ b/Examples/UIExplorer/Navigator/JumpingNavSample.js @@ -1,17 +1,22 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. * - * @providesModule JumpingNavSample + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; -var ReactNavigator = require('ReactNavigator'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var ScrollView = require('ScrollView'); -var Text = require('Text'); -var TouchableBounce = require('TouchableBounce'); -var View = require('View'); +var React = require('react-native'); +var { + Navigator, + StyleSheet, + ScrollView, + Text, + TouchableHighlight, + View, +} = React; var _getRandomRoute = function() { return { @@ -32,55 +37,55 @@ var renderScene = function(route, navigator) { {route.randNumber} - { navigator.jumpBack(); }}> jumpBack - - + { navigator.jumpForward(); }}> jumpForward - - + { navigator.jumpTo(INIT_ROUTE); }}> jumpTo initial route - - + { navigator.push(_getRandomRoute()); }}> destructive: push - - + { navigator.replace(_getRandomRoute()); }}> destructive: replace - - + { navigator.pop(); }}> destructive: pop - - + { navigator.immediatelyResetRouteStack([ _getRandomRoute(), @@ -90,15 +95,15 @@ var renderScene = function(route, navigator) { destructive: Immediate set two routes - - + { navigator.popToTop(); }}> destructive: pop to top - + ); @@ -109,7 +114,7 @@ class JumpingNavBar extends React.Component { return ( {this.props.routeStack.map((route, index) => ( - { + { this.props.navigator.jumpTo(route); }}> @@ -121,7 +126,7 @@ class JumpingNavBar extends React.Component { {index} - + ))} ); @@ -132,7 +137,7 @@ var JumpingNavSample = React.createClass({ render: function() { return ( - navigator.pop()}> + navigator.pop()}> {previousRoute.title} - + ); }, RightButton: function(route, navigator, index, navState) { return ( - navigator.push(newRandomRoute())}> Next - + ); }, @@ -70,7 +75,7 @@ var NavigationBarSample = React.createClass({ render: function() { return ( - )} navigationBar={ - } diff --git a/Examples/UIExplorer/ReactNavigator/ReactNavigatorExample.js b/Examples/UIExplorer/Navigator/NavigatorExample.js similarity index 77% rename from Examples/UIExplorer/ReactNavigator/ReactNavigatorExample.js rename to Examples/UIExplorer/Navigator/NavigatorExample.js index 2ebec71dd..f0cae637d 100644 --- a/Examples/UIExplorer/ReactNavigator/ReactNavigatorExample.js +++ b/Examples/UIExplorer/Navigator/NavigatorExample.js @@ -1,14 +1,21 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; -var React = require('React'); -var ReactNavigator = require('ReactNavigator'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var ScrollView = require('ScrollView'); -var TouchableHighlight = require('TouchableHighlight'); +var React = require('react-native'); +var { + Navigator, + ScrollView, + StyleSheet, + Text, + TouchableHighlight, +} = React; var BreadcrumbNavSample = require('./BreadcrumbNavSample'); var NavigationBarSample = require('./NavigationBarSample'); var JumpingNavSample = require('./JumpingNavSample'); @@ -35,7 +42,7 @@ class NavMenu extends React.Component { { this.props.onExampleExit(); }}> - Exit ReactNavigator Example + Exit Navigator Example ); @@ -45,7 +52,7 @@ class NavMenu extends React.Component { var TabBarExample = React.createClass({ statics: { - title: '', + title: '', description: 'JS-implemented navigation', }, @@ -69,11 +76,11 @@ var TabBarExample = React.createClass({ render: function() { return ( - ReactNavigator.SceneConfigs.FloatFromBottom} + configureScene={(route) => Navigator.SceneConfigs.FloatFromBottom} /> ); }, diff --git a/Examples/UIExplorer/ReactNavigator/NestedBreadcrumbNavSample.js b/Examples/UIExplorer/ReactNavigator/NestedBreadcrumbNavSample.js deleted file mode 100644 index 20d857472..000000000 --- a/Examples/UIExplorer/ReactNavigator/NestedBreadcrumbNavSample.js +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule NestedBreadcrumbNavSample - */ -'use strict'; - -var BreadcrumbNavigationBar = require('BreadcrumbNavigationBar'); -var ReactNavigator = require('ReactNavigator'); -var React = require('React'); -var ScrollView = require('ScrollView'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var TouchableBounce = require('TouchableBounce'); -var View = require('View'); - -var SAMPLE_TEXT = 'Top Pushes. Middle Replaces. Bottom Pops.'; - -var _getRandomRoute = function() { - return { - backButtonTitle: 'Back' + ('' + 10 * Math.random()).substr(0, 1), - content: - SAMPLE_TEXT + '\nHere\'s a random number ' + Math.random(), - title: 'Pushed!', - rightButtonTitle: Math.random() > 0.5 ? 'Right' : 'Button', - }; -}; - - -var HorizontalNavigationBarRouteMapper = { - rightContentForRoute: function(route, navigator) { - if (route.rightButtonTitle) { - return ( - - {route.rightButtonTitle} - - ); - } else { - return null; - } - }, - titleContentForRoute: function(route, navigator) { - return ( - () => { navigator.push(_getRandomRoute()); }}> - - {route.title} - - - ); - }, - iconForRoute: function(route, navigator) { - var onPress = - navigator.popToRoute.bind(navigator, route); - return ( - - - - ); - }, - separatorForRoute: function(route, navigator) { - return ( - - - - ); - } -}; - -var ThirdDeepRouteMapper = (route, navigator) => ( - - - - { navigator.push(_getRandomRoute()); }}> - - request push soon - - - - - -); - -var SecondDeepRouteMapper = (route, navigator) => ( - - { navigator.push(_getRandomRoute()); }}> - - Push Horizontal - - - - } - /> - -); - -var FirstDeepRouteMapper = (route, navigator) => ( - - { navigator.push(_getRandomRoute()); }}> - - Push Outer Vertical Stack - - - - } - /> - -); - -/** - * The outer component. - */ -var NestedBreadcrumbNavSample = React.createClass({ - render: function() { - var initialRoute = {title: 'Vertical'}; - // No navigation bar. - return ( - ReactNavigator.SceneConfigs.FloatFromBottom} - initialRoute={initialRoute} - renderScene={FirstDeepRouteMapper} - /> - ); - } -}); - -var styles = StyleSheet.create({ - navigationItem: { - backgroundColor: '#eeeeee', - shadowColor: 'black', - shadowRadius: 20, - shadowOffset: {w: 0, h: -10}, - }, - paddingForNavBar: { - paddingTop: 60, - }, - paddingForMenuBar: { - paddingTop: 10, - }, - button: { - backgroundColor: '#888888', - margin: 10, - marginTop: 10, - padding: 10, - marginRight: 20, - }, - buttonText: { - fontSize: 12, - textAlign: 'center', - color: 'white', - }, - appContainer: { - overflow: 'hidden', - backgroundColor: '#dddddd', - flex: 1, - }, - titleText: { - fontSize: 18, - color: '#666666', - textAlign: 'center', - fontWeight: '500', - lineHeight: 32, - }, - filterText: { - color: '#5577ff', - }, - // TODO: Accept icons from route. - crumbIconPlaceholder: { - flex: 1, - backgroundColor: '#666666', - }, - crumbSeparatorPlaceholder: { - flex: 1, - backgroundColor: '#aaaaaa', - }, - secondDeepNavigator: { - margin: 0, - borderColor: '#666666', - borderWidth: 0.5, - height: 400, - }, - thirdDeepNavigator: { - margin: 0, - borderColor: '#aaaaaa', - borderWidth: 0.5, - height: 400, - }, - thirdDeepScrollContent: { - height: 1000, - } -}); - -module.exports = NestedBreadcrumbNavSample; diff --git a/Examples/UIExplorer/ResponderExample.js b/Examples/UIExplorer/ResponderExample.js index 73398ed1b..529e9f5b6 100644 --- a/Examples/UIExplorer/ResponderExample.js +++ b/Examples/UIExplorer/ResponderExample.js @@ -1,5 +1,11 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * * @flow */ 'use strict'; diff --git a/Examples/UIExplorer/TabBarExample.js b/Examples/UIExplorer/TabBarExample.js index 793bfd309..f5d07d68f 100644 --- a/Examples/UIExplorer/TabBarExample.js +++ b/Examples/UIExplorer/TabBarExample.js @@ -10,14 +10,14 @@ */ 'use strict'; -var React = require('React'); -var TabBarIOS = require('TabBarIOS'); -var TabBarItemIOS = require('TabBarItemIOS'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); - - +var React = require('react-native'); +var { + StyleSheet, + TabBarIOS, + Text, + View, +} = React; +var TabBarItemIOS = TabBarIOS.Item; var TabBarExample = React.createClass({ statics: { diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index 0b4496435..e5e783e6c 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 00D2771B1AB8C55500DC1E48 /* libicucore.dylib */; }; 13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; }; 134180011AA9153C003F314A /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FEF1AA914B8003F314A /* libRCTText.a */; }; - 134180021AA9153C003F314A /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FFF1AA91531003F314A /* libReactKit.a */; }; 1341802C1AA9178B003F314A /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1341802B1AA91779003F314A /* libRCTNetwork.a */; }; 134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1344545A1AAFCAAE003F0779 /* libRCTAdSupport.a */; }; 134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 134A8A251AACED6A00945AAE /* libRCTGeolocation.a */; }; @@ -21,6 +20,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 */; }; + 14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; }; 14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; }; 58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; }; D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; }; @@ -55,13 +55,6 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; - 13417FFE1AA91531003F314A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; - }; 1341802A1AA91779003F314A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 134180261AA91779003F314A /* RCTNetwork.xcodeproj */; @@ -90,6 +83,13 @@ remoteGlobalIDString = 134814201AA4EA6300B7C361; remoteInfo = RCTActionSheet; }; + 14AADF031AC3DB95002390C9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 14AADEFF1AC3DB95002390C9 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; 14DC67F01AB71876001358AB /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */; @@ -121,7 +121,6 @@ 00D2771B1AB8C55500DC1E48 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; }; 13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../../Libraries/Image/RCTImage.xcodeproj; sourceTree = ""; }; 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; - 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = ""; }; 134180261AA91779003F314A /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../../Libraries/Network/RCTNetwork.xcodeproj; sourceTree = ""; }; 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = ../../Libraries/AdSupport/RCTAdSupport.xcodeproj; sourceTree = ""; }; 134A8A201AACED6A00945AAE /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../../Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = ""; }; @@ -132,6 +131,7 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = UIExplorer/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = UIExplorer/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = UIExplorer/main.m; sourceTree = ""; }; + 14AADEFF1AC3DB95002390C9 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = ""; }; 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTPushNotification.xcodeproj; path = ../../Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj; sourceTree = ""; }; 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = ""; }; 58005BE41ABA80530062E044 /* RCTTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTTest.xcodeproj; path = ../../Libraries/RCTTest/RCTTest.xcodeproj; sourceTree = ""; }; @@ -151,6 +151,7 @@ buildActionMask = 2147483647; files = ( 00D2771C1AB8C55500DC1E48 /* libicucore.dylib in Frameworks */, + 14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */, 00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */, 58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */, D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */, @@ -160,7 +161,6 @@ 134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */, 1341802C1AA9178B003F314A /* libRCTNetwork.a in Frameworks */, 134180011AA9153C003F314A /* libRCTText.a in Frameworks */, - 134180021AA9153C003F314A /* libReactKit.a in Frameworks */, 13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -196,7 +196,7 @@ 1316A21D1AA397F400C0188E /* Libraries */ = { isa = PBXGroup; children = ( - 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */, + 14AADEFF1AC3DB95002390C9 /* React.xcodeproj */, 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */, 14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */, 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */, @@ -228,14 +228,6 @@ name = Products; sourceTree = ""; }; - 13417FFB1AA91531003F314A /* Products */ = { - isa = PBXGroup; - children = ( - 13417FFF1AA91531003F314A /* libReactKit.a */, - ); - name = Products; - sourceTree = ""; - }; 134180271AA91779003F314A /* Products */ = { isa = PBXGroup; children = ( @@ -281,6 +273,14 @@ name = Products; sourceTree = ""; }; + 14AADF001AC3DB95002390C9 /* Products */ = { + isa = PBXGroup; + children = ( + 14AADF041AC3DB95002390C9 /* libReact.a */, + ); + name = Products; + sourceTree = ""; + }; 14DC67E81AB71876001358AB /* Products */ = { isa = PBXGroup; children = ( @@ -430,8 +430,8 @@ ProjectRef = 00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */; }, { - ProductGroup = 13417FFB1AA91531003F314A /* Products */; - ProjectRef = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */; + ProductGroup = 14AADF001AC3DB95002390C9 /* Products */; + ProjectRef = 14AADEFF1AC3DB95002390C9 /* React.xcodeproj */; }, ); projectRoot = ""; @@ -464,13 +464,6 @@ remoteRef = 13417FEE1AA914B8003F314A /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 13417FFF1AA91531003F314A /* libReactKit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReactKit.a; - remoteRef = 13417FFE1AA91531003F314A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 1341802B1AA91779003F314A /* libRCTNetwork.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -499,6 +492,13 @@ remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 14AADF041AC3DB95002390C9 /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 14AADF031AC3DB95002390C9 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 14DC67F11AB71876001358AB /* libRCTPushNotification.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -595,6 +595,11 @@ "FB_REFERENCE_IMAGE_DIR=\"\\\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\\\"\"", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = UIExplorerTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -611,6 +616,11 @@ "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); INFOPLIST_FILE = UIExplorerTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -622,11 +632,12 @@ 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -639,11 +650,12 @@ 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -690,7 +702,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -730,7 +742,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/Contents.json new file mode 100644 index 000000000..cf064d8c1 --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "tabnav_list@3x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/tabnav_list@3x.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/tabnav_list@3x.png new file mode 100644 index 000000000..6cf722790 Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_list.imageset/tabnav_list@3x.png differ diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/Contents.json new file mode 100644 index 000000000..eb75c050f --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "tabnav_notification@3x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/tabnav_notification@3x.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/tabnav_notification@3x.png new file mode 100644 index 000000000..1f65e6590 Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_notification.imageset/tabnav_notification@3x.png differ diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/Contents.json new file mode 100644 index 000000000..c665c5a07 --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "tabnav_settings@3x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/tabnav_settings@3x.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/tabnav_settings@3x.png new file mode 100644 index 000000000..581f2c72a Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/tabnav_settings.imageset/tabnav_settings@3x.png differ diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index a13da34dc..037fb3dcd 100644 --- a/Examples/UIExplorer/UIExplorerList.js +++ b/Examples/UIExplorer/UIExplorerList.js @@ -22,7 +22,7 @@ var { TouchableHighlight, View, } = React; -var ReactNavigatorExample = require('./ReactNavigator/ReactNavigatorExample'); +var NavigatorExample = require('./Navigator/NavigatorExample'); var { TestModule } = React.addons; @@ -36,7 +36,7 @@ var COMPONENTS = [ require('./ListViewSimpleExample'), require('./MapViewExample'), require('./NavigatorIOSExample'), - ReactNavigatorExample, + NavigatorExample, require('./PickerExample'), require('./ScrollViewExample'), require('./SliderIOSExample'), @@ -55,6 +55,7 @@ var APIS = [ require('./AlertIOSExample'), require('./AppStateIOSExample'), require('./AsyncStorageExample'), + require('./BorderExample'), require('./CameraRollExample.ios'), require('./GeolocationExample'), require('./LayoutExample'), @@ -176,9 +177,9 @@ class UIExplorerList extends React.Component { } _onPressRow(example) { - if (example === ReactNavigatorExample) { + if (example === NavigatorExample) { this.props.onExternalExampleRequested( - ReactNavigatorExample + NavigatorExample ); return; } diff --git a/Examples/UIExplorer/UIExplorerTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp/testTextExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp/testTextExampleSnapshot_1@2x.png index bdc9fc180..044576efc 100644 Binary files a/Examples/UIExplorer/UIExplorerTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp/testTextExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp/testTextExampleSnapshot_1@2x.png differ diff --git a/IntegrationTests/IntegrationTests.xcodeproj/project.pbxproj b/IntegrationTests/IntegrationTests.xcodeproj/project.pbxproj index 3c64d8f3d..6ae4db06c 100644 --- a/IntegrationTests/IntegrationTests.xcodeproj/project.pbxproj +++ b/IntegrationTests/IntegrationTests.xcodeproj/project.pbxproj @@ -12,7 +12,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 */; }; - 580C37601AB0F6180015E709 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 580C37461AB0F5320015E709 /* libReactKit.a */; }; + 1405E9C21AC3E65600F5BC37 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1405E9C11AC3E63C00F5BC37 /* libReact.a */; }; 580C37611AB0F61E0015E709 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 580C374B1AB0F54A0015E709 /* libRCTAdSupport.a */; }; 580C37621AB0F6260015E709 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 580C37501AB0F55C0015E709 /* libRCTGeolocation.a */; }; 580C37631AB0F62C0015E709 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 580C37551AB0F56E0015E709 /* libRCTImage.a */; }; @@ -22,6 +22,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 1405E9C01AC3E63C00F5BC37 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1405E9BC1AC3E63C00F5BC37 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; + remoteInfo = React; + }; 58005BCB1ABA44F10062E044 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; @@ -29,13 +36,6 @@ remoteGlobalIDString = 13B07F861A680F5B00A75B9A; remoteInfo = IntegrationTests; }; - 580C37451AB0F5320015E709 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = ReactKit; - }; 580C374A1AB0F54A0015E709 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */; @@ -86,7 +86,6 @@ 004D28A21AAF61C70097A701 /* IntegrationTestsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IntegrationTestsTests.m; sourceTree = ""; }; 13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../Libraries/Image/RCTImage.xcodeproj; sourceTree = ""; }; 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; - 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../ReactKit/ReactKit.xcodeproj; sourceTree = ""; }; 134180261AA91779003F314A /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../Libraries/Network/RCTNetwork.xcodeproj; sourceTree = ""; }; 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = ../Libraries/AdSupport/RCTAdSupport.xcodeproj; sourceTree = ""; }; 134A8A201AACED6A00945AAE /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../Libraries/GeoLocation/RCTGeolocation.xcodeproj; sourceTree = ""; }; @@ -97,6 +96,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 = ""; }; + 1405E9BC1AC3E63C00F5BC37 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../React/React.xcodeproj; sourceTree = ""; }; 580C37891AB104AF0015E709 /* RCTTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTTest.xcodeproj; path = ../Libraries/RCTTest/RCTTest.xcodeproj; sourceTree = ""; }; /* End PBXFileReference section */ @@ -112,7 +112,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 580C37601AB0F6180015E709 /* libReactKit.a in Frameworks */, + 1405E9C21AC3E65600F5BC37 /* libReact.a in Frameworks */, 580C37611AB0F61E0015E709 /* libRCTAdSupport.a in Frameworks */, 580C37621AB0F6260015E709 /* libRCTGeolocation.a in Frameworks */, 580C37631AB0F62C0015E709 /* libRCTImage.a in Frameworks */, @@ -145,7 +145,7 @@ 1316A21D1AA397F400C0188E /* Libraries */ = { isa = PBXGroup; children = ( - 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */, + 1405E9BC1AC3E63C00F5BC37 /* React.xcodeproj */, 134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */, 134A8A201AACED6A00945AAE /* RCTGeolocation.xcodeproj */, 13417FE31AA91428003F314A /* RCTImage.xcodeproj */, @@ -169,10 +169,10 @@ name = IntegrationTests; sourceTree = ""; }; - 580C37421AB0F5320015E709 /* Products */ = { + 1405E9BD1AC3E63C00F5BC37 /* Products */ = { isa = PBXGroup; children = ( - 580C37461AB0F5320015E709 /* libReactKit.a */, + 1405E9C11AC3E63C00F5BC37 /* libReact.a */, ); name = Products; sourceTree = ""; @@ -334,8 +334,8 @@ ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */; }, { - ProductGroup = 580C37421AB0F5320015E709 /* Products */; - ProjectRef = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */; + ProductGroup = 1405E9BD1AC3E63C00F5BC37 /* Products */; + ProjectRef = 1405E9BC1AC3E63C00F5BC37 /* React.xcodeproj */; }, ); projectRoot = ""; @@ -347,11 +347,11 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 580C37461AB0F5320015E709 /* libReactKit.a */ = { + 1405E9C11AC3E63C00F5BC37 /* libReact.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = libReactKit.a; - remoteRef = 580C37451AB0F5320015E709 /* PBXContainerItemProxy */; + path = libReact.a; + remoteRef = 1405E9C01AC3E63C00F5BC37 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 580C374B1AB0F54A0015E709 /* libRCTAdSupport.a */ = { @@ -471,6 +471,11 @@ "FB_REFERENCE_IMAGE_DIR=\"\\\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\\\"\"", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../React/**", + ); INFOPLIST_FILE = IntegrationTestsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -488,6 +493,11 @@ "$(SDKROOT)/Developer/Library/Frameworks", "$(DEVELOPER_FRAMEWORKS_DIR)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../React/**", + ); INFOPLIST_FILE = IntegrationTestsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -503,7 +513,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -520,7 +530,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../React/**", ); INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -567,7 +577,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../ReactKit/**", + "$(SRCROOT)/../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -607,7 +617,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../ReactKit/**", + "$(SRCROOT)/../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj b/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj index 4b05e5f43..1e32363c4 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj +++ b/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj @@ -199,7 +199,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; @@ -214,7 +214,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 2f66badfc..b388a4cc8 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -93,9 +93,24 @@ } }; } else { - share.completionHandler = ^(NSString *activityType, BOOL completed) { - successCallback(@[@(completed), (activityType ?: [NSNull null])]); - }; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 + + if (![UIActivityViewController instancesRespondToSelector:@selector(completionWithItemsHandler)]) { + // Legacy iOS 7 implementation + share.completionHandler = ^(NSString *activityType, BOOL completed) { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + }; + } else + +#endif + + { + // iOS 8 version + share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + }; + } } [ctrl presentViewController:share animated:YES completion:nil]; }); diff --git a/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj b/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj index dc1f0393b..d48bec56c 100644 --- a/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj +++ b/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -194,7 +194,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; @@ -206,6 +206,11 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -215,6 +220,11 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/Libraries/Animation/AnimationUtils.js b/Libraries/Animation/AnimationUtils.js index bc58219b5..56a3455b7 100644 --- a/Libraries/Animation/AnimationUtils.js +++ b/Libraries/Animation/AnimationUtils.js @@ -6,6 +6,12 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * + * The easing functions come from the the jQuery UI project. + * See http://api.jqueryui.com/easings/ + * Copyright jQuery Foundation and other contributors, https://jquery.org/ + * Copyright (c) 2008 George McGinley Smith + * Copyright (c) 2001 Robert Penner + * * @providesModule AnimationUtils * @flow */ diff --git a/Libraries/Animation/RCTAnimation.xcodeproj/project.pbxproj b/Libraries/Animation/RCTAnimation.xcodeproj/project.pbxproj index 36b95fba1..81eb52c70 100644 --- a/Libraries/Animation/RCTAnimation.xcodeproj/project.pbxproj +++ b/Libraries/Animation/RCTAnimation.xcodeproj/project.pbxproj @@ -199,12 +199,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTAnimation; SKIP_INSTALL = YES; @@ -217,12 +214,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTAnimation; SKIP_INSTALL = YES; diff --git a/Libraries/Animation/RCTAnimationManager.m b/Libraries/Animation/RCTAnimationManager.m index 21e76977f..a6e342db6 100644 --- a/Libraries/Animation/RCTAnimationManager.m +++ b/Libraries/Animation/RCTAnimationManager.m @@ -83,7 +83,7 @@ } else if ([obj respondsToSelector:@selector(count)]) { switch ([obj count]) { case 2: - if ([obj respondsToSelector:@selector(objectForKeyedSubscript:)] && obj[@"x"]) { + if (![obj respondsToSelector:@selector(objectForKeyedSubscript:)] || obj[@"x"]) { toValue = [NSValue valueWithCGPoint:[RCTConvert CGPoint:obj]]; } else { toValue = [NSValue valueWithCGSize:[RCTConvert CGSize:obj]]; @@ -192,9 +192,9 @@ UIView *view = viewRegistry[reactTag]; for (NSString *animationKey in view.layer.animationKeys) { if ([animationKey hasPrefix:@"RCT"]) { - NSRange periodLocation = [animationKey rangeOfString:@"." options:0 range:NSMakeRange(3, animationKey.length - 3)]; + NSRange periodLocation = [animationKey rangeOfString:@"." options:0 range:(NSRange){3, animationKey.length - 3}]; if (periodLocation.location != NSNotFound) { - NSInteger integerTag = [[animationKey substringWithRange:NSMakeRange(3, periodLocation.location)] integerValue]; + NSInteger integerTag = [[animationKey substringWithRange:(NSRange){3, periodLocation.location}] integerValue]; if (animationTag.integerValue == integerTag) { [view.layer removeAnimationForKey:animationKey]; } diff --git a/Libraries/Components/SliderIOS/SliderIOS.js b/Libraries/Components/SliderIOS/SliderIOS.js index aac9798d3..a8f2f5125 100644 --- a/Libraries/Components/SliderIOS/SliderIOS.js +++ b/Libraries/Components/SliderIOS/SliderIOS.js @@ -35,14 +35,25 @@ var SliderIOS = React.createClass({ style: View.propTypes.style, /** - * Initial value of the slider. The value should be between 0 and 1. + * Initial value of the slider. The value should be between minimumValue + * and maximumValue, which default to 0 and 1 respectively. * Default value is 0. * * *This is not a controlled component*, e.g. if you don't update - * the value, the component won't be reseted to it's inital value. + * the value, the component won't be reset to it's inital value. */ value: PropTypes.number, + /** + * Initial minimum value of the slider. Default value is 0. + */ + minimumValue: PropTypes.number, + + /** + * Initial maximum value of the slider. Default value is 1. + */ + maximumValue: PropTypes.number, + /** * Callback continuously called while the user is dragging the slider. */ diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index fa82dd4cb..e508268c5 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -13,11 +13,15 @@ var React = require('React'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); +var TabBarItemIOS = require('TabBarItemIOS'); var StyleSheet = require('StyleSheet'); var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); var TabBarIOS = React.createClass({ + statics: { + Item: TabBarItemIOS, + }, render: function() { return ( diff --git a/Libraries/Components/TextInput/TextInput.ios.js b/Libraries/Components/TextInput/TextInput.ios.js index 2653421be..02fec4d5a 100644 --- a/Libraries/Components/TextInput/TextInput.ios.js +++ b/Libraries/Components/TextInput/TextInput.ios.js @@ -39,7 +39,9 @@ var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { autoCapitalize: true, color: true, editable: true, + fontFamily: true, fontSize: true, + fontStyle: true, fontWeight: true, keyboardType: true, mostRecentEventCounter: true, diff --git a/Libraries/Components/TextInput/TextInputState.js b/Libraries/Components/TextInput/TextInputState.js index 7c5af440e..f22ac7927 100644 --- a/Libraries/Components/TextInput/TextInputState.js +++ b/Libraries/Components/TextInput/TextInputState.js @@ -37,7 +37,7 @@ var TextInputState = { * noop if the text field was already focused */ focusTextInput: function(textFieldID: string) { - if (this._currentlyFocusedID != textFieldID && textFieldID != null) { + if (this._currentlyFocusedID !== textFieldID && textFieldID !== null) { this._currentlyFocusedID = textFieldID; RCTUIManager.focus(textFieldID); } @@ -49,7 +49,7 @@ var TextInputState = { * noop if it wasn't focused */ blurTextInput: function(textFieldID: string) { - if (this._currentlyFocusedID == textFieldID && textFieldID != null) { + if (this._currentlyFocusedID === textFieldID && textFieldID !== null) { this._currentlyFocusedID = null; RCTUIManager.blur(textFieldID); } diff --git a/Libraries/CustomComponents/ReactNavigator/ReactNavigator.js b/Libraries/CustomComponents/Navigator/Navigator.js similarity index 79% rename from Libraries/CustomComponents/ReactNavigator/ReactNavigator.js rename to Libraries/CustomComponents/Navigator/Navigator.js index 004908d57..a8809ad55 100644 --- a/Libraries/CustomComponents/ReactNavigator/ReactNavigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -1,16 +1,38 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015, Facebook, Inc. All rights reserved. * - * @providesModule ReactNavigator + * Facebook, Inc. (“Facebook”) owns all right, title and interest, including + * all intellectual property and other proprietary rights, in and to the React + * Native CustomComponents software (the “Software”). Subject to your + * compliance with these terms, you are hereby granted a non-exclusive, + * worldwide, royalty-free copyright license to (1) use and copy the Software; + * and (2) reproduce and distribute the Software as part of your own software + * (“Your Software”). Facebook reserves all rights not expressly granted to + * you in this license agreement. + * + * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. + * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR + * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @providesModule Navigator */ - -"use strict" +'use strict'; var AnimationsDebugModule = require('NativeModules').AnimationsDebugModule; var Backstack = require('Backstack'); var Dimensions = require('Dimensions'); var InteractionMixin = require('InteractionMixin'); -var ReactNavigatorSceneConfigs = require('ReactNavigatorSceneConfigs'); +var NavigatorSceneConfigs = require('NavigatorSceneConfigs'); +var NavigatorNavigationBar = require('NavigatorNavigationBar'); +var NavigatorBreadcrumbNavigationBar = require('NavigatorBreadcrumbNavigationBar'); var PanResponder = require('PanResponder'); var React = require('React'); var StaticContainer = require('StaticContainer.react'); @@ -72,27 +94,151 @@ var styles = StyleSheet.create({ } }); -var ReactNavigator = React.createClass({ +/** + * Use `ReactNavigator` to transition between different scenes in your app. To + * accomplish this, provide route objects to the navigator to identify each + * scene, and also a `renderScene` function that the navigator can use to + * render the scene for a given route. + * + * To change the animation or gesture properties of the scene, provide a + * `configureScene` prop to get the config object for a given route. See + * `ReactNavigator.SceneConfigs` for default animations and more info on + * scene config options. + * + * ### Basic Usage + * + * ``` + * + * { + * var nextIndex = route.index + 1; + * navigator.push({ + * name: 'Scene ' + nextIndex, + * index: nextIndex, + * }); + * }} + * onBack={() => { + * if (route.index > 0) { + * navigator.pop(); + * } + * }} + * /> + * } + * /> + * ``` + * + * ### Navigation Methods + * + * `ReactNavigator` can be told to navigate in two ways. If you have a ref to + * the element, you can invoke several methods on it to trigger navigation: + * + * - `jumpBack()` - Jump backward without unmounting the current scene + * - `jumpForward()` - Jump forward to the next scene in the route stack + * - `jumpTo(route)` - Transition to an existing scene without unmounting + * - `push(route)` - Navigate forward to a new scene, squashing any scenes + * that you could `jumpForward` to + * - `pop()` - Transition back and unmount the current scene + * - `replace(route)` - Replace the current scene with a new route + * - `replaceAtIndex(route, index)` - Replace a scene as specified by an index + * - `replacePrevious(route)` - Replace the previous scene + * - `immediatelyResetRouteStack(routeStack)` - Reset every scene with an + * array of routes + * - `popToRoute(route)` - Pop to a particular scene, as specified by it's + * route. All scenes after it will be unmounted + * - `popToTop()` - Pop to the first scene in the stack, unmounting every + * other scene + * + * ### Navigator Object + * + * The navigator object is made available to scenes through the `renderScene` + * function. The object has all of the navigation methods on it, as well as a + * few utilities: + * + * - `parentNavigator` - a refrence to the parent navigator object that was + * passed in through props.navigator + * - `onWillFocus` - used to pass a navigation focus event up to the parent + * navigator + * - `onDidFocus` - used to pass a navigation focus event up to the parent + * navigator + * + */ +var Navigator = React.createClass({ propTypes: { + /** + * Optional function that allows configuration about scene animations and + * gestures. Will be invoked with the route and should return a scene + * configuration object + * + * ``` + * (route) => ReactNavigator.SceneConfigs.FloatFromRight + * ``` + */ configureScene: PropTypes.func, - // Returns the rendered scene to display when invoked with (route, navigator) + + /** + * Required function which renders the scene for a given route. Will be + * invoked with the route, the navigator object, and a ref handler that + * will allow a ref to your scene to be provided by props.onItemRef + * + * ``` + * (route, navigator, onRef) => + * + * ``` + */ renderScene: PropTypes.func.isRequired, + + /** + * Provide a single "route" to start on. A route is an arbitrary object + * that the navigator will use to identify each scene before rendering. + * Either initialRoute or initialRouteStack is required. + */ initialRoute: PropTypes.object, + + /** + * Provide a set of routes to initially mount the scenes for. Required if no + * initialRoute is provided + */ initialRouteStack: PropTypes.arrayOf(PropTypes.object), - // Will emit the target route on mounting and before each nav transition, - // overriding the handler in this.props.navigator + + /** + * Will emit the target route upon mounting and before each nav transition, + * overriding the handler in this.props.navigator. This overrides the onDidFocus + * handler that would be found in this.props.navigator + */ onWillFocus: PropTypes.func, - // Will emit the new route after mounting and after each nav transition, - // overriding the handler in this.props.navigator + + /** + * Will be called with the new route of each scene after the transition is + * complete or after the initial mounting. This overrides the onDidFocus + * handler that would be found in this.props.navigator + */ onDidFocus: PropTypes.func, - // Will be called with (ref, indexInStack) when an item ref resolves + + /** + * Will be called with (ref, indexInStack) when the scene ref changes + */ onItemRef: PropTypes.func, - // Define the component to use for the nav bar, which will get navState and navigator props + + /** + * Optionally provide a navigation bar that persists across scene + * transitions + */ navigationBar: PropTypes.node, - // The navigator object from a parent ReactNavigator + + /** + * Optionally provide the navigator object from a parent ReactNavigator + */ navigator: PropTypes.object, + /** + * Styles to apply to the container of each scene + */ + sceneStyle: View.propTypes.style, + /** * Should the backstack back button "jump" back instead of pop? Set to true * if a jump forward might happen after the android back button is pressed, @@ -102,14 +248,16 @@ var ReactNavigator = React.createClass({ }, statics: { - SceneConfigs: ReactNavigatorSceneConfigs, + BreadcrumbNavigationBar: NavigatorBreadcrumbNavigationBar, + NavigationBar: NavigatorNavigationBar, + SceneConfigs: NavigatorSceneConfigs, }, mixins: [TimerMixin, InteractionMixin, Subscribable.Mixin], getDefaultProps: function() { return { - configureScene: () => ReactNavigatorSceneConfigs.PushFromRight, + configureScene: () => NavigatorSceneConfigs.PushFromRight, sceneStyle: styles.defaultSceneStyle, }; }, @@ -128,7 +276,7 @@ var ReactNavigator = React.createClass({ } else { invariant( routeStack.length >= 1, - 'ReactNavigator requires props.initialRoute or props.initialRouteStack.' + 'Navigator requires props.initialRoute or props.initialRouteStack.' ); } return { @@ -151,7 +299,7 @@ var ReactNavigator = React.createClass({ }, componentWillMount: function() { - this.memoizedNavigationOperations = { + this.navigatorActions = { jumpBack: this.jumpBack, jumpForward: this.jumpForward, jumpTo: this.jumpTo, @@ -166,8 +314,9 @@ var ReactNavigator = React.createClass({ popToRoute: this.popToRoute, popToTop: this.popToTop, parentNavigator: this.props.navigator, - // We want to bubble focused routes to the top navigation stack. If we are - // a child, this will allow us to call this.props.navigator.on*Focus + // We want to bubble focused routes to the top navigation stack. If we + // are a child navigator, this allows us to call props.navigator.on*Focus + // of the topmost ReactNavigator onWillFocus: this.props.onWillFocus, onDidFocus: this.props.onDidFocus, }; @@ -798,7 +947,7 @@ var ReactNavigator = React.createClass({ i <= this.state.updatingRangeStart + this.state.updatingRangeLength; var child = this.props.renderScene( route, - this.memoizedNavigationOperations, + this.navigatorActions, this._onItemRef.bind(null, this.state.idStack[i]) ); @@ -842,7 +991,7 @@ var ReactNavigator = React.createClass({ } return React.cloneElement(this.props.navigationBar, { ref: NAVIGATION_BAR_REF, - navigator: this.memoizedNavigationOperations, + navigator: this.navigatorActions, navState: this.state, }); }, @@ -857,4 +1006,4 @@ var ReactNavigator = React.createClass({ }, }); -module.exports = ReactNavigator; +module.exports = Navigator; diff --git a/Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBar.js b/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js similarity index 89% rename from Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBar.js rename to Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js index 3f16e44cd..3a20e0533 100644 --- a/Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBar.js +++ b/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js @@ -1,19 +1,18 @@ /** * Copyright 2004-present Facebook. All Rights Reserved. * - * @providesModule BreadcrumbNavigationBar + * @providesModule NavigatorBreadcrumbNavigationBar */ 'use strict'; -var BreadcrumbNavigationBarStyles = require('BreadcrumbNavigationBarStyles'); -var PixelRatio = require('PixelRatio'); +var NavigatorBreadcrumbNavigationBarStyles = require('NavigatorBreadcrumbNavigationBarStyles'); +var NavigatorNavigationBarStyles = require('NavigatorNavigationBarStyles'); var React = require('React'); -var NavigationBarStyles = require('NavigationBarStyles'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); var View = require('View'); -var Interpolators = BreadcrumbNavigationBarStyles.Interpolators; +var Interpolators = NavigatorBreadcrumbNavigationBarStyles.Interpolators; var PropTypes = React.PropTypes; /** @@ -46,12 +45,12 @@ var navStatePresentedIndex = function(navState) { * @return {object} Style config for initial rendering of index. */ var initStyle = function(index, presentedIndex) { - return index === presentedIndex ? BreadcrumbNavigationBarStyles.Center[index] : - index < presentedIndex ? BreadcrumbNavigationBarStyles.Left[index] : - BreadcrumbNavigationBarStyles.Right[index]; + return index === presentedIndex ? NavigatorBreadcrumbNavigationBarStyles.Center[index] : + index < presentedIndex ? NavigatorBreadcrumbNavigationBarStyles.Left[index] : + NavigatorBreadcrumbNavigationBarStyles.Right[index]; }; -var BreadcrumbNavigationBar = React.createClass({ +var NavigatorBreadcrumbNavigationBar = React.createClass({ propTypes: { navigator: PropTypes.shape({ push: PropTypes.func, @@ -68,6 +67,10 @@ var BreadcrumbNavigationBar = React.createClass({ navigationBarStyles: PropTypes.number, }, + statics: { + Styles: NavigatorBreadcrumbNavigationBarStyles, + }, + _updateIndexProgress: function(progress, index, fromIndex, toIndex) { var amount = toIndex > fromIndex ? progress : (1 - progress); var oldDistToCenter = index - fromIndex; @@ -231,11 +234,11 @@ var styles = StyleSheet.create({ breadCrumbContainer: { overflow: 'hidden', position: 'absolute', - height: NavigationBarStyles.General.TotalNavHeight, + height: NavigatorNavigationBarStyles.General.TotalNavHeight, top: 0, left: 0, - width: NavigationBarStyles.General.ScreenWidth, + width: NavigatorNavigationBarStyles.General.ScreenWidth, }, }); -module.exports = BreadcrumbNavigationBar; +module.exports = NavigatorBreadcrumbNavigationBar; diff --git a/Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBarStyles.ios.js b/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js similarity index 73% rename from Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBarStyles.ios.js rename to Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js index c71772c23..7bc78ee92 100644 --- a/Libraries/CustomComponents/ReactNavigator/BreadcrumbNavigationBarStyles.ios.js +++ b/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js @@ -1,18 +1,39 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2015, Facebook, Inc. All rights reserved. * - * @providesModule BreadcrumbNavigationBarStyles + * Facebook, Inc. (“Facebook”) owns all right, title and interest, including + * all intellectual property and other proprietary rights, in and to the React + * Native CustomComponents software (the “Software”). Subject to your + * compliance with these terms, you are hereby granted a non-exclusive, + * worldwide, royalty-free copyright license to (1) use and copy the Software; + * and (2) reproduce and distribute the Software as part of your own software + * (“Your Software”). Facebook reserves all rights not expressly granted to + * you in this license agreement. + * + * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. + * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR + * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @providesModule NavigatorBreadcrumbNavigationBarStyles */ 'use strict'; -var NavigationBarStyles = require('NavigationBarStyles'); +var NavigatorNavigationBarStyles = require('NavigatorNavigationBarStyles'); var buildStyleInterpolator = require('buildStyleInterpolator'); var merge = require('merge'); -var SCREEN_WIDTH = NavigationBarStyles.General.ScreenWidth; -var STATUS_BAR_HEIGHT = NavigationBarStyles.General.StatusBarHeight; -var NAV_BAR_HEIGHT = NavigationBarStyles.General.NavBarHeight; +var SCREEN_WIDTH = NavigatorNavigationBarStyles.General.ScreenWidth; +var STATUS_BAR_HEIGHT = NavigatorNavigationBarStyles.General.StatusBarHeight; +var NAV_BAR_HEIGHT = NavigatorNavigationBarStyles.General.NavBarHeight; var SPACING = 4; var ICON_WIDTH = 40; diff --git a/Libraries/CustomComponents/ReactNavigator/NavigationBar.js b/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js similarity index 63% rename from Libraries/CustomComponents/ReactNavigator/NavigationBar.js rename to Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js index e1e27b3df..4e6c7c330 100644 --- a/Libraries/CustomComponents/ReactNavigator/NavigationBar.js +++ b/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js @@ -1,15 +1,36 @@ /** - * @providesModule NavigationBar - * @typechecks + * Copyright (c) 2015, Facebook, Inc. All rights reserved. + * + * Facebook, Inc. (“Facebook”) owns all right, title and interest, including + * all intellectual property and other proprietary rights, in and to the React + * Native CustomComponents software (the “Software”). Subject to your + * compliance with these terms, you are hereby granted a non-exclusive, + * worldwide, royalty-free copyright license to (1) use and copy the Software; + * and (2) reproduce and distribute the Software as part of your own software + * (“Your Software”). Facebook reserves all rights not expressly granted to + * you in this license agreement. + * + * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. + * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR + * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @providesModule NavigatorNavigationBar */ 'use strict'; var React = require('React'); -var NavigationBarStyles = require('NavigationBarStyles'); +var NavigatorNavigationBarStyles = require('NavigatorNavigationBarStyles'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); var View = require('View'); -var Text = require('Text'); var COMPONENT_NAMES = ['Title', 'LeftButton', 'RightButton']; @@ -24,7 +45,11 @@ var navStatePresentedIndex = function(navState) { } }; -var NavigationBar = React.createClass({ +var NavigatorNavigationBar = React.createClass({ + + statics: { + Styles: NavigatorNavigationBarStyles, + }, _getReusableProps: function( /*string*/componentName, @@ -32,7 +57,7 @@ var NavigationBar = React.createClass({ ) /*object*/ { if (!this._reusableProps) { this._reusableProps = {}; - }; + } var propStack = this._reusableProps[componentName]; if (!propStack) { propStack = this._reusableProps[componentName] = []; @@ -56,14 +81,14 @@ var NavigationBar = React.createClass({ var interpolate; if (oldDistToCenter > 0 && newDistToCenter === 0 || newDistToCenter > 0 && oldDistToCenter === 0) { - interpolate = NavigationBarStyles.Interpolators.RightToCenter; + interpolate = NavigatorNavigationBarStyles.Interpolators.RightToCenter; } else if (oldDistToCenter < 0 && newDistToCenter === 0 || newDistToCenter < 0 && oldDistToCenter === 0) { - interpolate = NavigationBarStyles.Interpolators.CenterToLeft; + interpolate = NavigatorNavigationBarStyles.Interpolators.CenterToLeft; } else if (oldDistToCenter === newDistToCenter) { - interpolate = NavigationBarStyles.Interpolators.RightToCenter; + interpolate = NavigatorNavigationBarStyles.Interpolators.RightToCenter; } else { - interpolate = NavigationBarStyles.Interpolators.RightToLeft; + interpolate = NavigatorNavigationBarStyles.Interpolators.RightToLeft; } COMPONENT_NAMES.forEach(function (componentName) { @@ -134,7 +159,7 @@ var NavigationBar = React.createClass({ } var initialStage = index === navStatePresentedIndex(this.props.navState) ? - NavigationBarStyles.Stages.Center : NavigationBarStyles.Stages.Left; + NavigatorNavigationBarStyles.Stages.Center : NavigatorNavigationBarStyles.Stages.Left; return ( component using this module. - DESC - spec.homepage = 'https://facebook.github.io/react-native/' - spec.license = { :type => 'BSD' } - spec.author = 'Facebook' - spec.platform = :ios, '7.0' - spec.requires_arc = true - spec.source_files = '**/*.{h,m,c}' - spec.dependency "ReactKit", "~> 0.0.1" - - # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Link your library with frameworks, or libraries. Libraries do not include - # the lib prefix of their name. - # - - # s.framework = "SomeFramework" - # s.frameworks = "SomeFramework", "AnotherFramework" - - # s.library = "iconv" - #spec.libraries = "RCTNetworkImage", "ReactKit" - -end diff --git a/Libraries/Image/RCTNetworkImageViewManager.m b/Libraries/Image/RCTNetworkImageViewManager.m index 33e55ffba..22268e8c0 100644 --- a/Libraries/Image/RCTNetworkImageViewManager.m +++ b/Libraries/Image/RCTNetworkImageViewManager.m @@ -25,8 +25,8 @@ return view; } -RCT_REMAP_VIEW_PROPERTY(defaultImageSrc, defaultImage) -RCT_REMAP_VIEW_PROPERTY(src, imageURL) -RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode) +RCT_REMAP_VIEW_PROPERTY(defaultImageSrc, defaultImage, UIImage) +RCT_REMAP_VIEW_PROPERTY(src, imageURL, NSURL) +RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode, UIViewContentMode) @end diff --git a/Libraries/Image/RCTStaticImageManager.m b/Libraries/Image/RCTStaticImageManager.m index 586961832..7668613bd 100644 --- a/Libraries/Image/RCTStaticImageManager.m +++ b/Libraries/Image/RCTStaticImageManager.m @@ -23,9 +23,9 @@ return [[RCTStaticImage alloc] init]; } -RCT_EXPORT_VIEW_PROPERTY(capInsets) -RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode) -RCT_CUSTOM_VIEW_PROPERTY(src, RCTStaticImage) +RCT_EXPORT_VIEW_PROPERTY(capInsets, UIEdgeInsets) +RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode, UIViewContentMode) +RCT_CUSTOM_VIEW_PROPERTY(src, NSURL, RCTStaticImage) { if (json) { if ([[[json description] pathExtension] caseInsensitiveCompare:@"gif"] == NSOrderedSame) { @@ -37,7 +37,7 @@ RCT_CUSTOM_VIEW_PROPERTY(src, RCTStaticImage) view.image = defaultView.image; } } -RCT_CUSTOM_VIEW_PROPERTY(tintColor, RCTStaticImage) +RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTStaticImage) { if (json) { view.renderingMode = UIImageRenderingModeAlwaysTemplate; @@ -47,15 +47,14 @@ RCT_CUSTOM_VIEW_PROPERTY(tintColor, RCTStaticImage) view.tintColor = defaultView.tintColor; } } -RCT_CUSTOM_VIEW_PROPERTY(imageTag, RCTStaticImage) +RCT_CUSTOM_VIEW_PROPERTY(imageTag, NSString, RCTStaticImage) { if (json) { [RCTImageLoader loadImageWithTag:[RCTConvert NSString:json] callback:^(NSError *error, UIImage *image) { if (error) { RCTLogWarn(@"%@", error.localizedDescription); - } else { - view.image = image; } + view.image = image; }]; } else { view.image = defaultView.image; diff --git a/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj b/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj index 0d9e593d2..a9a8f3f42 100644 --- a/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj +++ b/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj @@ -199,12 +199,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTLinking; SKIP_INSTALL = YES; @@ -217,12 +214,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTLinking; SKIP_INSTALL = YES; diff --git a/Libraries/Network/RCTDataManager.podspec b/Libraries/Network/RCTDataManager.podspec deleted file mode 100644 index 84df787b8..000000000 --- a/Libraries/Network/RCTDataManager.podspec +++ /dev/null @@ -1,28 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'RCTDataManager' - spec.version = '0.0.1' - spec.summary = 'Provides basic networking capabilities in ReactNative apps.' - spec.description = <<-DESC - Use XMLHttpRequest to fetch data over the network. - DESC - spec.homepage = 'https://facebook.github.io/react-native/' - spec.license = { :type => 'BSD' } - spec.author = 'Facebook' - spec.platform = :ios, '7.0' - spec.requires_arc = true - spec.source_files = '**/*.{h,m,c}' - spec.dependency "ReactKit", "~> 0.0.1" - - # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Link your library with frameworks, or libraries. Libraries do not include - # the lib prefix of their name. - # - - # s.framework = "SomeFramework" - # s.frameworks = "SomeFramework", "AnotherFramework" - - # s.library = "iconv" - #spec.libraries = "RCTDataManager", "ReactKit" - -end diff --git a/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj b/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj index f2f3f6a33..9aa64ad23 100644 --- a/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj +++ b/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj @@ -205,12 +205,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTNetwork; SKIP_INSTALL = YES; @@ -223,12 +220,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTNetwork; SKIP_INSTALL = YES; diff --git a/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj b/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj index 507f47aa0..9521a4dfc 100644 --- a/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj +++ b/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj @@ -199,12 +199,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTPushNotification; SKIP_INSTALL = YES; @@ -217,12 +214,9 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/nicklockwood/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/ReactKit/build/Debug-iphoneos", + "$(SRCROOT)/../../React/**", ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTPushNotification; SKIP_INSTALL = YES; diff --git a/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj b/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj index bb4457b1f..a710b09e9 100644 --- a/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj +++ b/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj @@ -193,7 +193,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = YES; @@ -232,7 +232,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; @@ -244,6 +244,11 @@ 580C37841AB104AF0015E709 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = ( "-ObjC", "-framework", @@ -257,6 +262,11 @@ 580C37851AB104AF0015E709 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = ( "-ObjC", "-framework", diff --git a/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj b/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj index 07d24eb36..082ba27b2 100644 --- a/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj +++ b/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj @@ -161,7 +161,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.2; MTL_ENABLE_DEBUG_INFO = YES; @@ -200,7 +200,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.2; MTL_ENABLE_DEBUG_INFO = NO; @@ -212,6 +212,11 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = ( "-ObjC", "-llibicucore", @@ -224,6 +229,11 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = ( "-ObjC", "-llibicucore", diff --git a/Libraries/Text/RCTRawTextManager.m b/Libraries/Text/RCTRawTextManager.m index 93535be2f..3215b36c1 100644 --- a/Libraries/Text/RCTRawTextManager.m +++ b/Libraries/Text/RCTRawTextManager.m @@ -23,5 +23,7 @@ return [[RCTShadowRawText alloc] init]; } +RCT_EXPORT_SHADOW_PROPERTY(text, NSString) + @end diff --git a/Libraries/Text/RCTShadowText.h b/Libraries/Text/RCTShadowText.h index b14a623c8..82ea2b632 100644 --- a/Libraries/Text/RCTShadowText.h +++ b/Libraries/Text/RCTShadowText.h @@ -17,7 +17,6 @@ extern NSString *const RCTReactTagAttributeName; @property (nonatomic, assign) NSWritingDirection writingDirection; @property (nonatomic, strong) UIColor *textBackgroundColor; @property (nonatomic, strong) UIColor *color; -@property (nonatomic, strong) UIFont *font; @property (nonatomic, copy) NSString *fontFamily; @property (nonatomic, assign) CGFloat fontSize; @property (nonatomic, copy) NSString *fontWeight; @@ -27,6 +26,9 @@ extern NSString *const RCTReactTagAttributeName; @property (nonatomic, assign) NSInteger maxNumberOfLines; @property (nonatomic, assign) CGSize shadowOffset; @property (nonatomic, assign) NSTextAlignment textAlign; + +// Not exposed to JS +@property (nonatomic, strong) UIFont *font; @property (nonatomic, assign) NSLineBreakMode truncationMode; - (NSAttributedString *)attributedString; diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index f00350205..03d327898 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -11,7 +11,6 @@ #import "RCTConvert.h" #import "RCTLog.h" - #import "RCTShadowRawText.h" #import "RCTUtils.h" @@ -154,7 +153,7 @@ static css_dim_t RCTMeasure(void *context, float width) } }]; - // TODO: umm, these can'e be null, so we're mapping left to natural - is that right? + // TODO: umm, these can't be null, so we're mapping left to natural - is that right? self.textAlign = _textAlign ?: NSTextAlignmentNatural; self.writingDirection = _writingDirection ?: NSWritingDirectionNatural; diff --git a/Libraries/Text/RCTText.m b/Libraries/Text/RCTText.m index e5af69be8..457079bcb 100644 --- a/Libraries/Text/RCTText.m +++ b/Libraries/Text/RCTText.m @@ -11,7 +11,7 @@ #import "RCTShadowText.h" #import "RCTUtils.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTText { diff --git a/Libraries/Text/RCTText.podspec b/Libraries/Text/RCTText.podspec deleted file mode 100644 index 656e0ee74..000000000 --- a/Libraries/Text/RCTText.podspec +++ /dev/null @@ -1,28 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'RCTText' - spec.version = '0.0.1' - spec.summary = 'Provides basic Text capabilities in ReactNative apps.' - spec.description = <<-DESC - Text can be rendered in ReactNative apps with the component using this module. - DESC - spec.homepage = 'https://facebook.github.io/react-native/' - spec.license = { :type => 'BSD' } - spec.author = 'Facebook' - spec.platform = :ios, '7.0' - spec.requires_arc = true - spec.source_files = '**/*.{h,m,c}' - spec.dependency "ReactKit", "~> 0.0.1" - - # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Link your library with frameworks, or libraries. Libraries do not include - # the lib prefix of their name. - # - - # s.framework = "SomeFramework" - # s.frameworks = "SomeFramework", "AnotherFramework" - - # s.library = "iconv" - #spec.libraries = "RCTText", "ReactKit" - -end diff --git a/Libraries/Text/RCTText.xcodeproj/project.pbxproj b/Libraries/Text/RCTText.xcodeproj/project.pbxproj index 22eafac25..7f34de484 100644 --- a/Libraries/Text/RCTText.xcodeproj/project.pbxproj +++ b/Libraries/Text/RCTText.xcodeproj/project.pbxproj @@ -223,7 +223,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -237,7 +237,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Libraries/Text/RCTTextManager.m b/Libraries/Text/RCTTextManager.m index 1c085f693..70cbd9ab5 100644 --- a/Libraries/Text/RCTTextManager.m +++ b/Libraries/Text/RCTTextManager.m @@ -16,7 +16,7 @@ #import "RCTShadowText.h" #import "RCTSparseArray.h" #import "RCTText.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTTextManager @@ -32,8 +32,8 @@ #pragma mark - View properties -RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor) -RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText) +RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor, UIColor) +RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, NSInteger, RCTText) { NSLineBreakMode truncationMode = NSLineBreakByClipping; view.numberOfLines = json ? [RCTConvert NSInteger:json] : defaultView.numberOfLines; @@ -45,16 +45,24 @@ RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText) #pragma mark - Shadow properties -RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowText) -{ - view.textBackgroundColor = json ? [RCTConvert UIColor:json] : defaultView.textBackgroundColor; -} -RCT_CUSTOM_SHADOW_PROPERTY(containerBackgroundColor, RCTShadowText) +RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection) +RCT_EXPORT_SHADOW_PROPERTY(color, UIColor) +RCT_EXPORT_SHADOW_PROPERTY(fontFamily, NSString) +RCT_EXPORT_SHADOW_PROPERTY(fontSize, CGFloat) +RCT_EXPORT_SHADOW_PROPERTY(fontWeight, NSString) +RCT_EXPORT_SHADOW_PROPERTY(fontStyle, NSString) +RCT_EXPORT_SHADOW_PROPERTY(isHighlighted, BOOL) +RCT_EXPORT_SHADOW_PROPERTY(lineHeight, CGFloat) +RCT_EXPORT_SHADOW_PROPERTY(maxNumberOfLines, NSInteger) +RCT_EXPORT_SHADOW_PROPERTY(shadowOffset, CGSize) +RCT_EXPORT_SHADOW_PROPERTY(textAlign, NSTextAlignment) +RCT_REMAP_SHADOW_PROPERTY(backgroundColor, textBackgroundColor, UIColor) +RCT_CUSTOM_SHADOW_PROPERTY(containerBackgroundColor, UIColor, RCTShadowText) { view.backgroundColor = json ? [RCTConvert UIColor:json] : defaultView.backgroundColor; view.isBGColorExplicitlySet = json ? YES : defaultView.isBGColorExplicitlySet; } -RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, RCTShadowText) +RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, NSInteger, RCTShadowText) { NSLineBreakMode truncationMode = NSLineBreakByClipping; view.maxNumberOfLines = json ? [RCTConvert NSInteger:json] : defaultView.maxNumberOfLines; @@ -63,10 +71,6 @@ RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, RCTShadowText) } view.truncationMode = truncationMode; } -RCT_CUSTOM_SHADOW_PROPERTY(textAlign, RCTShadowText) -{ - view.textAlign = json ? [RCTConvert NSTextAlignment:json] : defaultView.textAlign; -} - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowView { diff --git a/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj b/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj index 8de930901..c8d628bbe 100644 --- a/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj +++ b/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -194,7 +194,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../ReactKit/**", + "$(SRCROOT)/../../React/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; @@ -206,6 +206,11 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -215,6 +220,11 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/Libraries/react-native/react-native.js b/Libraries/react-native/react-native.js index 557f4f3f2..c0bb989f4 100644 --- a/Libraries/react-native/react-native.js +++ b/Libraries/react-native/react-native.js @@ -26,7 +26,7 @@ var ReactNative = Object.assign(Object.create(require('React')), { MapView: require('MapView'), NavigatorIOS: require('NavigatorIOS'), PickerIOS: require('PickerIOS'), - ReactNavigator: require('ReactNavigator'), + Navigator: require('Navigator'), ScrollView: require('ScrollView'), SliderIOS: require('SliderIOS'), SwitchIOS: require('SwitchIOS'), diff --git a/Libraries/vendor/react/browser/eventPlugins/PanResponder.js b/Libraries/vendor/react/browser/eventPlugins/PanResponder.js index 22bcaeffe..b6c11c9bc 100644 --- a/Libraries/vendor/react/browser/eventPlugins/PanResponder.js +++ b/Libraries/vendor/react/browser/eventPlugins/PanResponder.js @@ -18,66 +18,143 @@ var currentCentroidX = TouchHistoryMath.currentCentroidX; var currentCentroidY = TouchHistoryMath.currentCentroidY; /** + * `PanResponder` reconciles several touches into a single gesture. It makes + * single-touch gestures resilient to extra touches, and can be used to + * recognize simple multi-touch gestures. * - * +----------------------------+ +--------------------------------+ - * | ResponderTouchHistoryStore | |TouchHistoryMath | - * +----------------------------+ +----------+---------------------+ - * |Global store of touchHistory| |Allocation-less math util | - * |including activeness, start | |on touch history (centroids | - * |position, prev/cur position.| |and multitouch movement etc) | - * | | | | - * +----^-----------------------+ +----^---------------------------+ - * | | - * | (records relevant history | - * | of touches relevant for | - * | implementing higher level | - * | gestures) | - * | | - * +----+-----------------------+ +----|---------------------------+ - * | ResponderEventPlugin | | | Your App/Component | - * +----------------------------+ +----|---------------------------+ - * |Negotiates which view gets | Low level | | High level | - * |onResponderMove events. | events w/ | +-+-------+ events w/ | - * |Also records history into | touchHistory| | Pan | multitouch + | - * |ResponderTouchHistoryStore. +---------------->Responder+-----> accumulative| - * +----------------------------+ attached to | | | distance and | - * each event | +---------+ velocity. | - * | | - * | | - * +--------------------------------+ + * It provides a predictable wrapper of the responder handlers provided by the + * [gesture responder system](/react-native/docs/gesture-responder-system.html). + * For each handler, it provides a new `gestureState` object alongside the + * normal event. * + * A `gestureState` object has the following: * + * - `stateID` - ID of the gestureState- persisted as long as there at least + * one touch on screen + * - `moveX` - the latest screen coordinates of the recently-moved touch + * - `moveY` - the latest screen coordinates of the recently-moved touch + * - `x0` - the screen coordinates of the responder grant + * - `y0` - the screen coordinates of the responder grant + * - `dx` - accumulated distance of the gesture since the touch started + * - `dy` - accumulated distance of the gesture since the touch started + * - `vx` - current velocity of the gesture + * - `vy` - current velocity of the gesture + * - `numberActiveTouches` - Number of touches currently on screeen * - * Gesture that calculates cumulative movement over time in a way that just - * "does the right thing" for multiple touches. The "right thing" is very - * nuanced. When moving two touches in opposite directions, the cumulative - * distance is zero in each dimension. When two touches move in parallel five - * pixels in the same direction, the cumulative distance is five, not ten. If - * two touches start, one moves five in a direction, then stops and the other - * touch moves fives in the same direction, the cumulative distance is ten. + * ### Basic Usage * - * This logic requires a kind of processing of time "clusters" of touch events - * so that two touch moves that essentially occur in parallel but move every - * other frame respectively, are considered part of the same movement. + * ``` + * componentWillMount: function() { + * this._panGesture = PanResponder.create({ + * // Ask to be the responder: + * onStartShouldSetPanResponder: (evt, gestureState) => true, + * onStartShouldSetPanResponderCapture: (evt, gestureState) => true, + * onMoveShouldSetPanResponder: (evt, gestureState) => true, + * onMoveShouldSetPanResponderCapture: (evt, gestureState) => true, * - * Explanation of some of the non-obvious fields: + * onPanResponderGrant: (evt, gestureState) => { + * // The guesture has started. Show visual feedback so the user knows + * // what is happening! * - * - moveX/moveY: If no move event has been observed, then `(moveX, moveY)` is - * invalid. If a move event has been observed, `(moveX, moveY)` is the - * centroid of the most recently moved "cluster" of active touches. - * (Currently all move have the same timeStamp, but later we should add some - * threshold for what is considered to be "moving"). If a palm is - * accidentally counted as a touch, but a finger is moving greatly, the palm - * will move slightly, but we only want to count the single moving touch. - * - x0/y0: Centroid location (non-cumulative) at the time of becoming - * responder. - * - dx/dy: Cumulative touch distance - not the same thing as sum of each touch - * distance. Accounts for touch moves that are clustered together in time, - * moving the same direction. Only valid when currently responder (otherwise, - * it only represents the drag distance below the threshold). - * - vx/vy: Velocity. + * // gestureState.{x,y}0 will be set to zero now + * }, + * onPanResponderMove: (evt, gestureState) => { + * // The most recent move distance is gestureState.move{X,Y} + * + * // The accumulated gesture distance since becoming responder is + * // gestureState.d{x,y} + * }, + * onResponderTerminationRequest: (evt, gestureState) => true, + * onPanResponderRelease: (evt, gestureState) => { + * // The user has released all touches while this view is the + * // responder. This typically means a gesture has succeeded + * }, + * onPanResponderTerminate: (evt, gestureState) => { + * // Another component has become the responder, so this gesture + * // should be cancelled + * }, + * }); + * }, + * + * render: function() { + * return ( + * + * ); + * }, + * + * ``` + * + * ### Working Example + * + * To see it in action, try the + * [PanResponder example in UIExplorer](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ResponderExample.js) */ + var PanResponder = { + + /** + * + * A graphical explanation of the touch data flow: + * + * +----------------------------+ +--------------------------------+ + * | ResponderTouchHistoryStore | |TouchHistoryMath | + * +----------------------------+ +----------+---------------------+ + * |Global store of touchHistory| |Allocation-less math util | + * |including activeness, start | |on touch history (centroids | + * |position, prev/cur position.| |and multitouch movement etc) | + * | | | | + * +----^-----------------------+ +----^---------------------------+ + * | | + * | (records relevant history | + * | of touches relevant for | + * | implementing higher level | + * | gestures) | + * | | + * +----+-----------------------+ +----|---------------------------+ + * | ResponderEventPlugin | | | Your App/Component | + * +----------------------------+ +----|---------------------------+ + * |Negotiates which view gets | Low level | | High level | + * |onResponderMove events. | events w/ | +-+-------+ events w/ | + * |Also records history into | touchHistory| | Pan | multitouch + | + * |ResponderTouchHistoryStore. +---------------->Responder+-----> accumulative| + * +----------------------------+ attached to | | | distance and | + * each event | +---------+ velocity. | + * | | + * | | + * +--------------------------------+ + * + * + * + * Gesture that calculates cumulative movement over time in a way that just + * "does the right thing" for multiple touches. The "right thing" is very + * nuanced. When moving two touches in opposite directions, the cumulative + * distance is zero in each dimension. When two touches move in parallel five + * pixels in the same direction, the cumulative distance is five, not ten. If + * two touches start, one moves five in a direction, then stops and the other + * touch moves fives in the same direction, the cumulative distance is ten. + * + * This logic requires a kind of processing of time "clusters" of touch events + * so that two touch moves that essentially occur in parallel but move every + * other frame respectively, are considered part of the same movement. + * + * Explanation of some of the non-obvious fields: + * + * - moveX/moveY: If no move event has been observed, then `(moveX, moveY)` is + * invalid. If a move event has been observed, `(moveX, moveY)` is the + * centroid of the most recently moved "cluster" of active touches. + * (Currently all move have the same timeStamp, but later we should add some + * threshold for what is considered to be "moving"). If a palm is + * accidentally counted as a touch, but a finger is moving greatly, the palm + * will move slightly, but we only want to count the single moving touch. + * - x0/y0: Centroid location (non-cumulative) at the time of becoming + * responder. + * - dx/dy: Cumulative touch distance - not the same thing as sum of each touch + * distance. Accounts for touch moves that are clustered together in time, + * moving the same direction. Only valid when currently responder (otherwise, + * it only represents the drag distance below the threshold). + * - vx/vy: Velocity. + */ + _initializeGestureState: function(gestureState) { gestureState.moveX = 0; gestureState.moveY = 0; @@ -147,29 +224,29 @@ var PanResponder = { /** * @param {object} config Enhanced versions of all of the responder callbacks - * that accept not only the typical `ResponderSyntheticEvent`, but also the + * that provide not only the typical `ResponderSyntheticEvent`, but also the * `PanResponder` gesture state. Simply replace the word `Responder` with * `PanResponder` in each of the typical `onResponder*` callbacks. For * example, the `config` object would look like: * - * - onMoveShouldSetPanResponder: (e, gestureState) => {...} - * - onMoveShouldSetPanResponderCapture: (e, gestureState) => {...} - * - onStartShouldSetPanResponder: (e, gestureState) => {...} - * - onStartShouldSetPanResponderCapture: (e, gestureState) => {...} - * - onPanResponderReject: (e, gestureState) => {...} - * - onPanResponderGrant: (e, gestureState) => {...} - * - onPanResponderStart: (e, gestureState) => {...} - * - onPanResponderEnd: (e, gestureState) => {...} - * - onPanResponderRelease: (e, gestureState) => {...} - * - onPanResponderMove: (e, gestureState) => {...} - * - onPanResponderTerminate: (e, gestureState) => {...} - * - onPanResponderTerminationRequest: (e, gestureState) => {...} + * - `onMoveShouldSetPanResponder: (e, gestureState) => {...}` + * - `onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}` + * - `onStartShouldSetPanResponder: (e, gestureState) => {...}` + * - `onStartShouldSetPanResponderCapture: (e, gestureState) => {...}` + * - `onPanResponderReject: (e, gestureState) => {...}` + * - `onPanResponderGrant: (e, gestureState) => {...}` + * - `onPanResponderStart: (e, gestureState) => {...}` + * - `onPanResponderEnd: (e, gestureState) => {...}` + * - `onPanResponderRelease: (e, gestureState) => {...}` + * - `onPanResponderMove: (e, gestureState) => {...}` + * - `onPanResponderTerminate: (e, gestureState) => {...}` + * - `onPanResponderTerminationRequest: (e, gestureState) => {...}` * - * - In general, for events that have capture equivalents, we update the + * In general, for events that have capture equivalents, we update the * gestureState once in the capture phase and can use it in the bubble phase * as well. * - * - Be careful with onStartShould* callbacks. They only reflect updated + * Be careful with onStartShould* callbacks. They only reflect updated * `gestureState` for start/end events that bubble/capture to the Node. * Once the node is the responder, you can rely on every start/end event * being processed by the gesture and `gestureState` being updated diff --git a/React.podspec b/React.podspec new file mode 100644 index 000000000..e8403caab --- /dev/null +++ b/React.podspec @@ -0,0 +1,79 @@ +Pod::Spec.new do |s| + s.name = "React" + s.version = "0.1.0" + s.summary = "Build high quality mobile apps using React." + s.description= <<-DESC + React Native apps are built using the React JS framework, + and render directly to native UIKit elements using a fully + asynchronous architecture. There is no browser and no HTML. + We have picked what we think is the best set of features from + these and other technologies to build what we hope to become + the best product development framework available, with an + emphasis on iteration speed, developer delight, continuity + of technology, and absolutely beautiful and fast products + with no compromises in quality or capability. + DESC + s.homepage = "http://facebook.github.io/react-native/" + s.license = "BSD" + s.author = "Facebook" + s.platform = :ios, "7.0" + s.source = { :git => "https://github.com/facebook/react-native.git", :tag => "v#{s.version}" } + s.source_files = "React/**/*.{c,h,m}" + s.resources = "Resources/*.png" + s.preserve_paths = "cli.js", "Libraries/**/*.js", "lint", "linter.js", "node_modules", "package.json", "packager", "PATENTS", "react-native-cli" + s.exclude_files = "**/__tests__/*", "IntegrationTests/*" + s.frameworks = "JavaScriptCore" + s.requires_arc = true + s.prepare_command = 'npm install' + s.libraries = 'libicucore' + s.xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } + + s.subspec 'RCTActionSheet' do |ss| + ss.source_files = "Libraries/ActionSheetIOS/*.{h,m}" + ss.preserve_paths = "Libraries/ActionSheetIOS/*.js" + end + + s.subspec 'RCTAdSupport' do |ss| + ss.source_files = "Libraries/RCTAdSupport/*.{h,m}" + ss.preserve_paths = "Libraries/RCTAdSupport/*.js" + end + + s.subspec 'RCTAnimation' do |ss| + ss.source_files = "Libraries/Animation/*.{h,m}" + ss.preserve_paths = "Libraries/Animation/*.js" + end + + s.subspec 'RCTGeolocation' do |ss| + ss.source_files = "Libraries/Geolocation/*.{h,m}" + ss.preserve_paths = "Libraries/Geolocation/*.js" + end + + s.subspec 'RCTImage' do |ss| + ss.source_files = "Libraries/Image/*.{h,m}" + ss.preserve_paths = "Libraries/Image/*.js" + end + + s.subspec 'RCTNetwork' do |ss| + ss.source_files = "Libraries/Network/*.{h,m}" + ss.preserve_paths = "Libraries/Network/*.js" + end + + s.subspec 'RCTPushNotification' do |ss| + ss.source_files = "Libraries/PushNotificationIOS/*.{h,m}" + ss.preserve_paths = "Libraries/PushNotificationIOS/*.js" + end + + s.subspec 'RCTWebSocketDebugger' do |ss| + ss.source_files = "Libraries/RCTWebSocketDebugger/*.{h,m}" + end + + s.subspec 'RCTText' do |ss| + ss.source_files = "Libraries/Text/*.{h,m}" + ss.preserve_paths = "Libraries/Text/*.js" + end + + s.subspec 'RCTVibration' do |ss| + ss.source_files = "Libraries/Vibration/*.{h,m}" + ss.preserve_paths = "Libraries/Vibration/*.js" + end +end diff --git a/ReactKit/Base/RCTAssert.h b/React/Base/RCTAssert.h similarity index 100% rename from ReactKit/Base/RCTAssert.h rename to React/Base/RCTAssert.h diff --git a/ReactKit/Base/RCTAssert.m b/React/Base/RCTAssert.m similarity index 100% rename from ReactKit/Base/RCTAssert.m rename to React/Base/RCTAssert.m diff --git a/ReactKit/Base/RCTBridge.h b/React/Base/RCTBridge.h similarity index 100% rename from ReactKit/Base/RCTBridge.h rename to React/Base/RCTBridge.h diff --git a/ReactKit/Base/RCTBridge.m b/React/Base/RCTBridge.m similarity index 99% rename from ReactKit/Base/RCTBridge.m rename to React/Base/RCTBridge.m index fe13a1bfd..8a81a2327 100644 --- a/ReactKit/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -508,7 +508,7 @@ static id _latestJSExecutor; { if ((self = [super init])) { _eventDispatcher = [[RCTEventDispatcher alloc] initWithBridge:self]; - _shadowQueue = dispatch_queue_create("com.facebook.ReactKit.ShadowQueue", DISPATCH_QUEUE_SERIAL); + _shadowQueue = dispatch_queue_create("com.facebook.React.ShadowQueue", DISPATCH_QUEUE_SERIAL); _moduleProvider = block; _launchOptions = launchOptions; } diff --git a/ReactKit/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h similarity index 100% rename from ReactKit/Base/RCTBridgeModule.h rename to React/Base/RCTBridgeModule.h diff --git a/ReactKit/Base/RCTCache.h b/React/Base/RCTCache.h similarity index 100% rename from ReactKit/Base/RCTCache.h rename to React/Base/RCTCache.h diff --git a/ReactKit/Base/RCTCache.m b/React/Base/RCTCache.m similarity index 97% rename from ReactKit/Base/RCTCache.m rename to React/Base/RCTCache.m index efc68ae37..6297771d2 100644 --- a/ReactKit/Base/RCTCache.m +++ b/React/Base/RCTCache.m @@ -12,8 +12,8 @@ #import #import -static NSString *const RCTCacheSubdirectoryName = @"ReactKit"; -static NSString *const RCTKeyExtendedAttributeName = @"com.facebook.ReactKit.RCTCacheManager.Key"; +static NSString *const RCTCacheSubdirectoryName = @"React"; +static NSString *const RCTKeyExtendedAttributeName = @"com.facebook.React.RCTCacheManager.Key"; static NSMapTable *RCTLivingCachesByName; static NSError *RCTPOSIXError(int errorNumber) @@ -88,7 +88,7 @@ static BOOL RCTSetExtendedAttribute(NSURL *fileURL, NSString *key, NSString *val { dispatch_queue_t queue = _queue; if (!queue) { - NSString *queueName = [NSString stringWithFormat:@"com.facebook.ReactKit.RCTCache.%@", _UUID.UUIDString]; + NSString *queueName = [NSString stringWithFormat:@"com.facebook.React.RCTCache.%@", _UUID.UUIDString]; queue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL); _queue = queue; } diff --git a/ReactKit/Base/RCTConvert.h b/React/Base/RCTConvert.h similarity index 95% rename from ReactKit/Base/RCTConvert.h rename to React/Base/RCTConvert.h index fb4f51883..c8d6ecada 100644 --- a/ReactKit/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -48,8 +48,13 @@ + (NSTextAlignment)NSTextAlignment:(id)json; + (NSWritingDirection)NSWritingDirection:(id)json; + (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json; ++ (UITextFieldViewMode)UITextFieldViewMode:(id)json; ++ (UIScrollViewKeyboardDismissMode)UIScrollViewKeyboardDismissMode:(id)json; + (UIKeyboardType)UIKeyboardType:(id)json; ++ (UIViewContentMode)UIViewContentMode:(id)json; ++ (UIBarStyle)UIBarStyle:(id)json; + + (CGFloat)CGFloat:(id)json; + (CGPoint)CGPoint:(id)json; + (CGSize)CGSize:(id)json; @@ -72,13 +77,11 @@ + (UIFont *)UIFont:(UIFont *)font withWeight:(id)json; + (UIFont *)UIFont:(UIFont *)font withStyle:(id)json; + (UIFont *)UIFont:(UIFont *)font withFamily:(id)json; -+ (UIFont *)UIFont:(UIFont *)font - withFamily:(id)family - size:(id)size - weight:(id)weight - style:(id)style; ++ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family + size:(id)size weight:(id)weight style:(id)style; + (NSArray *)NSStringArray:(id)json; ++ (NSArray *)NSDictionaryArray:(id)json; + (NSArray *)NSURLArray:(id)json; + (NSArray *)NSNumberArray:(id)json; + (NSArray *)UIColorArray:(id)json; @@ -106,20 +109,14 @@ extern "C" { * applying an appropriate conversion method. If the property does not * exist, or the type cannot be inferred, the function will return NO. */ -BOOL RCTSetProperty(id target, NSString *keypath, id json); +BOOL RCTSetProperty(id target, NSString *keyPath, SEL type, id json); /** * This function attempts to copy a property from the source object to the * destination object using KVC. If the property does not exist, or cannot * be set, it will do nothing and return NO. */ -BOOL RCTCopyProperty(id target, id source, NSString *keypath); - -/** - * This function attempts to convert a JSON value to an object that can be used - * in KVC with the specific target and key path. - */ -id RCTConvertValue(id target, NSString *keypath, id json); +BOOL RCTCopyProperty(id target, id source, NSString *keyPath); #ifdef __cplusplus } diff --git a/ReactKit/Base/RCTConvert.m b/React/Base/RCTConvert.m similarity index 69% rename from ReactKit/Base/RCTConvert.m rename to React/Base/RCTConvert.m index 01300e306..9bf7104c9 100644 --- a/ReactKit/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -102,11 +102,45 @@ RCT_ENUM_CONVERTER(UITextAutocapitalizationType, (@{ @"characters": @(UITextAutocapitalizationTypeAllCharacters) }), UITextAutocapitalizationTypeSentences, integerValue) +RCT_ENUM_CONVERTER(UITextFieldViewMode, (@{ + @"never": @(UITextFieldViewModeNever), + @"while-editing": @(UITextFieldViewModeWhileEditing), + @"unless-editing": @(UITextFieldViewModeUnlessEditing), + @"always": @(UITextFieldViewModeAlways), +}), UITextFieldViewModeNever, integerValue) + +RCT_ENUM_CONVERTER(UIScrollViewKeyboardDismissMode, (@{ + @"none": @(UIScrollViewKeyboardDismissModeNone), + @"on-drag": @(UIScrollViewKeyboardDismissModeOnDrag), + @"interactive": @(UIScrollViewKeyboardDismissModeInteractive), +}), UIScrollViewKeyboardDismissModeNone, integerValue) + RCT_ENUM_CONVERTER(UIKeyboardType, (@{ @"numeric": @(UIKeyboardTypeDecimalPad), @"default": @(UIKeyboardTypeDefault), }), UIKeyboardTypeDefault, integerValue) +RCT_ENUM_CONVERTER(UIViewContentMode, (@{ + @"scale-to-fill": @(UIViewContentModeScaleToFill), + @"scale-aspect-fit": @(UIViewContentModeScaleAspectFit), + @"scale-aspect-fill": @(UIViewContentModeScaleAspectFill), + @"redraw": @(UIViewContentModeRedraw), + @"center": @(UIViewContentModeCenter), + @"top": @(UIViewContentModeTop), + @"bottom": @(UIViewContentModeBottom), + @"left": @(UIViewContentModeLeft), + @"right": @(UIViewContentModeRight), + @"top-left": @(UIViewContentModeTopLeft), + @"top-right": @(UIViewContentModeTopRight), + @"bottom-left": @(UIViewContentModeBottomLeft), + @"bottom-right": @(UIViewContentModeBottomRight), +}), UIViewContentModeScaleToFill, integerValue) + +RCT_ENUM_CONVERTER(UIBarStyle, (@{ + @"default": @(UIBarStyleDefault), + @"black": @(UIBarStyleBlack), +}), UIBarStyleDefault, integerValue) + // TODO: normalise the use of w/width so we can do away with the alias values (#6566645) RCT_CONVERTER_CUSTOM(CGFloat, CGFloat, [self double:json]) RCT_CGSTRUCT_CONVERTER(CGPoint, (@[@"x", @"y"]), nil) @@ -424,7 +458,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ // These constants are defined in iPhone SDK 8.2 // They'll work fine in earlier iOS versions, but the app cannot be built with // an SDK version < 8.2 unless we redefine them here. This will be removed -// in a future version of ReactKit, once 8.2 is more widely adopted. +// in a future version of React, once 8.2 is more widely adopted. static const CGFloat UIFontWeightUltraLight = -0.8; static const CGFloat UIFontWeightThin = -0.6; @@ -500,11 +534,8 @@ static BOOL RCTFontIsCondensed(UIFont *font) return [self UIFont:font withFamily:json size:nil weight:nil style:nil]; } -+ (UIFont *)UIFont:(UIFont *)font - withFamily:(id)family - size:(id)size - weight:(id)weight - style:(id)style ++ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family + size:(id)size weight:(id)weight style:(id)style { // Defaults NSString *const RCTDefaultFontFamily = @"Helvetica Neue"; @@ -579,6 +610,7 @@ static BOOL RCTFontIsCondensed(UIFont *font) } RCT_ARRAY_CONVERTER(NSString) +RCT_ARRAY_CONVERTER(NSDictionary) RCT_ARRAY_CONVERTER(NSURL) RCT_ARRAY_CONVERTER(NSNumber) RCT_ARRAY_CONVERTER(UIColor) @@ -648,229 +680,10 @@ RCT_ENUM_CONVERTER(RCTAnimationType, (@{ @end -static NSString *RCTGuessTypeEncoding(id target, NSString *key, id value, NSString *encoding) -{ - /** - * NOTE: the property names below may seem weird, but it's - * because they are tested as case-sensitive suffixes, so - * "ffset" will match any of the following - * - * - offset - * - contentOffset - */ - - // TODO (#5906496): handle more cases - if ([key hasSuffix:@"olor"]) { - if ([target isKindOfClass:[CALayer class]]) { - return @(@encode(CGColorRef)); - } else { - return @"@\"UIColor\""; - } - } else if ([key hasSuffix:@"Inset"] || [key hasSuffix:@"Insets"]) { - return @(@encode(UIEdgeInsets)); - } else if ([key hasSuffix:@"rame"] || [key hasSuffix:@"ounds"]) { - return @(@encode(CGRect)); - } else if ([key hasSuffix:@"ffset"] || [key hasSuffix:@"osition"]) { - return @(@encode(CGPoint)); - } else if ([key hasSuffix:@"ize"]) { - return @(@encode(CGSize)); - } - return nil; -} - -static id RCTConvertValueWithEncoding(id value, NSString *encoding) -{ - static NSDictionary *converters = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - - id (^numberConvert)(id) = ^(id val){ - return [RCTConvert NSNumber:val]; - }; - - id (^boolConvert)(id) = ^(id val){ - return @([RCTConvert BOOL:val]); - }; - - // TODO (#5906496): add the rest of RCTConvert here - converters = - @{ - @(@encode(char)): boolConvert, - @(@encode(int)): numberConvert, - @(@encode(short)): numberConvert, - @(@encode(long)): numberConvert, - @(@encode(long long)): numberConvert, - @(@encode(unsigned char)): numberConvert, - @(@encode(unsigned int)): numberConvert, - @(@encode(unsigned short)): numberConvert, - @(@encode(unsigned long)): numberConvert, - @(@encode(unsigned long long)): numberConvert, - @(@encode(float)): numberConvert, - @(@encode(double)): numberConvert, - @(@encode(bool)): boolConvert, - @(@encode(UIEdgeInsets)): ^(id val) { - return [NSValue valueWithUIEdgeInsets:[RCTConvert UIEdgeInsets:val]]; - }, - @(@encode(CGPoint)): ^(id val) { - return [NSValue valueWithCGPoint:[RCTConvert CGPoint:val]]; - }, - @(@encode(CGSize)): ^(id val) { - return [NSValue valueWithCGSize:[RCTConvert CGSize:val]]; - }, - @(@encode(CGRect)): ^(id val) { - return [NSValue valueWithCGRect:[RCTConvert CGRect:val]]; - }, - @(@encode(CGColorRef)): ^(id val) { - return (id)[RCTConvert CGColor:val]; - }, - @(@encode(CGAffineTransform)): ^(id val) { - return [NSValue valueWithCGAffineTransform:[RCTConvert CGAffineTransform:val]]; - }, - @(@encode(CATransform3D)): ^(id val) { - return [NSValue valueWithCATransform3D:[RCTConvert CATransform3D:val]]; - }, - @"@\"NSString\"": ^(id val) { - return [RCTConvert NSString:val]; - }, - @"@\"NSURL\"": ^(id val) { - return [RCTConvert NSURL:val]; - }, - @"@\"UIColor\"": ^(id val) { - return [RCTConvert UIColor:val]; - }, - @"@\"UIImage\"": ^(id val) { - return [RCTConvert UIImage:val]; - }, - @"@\"NSDate\"": ^(id val) { - return [RCTConvert NSDate:val]; - }, - @"@\"NSTimeZone\"": ^(id val) { - return [RCTConvert NSTimeZone:val]; - }, - }; - }); - - // Handle null values - if (value == [NSNull null] && ![encoding isEqualToString:@"@\"NSNull\""]) { - return nil; - } - - // Convert value - id (^converter)(id) = converters[encoding]; - return converter ? converter(value) : value; -} - -static NSString *RCTPropertyEncoding(id target, NSString *key, id value) -{ - // Check target class for property definition - NSString *encoding = nil; - objc_property_t property = class_getProperty([target class], [key UTF8String]); - if (property) { - - // Get type info - char *typeEncoding = property_copyAttributeValue(property, "T"); - encoding = @(typeEncoding); - free(typeEncoding); - - } else { - - // Check if setter exists - SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", - [[key substringToIndex:1] uppercaseString], - [key substringFromIndex:1]]); - - if (![target respondsToSelector:setter]) { - return nil; - } - - // Get type of first method argument - Method method = class_getInstanceMethod([target class], setter); - char *typeEncoding = method_copyArgumentType(method, 2); - if (typeEncoding) { - encoding = @(typeEncoding); - free(typeEncoding); - } - - if (encoding.length == 0 || [encoding isEqualToString:@(@encode(id))]) { - // Not enough info about the type encoding to be useful, so - // try to guess the type from the value and property name - encoding = RCTGuessTypeEncoding(target, key, value, encoding); - } - - } - - // id encoding means unknown, as opposed to nil which means no setter exists. - return encoding ?: @(@encode(id)); -} - -static id RCTConvertValueWithExplicitEncoding(id target, NSString *key, id json, NSString *encoding) -{ - // Special case for numeric encodings, which may be enums - if ([json isKindOfClass:[NSString class]] && - ([encoding isEqualToString:@(@encode(id))] || - [@"iIsSlLqQ" rangeOfString:[encoding substringToIndex:1]].length)) { - - /** - * NOTE: the property names below may seem weird, but it's - * because they are tested as case-sensitive suffixes, so - * "apitalizationType" will match any of the following - * - * - capitalizationType - * - autocapitalizationType - * - autoCapitalizationType - * - titleCapitalizationType - * - etc. - */ - static NSDictionary *converters = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - converters = - @{ - @"apitalizationType": ^(id val) { - return [RCTConvert UITextAutocapitalizationType:val]; - }, - @"eyboardType": ^(id val) { - return [RCTConvert UIKeyboardType:val]; - }, - @"extAlignment": ^(id val) { - return [RCTConvert NSTextAlignment:val]; - }, - @"ritingDirection": ^(id val) { - return [RCTConvert NSWritingDirection:val]; - }, - @"Cap": ^(id val) { - return [RCTConvert CGLineCap:val]; - }, - @"Join": ^(id val) { - return [RCTConvert CGLineJoin:val]; - }, - @"ointerEvents": ^(id val) { - return [RCTConvert RCTPointerEvents:val]; - }, - }; - }); - for (NSString *subkey in converters) { - if ([key hasSuffix:subkey]) { - NSInteger (^converter)(NSString *) = converters[subkey]; - json = @(converter(json)); - break; - } - } - } - - return RCTConvertValueWithEncoding(json, encoding); -} - -id RCTConvertValue(id target, NSString *key, id json) -{ - NSString *encoding = RCTPropertyEncoding(target, key, json); - return RCTConvertValueWithExplicitEncoding(target, key, json, encoding); -} - -BOOL RCTSetProperty(id target, NSString *keypath, id value) +BOOL RCTSetProperty(id target, NSString *keyPath, SEL type, id json) { // Split keypath - NSArray *parts = [keypath componentsSeparatedByString:@"."]; + NSArray *parts = [keyPath componentsSeparatedByString:@"."]; NSString *key = [parts lastObject]; for (NSUInteger i = 0; i < parts.count - 1; i++) { target = [target valueForKey:parts[i]]; @@ -879,48 +692,41 @@ BOOL RCTSetProperty(id target, NSString *keypath, id value) } } - // Get encoding - NSString *encoding = RCTPropertyEncoding(target, key, value); - if (!encoding) { + // Get property setter + SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", + [[key substringToIndex:1] uppercaseString], + [key substringFromIndex:1]]); + + // Fail early + if (![target respondsToSelector:setter]) { return NO; } - // Convert value - value = RCTConvertValueWithExplicitEncoding(target, keypath, value, encoding); - - // Another nasty special case - if ([target isKindOfClass:[UITextField class]]) { - static NSDictionary *specialCases = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - specialCases = @{ - @"autocapitalizationType": ^(UITextField *f, NSInteger v){ f.autocapitalizationType = v; }, - @"autocorrectionType": ^(UITextField *f, NSInteger v){ f.autocorrectionType = v; }, - @"spellCheckingType": ^(UITextField *f, NSInteger v){ f.spellCheckingType = v; }, - @"keyboardType": ^(UITextField *f, NSInteger v){ f.keyboardType = v; }, - @"keyboardAppearance": ^(UITextField *f, NSInteger v){ f.keyboardAppearance = v; }, - @"returnKeyType": ^(UITextField *f, NSInteger v){ f.returnKeyType = v; }, - @"enablesReturnKeyAutomatically": ^(UITextField *f, NSInteger v){ f.enablesReturnKeyAutomatically = !!v; }, - @"secureTextEntry": ^(UITextField *f, NSInteger v){ f.secureTextEntry = !!v; }}; - }); - - void (^block)(UITextField *f, NSInteger v) = specialCases[key]; - if (block) { - block(target, [value integerValue]); - return YES; - } - } + // Get converted value + NSMethodSignature *signature = [RCTConvert methodSignatureForSelector:type]; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; + [invocation setArgument:&type atIndex:1]; + [invocation setArgument:&json atIndex:2]; + [invocation invokeWithTarget:[RCTConvert class]]; + NSUInteger length = [signature methodReturnLength]; + void *value = malloc(length); + [invocation getReturnValue:value]; // Set converted value - [target setValue:value forKey:key]; + signature = [target methodSignatureForSelector:setter]; + invocation = [NSInvocation invocationWithMethodSignature:signature]; + [invocation setArgument:&setter atIndex:1]; + [invocation setArgument:value atIndex:2]; + [invocation invokeWithTarget:target]; + free(value); return YES; } -BOOL RCTCopyProperty(id target, id source, NSString *keypath) +BOOL RCTCopyProperty(id target, id source, NSString *keyPath) { // Split keypath - NSArray *parts = [keypath componentsSeparatedByString:@"."]; + NSArray *parts = [keyPath componentsSeparatedByString:@"."]; NSString *key = [parts lastObject]; for (NSUInteger i = 0; i < parts.count - 1; i++) { source = [source valueForKey:parts[i]]; @@ -930,19 +736,35 @@ BOOL RCTCopyProperty(id target, id source, NSString *keypath) } } - // Check class for property definition - if (!class_getProperty([source class], [key UTF8String])) { - // Check if setter exists - SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", - [[key substringToIndex:1] uppercaseString], - [key substringFromIndex:1]]); + // Get property getter + SEL getter = NSSelectorFromString(key); - if (![source respondsToSelector:setter] - || ![target respondsToSelector:setter]) { - return NO; - } + // Get property setter + SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", + [[key substringToIndex:1] uppercaseString], + [key substringFromIndex:1]]); + + // Fail early + if (![source respondsToSelector:getter] || ![target respondsToSelector:setter]) { + return NO; } - [target setValue:[source valueForKey:key] forKey:key]; + // Get converted value + NSMethodSignature *signature = [source methodSignatureForSelector:getter]; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; + [invocation setArgument:&getter atIndex:1]; + [invocation invokeWithTarget:source]; + NSUInteger length = [signature methodReturnLength]; + void *value = malloc(length); + [invocation getReturnValue:value]; + + // Set converted value + signature = [target methodSignatureForSelector:setter]; + invocation = [NSInvocation invocationWithMethodSignature:signature]; + [invocation setArgument:&setter atIndex:1]; + [invocation setArgument:value atIndex:2]; + [invocation invokeWithTarget:target]; + free(value); + return YES; } diff --git a/ReactKit/Base/RCTDevMenu.h b/React/Base/RCTDevMenu.h similarity index 100% rename from ReactKit/Base/RCTDevMenu.h rename to React/Base/RCTDevMenu.h diff --git a/ReactKit/Base/RCTDevMenu.m b/React/Base/RCTDevMenu.m similarity index 100% rename from ReactKit/Base/RCTDevMenu.m rename to React/Base/RCTDevMenu.m diff --git a/ReactKit/Base/RCTEventDispatcher.h b/React/Base/RCTEventDispatcher.h similarity index 100% rename from ReactKit/Base/RCTEventDispatcher.h rename to React/Base/RCTEventDispatcher.h diff --git a/ReactKit/Base/RCTEventDispatcher.m b/React/Base/RCTEventDispatcher.m similarity index 100% rename from ReactKit/Base/RCTEventDispatcher.m rename to React/Base/RCTEventDispatcher.m diff --git a/ReactKit/Base/RCTInvalidating.h b/React/Base/RCTInvalidating.h similarity index 100% rename from ReactKit/Base/RCTInvalidating.h rename to React/Base/RCTInvalidating.h diff --git a/ReactKit/Base/RCTJSMethodRegistrar.h b/React/Base/RCTJSMethodRegistrar.h similarity index 100% rename from ReactKit/Base/RCTJSMethodRegistrar.h rename to React/Base/RCTJSMethodRegistrar.h diff --git a/ReactKit/Base/RCTJavaScriptExecutor.h b/React/Base/RCTJavaScriptExecutor.h similarity index 100% rename from ReactKit/Base/RCTJavaScriptExecutor.h rename to React/Base/RCTJavaScriptExecutor.h diff --git a/ReactKit/Base/RCTKeyCommands.h b/React/Base/RCTKeyCommands.h similarity index 100% rename from ReactKit/Base/RCTKeyCommands.h rename to React/Base/RCTKeyCommands.h diff --git a/ReactKit/Base/RCTKeyCommands.m b/React/Base/RCTKeyCommands.m similarity index 100% rename from ReactKit/Base/RCTKeyCommands.m rename to React/Base/RCTKeyCommands.m diff --git a/ReactKit/Base/RCTLog.h b/React/Base/RCTLog.h similarity index 100% rename from ReactKit/Base/RCTLog.h rename to React/Base/RCTLog.h diff --git a/ReactKit/Base/RCTLog.m b/React/Base/RCTLog.m similarity index 100% rename from ReactKit/Base/RCTLog.m rename to React/Base/RCTLog.m diff --git a/ReactKit/Base/RCTRedBox.h b/React/Base/RCTRedBox.h similarity index 100% rename from ReactKit/Base/RCTRedBox.h rename to React/Base/RCTRedBox.h diff --git a/ReactKit/Base/RCTRedBox.m b/React/Base/RCTRedBox.m similarity index 100% rename from ReactKit/Base/RCTRedBox.m rename to React/Base/RCTRedBox.m diff --git a/ReactKit/Base/RCTRootView.h b/React/Base/RCTRootView.h similarity index 100% rename from ReactKit/Base/RCTRootView.h rename to React/Base/RCTRootView.h diff --git a/ReactKit/Base/RCTRootView.m b/React/Base/RCTRootView.m similarity index 99% rename from ReactKit/Base/RCTRootView.m rename to React/Base/RCTRootView.m index 7f60598c3..ac39a9aed 100644 --- a/ReactKit/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -21,7 +21,7 @@ #import "RCTUIManager.h" #import "RCTUtils.h" #import "RCTWebViewExecutor.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" NSString *const RCTReloadNotification = @"RCTReloadNotification"; @@ -244,7 +244,7 @@ static Class _globalExecutorClass; if (error) { if ([[error domain] isEqualToString:NSURLErrorDomain]) { NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: @"Could not connect to development server. Ensure node server is running - run 'npm start' from ReactKit root", + NSLocalizedDescriptionKey: @"Could not connect to development server. Ensure node server is running - run 'npm start' from React root", NSLocalizedFailureReasonErrorKey: [error localizedDescription], NSUnderlyingErrorKey: error, }; diff --git a/ReactKit/Base/RCTSparseArray.h b/React/Base/RCTSparseArray.h similarity index 100% rename from ReactKit/Base/RCTSparseArray.h rename to React/Base/RCTSparseArray.h diff --git a/ReactKit/Base/RCTSparseArray.m b/React/Base/RCTSparseArray.m similarity index 100% rename from ReactKit/Base/RCTSparseArray.m rename to React/Base/RCTSparseArray.m diff --git a/ReactKit/Base/RCTTouchHandler.h b/React/Base/RCTTouchHandler.h similarity index 100% rename from ReactKit/Base/RCTTouchHandler.h rename to React/Base/RCTTouchHandler.h diff --git a/ReactKit/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m similarity index 99% rename from ReactKit/Base/RCTTouchHandler.m rename to React/Base/RCTTouchHandler.m index 108e43cce..b5d3b1e72 100644 --- a/ReactKit/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -16,7 +16,7 @@ #import "RCTLog.h" #import "RCTUIManager.h" #import "RCTUtils.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" // TODO: this class behaves a lot like a module, and could be implemented as a // module if we were to assume that modules and RootViews had a 1:1 relationship diff --git a/ReactKit/Base/RCTUtils.h b/React/Base/RCTUtils.h similarity index 100% rename from ReactKit/Base/RCTUtils.h rename to React/Base/RCTUtils.h diff --git a/ReactKit/Base/RCTUtils.m b/React/Base/RCTUtils.m similarity index 100% rename from ReactKit/Base/RCTUtils.m rename to React/Base/RCTUtils.m diff --git a/ReactKit/Executors/RCTContextExecutor.h b/React/Executors/RCTContextExecutor.h similarity index 100% rename from ReactKit/Executors/RCTContextExecutor.h rename to React/Executors/RCTContextExecutor.h diff --git a/ReactKit/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m similarity index 99% rename from ReactKit/Executors/RCTContextExecutor.m rename to React/Executors/RCTContextExecutor.m index e13f296e7..4370bd7bd 100644 --- a/ReactKit/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -121,7 +121,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError) dispatch_once(&onceToken, ^{ // All JS is single threaded, so a serial queue is our only option. javaScriptThread = [[NSThread alloc] initWithTarget:[self class] selector:@selector(runRunLoopThread) object:nil]; - [javaScriptThread setName:@"com.facebook.ReactKit.JavaScript"]; + [javaScriptThread setName:@"com.facebook.React.JavaScript"]; [javaScriptThread setThreadPriority:[[NSThread mainThread] threadPriority]]; [javaScriptThread start]; }); diff --git a/ReactKit/Executors/RCTWebViewExecutor.h b/React/Executors/RCTWebViewExecutor.h similarity index 100% rename from ReactKit/Executors/RCTWebViewExecutor.h rename to React/Executors/RCTWebViewExecutor.h diff --git a/ReactKit/Executors/RCTWebViewExecutor.m b/React/Executors/RCTWebViewExecutor.m similarity index 100% rename from ReactKit/Executors/RCTWebViewExecutor.m rename to React/Executors/RCTWebViewExecutor.m diff --git a/ReactKit/Layout/Layout.c b/React/Layout/Layout.c similarity index 100% rename from ReactKit/Layout/Layout.c rename to React/Layout/Layout.c diff --git a/ReactKit/Layout/Layout.h b/React/Layout/Layout.h similarity index 100% rename from ReactKit/Layout/Layout.h rename to React/Layout/Layout.h diff --git a/ReactKit/Modules/RCTAlertManager.h b/React/Modules/RCTAlertManager.h similarity index 100% rename from ReactKit/Modules/RCTAlertManager.h rename to React/Modules/RCTAlertManager.h diff --git a/ReactKit/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m similarity index 100% rename from ReactKit/Modules/RCTAlertManager.m rename to React/Modules/RCTAlertManager.m diff --git a/ReactKit/Modules/RCTAppState.h b/React/Modules/RCTAppState.h similarity index 100% rename from ReactKit/Modules/RCTAppState.h rename to React/Modules/RCTAppState.h diff --git a/ReactKit/Modules/RCTAppState.m b/React/Modules/RCTAppState.m similarity index 100% rename from ReactKit/Modules/RCTAppState.m rename to React/Modules/RCTAppState.m diff --git a/ReactKit/Modules/RCTAsyncLocalStorage.h b/React/Modules/RCTAsyncLocalStorage.h similarity index 100% rename from ReactKit/Modules/RCTAsyncLocalStorage.h rename to React/Modules/RCTAsyncLocalStorage.h diff --git a/ReactKit/Modules/RCTAsyncLocalStorage.m b/React/Modules/RCTAsyncLocalStorage.m similarity index 100% rename from ReactKit/Modules/RCTAsyncLocalStorage.m rename to React/Modules/RCTAsyncLocalStorage.m diff --git a/ReactKit/Modules/RCTExceptionsManager.h b/React/Modules/RCTExceptionsManager.h similarity index 100% rename from ReactKit/Modules/RCTExceptionsManager.h rename to React/Modules/RCTExceptionsManager.h diff --git a/ReactKit/Modules/RCTExceptionsManager.m b/React/Modules/RCTExceptionsManager.m similarity index 100% rename from ReactKit/Modules/RCTExceptionsManager.m rename to React/Modules/RCTExceptionsManager.m diff --git a/ReactKit/Modules/RCTSourceCode.h b/React/Modules/RCTSourceCode.h similarity index 100% rename from ReactKit/Modules/RCTSourceCode.h rename to React/Modules/RCTSourceCode.h diff --git a/ReactKit/Modules/RCTSourceCode.m b/React/Modules/RCTSourceCode.m similarity index 100% rename from ReactKit/Modules/RCTSourceCode.m rename to React/Modules/RCTSourceCode.m diff --git a/ReactKit/Modules/RCTStatusBarManager.h b/React/Modules/RCTStatusBarManager.h similarity index 100% rename from ReactKit/Modules/RCTStatusBarManager.h rename to React/Modules/RCTStatusBarManager.h diff --git a/ReactKit/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m similarity index 100% rename from ReactKit/Modules/RCTStatusBarManager.m rename to React/Modules/RCTStatusBarManager.m diff --git a/ReactKit/Modules/RCTTiming.h b/React/Modules/RCTTiming.h similarity index 100% rename from ReactKit/Modules/RCTTiming.h rename to React/Modules/RCTTiming.h diff --git a/ReactKit/Modules/RCTTiming.m b/React/Modules/RCTTiming.m similarity index 100% rename from ReactKit/Modules/RCTTiming.m rename to React/Modules/RCTTiming.m diff --git a/ReactKit/Modules/RCTUIManager.h b/React/Modules/RCTUIManager.h similarity index 100% rename from ReactKit/Modules/RCTUIManager.h rename to React/Modules/RCTUIManager.h diff --git a/ReactKit/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m similarity index 98% rename from ReactKit/Modules/RCTUIManager.m rename to React/Modules/RCTUIManager.m index 73c6929a7..e6a540db2 100644 --- a/ReactKit/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -27,7 +27,7 @@ #import "RCTView.h" #import "RCTViewManager.h" #import "RCTViewNodeProtocol.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" typedef void (^react_view_node_block_t)(id); @@ -437,9 +437,6 @@ static NSString *RCTViewNameForModuleName(NSString *moduleName) completion(YES); } - // TODO: deprecate this - [view reactSetBorders]; - // Animate view creation BOOL shouldAnimateCreation = isNew && ![parentsAreNew[ii] boolValue]; RCTAnimation *createAnimation = _layoutAnimation.createAnimation; @@ -683,10 +680,8 @@ static void RCTSetViewProps(NSDictionary *props, UIView *view, [props enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set_%@:forView:withDefaultView:", key]); - - // For regular views we don't attempt to set properties - // unless the view property has been explicitly exported. RCTCallPropertySetter(setter, obj, view, defaultView, manager); + }]; } @@ -696,20 +691,8 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView [props enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set_%@:forShadowView:withDefaultView:", key]); + RCTCallPropertySetter(setter, obj, shadowView, defaultView, manager); - // For shadow views we call any custom setter methods by default, - // but if none is specified, we attempt to set property anyway. - if (!RCTCallPropertySetter(setter, obj, shadowView, defaultView, manager)) { - - if (obj == [NSNull null]) { - // Copy property from default view to current - // Note: not just doing `[defaultView valueForKey:key]`, the - // key may not exist, in which case we'd get an exception. - RCTCopyProperty(shadowView, defaultView, key); - } else { - RCTSetProperty(shadowView, key, obj); - } - } }]; // Update layout diff --git a/ReactKit/ReactKit.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj similarity index 97% rename from ReactKit/ReactKit.xcodeproj/project.pbxproj rename to React/React.xcodeproj/project.pbxproj index b7c68ccd5..ba6ec3aab 100644 --- a/ReactKit/ReactKit.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -38,7 +38,7 @@ 13E067551A70F44B002CDEE1 /* RCTShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E0674C1A70F44B002CDEE1 /* RCTShadowView.m */; }; 13E067561A70F44B002CDEE1 /* RCTViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E0674E1A70F44B002CDEE1 /* RCTViewManager.m */; }; 13E067571A70F44B002CDEE1 /* RCTView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067501A70F44B002CDEE1 /* RCTView.m */; }; - 13E067591A70F44B002CDEE1 /* UIView+ReactKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */; }; + 13E067591A70F44B002CDEE1 /* UIView+React.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067541A70F44B002CDEE1 /* UIView+React.m */; }; 14435CE51AAC4AE100FC20F4 /* RCTMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 14435CE21AAC4AE100FC20F4 /* RCTMap.m */; }; 14435CE61AAC4AE100FC20F4 /* RCTMapManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14435CE41AAC4AE100FC20F4 /* RCTMapManager.m */; }; 14F3620D1AABD06A001CE568 /* RCTSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F362081AABD06A001CE568 /* RCTSwitch.m */; }; @@ -143,8 +143,8 @@ 13E0674E1A70F44B002CDEE1 /* RCTViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTViewManager.m; sourceTree = ""; }; 13E0674F1A70F44B002CDEE1 /* RCTView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTView.h; sourceTree = ""; }; 13E067501A70F44B002CDEE1 /* RCTView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTView.m; sourceTree = ""; }; - 13E067531A70F44B002CDEE1 /* UIView+ReactKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+ReactKit.h"; sourceTree = ""; }; - 13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ReactKit.m"; sourceTree = ""; }; + 13E067531A70F44B002CDEE1 /* UIView+React.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+React.h"; sourceTree = ""; }; + 13E067541A70F44B002CDEE1 /* UIView+React.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+React.m"; sourceTree = ""; }; 13EFFCCF1A98E6FE002607DC /* RCTJSMethodRegistrar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSMethodRegistrar.h; sourceTree = ""; }; 14435CE11AAC4AE100FC20F4 /* RCTMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMap.h; sourceTree = ""; }; 14435CE21AAC4AE100FC20F4 /* RCTMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMap.m; sourceTree = ""; }; @@ -171,7 +171,7 @@ 830BA4541A8E3BDA00D53203 /* RCTCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTCache.m; sourceTree = ""; }; 83BEE46C1A6D19BC00B5863B /* RCTSparseArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSparseArray.h; sourceTree = ""; }; 83BEE46D1A6D19BC00B5863B /* RCTSparseArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSparseArray.m; sourceTree = ""; }; - 83CBBA2E1A601D0E00E9B192 /* libReactKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 83CBBA2E1A601D0E00E9B192 /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; }; 83CBBA4A1A601E3B00E9B192 /* RCTAssert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAssert.h; sourceTree = ""; }; 83CBBA4B1A601E3B00E9B192 /* RCTAssert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAssert.m; sourceTree = ""; }; 83CBBA4C1A601E3B00E9B192 /* RCTInvalidating.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTInvalidating.h; sourceTree = ""; }; @@ -309,8 +309,8 @@ 13C156041AB1A2840079392D /* RCTWebViewManager.m */, 13B080231A694A8400A75B9A /* RCTWrapperViewController.h */, 13B080241A694A8400A75B9A /* RCTWrapperViewController.m */, - 13E067531A70F44B002CDEE1 /* UIView+ReactKit.h */, - 13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */, + 13E067531A70F44B002CDEE1 /* UIView+React.h */, + 13E067541A70F44B002CDEE1 /* UIView+React.m */, ); path = Views; sourceTree = ""; @@ -318,7 +318,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( - 83CBBA2F1A601D0F00E9B192 /* ReactKit */, + 83CBBA2F1A601D0F00E9B192 /* React */, 83CBBA001A601CBA00E9B192 /* Products */, ); sourceTree = ""; @@ -326,12 +326,12 @@ 83CBBA001A601CBA00E9B192 /* Products */ = { isa = PBXGroup; children = ( - 83CBBA2E1A601D0E00E9B192 /* libReactKit.a */, + 83CBBA2E1A601D0E00E9B192 /* libReact.a */, ); name = Products; sourceTree = ""; }; - 83CBBA2F1A601D0F00E9B192 /* ReactKit */ = { + 83CBBA2F1A601D0F00E9B192 /* React */ = { isa = PBXGroup; children = ( 83CBBA491A601E3B00E9B192 /* Base */, @@ -340,7 +340,7 @@ 13B07FE01A69315300A75B9A /* Modules */, 13B07FF31A6947C200A75B9A /* Views */, ); - name = ReactKit; + name = React; sourceTree = ""; }; 83CBBA491A601E3B00E9B192 /* Base */ = { @@ -383,9 +383,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 83CBBA2D1A601D0E00E9B192 /* ReactKit */ = { + 83CBBA2D1A601D0E00E9B192 /* React */ = { isa = PBXNativeTarget; - buildConfigurationList = 83CBBA3F1A601D0F00E9B192 /* Build configuration list for PBXNativeTarget "ReactKit" */; + buildConfigurationList = 83CBBA3F1A601D0F00E9B192 /* Build configuration list for PBXNativeTarget "React" */; buildPhases = ( 006B79A01A781F38006873D1 /* ShellScript */, 83CBBA2A1A601D0E00E9B192 /* Sources */, @@ -396,9 +396,9 @@ ); dependencies = ( ); - name = ReactKit; - productName = ReactKit; - productReference = 83CBBA2E1A601D0E00E9B192 /* libReactKit.a */; + name = React; + productName = React; + productReference = 83CBBA2E1A601D0E00E9B192 /* libReact.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ @@ -415,7 +415,7 @@ }; }; }; - buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactKit" */; + buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "React" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -428,7 +428,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 83CBBA2D1A601D0E00E9B192 /* ReactKit */, + 83CBBA2D1A601D0E00E9B192 /* React */, ); }; /* End PBXProject section */ @@ -478,7 +478,7 @@ 1372B70A1AB030C200659ED6 /* RCTAppState.m in Sources */, 13B0801F1A69489C00A75B9A /* RCTTextFieldManager.m in Sources */, 134FCB3D1A6E7F0800051CC8 /* RCTContextExecutor.m in Sources */, - 13E067591A70F44B002CDEE1 /* UIView+ReactKit.m in Sources */, + 13E067591A70F44B002CDEE1 /* UIView+React.m in Sources */, 14F484561AABFCE100FDF6B9 /* RCTSliderManager.m in Sources */, 83CBBA981A6020BB00E9B192 /* RCTTouchHandler.m in Sources */, 83CBBA521A601E3B00E9B192 /* RCTLog.m in Sources */, @@ -623,7 +623,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactKit" */ = { + 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "React" */ = { isa = XCConfigurationList; buildConfigurations = ( 83CBBA201A601CBA00E9B192 /* Debug */, @@ -632,7 +632,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 83CBBA3F1A601D0F00E9B192 /* Build configuration list for PBXNativeTarget "ReactKit" */ = { + 83CBBA3F1A601D0F00E9B192 /* Build configuration list for PBXNativeTarget "React" */ = { isa = XCConfigurationList; buildConfigurations = ( 83CBBA401A601D0F00E9B192 /* Debug */, diff --git a/ReactKit/Views/RCTAnimationType.h b/React/Views/RCTAnimationType.h similarity index 100% rename from ReactKit/Views/RCTAnimationType.h rename to React/Views/RCTAnimationType.h diff --git a/ReactKit/Views/RCTAutoInsetsProtocol.h b/React/Views/RCTAutoInsetsProtocol.h similarity index 100% rename from ReactKit/Views/RCTAutoInsetsProtocol.h rename to React/Views/RCTAutoInsetsProtocol.h diff --git a/ReactKit/Views/RCTDatePickerManager.h b/React/Views/RCTDatePickerManager.h similarity index 100% rename from ReactKit/Views/RCTDatePickerManager.h rename to React/Views/RCTDatePickerManager.h diff --git a/ReactKit/Views/RCTDatePickerManager.m b/React/Views/RCTDatePickerManager.m similarity index 66% rename from ReactKit/Views/RCTDatePickerManager.m rename to React/Views/RCTDatePickerManager.m index 2a2b6bc48..4029998c2 100644 --- a/ReactKit/Views/RCTDatePickerManager.m +++ b/React/Views/RCTDatePickerManager.m @@ -12,7 +12,18 @@ #import "RCTBridge.h" #import "RCTConvert.h" #import "RCTEventDispatcher.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" + +@implementation RCTConvert(UIDatePicker) + +RCT_ENUM_CONVERTER(UIDatePickerMode, (@{ + @"time": @(UIDatePickerModeTime), + @"date": @(UIDatePickerModeDate), + @"datetime": @(UIDatePickerModeDateAndTime), + //@"countdown": @(UIDatePickerModeCountDownTimer) // not supported yet +}), UIDatePickerModeTime, integerValue) + +@end @implementation RCTDatePickerManager @@ -25,12 +36,12 @@ return picker; } -RCT_EXPORT_VIEW_PROPERTY(date) -RCT_EXPORT_VIEW_PROPERTY(minimumDate) -RCT_EXPORT_VIEW_PROPERTY(maximumDate) -RCT_EXPORT_VIEW_PROPERTY(minuteInterval) -RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode) -RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone) +RCT_EXPORT_VIEW_PROPERTY(date, NSDate) +RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSDate) +RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSDate) +RCT_EXPORT_VIEW_PROPERTY(minuteInterval, NSInteger) +RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode) +RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone) - (void)onChange:(UIDatePicker *)sender { diff --git a/ReactKit/Views/RCTMap.h b/React/Views/RCTMap.h similarity index 88% rename from ReactKit/Views/RCTMap.h rename to React/Views/RCTMap.h index 95927d2a7..3850378e9 100644 --- a/ReactKit/Views/RCTMap.h +++ b/React/Views/RCTMap.h @@ -19,13 +19,9 @@ extern const CGFloat RCTMapZoomBoundBuffer; @interface RCTMap: MKMapView @property (nonatomic, assign) BOOL followUserLocation; -@property (nonatomic, copy) NSDictionary *JSONRegion; @property (nonatomic, assign) CGFloat minDelta; @property (nonatomic, assign) CGFloat maxDelta; @property (nonatomic, assign) UIEdgeInsets legalLabelInsets; @property (nonatomic, strong) NSTimer *regionChangeObserveTimer; @end - -#define FLUSH_NAN(value) \ - (isnan(value) ? 0 : value) diff --git a/ReactKit/Views/RCTMap.m b/React/Views/RCTMap.m similarity index 67% rename from ReactKit/Views/RCTMap.m rename to React/Views/RCTMap.m index a133e69ef..72c0db5eb 100644 --- a/ReactKit/Views/RCTMap.m +++ b/React/Views/RCTMap.m @@ -18,19 +18,15 @@ const CLLocationDegrees RCTMapDefaultSpan = 0.005; const NSTimeInterval RCTMapRegionChangeObserveInterval = 0.1; const CGFloat RCTMapZoomBoundBuffer = 0.01; -@interface RCTMap() - -@property (nonatomic, strong) UIView *legalLabel; -@property (nonatomic, strong) CLLocationManager *locationManager; - -@end - @implementation RCTMap +{ + UIView *_legalLabel; + CLLocationManager *_locationManager; +} - (instancetype)init { - self = [super init]; - if (self) { + if ((self = [super init])) { // Find Apple link label for (UIView *subview in self.subviews) { if ([NSStringFromClass(subview.class) isEqualToString:@"MKAttributionLabel"]) { @@ -45,7 +41,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; - (void)dealloc { - [self.regionChangeObserveTimer invalidate]; + [_regionChangeObserveTimer invalidate]; } - (void)layoutSubviews @@ -94,36 +90,23 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; } } -- (void)setJSONRegion:(NSDictionary *)region +- (void)setRegion:(MKCoordinateRegion)region { - if (region) { - MKCoordinateRegion coordinateRegion = self.region; - 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]; - } - if ([region[@"longitudeDelta"] isKindOfClass:[NSNumber class]]) { - coordinateRegion.span.longitudeDelta = [region[@"longitudeDelta"] doubleValue]; - } - - [self setRegion:coordinateRegion animated:YES]; - } -} - -- (NSDictionary *)JSONRegion -{ - MKCoordinateRegion region = self.region; + // If location is invalid, abort if (!CLLocationCoordinate2DIsValid(region.center)) { - return nil; + return; } - return @{ - @"latitude": @(FLUSH_NAN(region.center.latitude)), - @"longitude": @(FLUSH_NAN(region.center.longitude)), - @"latitudeDelta": @(FLUSH_NAN(region.span.latitudeDelta)), - @"longitudeDelta": @(FLUSH_NAN(region.span.longitudeDelta)), - }; + + // If new span values are nil, use old values instead + if (!region.span.latitudeDelta) { + region.span.latitudeDelta = self.region.span.latitudeDelta; + } + if (!region.span.longitudeDelta) { + region.span.longitudeDelta = self.region.span.longitudeDelta; + } + + // Animate to new position + [super setRegion:region animated:YES]; } @end diff --git a/ReactKit/Views/RCTMapManager.h b/React/Views/RCTMapManager.h similarity index 100% rename from ReactKit/Views/RCTMapManager.h rename to React/Views/RCTMapManager.h diff --git a/ReactKit/Views/RCTMapManager.m b/React/Views/RCTMapManager.m similarity index 66% rename from ReactKit/Views/RCTMapManager.m rename to React/Views/RCTMapManager.m index 07d43ec80..9bd0f7eab 100644 --- a/ReactKit/Views/RCTMapManager.m +++ b/React/Views/RCTMapManager.m @@ -12,7 +12,41 @@ #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "RCTMap.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" + +@implementation RCTConvert(CoreLocation) + ++ (CLLocationCoordinate2D)CLLocationCoordinate2D:(id)json +{ + json = [self NSDictionary:json]; + return (CLLocationCoordinate2D){ + [self double:json[@"latitude"]], + [self double:json[@"longitude"]] + }; +} + +@end + +@implementation RCTConvert(MapKit) + ++ (MKCoordinateSpan)MKCoordinateSpan:(id)json +{ + json = [self NSDictionary:json]; + return (MKCoordinateSpan){ + [self double:json[@"latitudeDelta"]], + [self double:json[@"longitudeDelta"]] + }; +} + ++ (MKCoordinateRegion)MKCoordinateRegion:(id)json +{ + return (MKCoordinateRegion){ + [self CLLocationCoordinate2D:json], + [self MKCoordinateSpan:json] + }; +} + +@end @interface RCTMapManager() @@ -27,15 +61,15 @@ return map; } -RCT_EXPORT_VIEW_PROPERTY(showsUserLocation); -RCT_EXPORT_VIEW_PROPERTY(zoomEnabled); -RCT_EXPORT_VIEW_PROPERTY(rotateEnabled); -RCT_EXPORT_VIEW_PROPERTY(pitchEnabled); -RCT_EXPORT_VIEW_PROPERTY(scrollEnabled); -RCT_EXPORT_VIEW_PROPERTY(maxDelta); -RCT_EXPORT_VIEW_PROPERTY(minDelta); -RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets); -RCT_REMAP_VIEW_PROPERTY(region, JSONRegion) +RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL) +RCT_EXPORT_VIEW_PROPERTY(zoomEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(rotateEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(pitchEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(maxDelta, CGFloat) +RCT_EXPORT_VIEW_PROPERTY(minDelta, CGFloat) +RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets, UIEdgeInsets) +RCT_EXPORT_VIEW_PROPERTY(region, MKCoordinateRegion) #pragma mark MKMapViewDelegate @@ -112,15 +146,24 @@ RCT_REMAP_VIEW_PROPERTY(region, JSONRegion) - (void)_emitRegionChangeEvent:(RCTMap *)mapView continuous:(BOOL)continuous { - NSDictionary *region = mapView.JSONRegion; - if (region) { - NSDictionary *event = @{ - @"target": [mapView reactTag], - @"continuous": @(continuous), - @"region": mapView.JSONRegion, - }; - [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event]; + MKCoordinateRegion region = mapView.region; + if (!CLLocationCoordinate2DIsValid(region.center)) { + return; } + +#define FLUSH_NAN(value) (isnan(value) ? 0 : value) + + NSDictionary *event = @{ + @"target": [mapView reactTag], + @"continuous": @(continuous), + @"region": @{ + @"latitude": @(FLUSH_NAN(region.center.latitude)), + @"longitude": @(FLUSH_NAN(region.center.longitude)), + @"latitudeDelta": @(FLUSH_NAN(region.span.latitudeDelta)), + @"longitudeDelta": @(FLUSH_NAN(region.span.longitudeDelta)), + } + }; + [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event]; } @end diff --git a/ReactKit/Views/RCTNavItem.h b/React/Views/RCTNavItem.h similarity index 100% rename from ReactKit/Views/RCTNavItem.h rename to React/Views/RCTNavItem.h diff --git a/ReactKit/Views/RCTNavItem.m b/React/Views/RCTNavItem.m similarity index 100% rename from ReactKit/Views/RCTNavItem.m rename to React/Views/RCTNavItem.m diff --git a/ReactKit/Views/RCTNavItemManager.h b/React/Views/RCTNavItemManager.h similarity index 100% rename from ReactKit/Views/RCTNavItemManager.h rename to React/Views/RCTNavItemManager.h diff --git a/ReactKit/Views/RCTNavItemManager.m b/React/Views/RCTNavItemManager.m similarity index 62% rename from ReactKit/Views/RCTNavItemManager.m rename to React/Views/RCTNavItemManager.m index 1c574cbd1..549859ae0 100644 --- a/ReactKit/Views/RCTNavItemManager.m +++ b/React/Views/RCTNavItemManager.m @@ -19,12 +19,11 @@ return [[RCTNavItem alloc] init]; } -RCT_EXPORT_VIEW_PROPERTY(title) -RCT_EXPORT_VIEW_PROPERTY(rightButtonTitle); -RCT_EXPORT_VIEW_PROPERTY(backButtonTitle); -RCT_EXPORT_VIEW_PROPERTY(tintColor); -RCT_EXPORT_VIEW_PROPERTY(barTintColor); -RCT_EXPORT_VIEW_PROPERTY(titleTextColor); +RCT_EXPORT_VIEW_PROPERTY(title, NSString) +RCT_EXPORT_VIEW_PROPERTY(rightButtonTitle, NSString); +RCT_EXPORT_VIEW_PROPERTY(backButtonTitle, NSString); +RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(titleTextColor, UIColor); @end - diff --git a/ReactKit/Views/RCTNavigator.h b/React/Views/RCTNavigator.h similarity index 100% rename from ReactKit/Views/RCTNavigator.h rename to React/Views/RCTNavigator.h diff --git a/ReactKit/Views/RCTNavigator.m b/React/Views/RCTNavigator.m similarity index 99% rename from ReactKit/Views/RCTNavigator.m rename to React/Views/RCTNavigator.m index e3ee09a5a..373313b93 100644 --- a/ReactKit/Views/RCTNavigator.m +++ b/React/Views/RCTNavigator.m @@ -17,7 +17,7 @@ #import "RCTUtils.h" #import "RCTView.h" #import "RCTWrapperViewController.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" typedef NS_ENUM(NSUInteger, RCTNavigationLock) { RCTNavigationLockNone, diff --git a/ReactKit/Views/RCTNavigatorManager.h b/React/Views/RCTNavigatorManager.h similarity index 100% rename from ReactKit/Views/RCTNavigatorManager.h rename to React/Views/RCTNavigatorManager.h diff --git a/ReactKit/Views/RCTNavigatorManager.m b/React/Views/RCTNavigatorManager.m similarity index 96% rename from ReactKit/Views/RCTNavigatorManager.m rename to React/Views/RCTNavigatorManager.m index 5954465e0..7df00c764 100644 --- a/ReactKit/Views/RCTNavigatorManager.m +++ b/React/Views/RCTNavigatorManager.m @@ -22,7 +22,7 @@ return [[RCTNavigator alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } -RCT_EXPORT_VIEW_PROPERTY(requestedTopOfStack) +RCT_EXPORT_VIEW_PROPERTY(requestedTopOfStack, NSInteger) - (NSDictionary *)customDirectEventTypes { diff --git a/ReactKit/Views/RCTPicker.h b/React/Views/RCTPicker.h similarity index 100% rename from ReactKit/Views/RCTPicker.h rename to React/Views/RCTPicker.h diff --git a/ReactKit/Views/RCTPicker.m b/React/Views/RCTPicker.m similarity index 95% rename from ReactKit/Views/RCTPicker.m rename to React/Views/RCTPicker.m index 25b3a3186..dd2bcdb8a 100644 --- a/ReactKit/Views/RCTPicker.m +++ b/React/Views/RCTPicker.m @@ -12,19 +12,20 @@ #import "RCTConvert.h" #import "RCTEventDispatcher.h" #import "RCTUtils.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" const NSInteger UNINITIALIZED_INDEX = -1; @interface RCTPicker() + +@end + +@implementation RCTPicker { RCTEventDispatcher *_eventDispatcher; NSArray *_items; NSInteger _selectedIndex; } -@end - -@implementation RCTPicker - (id)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher { @@ -64,14 +65,14 @@ const NSInteger UNINITIALIZED_INDEX = -1; - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { - return [_items count]; + return _items.count; } #pragma mark - UIPickerViewDelegate methods - (NSDictionary *)itemForRow:(NSInteger)row { - return (NSDictionary*)[_items objectAtIndex:row]; + return _items[row]; } - (id)valueForRow:(NSInteger)row diff --git a/ReactKit/Views/RCTPickerManager.h b/React/Views/RCTPickerManager.h similarity index 100% rename from ReactKit/Views/RCTPickerManager.h rename to React/Views/RCTPickerManager.h diff --git a/ReactKit/Views/RCTPickerManager.m b/React/Views/RCTPickerManager.m similarity index 88% rename from ReactKit/Views/RCTPickerManager.m rename to React/Views/RCTPickerManager.m index fb92c05db..cffacca68 100644 --- a/ReactKit/Views/RCTPickerManager.m +++ b/React/Views/RCTPickerManager.m @@ -20,8 +20,8 @@ return [[RCTPicker alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } -RCT_EXPORT_VIEW_PROPERTY(items) -RCT_EXPORT_VIEW_PROPERTY(selectedIndex) +RCT_EXPORT_VIEW_PROPERTY(items, NSDictionaryArray) +RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) - (NSDictionary *)constantsToExport { diff --git a/ReactKit/Views/RCTPointerEvents.h b/React/Views/RCTPointerEvents.h similarity index 100% rename from ReactKit/Views/RCTPointerEvents.h rename to React/Views/RCTPointerEvents.h diff --git a/ReactKit/Views/RCTScrollView.h b/React/Views/RCTScrollView.h similarity index 100% rename from ReactKit/Views/RCTScrollView.h rename to React/Views/RCTScrollView.h diff --git a/ReactKit/Views/RCTScrollView.m b/React/Views/RCTScrollView.m similarity index 99% rename from ReactKit/Views/RCTScrollView.m rename to React/Views/RCTScrollView.m index 8c3db22be..e3e1c2f79 100644 --- a/ReactKit/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -16,7 +16,7 @@ #import "RCTLog.h" #import "RCTUIManager.h" #import "RCTUtils.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" CGFloat const ZINDEX_DEFAULT = 0; CGFloat const ZINDEX_STICKY_HEADER = 50; diff --git a/ReactKit/Views/RCTScrollViewManager.h b/React/Views/RCTScrollViewManager.h similarity index 100% rename from ReactKit/Views/RCTScrollViewManager.h rename to React/Views/RCTScrollViewManager.h diff --git a/ReactKit/Views/RCTScrollViewManager.m b/React/Views/RCTScrollViewManager.m similarity index 55% rename from ReactKit/Views/RCTScrollViewManager.m rename to React/Views/RCTScrollViewManager.m index dc68de214..8001947d1 100644 --- a/ReactKit/Views/RCTScrollViewManager.m +++ b/React/Views/RCTScrollViewManager.m @@ -22,29 +22,29 @@ return [[RCTScrollView alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } -RCT_EXPORT_VIEW_PROPERTY(alwaysBounceHorizontal) -RCT_EXPORT_VIEW_PROPERTY(alwaysBounceVertical) -RCT_EXPORT_VIEW_PROPERTY(bounces) -RCT_EXPORT_VIEW_PROPERTY(bouncesZoom) -RCT_EXPORT_VIEW_PROPERTY(canCancelContentTouches) -RCT_EXPORT_VIEW_PROPERTY(centerContent) -RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets) -RCT_EXPORT_VIEW_PROPERTY(decelerationRate) -RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled) -RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode) -RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale) -RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale) -RCT_EXPORT_VIEW_PROPERTY(pagingEnabled) -RCT_EXPORT_VIEW_PROPERTY(scrollEnabled) -RCT_EXPORT_VIEW_PROPERTY(scrollsToTop) -RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator) -RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator) -RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices); -RCT_EXPORT_VIEW_PROPERTY(throttleScrollCallbackMS); -RCT_EXPORT_VIEW_PROPERTY(zoomScale); -RCT_EXPORT_VIEW_PROPERTY(contentInset); -RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets); -RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset); +RCT_EXPORT_VIEW_PROPERTY(alwaysBounceHorizontal, BOOL) +RCT_EXPORT_VIEW_PROPERTY(alwaysBounceVertical, BOOL) +RCT_EXPORT_VIEW_PROPERTY(bounces, BOOL) +RCT_EXPORT_VIEW_PROPERTY(bouncesZoom, BOOL) +RCT_EXPORT_VIEW_PROPERTY(canCancelContentTouches, BOOL) +RCT_EXPORT_VIEW_PROPERTY(centerContent, BOOL) +RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL) +RCT_EXPORT_VIEW_PROPERTY(decelerationRate, CGFloat) +RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode, UIScrollViewKeyboardDismissMode) +RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale, CGFloat) +RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale, CGFloat) +RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL) +RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL) +RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL) +RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices, NSNumberArray); +RCT_EXPORT_VIEW_PROPERTY(throttleScrollCallbackMS, double); +RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat); +RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets); +RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets); +RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint); - (NSDictionary *)constantsToExport { diff --git a/ReactKit/Views/RCTScrollableProtocol.h b/React/Views/RCTScrollableProtocol.h similarity index 100% rename from ReactKit/Views/RCTScrollableProtocol.h rename to React/Views/RCTScrollableProtocol.h diff --git a/ReactKit/Views/RCTShadowView.h b/React/Views/RCTShadowView.h similarity index 96% rename from ReactKit/Views/RCTShadowView.h rename to React/Views/RCTShadowView.h index be1b2465e..8d68855f7 100644 --- a/ReactKit/Views/RCTShadowView.h +++ b/React/Views/RCTShadowView.h @@ -68,10 +68,10 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); /** * Border. Defaults to { 0, 0, 0, 0 }. */ -@property (nonatomic, assign) CGFloat borderTop; -@property (nonatomic, assign) CGFloat borderLeft; -@property (nonatomic, assign) CGFloat borderBottom; -@property (nonatomic, assign) CGFloat borderRight; +@property (nonatomic, assign) CGFloat borderTopWidth; +@property (nonatomic, assign) CGFloat borderLeftWidth; +@property (nonatomic, assign) CGFloat borderBottomWidth; +@property (nonatomic, assign) CGFloat borderRightWidth; - (void)setBorderWidth:(CGFloat)value; diff --git a/ReactKit/Views/RCTShadowView.m b/React/Views/RCTShadowView.m similarity index 99% rename from ReactKit/Views/RCTShadowView.m rename to React/Views/RCTShadowView.m index f43f9cd28..e5975dff2 100644 --- a/ReactKit/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -411,12 +411,12 @@ RCT_PADDING_PROPERTY(Right, RIGHT) // Border #define RCT_BORDER_PROPERTY(prop, metaProp) \ -- (void)setBorder##prop:(CGFloat)value \ +- (void)setBorder##prop##Width:(CGFloat)value \ { \ _cssNode->style.border[CSS_##metaProp] = value; \ [self dirtyLayout]; \ } \ -- (CGFloat)border##prop \ +- (CGFloat)border##prop##Width \ { \ return _cssNode->style.border[META_PROP_##metaProp]; \ } diff --git a/ReactKit/Views/RCTSliderManager.h b/React/Views/RCTSliderManager.h similarity index 100% rename from ReactKit/Views/RCTSliderManager.h rename to React/Views/RCTSliderManager.h diff --git a/ReactKit/Views/RCTSliderManager.m b/React/Views/RCTSliderManager.m similarity index 88% rename from ReactKit/Views/RCTSliderManager.m rename to React/Views/RCTSliderManager.m index 133905e9b..0228eab68 100644 --- a/ReactKit/Views/RCTSliderManager.m +++ b/React/Views/RCTSliderManager.m @@ -11,7 +11,7 @@ #import "RCTBridge.h" #import "RCTEventDispatcher.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTSliderManager @@ -45,6 +45,8 @@ [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event]; } -RCT_EXPORT_VIEW_PROPERTY(value); +RCT_EXPORT_VIEW_PROPERTY(value, float); +RCT_EXPORT_VIEW_PROPERTY(minimumValue, float); +RCT_EXPORT_VIEW_PROPERTY(maximumValue, float); @end diff --git a/ReactKit/Views/RCTSwitch.h b/React/Views/RCTSwitch.h similarity index 100% rename from ReactKit/Views/RCTSwitch.h rename to React/Views/RCTSwitch.h diff --git a/ReactKit/Views/RCTSwitch.m b/React/Views/RCTSwitch.m similarity index 94% rename from ReactKit/Views/RCTSwitch.m rename to React/Views/RCTSwitch.m index 94ee6b905..6c4e28564 100644 --- a/ReactKit/Views/RCTSwitch.m +++ b/React/Views/RCTSwitch.m @@ -10,7 +10,7 @@ #import "RCTSwitch.h" #import "RCTEventDispatcher.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTSwitch diff --git a/ReactKit/Views/RCTSwitchManager.h b/React/Views/RCTSwitchManager.h similarity index 100% rename from ReactKit/Views/RCTSwitchManager.h rename to React/Views/RCTSwitchManager.h diff --git a/ReactKit/Views/RCTSwitchManager.m b/React/Views/RCTSwitchManager.m similarity index 79% rename from ReactKit/Views/RCTSwitchManager.m rename to React/Views/RCTSwitchManager.m index ca5cb2c16..e2118023d 100644 --- a/ReactKit/Views/RCTSwitchManager.m +++ b/React/Views/RCTSwitchManager.m @@ -12,7 +12,7 @@ #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "RCTSwitch.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTSwitchManager @@ -37,10 +37,10 @@ } } -RCT_EXPORT_VIEW_PROPERTY(onTintColor); -RCT_EXPORT_VIEW_PROPERTY(tintColor); -RCT_EXPORT_VIEW_PROPERTY(thumbTintColor); -RCT_EXPORT_VIEW_PROPERTY(on); -RCT_EXPORT_VIEW_PROPERTY(enabled); +RCT_EXPORT_VIEW_PROPERTY(onTintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(thumbTintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(on, BOOL); +RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL); @end diff --git a/ReactKit/Views/RCTTabBar.h b/React/Views/RCTTabBar.h similarity index 100% rename from ReactKit/Views/RCTTabBar.h rename to React/Views/RCTTabBar.h diff --git a/ReactKit/Views/RCTTabBar.m b/React/Views/RCTTabBar.m similarity index 99% rename from ReactKit/Views/RCTTabBar.m rename to React/Views/RCTTabBar.m index 86e609df9..11ad47e32 100644 --- a/ReactKit/Views/RCTTabBar.m +++ b/React/Views/RCTTabBar.m @@ -16,7 +16,7 @@ #import "RCTView.h" #import "RCTViewControllerProtocol.h" #import "RCTWrapperViewController.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @interface RKCustomTabBarController : UITabBarController diff --git a/ReactKit/Views/RCTTabBarItem.h b/React/Views/RCTTabBarItem.h similarity index 100% rename from ReactKit/Views/RCTTabBarItem.h rename to React/Views/RCTTabBarItem.h diff --git a/ReactKit/Views/RCTTabBarItem.m b/React/Views/RCTTabBarItem.m similarity index 98% rename from ReactKit/Views/RCTTabBarItem.m rename to React/Views/RCTTabBarItem.m index 9de3ac929..530fef893 100644 --- a/ReactKit/Views/RCTTabBarItem.m +++ b/React/Views/RCTTabBarItem.m @@ -11,7 +11,7 @@ #import "RCTConvert.h" #import "RCTLog.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTTabBarItem diff --git a/ReactKit/Views/RCTTabBarItemManager.h b/React/Views/RCTTabBarItemManager.h similarity index 100% rename from ReactKit/Views/RCTTabBarItemManager.h rename to React/Views/RCTTabBarItemManager.h diff --git a/ReactKit/Views/RCTTabBarItemManager.m b/React/Views/RCTTabBarItemManager.m similarity index 71% rename from ReactKit/Views/RCTTabBarItemManager.m rename to React/Views/RCTTabBarItemManager.m index 4dc0a65eb..7f4ce9642 100644 --- a/ReactKit/Views/RCTTabBarItemManager.m +++ b/React/Views/RCTTabBarItemManager.m @@ -19,11 +19,11 @@ return [[RCTTabBarItem alloc] init]; } -RCT_EXPORT_VIEW_PROPERTY(selected); -RCT_EXPORT_VIEW_PROPERTY(icon); -RCT_REMAP_VIEW_PROPERTY(selectedIcon, barItem.selectedImage); -RCT_REMAP_VIEW_PROPERTY(badgeValue, barItem.badgeValue); -RCT_CUSTOM_VIEW_PROPERTY(title, RCTTabBarItem) +RCT_EXPORT_VIEW_PROPERTY(selected, BOOL); +RCT_EXPORT_VIEW_PROPERTY(icon, NSString); +RCT_REMAP_VIEW_PROPERTY(selectedIcon, barItem.selectedImage, UIImage); +RCT_REMAP_VIEW_PROPERTY(badgeValue, barItem.badgeValue, NSString); +RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem) { view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title; view.barItem.imageInsets = [view.barItem.title length] ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0}; diff --git a/ReactKit/Views/RCTTabBarManager.h b/React/Views/RCTTabBarManager.h similarity index 100% rename from ReactKit/Views/RCTTabBarManager.h rename to React/Views/RCTTabBarManager.h diff --git a/ReactKit/Views/RCTTabBarManager.m b/React/Views/RCTTabBarManager.m similarity index 100% rename from ReactKit/Views/RCTTabBarManager.m rename to React/Views/RCTTabBarManager.m diff --git a/ReactKit/Views/RCTTextField.h b/React/Views/RCTTextField.h similarity index 100% rename from ReactKit/Views/RCTTextField.h rename to React/Views/RCTTextField.h diff --git a/ReactKit/Views/RCTTextField.m b/React/Views/RCTTextField.m similarity index 99% rename from ReactKit/Views/RCTTextField.m rename to React/Views/RCTTextField.m index 4901be411..1ccf17d7f 100644 --- a/ReactKit/Views/RCTTextField.m +++ b/React/Views/RCTTextField.m @@ -12,7 +12,7 @@ #import "RCTConvert.h" #import "RCTEventDispatcher.h" #import "RCTUtils.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTTextField { diff --git a/ReactKit/Views/RCTTextFieldManager.h b/React/Views/RCTTextFieldManager.h similarity index 100% rename from ReactKit/Views/RCTTextFieldManager.h rename to React/Views/RCTTextFieldManager.h diff --git a/ReactKit/Views/RCTTextFieldManager.m b/React/Views/RCTTextFieldManager.m similarity index 64% rename from ReactKit/Views/RCTTextFieldManager.m rename to React/Views/RCTTextFieldManager.m index 8418c8858..087dc5b26 100644 --- a/ReactKit/Views/RCTTextFieldManager.m +++ b/React/Views/RCTTextFieldManager.m @@ -22,32 +22,28 @@ return [[RCTTextField alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } -RCT_EXPORT_VIEW_PROPERTY(caretHidden) -RCT_EXPORT_VIEW_PROPERTY(autoCorrect) -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) +RCT_EXPORT_VIEW_PROPERTY(caretHidden, BOOL) +RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL) +RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString) +RCT_EXPORT_VIEW_PROPERTY(text, NSString) +RCT_EXPORT_VIEW_PROPERTY(clearButtonMode, UITextFieldViewMode) +RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType) +RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor) +RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType) +RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextField) { view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)]; } -RCT_CUSTOM_VIEW_PROPERTY(fontWeight, RCTTextField) +RCT_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, RCTTextField) { view.font = [RCTConvert UIFont:view.font withWeight:json]; // defaults to normal } -RCT_CUSTOM_VIEW_PROPERTY(fontStyle, RCTTextField) +RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, RCTTextField) { view.font = [RCTConvert UIFont:view.font withStyle:json]; // defaults to normal } -RCT_CUSTOM_VIEW_PROPERTY(fontFamily, RCTTextField) +RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, RCTTextField) { view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName]; } diff --git a/ReactKit/Views/RCTUIActivityIndicatorViewManager.h b/React/Views/RCTUIActivityIndicatorViewManager.h similarity index 100% rename from ReactKit/Views/RCTUIActivityIndicatorViewManager.h rename to React/Views/RCTUIActivityIndicatorViewManager.h diff --git a/ReactKit/Views/RCTUIActivityIndicatorViewManager.m b/React/Views/RCTUIActivityIndicatorViewManager.m similarity index 62% rename from ReactKit/Views/RCTUIActivityIndicatorViewManager.m rename to React/Views/RCTUIActivityIndicatorViewManager.m index 409012f11..09a5cb6f9 100644 --- a/ReactKit/Views/RCTUIActivityIndicatorViewManager.m +++ b/React/Views/RCTUIActivityIndicatorViewManager.m @@ -11,6 +11,17 @@ #import "RCTConvert.h" +@implementation RCTConvert (UIActivityIndicatorView) + +RCT_ENUM_CONVERTER(UIActivityIndicatorViewStyle, (@{ + @"white-large": @(UIActivityIndicatorViewStyleWhiteLarge), + @"large-white": @(UIActivityIndicatorViewStyleWhiteLarge), + @"white": @(UIActivityIndicatorViewStyleWhite), + @"gray": @(UIActivityIndicatorViewStyleGray), +}), UIActivityIndicatorViewStyleWhiteLarge, integerValue) + +@end + @implementation RCTUIActivityIndicatorViewManager - (UIView *)view @@ -18,9 +29,9 @@ return [[UIActivityIndicatorView alloc] init]; } -RCT_EXPORT_VIEW_PROPERTY(activityIndicatorViewStyle) -RCT_EXPORT_VIEW_PROPERTY(color) -RCT_CUSTOM_VIEW_PROPERTY(animating, UIActivityIndicatorView) +RCT_EXPORT_VIEW_PROPERTY(activityIndicatorViewStyle, UIActivityIndicatorViewStyle) +RCT_EXPORT_VIEW_PROPERTY(color, UIColor) +RCT_CUSTOM_VIEW_PROPERTY(animating, BOOL, UIActivityIndicatorView) { BOOL animating = json ? [json boolValue] : [defaultView isAnimating]; if (animating != [view isAnimating]) { diff --git a/ReactKit/Views/RCTView.h b/React/Views/RCTView.h similarity index 67% rename from ReactKit/Views/RCTView.h rename to React/Views/RCTView.h index 4d99c876f..73fe2c7cb 100644 --- a/ReactKit/Views/RCTView.h +++ b/React/Views/RCTView.h @@ -13,6 +13,13 @@ #import "RCTPointerEvents.h" +typedef NS_ENUM(NSInteger, RCTBorderSide) { + RCTBorderSideTop, + RCTBorderSideRight, + RCTBorderSideBottom, + RCTBorderSideLeft +}; + @protocol RCTAutoInsetsProtocol; @interface RCTView : UIView @@ -48,4 +55,22 @@ */ - (void)updateClippedSubviews; +/** + * Border colors. + */ +@property (nonatomic, assign) CGColorRef borderTopColor; +@property (nonatomic, assign) CGColorRef borderRightColor; +@property (nonatomic, assign) CGColorRef borderBottomColor; +@property (nonatomic, assign) CGColorRef borderLeftColor; +@property (nonatomic, assign) CGColorRef borderColor; + +/** + * Border widths. + */ +@property (nonatomic, assign) CGFloat borderTopWidth; +@property (nonatomic, assign) CGFloat borderRightWidth; +@property (nonatomic, assign) CGFloat borderBottomWidth; +@property (nonatomic, assign) CGFloat borderLeftWidth; +@property (nonatomic, assign) CGFloat borderWidth; + @end diff --git a/ReactKit/Views/RCTView.m b/React/Views/RCTView.m similarity index 66% rename from ReactKit/Views/RCTView.m rename to React/Views/RCTView.m index 5bb13ab86..febf56703 100644 --- a/ReactKit/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -12,7 +12,9 @@ #import "RCTAutoInsetsProtocol.h" #import "RCTConvert.h" #import "RCTLog.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" + +static const RCTBorderSide RCTBorderSideCount = 4; @implementation UIView (RCTViewUnmounting) @@ -91,6 +93,8 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) @implementation RCTView { NSMutableArray *_reactSubviews; + CAShapeLayer *_borderLayers[RCTBorderSideCount]; + CGFloat _borderWidths[RCTBorderSideCount]; } - (NSString *)accessibilityLabel @@ -106,7 +110,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) _pointerEvents = pointerEvents; self.userInteractionEnabled = (pointerEvents != RCTPointerEventsNone); if (pointerEvents == RCTPointerEventsBoxNone) { - self.accessibilityViewIsModal = NO; // TODO: find out what this is for + self.accessibilityViewIsModal = NO; } } @@ -368,9 +372,193 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) // to updateClippedSubviews manually after loading [super layoutSubviews]; + if (_reactSubviews) { [self updateClippedSubviews]; } + + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + if (_borderLayers[side]) [self updatePathForShapeLayerForSide:side]; + } +} + +- (void)layoutSublayersOfLayer:(CALayer *)layer +{ + [super layoutSublayersOfLayer:layer]; + + const CGRect bounds = layer.bounds; + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + _borderLayers[side].frame = bounds; + } +} + +- (BOOL)getTrapezoidPoints:(CGPoint[4])outPoints forSide:(RCTBorderSide)side +{ + const CGRect bounds = self.layer.bounds; + const CGFloat minX = CGRectGetMinX(bounds); + const CGFloat maxX = CGRectGetMaxX(bounds); + const CGFloat minY = CGRectGetMinY(bounds); + const CGFloat maxY = CGRectGetMaxY(bounds); + +#define BW(SIDE) [self borderWidthForSide:RCTBorderSide##SIDE] + + switch (side) { + case RCTBorderSideRight: + outPoints[0] = CGPointMake(maxX - BW(Right), maxY - BW(Bottom)); + outPoints[1] = CGPointMake(maxX - BW(Right), minY + BW(Top)); + outPoints[2] = CGPointMake(maxX, minY); + outPoints[3] = CGPointMake(maxX, maxY); + break; + case RCTBorderSideBottom: + outPoints[0] = CGPointMake(minX + BW(Left), maxY - BW(Bottom)); + outPoints[1] = CGPointMake(maxX - BW(Right), maxY - BW(Bottom)); + outPoints[2] = CGPointMake(maxX, maxY); + outPoints[3] = CGPointMake(minX, maxY); + break; + case RCTBorderSideLeft: + outPoints[0] = CGPointMake(minX + BW(Left), minY + BW(Top)); + outPoints[1] = CGPointMake(minX + BW(Left), maxY - BW(Bottom)); + outPoints[2] = CGPointMake(minX, maxY); + outPoints[3] = CGPointMake(minX, minY); + break; + case RCTBorderSideTop: + outPoints[0] = CGPointMake(maxX - BW(Right), minY + BW(Top)); + outPoints[1] = CGPointMake(minX + BW(Left), minY + BW(Top)); + outPoints[2] = CGPointMake(minX, minY); + outPoints[3] = CGPointMake(maxX, minY); + break; + } + + return YES; +} + +- (CAShapeLayer *)createShapeLayerIfNotExistsForSide:(RCTBorderSide)side +{ + CAShapeLayer *borderLayer = _borderLayers[side]; + if (!borderLayer) { + borderLayer = [CAShapeLayer layer]; + borderLayer.fillColor = self.layer.borderColor; + [self.layer addSublayer:borderLayer]; + _borderLayers[side] = borderLayer; + } + return borderLayer; +} + +- (void)updatePathForShapeLayerForSide:(RCTBorderSide)side +{ + CAShapeLayer *borderLayer = [self createShapeLayerIfNotExistsForSide:side]; + + CGPoint trapezoidPoints[4]; + [self getTrapezoidPoints:trapezoidPoints forSide:side]; + + CGMutablePathRef path = CGPathCreateMutable(); + CGPathAddLines(path, NULL, trapezoidPoints, 4); + CGPathCloseSubpath(path); + borderLayer.path = path; + CGPathRelease(path); +} + +- (void)updateBorderLayers +{ + BOOL widthsAndColorsSame = YES; + CGFloat width = _borderWidths[0]; + CGColorRef color = _borderLayers[0].fillColor; + for (RCTBorderSide side = 1; side < RCTBorderSideCount; side++) { + CAShapeLayer *layer = _borderLayers[side]; + if (_borderWidths[side] != width || (layer && !CGColorEqualToColor(layer.fillColor, color))) { + widthsAndColorsSame = NO; + break; + } + } + if (widthsAndColorsSame) { + + // Set main layer border + if (width) { + _borderWidth = self.layer.borderWidth = width; + } + if (color) { + self.layer.borderColor = color; + } + + // Remove border layers + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + [_borderLayers[side] removeFromSuperlayer]; + _borderLayers[side] = nil; + } + + } else { + + // Clear main layer border + self.layer.borderWidth = 0; + + // Set up border layers + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + [self updatePathForShapeLayerForSide:side]; + } + } +} + +- (CGFloat)borderWidthForSide:(RCTBorderSide)side +{ + return _borderWidths[side] ?: _borderWidth; +} + +- (void)setBorderWidth:(CGFloat)width forSide:(RCTBorderSide)side +{ + _borderWidths[side] = width; + [self updateBorderLayers]; +} + +#define BORDER_WIDTH(SIDE) \ +- (CGFloat)border##SIDE##Width { return [self borderWidthForSide:RCTBorderSide##SIDE]; } \ +- (void)setBorder##SIDE##Width:(CGFloat)width { [self setBorderWidth:width forSide:RCTBorderSide##SIDE]; } + +BORDER_WIDTH(Top) +BORDER_WIDTH(Right) +BORDER_WIDTH(Bottom) +BORDER_WIDTH(Left) + +- (CGColorRef)borderColorForSide:(RCTBorderSide)side +{ + return _borderLayers[side].fillColor ?: self.layer.borderColor; +} + +- (void)setBorderColor:(CGColorRef)color forSide:(RCTBorderSide)side +{ + [self createShapeLayerIfNotExistsForSide:side].fillColor = color; + [self updateBorderLayers]; +} + +#define BORDER_COLOR(SIDE) \ +- (CGColorRef)border##SIDE##Color { return [self borderColorForSide:RCTBorderSide##SIDE]; } \ +- (void)setBorder##SIDE##Color:(CGColorRef)color { [self setBorderColor:color forSide:RCTBorderSide##SIDE]; } + +BORDER_COLOR(Top) +BORDER_COLOR(Right) +BORDER_COLOR(Bottom) +BORDER_COLOR(Left) + +- (void)setBorderWidth:(CGFloat)borderWidth +{ + _borderWidth = borderWidth; + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + _borderWidths[side] = borderWidth; + } + [self updateBorderLayers]; +} + +- (void)setBorderColor:(CGColorRef)borderColor +{ + self.layer.borderColor = borderColor; + for (RCTBorderSide side = 0; side < RCTBorderSideCount; side++) { + _borderLayers[side].fillColor = borderColor; + } + [self updateBorderLayers]; +} + +- (CGColorRef)borderColor +{ + return self.layer.borderColor; } @end diff --git a/ReactKit/Views/RCTViewControllerProtocol.h b/React/Views/RCTViewControllerProtocol.h similarity index 100% rename from ReactKit/Views/RCTViewControllerProtocol.h rename to React/Views/RCTViewControllerProtocol.h diff --git a/ReactKit/Views/RCTViewManager.h b/React/Views/RCTViewManager.h similarity index 83% rename from ReactKit/Views/RCTViewManager.h rename to React/Views/RCTViewManager.h index 719a970ab..6f2188d3d 100644 --- a/ReactKit/Views/RCTViewManager.h +++ b/React/Views/RCTViewManager.h @@ -106,20 +106,28 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry; /** - * This handles the simple case, where JS and native property names match - * And the type can be automatically inferred. + * This handles the simple case, where JS and native property names match. */ -#define RCT_EXPORT_VIEW_PROPERTY(name) \ -RCT_REMAP_VIEW_PROPERTY(name, name) +#define RCT_EXPORT_VIEW_PROPERTY(name, type) RCT_REMAP_VIEW_PROPERTY(name, name, type) + +#define RCT_EXPORT_SHADOW_PROPERTY(name, type) RCT_REMAP_SHADOW_PROPERTY(name, name, type) /** * This macro maps a named property on the module to an arbitrary key path - * within the view. + * within the view or shadowView. */ -#define RCT_REMAP_VIEW_PROPERTY(name, keypath) \ +#define RCT_REMAP_VIEW_PROPERTY(name, keyPath, type) \ - (void)set_##name:(id)json forView:(id)view withDefaultView:(id)defaultView { \ - if ((json && !RCTSetProperty(view, @#keypath, json)) || \ - (!json && !RCTCopyProperty(view, defaultView, @#keypath))) { \ + if ((json && !RCTSetProperty(view, @#keyPath, @selector(type:), json)) || \ + (!json && !RCTCopyProperty(view, defaultView, @#keyPath))) { \ + RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \ + } \ +} + +#define RCT_REMAP_SHADOW_PROPERTY(name, keyPath, type) \ +- (void)set_##name:(id)json forShadowView:(id)view withDefaultView:(id)defaultView { \ + if ((json && !RCTSetProperty(view, @#keyPath, @selector(type:), json)) || \ + (!json && !RCTCopyProperty(view, defaultView, @#keyPath))) { \ RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \ } \ } @@ -129,10 +137,10 @@ RCT_REMAP_VIEW_PROPERTY(name, name) * view properties. The macro should be followed by a method body, which can * refer to "json", "view" and "defaultView" to implement the required logic. */ -#define RCT_CUSTOM_VIEW_PROPERTY(name, viewClass) \ +#define RCT_CUSTOM_VIEW_PROPERTY(name, type, viewClass) \ - (void)set_##name:(id)json forView:(viewClass *)view withDefaultView:(viewClass *)defaultView -#define RCT_CUSTOM_SHADOW_PROPERTY(name, viewClass) \ +#define RCT_CUSTOM_SHADOW_PROPERTY(name, type, viewClass) \ - (void)set_##name:(id)json forShadowView:(viewClass *)view withDefaultView:(viewClass *)defaultView /** diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m new file mode 100644 index 000000000..fa9975ac8 --- /dev/null +++ b/React/Views/RCTViewManager.m @@ -0,0 +1,205 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import "RCTViewManager.h" + +#import "RCTBridge.h" +#import "RCTConvert.h" +#import "RCTEventDispatcher.h" +#import "RCTLog.h" +#import "RCTShadowView.h" +#import "RCTUtils.h" +#import "RCTView.h" + +@implementation RCTViewManager + +@synthesize bridge = _bridge; + ++ (NSString *)moduleName +{ + // Default implementation, works in most cases + NSString *name = NSStringFromClass(self); + if ([name hasPrefix:@"RK"]) { + name = [name stringByReplacingCharactersInRange:(NSRange){0,@"RK".length} withString:@"RCT"]; + } + if ([name hasPrefix:@"RCTUI"]) { + name = [name substringFromIndex:@"RCT".length]; + } + return name; +} + +- (UIView *)view +{ + return [[RCTView alloc] init]; +} + +- (RCTShadowView *)shadowView +{ + return [[RCTShadowView alloc] init]; +} + +- (NSDictionary *)customBubblingEventTypes +{ + return nil; +} + +- (NSDictionary *)customDirectEventTypes +{ + return nil; +} + +- (NSDictionary *)constantsToExport +{ + return nil; +} + +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView +{ + return nil; +} + +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry +{ + return nil; +} + +#pragma mark - View properties + +RCT_EXPORT_VIEW_PROPERTY(accessibilityLabel, NSString) +RCT_EXPORT_VIEW_PROPERTY(hidden, BOOL) +RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor) +RCT_REMAP_VIEW_PROPERTY(accessible, isAccessibilityElement, BOOL) +RCT_REMAP_VIEW_PROPERTY(testID, accessibilityIdentifier, NSString) +RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat) +RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor); +RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize); +RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, CGFloat) +RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat) +RCT_REMAP_VIEW_PROPERTY(transformMatrix, layer.transform, CATransform3D) +RCT_CUSTOM_VIEW_PROPERTY(overflow, css_overflow, RCTView) +{ + view.clipsToBounds = json ? ![RCTConvert css_overflow:json] : defaultView.clipsToBounds; +} +RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RCTView) +{ + if ([view respondsToSelector:@selector(setPointerEvents:)]) { + view.pointerEvents = json ? [RCTConvert RCTPointerEvents:json] : defaultView.pointerEvents; + return; + } + + if (!json) { + view.userInteractionEnabled = defaultView.userInteractionEnabled; + return; + } + + switch ([RCTConvert RCTPointerEvents:json]) { + case RCTPointerEventsUnspecified: + // Pointer events "unspecified" acts as if a stylesheet had not specified, + // which is different than "auto" in CSS (which cannot and will not be + // supported in `React`. "auto" may override a parent's "none". + // Unspecified values do not. + // This wouldn't override a container view's `userInteractionEnabled = NO` + view.userInteractionEnabled = YES; + case RCTPointerEventsNone: + view.userInteractionEnabled = NO; + break; + default: + RCTLogError(@"UIView base class does not support pointerEvent value: %@", json); + } +} +RCT_CUSTOM_VIEW_PROPERTY(removeClippedSubviews, BOOL, RCTView) +{ + if ([view respondsToSelector:@selector(setRemoveClippedSubviews:)]) { + view.removeClippedSubviews = json ? [RCTConvert BOOL:json] : defaultView.removeClippedSubviews; + } +} +RCT_REMAP_VIEW_PROPERTY(borderRadius, layer.cornerRadius, CGFloat) +RCT_CUSTOM_VIEW_PROPERTY(borderColor, CGColor, RCTView) +{ + if ([view respondsToSelector:@selector(setBorderColor:)]) { + view.borderColor = json ? [RCTConvert CGColor:json] : defaultView.borderColor; + } else { + view.layer.borderColor = json ? [RCTConvert CGColor:json] : defaultView.layer.borderColor; + } +} +RCT_CUSTOM_VIEW_PROPERTY(borderWidth, CGFloat, RCTView) +{ + if ([view respondsToSelector:@selector(setBorderWidth:)]) { + view.borderWidth = json ? [RCTConvert CGFloat:json] : defaultView.borderWidth; + } else { + view.layer.borderWidth = json ? [RCTConvert CGFloat:json] : defaultView.layer.borderWidth; + } +} + +#define RCT_VIEW_BORDER_PROPERTY(SIDE) \ +RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Width, CGFloat, RCTView) \ +{ \ + if ([view respondsToSelector:@selector(setBorder##SIDE##Width:)]) { \ + view.border##SIDE##Width = json ? [RCTConvert CGFloat:json] : defaultView.border##SIDE##Width; \ + } \ +} \ +RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Color, UIColor, RCTView) \ +{ \ + if ([view respondsToSelector:@selector(setBorder##SIDE##Color:)]) { \ + view.border##SIDE##Color = json ? [RCTConvert CGColor:json] : defaultView.border##SIDE##Color; \ + } \ +} + +RCT_VIEW_BORDER_PROPERTY(Top) +RCT_VIEW_BORDER_PROPERTY(Right) +RCT_VIEW_BORDER_PROPERTY(Bottom) +RCT_VIEW_BORDER_PROPERTY(Left) + +#pragma mark - ShadowView properties + +RCT_EXPORT_SHADOW_PROPERTY(top, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(right, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(bottom, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(left, CGFloat); + +RCT_EXPORT_SHADOW_PROPERTY(width, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(height, CGFloat); + +RCT_EXPORT_SHADOW_PROPERTY(borderTopWidth, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(borderRightWidth, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(borderBottomWidth, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(borderLeftWidth, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(borderWidth, CGFloat); + +RCT_EXPORT_SHADOW_PROPERTY(marginTop, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(marginRight, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(marginBottom, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(marginLeft, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(marginVertical, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(marginHorizontal, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(margin, CGFloat); + +RCT_EXPORT_SHADOW_PROPERTY(paddingTop, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(paddingRight, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(paddingBottom, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(paddingLeft, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(paddingVertical, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(paddingHorizontal, CGFloat); +RCT_EXPORT_SHADOW_PROPERTY(padding, CGFloat); + +RCT_EXPORT_SHADOW_PROPERTY(flex, CGFloat) +RCT_EXPORT_SHADOW_PROPERTY(flexDirection, css_flex_direction_t) +RCT_EXPORT_SHADOW_PROPERTY(flexWrap, css_wrap_type_t) +RCT_EXPORT_SHADOW_PROPERTY(justifyContent, css_justify_t) +RCT_EXPORT_SHADOW_PROPERTY(alignItems, css_align_t) +RCT_EXPORT_SHADOW_PROPERTY(alignSelf, css_align_t) +RCT_REMAP_SHADOW_PROPERTY(position, positionType, css_position_type_t) + +RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, UIColor, RCTShadowView) +{ + view.backgroundColor = json ? [RCTConvert UIColor:json] : defaultView.backgroundColor; + view.isBGColorExplicitlySet = json ? YES : defaultView.isBGColorExplicitlySet; +} + +@end diff --git a/ReactKit/Views/RCTViewNodeProtocol.h b/React/Views/RCTViewNodeProtocol.h similarity index 94% rename from ReactKit/Views/RCTViewNodeProtocol.h rename to React/Views/RCTViewNodeProtocol.h index 998c53bce..691aaaba1 100644 --- a/ReactKit/Views/RCTViewNodeProtocol.h +++ b/React/Views/RCTViewNodeProtocol.h @@ -9,7 +9,7 @@ /** * Logical node in a tree of application components. Both `ShadowView`s and - * `UIView+ReactKit`s conform to this. Allows us to write utilities that + * `UIView+React`s conform to this. Allows us to write utilities that * reason about trees generally. */ @protocol RCTViewNodeProtocol diff --git a/ReactKit/Views/RCTWebView.h b/React/Views/RCTWebView.h similarity index 100% rename from ReactKit/Views/RCTWebView.h rename to React/Views/RCTWebView.h diff --git a/ReactKit/Views/RCTWebView.m b/React/Views/RCTWebView.m similarity index 99% rename from ReactKit/Views/RCTWebView.m rename to React/Views/RCTWebView.m index feb9669d8..86dae0172 100644 --- a/ReactKit/Views/RCTWebView.m +++ b/React/Views/RCTWebView.m @@ -16,7 +16,7 @@ #import "RCTLog.h" #import "RCTUtils.h" #import "RCTView.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @interface RCTWebView () diff --git a/ReactKit/Views/RCTWebViewManager.h b/React/Views/RCTWebViewManager.h similarity index 100% rename from ReactKit/Views/RCTWebViewManager.h rename to React/Views/RCTWebViewManager.h diff --git a/ReactKit/Views/RCTWebViewManager.m b/React/Views/RCTWebViewManager.m similarity index 90% rename from ReactKit/Views/RCTWebViewManager.m rename to React/Views/RCTWebViewManager.m index b11426342..4b02f6c0a 100644 --- a/ReactKit/Views/RCTWebViewManager.m +++ b/React/Views/RCTWebViewManager.m @@ -21,10 +21,10 @@ return [[RCTWebView alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } -RCT_REMAP_VIEW_PROPERTY(url, URL); -RCT_EXPORT_VIEW_PROPERTY(contentInset); -RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets); -RCT_EXPORT_VIEW_PROPERTY(shouldInjectAJAXHandler); +RCT_REMAP_VIEW_PROPERTY(url, URL, NSURL); +RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets); +RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, UIEdgeInsets); +RCT_EXPORT_VIEW_PROPERTY(shouldInjectAJAXHandler, BOOL); - (NSDictionary *)constantsToExport { diff --git a/ReactKit/Views/RCTWrapperViewController.h b/React/Views/RCTWrapperViewController.h similarity index 100% rename from ReactKit/Views/RCTWrapperViewController.h rename to React/Views/RCTWrapperViewController.h diff --git a/ReactKit/Views/RCTWrapperViewController.m b/React/Views/RCTWrapperViewController.m similarity index 99% rename from ReactKit/Views/RCTWrapperViewController.m rename to React/Views/RCTWrapperViewController.m index e9b9d5c77..2008c1f83 100644 --- a/ReactKit/Views/RCTWrapperViewController.m +++ b/React/Views/RCTWrapperViewController.m @@ -15,7 +15,7 @@ #import "RCTNavItem.h" #import "RCTUtils.h" #import "RCTViewControllerProtocol.h" -#import "UIView+ReactKit.h" +#import "UIView+React.h" @implementation RCTWrapperViewController { diff --git a/ReactKit/Views/UIView+ReactKit.h b/React/Views/UIView+React.h similarity index 85% rename from ReactKit/Views/UIView+ReactKit.h rename to React/Views/UIView+React.h index b2ba2ca9a..28bca9db9 100644 --- a/ReactKit/Views/UIView+ReactKit.h +++ b/React/Views/UIView+React.h @@ -13,7 +13,7 @@ //TODO: let's try to eliminate this category if possible -@interface UIView (ReactKit) +@interface UIView (React) /** * Used by the UIIManager to set the view frame. @@ -42,12 +42,3 @@ - (BOOL)reactRespondsToTouch:(UITouch *)touch; @end - -@interface UIView (ReactKitBorders) - -/** - * Borders stuff - pay no attention to this, it's going away (#6548297) - */ -- (void)reactSetBorders; - -@end diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m new file mode 100644 index 000000000..6e4a8c45c --- /dev/null +++ b/React/Views/UIView+React.m @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import "UIView+React.h" + +#import + +#import "RCTAssert.h" +#import "RCTLog.h" +#import "RCTWrapperViewController.h" + +@implementation UIView (React) + +- (NSNumber *)reactTag +{ + return objc_getAssociatedObject(self, _cmd); +} + +- (void)setReactTag:(NSNumber *)reactTag +{ + objc_setAssociatedObject(self, @selector(reactTag), reactTag, OBJC_ASSOCIATION_COPY_NONATOMIC); +} + +- (BOOL)isReactRootView +{ + return RCTIsReactRootView(self.reactTag); +} + +- (NSNumber *)reactTagAtPoint:(CGPoint)point +{ + UIView *view = [self hitTest:point withEvent:nil]; + while (view && !view.reactTag) { + view = view.superview; + } + return view.reactTag; +} + +- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex +{ + [self insertSubview:subview atIndex:atIndex]; +} + +- (void)removeReactSubview:(UIView *)subview +{ + RCTAssert(subview.superview == self, @"%@ is a not a subview of %@", subview, self); + [subview removeFromSuperview]; +} + +- (NSArray *)reactSubviews +{ + return self.subviews; +} + +- (UIView *)reactSuperview +{ + return self.superview; +} + +- (void)reactSetFrame:(CGRect)frame +{ + // These frames are in terms of anchorPoint = topLeft, but internally the + // views are anchorPoint = center for easier scale and rotation animations. + // Convert the frame so it works with anchorPoint = center. + CGPoint position = {CGRectGetMidX(frame), CGRectGetMidY(frame)}; + CGRect bounds = {CGPointZero, frame.size}; + + // Avoid crashes due to nan coords + if (isnan(position.x) || isnan(position.y) || + isnan(bounds.origin.x) || isnan(bounds.origin.y) || + isnan(bounds.size.width) || isnan(bounds.size.height)) { + RCTLogError(@"Invalid layout for (%@)%@. position: %@. bounds: %@", + self.reactTag, self, NSStringFromCGPoint(position), NSStringFromCGRect(bounds)); + return; + } + + self.layer.position = position; + self.layer.bounds = bounds; +} + +- (UIViewController *)backingViewController +{ + id responder = [self nextResponder]; + if ([responder isKindOfClass:[RCTWrapperViewController class]]) { + return responder; + } + return nil; +} + +- (void)addControllerToClosestParent:(UIViewController *)controller +{ + if (!controller.parentViewController) { + UIView *parentView = (UIView *)self.reactSuperview; + while (parentView) { + if (parentView.backingViewController) { + [parentView.backingViewController addChildViewController:controller]; + [controller didMoveToParentViewController:parentView.backingViewController]; + break; + } + parentView = (UIView *)parentView.reactSuperview; + } + return; + } +} + +/** + * Responder overrides - to be deprecated. + */ +- (void)reactWillMakeFirstResponder {}; +- (void)reactDidMakeFirstResponder {}; +- (BOOL)reactRespondsToTouch:(UITouch *)touch +{ + return YES; +} + +@end diff --git a/ReactKit/ReactKit.podspec b/ReactKit/ReactKit.podspec deleted file mode 100644 index 3e1a8a6e2..000000000 --- a/ReactKit/ReactKit.podspec +++ /dev/null @@ -1,16 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'ReactKit' - spec.version = '0.0.1' - spec.summary = 'An implementation of React that targets UIKit for iOS' - spec.description = <<-DESC - Our first React Native implementation is ReactKit, targeting iOS. We are also working on an Android implementation which we will release later. ReactKit apps are built using the React JS framework, and render directly to native UIKit elements using a fully asynchronous architecture. There is no browser and no HTML. We have picked what we think is the best set of features from these and other technologies to build what we hope to become the best product development framework available, with an emphasis on iteration speed, developer delight, continuity of technology, and absolutely beautiful and fast products with no compromises in quality or capability. - DESC - spec.homepage = 'https://facebook.github.io/react-native/' - spec.license = { :type => 'BSD' } - spec.author = 'Facebook' - spec.platform = :ios, '7.0' - spec.requires_arc = true - spec.source_files = '**/*.{h,m,c}' - spec.public_header_files = "**/*.h" - #spec.library = "ReactKit" -end diff --git a/ReactKit/Views/RCTViewManager.m b/ReactKit/Views/RCTViewManager.m deleted file mode 100644 index 2f3ed2d47..000000000 --- a/ReactKit/Views/RCTViewManager.m +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "RCTViewManager.h" - -#import "RCTBridge.h" -#import "RCTConvert.h" -#import "RCTEventDispatcher.h" -#import "RCTLog.h" -#import "RCTShadowView.h" -#import "RCTUtils.h" -#import "RCTView.h" - -@implementation RCTViewManager - -@synthesize bridge = _bridge; - -+ (NSString *)moduleName -{ - // Default implementation, works in most cases - NSString *name = NSStringFromClass(self); - if ([name hasPrefix:@"RK"]) { - name = [name stringByReplacingCharactersInRange:(NSRange){0,@"RK".length} withString:@"RCT"]; - } - if ([name hasPrefix:@"RCTUI"]) { - name = [name substringFromIndex:@"RCT".length]; - } - return name; -} - -- (UIView *)view -{ - return [[RCTView alloc] init]; -} - -- (RCTShadowView *)shadowView -{ - return [[RCTShadowView alloc] init]; -} - -- (NSDictionary *)customBubblingEventTypes -{ - return nil; -} - -- (NSDictionary *)customDirectEventTypes -{ - return nil; -} - -- (NSDictionary *)constantsToExport -{ - return nil; -} - -- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView -{ - return nil; -} - -- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry -{ - return nil; -} - -#pragma mark - View properties - -RCT_EXPORT_VIEW_PROPERTY(accessibilityLabel) -RCT_EXPORT_VIEW_PROPERTY(hidden) -RCT_EXPORT_VIEW_PROPERTY(backgroundColor) -RCT_REMAP_VIEW_PROPERTY(accessible, isAccessibilityElement) -RCT_REMAP_VIEW_PROPERTY(testID, accessibilityIdentifier) -RCT_REMAP_VIEW_PROPERTY(opacity, alpha) -RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor); -RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset); -RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity) -RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius) -RCT_REMAP_VIEW_PROPERTY(borderColor, layer.borderColor); -RCT_REMAP_VIEW_PROPERTY(borderRadius, layer.cornerRadius) -RCT_REMAP_VIEW_PROPERTY(borderWidth, layer.borderWidth) -RCT_REMAP_VIEW_PROPERTY(transformMatrix, layer.transform) -RCT_CUSTOM_VIEW_PROPERTY(overflow, UIView) -{ - view.clipsToBounds = json ? ![RCTConvert css_overflow:json] : defaultView.clipsToBounds; -} -RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTView) -{ - if ([view respondsToSelector:@selector(setPointerEvents:)]) { - view.pointerEvents = json ? [RCTConvert RCTPointerEvents:json] : defaultView.pointerEvents; - return; - } - - if (!json) { - view.userInteractionEnabled = defaultView.userInteractionEnabled; - return; - } - - switch ([RCTConvert RCTPointerEvents:json]) { - case RCTPointerEventsUnspecified: - // Pointer events "unspecified" acts as if a stylesheet had not specified, - // which is different than "auto" in CSS (which cannot and will not be - // supported in `ReactKit`. "auto" may override a parent's "none". - // Unspecified values do not. - // This wouldn't override a container view's `userInteractionEnabled = NO` - view.userInteractionEnabled = YES; - case RCTPointerEventsNone: - view.userInteractionEnabled = NO; - break; - default: - RCTLogError(@"UIView base class does not support pointerEvent value: %@", json); - } -} -RCT_CUSTOM_VIEW_PROPERTY(removeClippedSubviews, RCTView) -{ - if ([view respondsToSelector:@selector(setRemoveClippedSubviews:)]) { - view.removeClippedSubviews = json ? [RCTConvert BOOL:json] : defaultView.removeClippedSubviews; - } -} - -#pragma mark - ShadowView properties - -RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowView) -{ - view.backgroundColor = json ? [RCTConvert UIColor:json] : defaultView.backgroundColor; - view.isBGColorExplicitlySet = json ? YES : defaultView.isBGColorExplicitlySet; -} -RCT_CUSTOM_SHADOW_PROPERTY(flexDirection, RCTShadowView) -{ - view.flexDirection = json? [RCTConvert css_flex_direction_t:json] : defaultView.flexDirection; -} -RCT_CUSTOM_SHADOW_PROPERTY(flexWrap, RCTShadowView) -{ - view.flexWrap = json ? [RCTConvert css_wrap_type_t:json] : defaultView.flexWrap; -} -RCT_CUSTOM_SHADOW_PROPERTY(justifyContent, RCTShadowView) -{ - view.justifyContent = json ? [RCTConvert css_justify_t:json] : defaultView.justifyContent; -} -RCT_CUSTOM_SHADOW_PROPERTY(alignItems, RCTShadowView) -{ - view.alignItems = json ? [RCTConvert css_align_t:json] : defaultView.alignItems; -} -RCT_CUSTOM_SHADOW_PROPERTY(alignSelf, RCTShadowView) -{ - view.alignSelf = json ? [RCTConvert css_align_t:json] : defaultView.alignSelf; -} -RCT_CUSTOM_SHADOW_PROPERTY(position, RCTShadowView) -{ - view.positionType = json ? [RCTConvert css_position_type_t:json] : defaultView.positionType; -} - -// Border properties - to be deprecated - -RCT_REMAP_VIEW_PROPERTY(borderTopWidth, reactBorderTop.width); -RCT_REMAP_VIEW_PROPERTY(borderRightWidth, reactBorderRight.width); -RCT_REMAP_VIEW_PROPERTY(borderBottomWidth, reactBorderBottom.width); -RCT_REMAP_VIEW_PROPERTY(borderLeftWidth, reactBorderLeft.width); -RCT_REMAP_VIEW_PROPERTY(borderTopColor, reactBorderTop.color); -RCT_REMAP_VIEW_PROPERTY(borderRightColor, reactBorderRight.color); -RCT_REMAP_VIEW_PROPERTY(borderBottomColor, reactBorderBottom.color); -RCT_REMAP_VIEW_PROPERTY(borderLeftColor, reactBorderLeft.color); - -@end diff --git a/ReactKit/Views/UIView+ReactKit.m b/ReactKit/Views/UIView+ReactKit.m deleted file mode 100644 index 2ef2ce31b..000000000 --- a/ReactKit/Views/UIView+ReactKit.m +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "UIView+ReactKit.h" - -#import - -#import "RCTAssert.h" -#import "RCTLog.h" -#import "RCTWrapperViewController.h" - -@implementation UIView (ReactKit) - -- (NSNumber *)reactTag -{ - return objc_getAssociatedObject(self, _cmd); -} - -- (void)setReactTag:(NSNumber *)reactTag -{ - objc_setAssociatedObject(self, @selector(reactTag), reactTag, OBJC_ASSOCIATION_COPY_NONATOMIC); -} - -- (BOOL)isReactRootView -{ - return RCTIsReactRootView(self.reactTag); -} - -- (NSNumber *)reactTagAtPoint:(CGPoint)point -{ - UIView *view = [self hitTest:point withEvent:nil]; - while (view && !view.reactTag) { - view = view.superview; - } - return view.reactTag; -} - -- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex -{ - [self insertSubview:subview atIndex:atIndex]; -} - -- (void)removeReactSubview:(UIView *)subview -{ - RCTAssert(subview.superview == self, @"%@ is a not a subview of %@", subview, self); - [subview removeFromSuperview]; -} - -- (NSArray *)reactSubviews -{ - return self.subviews; -} - -- (UIView *)reactSuperview -{ - return self.superview; -} - -- (void)reactSetFrame:(CGRect)frame -{ - // These frames are in terms of anchorPoint = topLeft, but internally the - // views are anchorPoint = center for easier scale and rotation animations. - // Convert the frame so it works with anchorPoint = center. - CGPoint position = {CGRectGetMidX(frame), CGRectGetMidY(frame)}; - CGRect bounds = {CGPointZero, frame.size}; - - // Avoid crashes due to nan coords - if (isnan(position.x) || isnan(position.y) || - isnan(bounds.origin.x) || isnan(bounds.origin.y) || - isnan(bounds.size.width) || isnan(bounds.size.height)) { - RCTLogError(@"Invalid layout for (%@)%@. position: %@. bounds: %@", - self.reactTag, self, NSStringFromCGPoint(position), NSStringFromCGRect(bounds)); - return; - } - - self.layer.position = position; - self.layer.bounds = bounds; -} - -- (UIViewController *)backingViewController -{ - id responder = [self nextResponder]; - if ([responder isKindOfClass:[RCTWrapperViewController class]]) { - return responder; - } - return nil; -} - -- (void)addControllerToClosestParent:(UIViewController *)controller -{ - if (!controller.parentViewController) { - UIView *parentView = (UIView *)self.reactSuperview; - while (parentView) { - if (parentView.backingViewController) { - [parentView.backingViewController addChildViewController:controller]; - [controller didMoveToParentViewController:parentView.backingViewController]; - break; - } - parentView = (UIView *)parentView.reactSuperview; - } - return; - } -} - -/** - * Responder overrides - to be deprecated. - */ -- (void)reactWillMakeFirstResponder {}; -- (void)reactDidMakeFirstResponder {}; -- (BOOL)reactRespondsToTouch:(UITouch *)touch -{ - return YES; -} - -@end - -#pragma mark - Borders - -// Note: the value of this enum determines their relative zPosition -typedef NS_ENUM(NSUInteger, RCTBorderSide) { - RCTBorderSideTop = 0, - RCTBorderSideRight = 1, - RCTBorderSideBottom = 2, - RCTBorderSideLeft = 3 -}; - -@interface RCTSingleSidedBorder : NSObject - -@property (nonatomic, readwrite, assign) CGFloat width; -@property (nonatomic, readwrite, strong) UIColor *color; -@property (nonatomic, readonly, assign) RCTBorderSide side; - -- (instancetype)initWithSide:(RCTBorderSide)side superlayer:(CALayer *)superlayer; - -- (void)superLayerBoundsDidChange; - -@end - -@implementation RCTSingleSidedBorder -{ - CALayer *_borderLayer; -} - -- (instancetype)initWithSide:(RCTBorderSide)side superlayer:(CALayer *)superlayer -{ - if (self = [super init]) { - _side = side; - - _borderLayer = [CALayer layer]; - _borderLayer.delegate = self; - _borderLayer.zPosition = INT_MAX - _side; - - [superlayer insertSublayer:_borderLayer atIndex:0]; - } - return self; -} - -- (void)dealloc -{ - _borderLayer.delegate = nil; -} - -- (void)setWidth:(CGFloat)width -{ - _width = width; - [_borderLayer setNeedsLayout]; -} - -- (void)setColor:(UIColor *)color -{ - _color = color; - _borderLayer.backgroundColor = _color.CGColor; - [_borderLayer setNeedsLayout]; -} - -- (void)superLayerBoundsDidChange -{ - [_borderLayer setNeedsLayout]; -} - -#pragma mark - CALayerDelegate - -- (void)layoutSublayersOfLayer:(CALayer *)layer -{ - CGSize superlayerSize = layer.superlayer.frame.size; - - CGFloat xPosition = 0.0f; - CGFloat yPosition = 0.0f; - - // Note: we ensure side layers are below top & bottom for snapshot test consistency - - switch (self.side) { - case RCTBorderSideTop: - layer.frame = CGRectMake(xPosition, yPosition, superlayerSize.width, self.width); - break; - case RCTBorderSideRight: - xPosition = superlayerSize.width - self.width; - layer.frame = CGRectMake(xPosition, yPosition, self.width, superlayerSize.height); - [layer.superlayer insertSublayer:layer atIndex:0]; - break; - case RCTBorderSideBottom: - yPosition = superlayerSize.height - self.width; - layer.frame = CGRectMake(xPosition, yPosition, superlayerSize.width, self.width); - break; - case RCTBorderSideLeft: - layer.frame = CGRectMake(xPosition, yPosition, self.width, superlayerSize.height); - [layer.superlayer insertSublayer:layer atIndex:0]; - break; - } -} - -// Disable animations for layer -- (id)actionForLayer:(CALayer *)layer forKey:(NSString *)event -{ - return (id)[NSNull null]; -} - -@end - -@implementation UIView (ReactKitBorders) - -- (void)reactSetBorders -{ - NSMutableDictionary *borders = objc_getAssociatedObject(self, @selector(_createOrGetBorderWithSide:)); - if (borders) { - for (RCTSingleSidedBorder *border in [borders allValues]) { - [border superLayerBoundsDidChange]; - } - } -} - -- (RCTSingleSidedBorder *)reactBorderTop -{ - return [self _createOrGetBorderWithSide:RCTBorderSideTop]; -} - -- (RCTSingleSidedBorder *)reactBorderRight -{ - return [self _createOrGetBorderWithSide:RCTBorderSideRight]; -} - -- (RCTSingleSidedBorder *)reactBorderBottom -{ - return [self _createOrGetBorderWithSide:RCTBorderSideBottom]; -} - -- (RCTSingleSidedBorder *)reactBorderLeft -{ - return [self _createOrGetBorderWithSide:RCTBorderSideLeft]; -} - -- (RCTSingleSidedBorder *)_createOrGetBorderWithSide:(RCTBorderSide)side -{ - NSMutableDictionary *borders = objc_getAssociatedObject(self, _cmd); - if (!borders) { - borders = [[NSMutableDictionary alloc] init]; - objc_setAssociatedObject(self, _cmd, borders, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - - RCTSingleSidedBorder *border = [borders objectForKey:@(side)]; - if (!border) { - border = [[RCTSingleSidedBorder alloc] initWithSide:side superlayer:self.layer]; - [borders setObject:border forKey:@(side)]; - } - return border; -} - -@end diff --git a/package.json b/package.json index 3cc2ae49c..c9a561ba4 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "main": "Libraries/react-native/react-native.js", "files": [ - "ReactKit", + "React", "Examples/SampleApp", "Libraries", "packager", diff --git a/packager/packager.js b/packager/packager.js index 12ef9ddde..119336edc 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -36,6 +36,9 @@ var options = parseCommandLine([{ }, { command: 'root', description: 'add another root(s) to be used by the packager in this project', +}, { + command: 'assetRoots', + description: 'specify the root directories of app assets' }]); if (options.projectRoots) { @@ -61,7 +64,11 @@ if (options.root) { } } -if (!options.assetRoots) { +if (options.assetRoots) { + if (!Array.isArray(options.assetRoots)) { + options.assetRoots = options.assetRoots.split(','); + } +} else { options.assetRoots = [path.resolve(__dirname, '..')]; }