Skip to content

Commit

Permalink
feat: support new react-native versions (continuation) (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakex7 authored Nov 9, 2024
1 parent 66389e9 commit 815ae6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class LocalizationSettingsModule internal constructor(context: ReactApplicationC
/**
* Expose constants to react-native
**/
override fun getTypedExportedConstants(): MutableMap<String, String?>? {
val constants: MutableMap<String, String?> = HashMap()
constants["language"] = getCurrentLanguage()
return constants
override fun getTypedExportedConstants(): Map<String, String?> {
return mapOf(
"language" to getCurrentLanguage()
)
}

/**
Expand Down
1 change: 0 additions & 1 deletion android/src/oldarch/LocalizationSettingsSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String?>?

override fun getConstants(): Map<String, String?>? {
return getTypedExportedConstants()
}
Expand Down
14 changes: 12 additions & 2 deletions ios/LocalizationSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,30 @@ - (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
**/
RCT_REMAP_METHOD(getLanguage,
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];
}

/**
Expand Down
17 changes: 4 additions & 13 deletions react-native-localization-settings.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

0 comments on commit 815ae6e

Please sign in to comment.