mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(Utils): add dismissSoftInput helper (#9392)
closes #4594 Co-authored-by: Nathan Walker <walkerrunpdx@gmail.com>
This commit is contained in:
3
packages/core/index.d.ts
vendored
3
packages/core/index.d.ts
vendored
@@ -101,7 +101,7 @@ export type { InstrumentationMode, TimerInfo } from './profiling';
|
|||||||
export { encoding } from './text';
|
export { encoding } from './text';
|
||||||
export * from './trace';
|
export * from './trace';
|
||||||
export * from './ui';
|
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';
|
import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types';
|
||||||
export declare const Utils: {
|
export declare const Utils: {
|
||||||
GC: typeof GC;
|
GC: typeof GC;
|
||||||
@@ -144,5 +144,6 @@ export declare const Utils: {
|
|||||||
isUndefined: typeof isUndefined;
|
isUndefined: typeof isUndefined;
|
||||||
toUIString: typeof toUIString;
|
toUIString: typeof toUIString;
|
||||||
verifyCallback: typeof verifyCallback;
|
verifyCallback: typeof verifyCallback;
|
||||||
|
dismissSoftInput: typeof dismissSoftInput;
|
||||||
};
|
};
|
||||||
export { XmlParser, ParserEventType, ParserEvent } from './xml';
|
export { XmlParser, ParserEventType, ParserEvent } from './xml';
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export * from './trace';
|
|||||||
|
|
||||||
export * from './ui';
|
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';
|
import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types';
|
||||||
|
|
||||||
export const Utils = {
|
export const Utils = {
|
||||||
@@ -170,6 +170,7 @@ export const Utils = {
|
|||||||
isUndefined,
|
isUndefined,
|
||||||
toUIString,
|
toUIString,
|
||||||
verifyCallback,
|
verifyCallback,
|
||||||
|
dismissSoftInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { XmlParser, ParserEventType, ParserEvent } from './xml';
|
export { XmlParser, ParserEventType, ParserEvent } from './xml';
|
||||||
|
|||||||
@@ -167,3 +167,7 @@ Please ensure you have your manifest correctly configured with the FileProvider.
|
|||||||
export function isRealDevice(): boolean {
|
export function isRealDevice(): boolean {
|
||||||
return ad.isRealDevice();
|
return ad.isRealDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dismissSoftInput(nativeView?: any): void {
|
||||||
|
ad.dismissSoftInput(nativeView);
|
||||||
|
}
|
||||||
|
|||||||
5
packages/core/utils/index.d.ts
vendored
5
packages/core/utils/index.d.ts
vendored
@@ -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.
|
* Checks whether the application is running on real device and not on simulator/emulator.
|
||||||
*/
|
*/
|
||||||
export function isRealDevice(): boolean;
|
export function isRealDevice(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the soft input method, usually a soft keyboard.
|
||||||
|
*/
|
||||||
|
export function dismissSoftInput(nativeView?: any): void;
|
||||||
|
|||||||
@@ -48,3 +48,10 @@ export function isRealDevice(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ad = 0;
|
export const ad = 0;
|
||||||
|
|
||||||
|
export function dismissSoftInput(nativeView?: UIView): void {
|
||||||
|
if (nativeView instanceof UIView && !nativeView.isFirstResponder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UIApplication.sharedApplication.sendActionToFromForEvent('resignFirstResponder', null, null, null);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user