From e209f2f1e93b12d64be8197bbe8eba7e28355ded Mon Sep 17 00:00:00 2001 From: Mengjue Wang Date: Wed, 6 Jul 2016 16:26:59 -0700 Subject: [PATCH] Move Bridge functions to OSS -- RTL experiment Summary: Delete the bridge functions(isRTL, allowRTL()) in internal module and move to OSS. Create bridge for RCTI18nUtil Reviewed By: fkgozali Differential Revision: D3519224 fbshipit-source-id: 3853edcfcc78777d957874448117de72ae0700b5 --- React/Modules/RCTI18nManager.h | 19 ++++++++++++++++++ React/Modules/RCTI18nManager.m | 29 +++++++++++++++++++++++++++ React/React.xcodeproj/project.pbxproj | 6 ++++++ 3 files changed, 54 insertions(+) create mode 100644 React/Modules/RCTI18nManager.h create mode 100644 React/Modules/RCTI18nManager.m diff --git a/React/Modules/RCTI18nManager.h b/React/Modules/RCTI18nManager.h new file mode 100644 index 0000000000..5a36d0f2c7 --- /dev/null +++ b/React/Modules/RCTI18nManager.h @@ -0,0 +1,19 @@ +/** + * 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 "RCTBridgeModule.h" + +/** + * @experimental + * This is a experimental module for RTL support + * This module bridges the i18n utility from RCTI18nUtil + */ +@interface RCTI18nManager : NSObject + +@end diff --git a/React/Modules/RCTI18nManager.m b/React/Modules/RCTI18nManager.m new file mode 100644 index 0000000000..32371f229a --- /dev/null +++ b/React/Modules/RCTI18nManager.m @@ -0,0 +1,29 @@ +/** + * 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 "RCTI18nManager.h" +#import "RCTI18nUtil.h" + +@implementation RCTI18nManager + +RCT_EXPORT_MODULE() + +RCT_EXPORT_METHOD(allowRTL:(BOOL)value) +{ + [[RCTI18nUtil sharedInstance] setAllowRTL:value]; +} + +- (NSDictionary *)constantsToExport +{ + return @{ + @"isRTL": @([[RCTI18nUtil sharedInstance] isRTL]) + }; +} + +@end diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 08c7d0ef7c..3873f67f1c 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -96,6 +96,7 @@ 83CBBA981A6020BB00E9B192 /* RCTTouchHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBA971A6020BB00E9B192 /* RCTTouchHandler.m */; }; 83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBACB1A6023D300E9B192 /* RCTConvert.m */; }; 85C199EE1CD2407900DAD810 /* RCTJSCWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85C199ED1CD2407900DAD810 /* RCTJSCWrapper.mm */; }; + B233E6EA1D2D845D00BC68BA /* RCTI18nManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */; }; B95154321D1B34B200FE7B80 /* RCTActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = B95154311D1B34B200FE7B80 /* RCTActivityIndicatorView.m */; }; E9B20B7B1B500126007A2DA7 /* RCTAccessibilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */; }; /* End PBXBuildFile section */ @@ -310,6 +311,8 @@ 85C199EC1CD2407900DAD810 /* RCTJSCWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSCWrapper.h; sourceTree = ""; }; 85C199ED1CD2407900DAD810 /* RCTJSCWrapper.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = RCTJSCWrapper.mm; sourceTree = ""; }; ACDD3FDA1BC7430D00E7DE33 /* RCTBorderStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBorderStyle.h; sourceTree = ""; }; + B233E6E81D2D843200BC68BA /* RCTI18nManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTI18nManager.h; sourceTree = ""; }; + B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTI18nManager.m; sourceTree = ""; }; B95154301D1B34B200FE7B80 /* RCTActivityIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTActivityIndicatorView.h; sourceTree = ""; }; B95154311D1B34B200FE7B80 /* RCTActivityIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTActivityIndicatorView.m; sourceTree = ""; }; E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = ""; }; @@ -377,6 +380,8 @@ 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */, 352DCFEE1D19F4C20056D623 /* RCTI18nUtil.h */, 352DCFEF1D19F4C20056D623 /* RCTI18nUtil.m */, + B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */, + B233E6E81D2D843200BC68BA /* RCTI18nManager.h */, 13D9FEEC1CDCD93000158BD7 /* RCTKeyboardObserver.h */, 13D9FEED1CDCD93000158BD7 /* RCTKeyboardObserver.m */, 13B07FED1A69327A00A75B9A /* RCTTiming.h */, @@ -749,6 +754,7 @@ 13E067571A70F44B002CDEE1 /* RCTView.m in Sources */, 13AFBCA01C07247D00BBAEAA /* RCTMapOverlay.m in Sources */, 13D9FEEE1CDCD93000158BD7 /* RCTKeyboardObserver.m in Sources */, + B233E6EA1D2D845D00BC68BA /* RCTI18nManager.m in Sources */, 13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */, 137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */, 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */,