Implement gating support for direction-aware API changes

Reviewed By: achen1

Differential Revision: D6045083

fbshipit-source-id: 857a43029ad88d2324ec77145a1e30d92b5e8fae
This commit is contained in:
Ramanpreet Nara authored and Facebook Github Bot committed 2017-10-18 19:33:31 -07:00
1 parent f7888310d4
commit 98547d4bcf
6 files changed
+41 -1

No files matched your search

+7 -1
View File
@@ -29,10 +29,16 @@ RCT_EXPORT_METHOD(forceRTL:(BOOL)value)
[[RCTI18nUtil sharedInstance] forceRTL:value];
}
RCT_EXPORT_METHOD(makeRTLFlipLeftAndRightStyles:(BOOL)value)
{
[[RCTI18nUtil sharedInstance] makeRTLFlipLeftAndRightStyles:value];
}
- (NSDictionary *)constantsToExport
{
return @{
@"isRTL": @([[RCTI18nUtil sharedInstance] isRTL])
@"isRTL": @([[RCTI18nUtil sharedInstance] isRTL]),
@"doesRTLFlipLeftAndRightStyles": @([[RCTI18nUtil sharedInstance] doesRTLFlipLeftAndRightStyles])
};
}
+2
View File
@@ -24,5 +24,7 @@
- (void)allowRTL:(BOOL)value;
- (BOOL)isRTLForced;
- (void)forceRTL:(BOOL)value;
- (BOOL)doesRTLFlipLeftAndRightStyles;
- (void)makeRTLFlipLeftAndRightStyles:(BOOL)value;
@end
+12
View File
@@ -19,6 +19,7 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [self new];
[sharedInstance makeRTLFlipLeftAndRightStyles: true];
});
return sharedInstance;
@@ -78,6 +79,17 @@
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (BOOL)doesRTLFlipLeftAndRightStyles
{
return [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"];
}
- (void)makeRTLFlipLeftAndRightStyles:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
// Check if the current device language is RTL
- (BOOL)isDevicePreferredLanguageRTL
{