From 6cdfe52294aa77ef407f3aabc97e719edf48c7fd Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Feb 2021 15:04:02 -0600 Subject: [PATCH 1/6] Initial Commit --- React/Modules/RCTI18nUtil.h | 23 ++++++++++++----- React/Modules/RCTI18nUtil.m | 49 +------------------------------------ 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index f3a1550e5ec778..723430cd92f2c2 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -18,11 +18,22 @@ + (instancetype)sharedInstance; - (BOOL)isRTL; -- (BOOL)isRTLAllowed; -- (void)allowRTL:(BOOL)value; -- (BOOL)isRTLForced; -- (void)forceRTL:(BOOL)value; -- (BOOL)doLeftAndRightSwapInRTL; -- (void)swapLeftAndRightInRTL:(BOOL)value; + +/** + * Should be used very early during app start up + * Before the bridge is initialized + * @return whether the app allows RTL layout, default is true + */ +@property(atomic, readwrite, setter=allowRTL:) bool isRTLAllowed; + +/** + * Could be used to test RTL layout with English + * Used for development and testing purpose + */ +@property(atomic, readwrite, setter=forceRTL:) bool isRTLForced; + +@property(atomic, readwrite, setter=swapLeftAndRightInRTL:) bool doLeftAndRightSwapInRTL; + + @end diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index e04582a505b06d..c89543fa8a3530 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -15,7 +15,7 @@ + (instancetype)sharedInstance { static RCTI18nUtil *sharedInstance; static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ + dispatch_once(&onceToken, ^{git s sharedInstance = [self new]; [sharedInstance swapLeftAndRightInRTL:true]; }); @@ -40,53 +40,6 @@ - (BOOL)isRTL return NO; } -/** - * Should be used very early during app start up - * Before the bridge is initialized - * @return whether the app allows RTL layout, default is true - */ -- (BOOL)isRTLAllowed -{ - NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"RCTI18nUtil_allowRTL"]; - if (value == nil) { - return YES; - } - return [value boolValue]; -} - -- (void)allowRTL:(BOOL)rtlStatus -{ - [[NSUserDefaults standardUserDefaults] setBool:rtlStatus forKey:@"RCTI18nUtil_allowRTL"]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -/** - * Could be used to test RTL layout with English - * Used for development and testing purpose - */ -- (BOOL)isRTLForced -{ - BOOL rtlStatus = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"]; - return rtlStatus; -} - -- (void)forceRTL:(BOOL)rtlStatus -{ - [[NSUserDefaults standardUserDefaults] setBool:rtlStatus forKey:@"RCTI18nUtil_forceRTL"]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -- (BOOL)doLeftAndRightSwapInRTL -{ - return [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"]; -} - -- (void)swapLeftAndRightInRTL:(BOOL)value -{ - [[NSUserDefaults standardUserDefaults] setBool:value forKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - // Check if the current device language is RTL - (BOOL)isDevicePreferredLanguageRTL { From 12fa03b443f083b2a7e8fcc669ba8b1c040cfd88 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Feb 2021 16:33:54 -0600 Subject: [PATCH 2/6] Fix typo --- React/Modules/RCTI18nUtil.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index c89543fa8a3530..49a0e2786943e3 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -15,7 +15,7 @@ + (instancetype)sharedInstance { static RCTI18nUtil *sharedInstance; static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{git s + dispatch_once(&onceToken, ^{ sharedInstance = [self new]; [sharedInstance swapLeftAndRightInRTL:true]; }); From 86f185e2639555802c2a04007cecdac0142b9716 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Feb 2021 17:15:52 -0600 Subject: [PATCH 3/6] Fix default initialization of isRTLAllowed and documentation --- React/Modules/RCTI18nUtil.h | 1 - React/Modules/RCTI18nUtil.m | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index 723430cd92f2c2..86aa38500910e1 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -22,7 +22,6 @@ /** * Should be used very early during app start up * Before the bridge is initialized - * @return whether the app allows RTL layout, default is true */ @property(atomic, readwrite, setter=allowRTL:) bool isRTLAllowed; diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index 49a0e2786943e3..ea337d5e6f6083 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -18,6 +18,7 @@ + (instancetype)sharedInstance dispatch_once(&onceToken, ^{ sharedInstance = [self new]; [sharedInstance swapLeftAndRightInRTL:true]; + [sharedIntance allowRTL:true]; }); return sharedInstance; From f0e8bbb82ad028e518701471cec3922bdbccf27a Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Feb 2021 17:24:52 -0600 Subject: [PATCH 4/6] use BOOL, remove superfluous readwrite decorator --- React/Modules/RCTI18nUtil.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index 86aa38500910e1..e6ed3ffb563290 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -23,15 +23,15 @@ * Should be used very early during app start up * Before the bridge is initialized */ -@property(atomic, readwrite, setter=allowRTL:) bool isRTLAllowed; +@property(atomic, setter=allowRTL:) BOOL isRTLAllowed; /** * Could be used to test RTL layout with English * Used for development and testing purpose */ -@property(atomic, readwrite, setter=forceRTL:) bool isRTLForced; +@property(atomic, setter=forceRTL:) BOOL isRTLForced; -@property(atomic, readwrite, setter=swapLeftAndRightInRTL:) bool doLeftAndRightSwapInRTL; +@property(atomic, setter=swapLeftAndRightInRTL:) BOOL doLeftAndRightSwapInRTL; From 548be0b1fae371add5953a2c80abdcc84efbe4be Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Tue, 23 Feb 2021 13:52:11 -0600 Subject: [PATCH 5/6] Fix another typo --- React/Modules/RCTI18nUtil.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index ea337d5e6f6083..835a603356fafe 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -18,7 +18,7 @@ + (instancetype)sharedInstance dispatch_once(&onceToken, ^{ sharedInstance = [self new]; [sharedInstance swapLeftAndRightInRTL:true]; - [sharedIntance allowRTL:true]; + [sharedInstance allowRTL:true]; }); return sharedInstance; From 7456af4aca74ea021e4f2c80dfad5f9a624cab7f Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 26 Feb 2021 01:13:56 -0600 Subject: [PATCH 6/6] Add TODO Marker --- React/Modules/RCTI18nUtil.h | 5 ++--- React/Modules/RCTI18nUtil.m | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index e6ed3ffb563290..79e2f5ba2643e7 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -18,7 +18,7 @@ + (instancetype)sharedInstance; - (BOOL)isRTL; - +// [ TODO(macOS#4904077) /** * Should be used very early during app start up * Before the bridge is initialized @@ -32,7 +32,6 @@ @property(atomic, setter=forceRTL:) BOOL isRTLForced; @property(atomic, setter=swapLeftAndRightInRTL:) BOOL doLeftAndRightSwapInRTL; - - +// ]TODO(macOS#4904077) @end diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index 835a603356fafe..800d14398f280d 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -18,7 +18,7 @@ + (instancetype)sharedInstance dispatch_once(&onceToken, ^{ sharedInstance = [self new]; [sharedInstance swapLeftAndRightInRTL:true]; - [sharedInstance allowRTL:true]; + [sharedInstance allowRTL:true]; // TODO(macOS#4904077) }); return sharedInstance;