From 7abe390da5efe405fc6de8473c05ed29f45678f7 Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Sat, 9 Nov 2024 21:27:08 +0100 Subject: [PATCH 1/3] refactor: simplify podspec --- react-native-localization-settings.podspec | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/react-native-localization-settings.podspec b/react-native-localization-settings.podspec index 99ca220..ca82070 100644 --- a/react-native-localization-settings.podspec +++ b/react-native-localization-settings.podspec @@ -1,7 +1,6 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "package.json"))) -folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' Pod::Spec.new do |s| s.name = "react-native-localization-settings" @@ -18,18 +17,10 @@ Pod::Spec.new do |s| s.dependency "React-Core" - # Don't install the dependencies when we run `pod install` in the old architecture. if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", - "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" - } - s.dependency "React-Codegen" - s.dependency "RCT-Folly" - s.dependency "RCTRequired" - s.dependency "RCTTypeSafety" - s.dependency "ReactCommon/turbomodule/core" + install_modules_dependencies(s) + else + s.dependency 'React-Core' end + end From 18b5ac7570214878fdf4e9e6b1c4b3b8b36dd648 Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Sat, 9 Nov 2024 21:27:28 +0100 Subject: [PATCH 2/3] refactor: simplify kotlin module --- .../localizationsettings/LocalizationSettingsModule.kt | 8 ++++---- android/src/oldarch/LocalizationSettingsSpec.kt | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/localizationsettings/LocalizationSettingsModule.kt b/android/src/main/java/com/localizationsettings/LocalizationSettingsModule.kt index 2b606c1..67fffcf 100644 --- a/android/src/main/java/com/localizationsettings/LocalizationSettingsModule.kt +++ b/android/src/main/java/com/localizationsettings/LocalizationSettingsModule.kt @@ -96,10 +96,10 @@ class LocalizationSettingsModule internal constructor(context: ReactApplicationC /** * Expose constants to react-native **/ - override fun getTypedExportedConstants(): MutableMap? { - val constants: MutableMap = HashMap() - constants["language"] = getCurrentLanguage() - return constants + override fun getTypedExportedConstants(): Map { + return mapOf( + "language" to getCurrentLanguage() + ) } /** diff --git a/android/src/oldarch/LocalizationSettingsSpec.kt b/android/src/oldarch/LocalizationSettingsSpec.kt index 3aef287..a7257ea 100644 --- a/android/src/oldarch/LocalizationSettingsSpec.kt +++ b/android/src/oldarch/LocalizationSettingsSpec.kt @@ -10,7 +10,6 @@ abstract class LocalizationSettingsSpec internal constructor(context: ReactAppli abstract fun getLanguage(promise: Promise) abstract fun setLanguage(language: String) abstract fun getTypedExportedConstants(): Map? - override fun getConstants(): Map? { return getTypedExportedConstants() } From 6d715f899f32b0ad0de7e8f26f1f5bc8372fd806 Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Sat, 9 Nov 2024 21:30:11 +0100 Subject: [PATCH 3/3] feat: support new arch --- ios/LocalizationSettings.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ios/LocalizationSettings.mm b/ios/LocalizationSettings.mm index 5f5889f..3066ba9 100644 --- a/ios/LocalizationSettings.mm +++ b/ios/LocalizationSettings.mm @@ -50,6 +50,16 @@ - (void)setCurrentLanguage:(NSString *)lang { [[NSUserDefaults standardUserDefaults] synchronize]; } + +- (void)getLanguage:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { + resolve([self getCurrentLanguage]); +} + + +- (void)setLanguage:(NSString *)lang { + [self setCurrentLanguage:lang]; +} + /** * Expose functions to react-native **/ @@ -57,13 +67,13 @@ - (void)setCurrentLanguage:(NSString *)lang { withResolver:(RCTPromiseResolveBlock)resolve withReject:(RCTPromiseRejectBlock)reject) { - resolve([self getCurrentLanguage]); + return [self getLanguage:resolve reject:reject]; } RCT_REMAP_METHOD(setLanguage, language:(NSString *)lang) { - [self setCurrentLanguage:lang]; + return [self setLanguage:lang]; } /**