From d8b4737ca67591737e277cc43b7e352bd113dc7f Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 14 Mar 2023 09:30:07 -0700 Subject: [PATCH] Fix duplicate [RCTConvert UIUserInterfaceStyle:] Summary: After https://github.com/facebook/react-native/pull/36122 we have two of these. This change consolidates the two category methods to be part of the base RCTConvert class instead. Changelog: [iOS][Fixed] - Fix duplicate [RCTConvert UIUserInterfaceStyle:] Reviewed By: cipolleschi Differential Revision: D44050929 fbshipit-source-id: dd216545e6194446c593cd693072f3959d653d7f --- React/Base/RCTConvert.h | 1 + React/Base/RCTConvert.m | 10 ++++++++++ React/CoreModules/RCTAlertManager.mm | 14 -------------- React/CoreModules/RCTAppearance.mm | 14 -------------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/React/Base/RCTConvert.h b/React/Base/RCTConvert.h index 386c17175d355e..abb59d161804fa 100644 --- a/React/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -71,6 +71,7 @@ typedef NSURL RCTFileURL; + (UIKeyboardType)UIKeyboardType:(id)json; + (UIKeyboardAppearance)UIKeyboardAppearance:(id)json; + (UIReturnKeyType)UIReturnKeyType:(id)json; ++ (UIUserInterfaceStyle)UIUserInterfaceStyle:(id)json API_AVAILABLE(ios(12)); #if !TARGET_OS_TV + (UIDataDetectorTypes)UIDataDetectorTypes:(id)json; #endif diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index f24c09b539ae73..8960df94c0926a 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -501,6 +501,16 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC UIReturnKeyDefault, integerValue) +RCT_ENUM_CONVERTER( + UIUserInterfaceStyle, + (@{ + @"unspecified" : @(UIUserInterfaceStyleUnspecified), + @"light" : @(UIUserInterfaceStyleLight), + @"dark" : @(UIUserInterfaceStyleDark), + }), + UIUserInterfaceStyleUnspecified, + integerValue) + RCT_ENUM_CONVERTER( UIViewContentMode, (@{ diff --git a/React/CoreModules/RCTAlertManager.mm b/React/CoreModules/RCTAlertManager.mm index 532e898faf05a0..df46ec58423a1d 100644 --- a/React/CoreModules/RCTAlertManager.mm +++ b/React/CoreModules/RCTAlertManager.mm @@ -32,20 +32,6 @@ @implementation RCTConvert (UIAlertViewStyle) @end -@implementation RCTConvert (UIUserInterfaceStyle) - -RCT_ENUM_CONVERTER( - UIUserInterfaceStyle, - (@{ - @"unspecified" : @(UIUserInterfaceStyleUnspecified), - @"light" : @(UIUserInterfaceStyleLight), - @"dark" : @(UIUserInterfaceStyleDark), - }), - UIUserInterfaceStyleUnspecified, - integerValue) - -@end - @interface RCTAlertManager () @end diff --git a/React/CoreModules/RCTAppearance.mm b/React/CoreModules/RCTAppearance.mm index 72257c8fa1bfdc..17535a99f1a3fc 100644 --- a/React/CoreModules/RCTAppearance.mm +++ b/React/CoreModules/RCTAppearance.mm @@ -69,20 +69,6 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride) return RCTAppearanceColorSchemeLight; } -@implementation RCTConvert (UIUserInterfaceStyle) - -RCT_ENUM_CONVERTER( - UIUserInterfaceStyle, - (@{ - @"light" : @(UIUserInterfaceStyleLight), - @"dark" : @(UIUserInterfaceStyleDark), - @"unspecified" : @(UIUserInterfaceStyleUnspecified) - }), - UIUserInterfaceStyleUnspecified, - integerValue); - -@end - @interface RCTAppearance () @end