Files
bsky-social-app/modules/expo-keyboard-language/ios/ExpoKeyboardLanguageModule.swift
T
Claude 3ca5a865a1 Add expo-keyboard-language native module
New Expo module that exposes keyboard language detection via a node
handle. On iOS it resolves the React Native view tag to the underlying
UITextField/UITextView and returns textInputMode.primaryLanguage (BCP 47
tag). Android and web return null for now.

https://claude.ai/code/session_01AMCp4M56WtFPz1pZtwgcvx
2026-02-28 14:49:15 +00:00

34 lines
811 B
Swift

import ExpoModulesCore
public class ExpoKeyboardLanguageModule: Module {
public func definition() -> ModuleDefinition {
Name("ExpoKeyboardLanguage")
Function("getKeyboardLanguage") { (nodeHandle: Int) -> String? in
guard let view = self.appContext?.findView(withTag: nodeHandle, ofType: UIView.self) else {
return nil
}
if let textInput = self.findTextInput(in: view) {
return textInput.textInputMode?.primaryLanguage
}
return view.textInputMode?.primaryLanguage
}
}
private func findTextInput(in view: UIView) -> UIView? {
if view is UITextField || view is UITextView {
return view
}
for subview in view.subviews {
if let found = findTextInput(in: subview) {
return found
}
}
return nil
}
}