feat(Utils): add dismissSoftInput helper (#9392)

closes #4594

Co-authored-by: Nathan Walker <walkerrunpdx@gmail.com>
This commit is contained in:
Osei Fortune
2021-05-13 11:43:59 -04:00
committed by GitHub
parent dac36c6801
commit 6cf4c5981b
5 changed files with 20 additions and 2 deletions

View File

@@ -101,7 +101,7 @@ export type { InstrumentationMode, TimerInfo } from './profiling';
export { encoding } from './text';
export * from './trace';
export * from './ui';
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, escapeRegexSymbols, convertString } from './utils';
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, escapeRegexSymbols, convertString, dismissSoftInput } from './utils';
import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types';
export declare const Utils: {
GC: typeof GC;
@@ -144,5 +144,6 @@ export declare const Utils: {
isUndefined: typeof isUndefined;
toUIString: typeof toUIString;
verifyCallback: typeof verifyCallback;
dismissSoftInput: typeof dismissSoftInput;
};
export { XmlParser, ParserEventType, ParserEvent } from './xml';

View File

@@ -122,7 +122,7 @@ export * from './trace';
export * from './ui';
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, queueMacrotask, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, RESOURCE_PREFIX, FILE_PREFIX, escapeRegexSymbols, convertString } from './utils';
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, queueMacrotask, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, RESOURCE_PREFIX, FILE_PREFIX, escapeRegexSymbols, convertString, dismissSoftInput } from './utils';
import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types';
export const Utils = {
@@ -170,6 +170,7 @@ export const Utils = {
isUndefined,
toUIString,
verifyCallback,
dismissSoftInput,
};
export { XmlParser, ParserEventType, ParserEvent } from './xml';

View File

@@ -167,3 +167,7 @@ Please ensure you have your manifest correctly configured with the FileProvider.
export function isRealDevice(): boolean {
return ad.isRealDevice();
}
export function dismissSoftInput(nativeView?: any): void {
ad.dismissSoftInput(nativeView);
}

View File

@@ -286,3 +286,8 @@ export function eliminateDuplicates(arr: Array<any>): Array<any>;
* Checks whether the application is running on real device and not on simulator/emulator.
*/
export function isRealDevice(): boolean;
/**
* Hides the soft input method, usually a soft keyboard.
*/
export function dismissSoftInput(nativeView?: any): void;

View File

@@ -48,3 +48,10 @@ export function isRealDevice(): boolean {
}
export const ad = 0;
export function dismissSoftInput(nativeView?: UIView): void {
if (nativeView instanceof UIView && !nativeView.isFirstResponder) {
return;
}
UIApplication.sharedApplication.sendActionToFromForEvent('resignFirstResponder', null, null, null);
}