mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-19 23:13:04 +08:00
fix android modal not following activity windowSoftInputMode
Also added an android modal parameter to set a custom windowSoftInputMode
This commit is contained in:
4
packages/core/ui/core/view-base/index.d.ts
vendored
4
packages/core/ui/core/view-base/index.d.ts
vendored
@ -83,6 +83,10 @@ export interface ShowModalOptions {
|
|||||||
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
||||||
*/
|
*/
|
||||||
cancelable?: boolean;
|
cancelable?: boolean;
|
||||||
|
/**
|
||||||
|
* An optional parameter specifying the windowSoftInputMode of the dialog window
|
||||||
|
*/
|
||||||
|
windowSoftInputMode?: number;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
||||||
|
@ -87,6 +87,11 @@ export interface ShowModalOptions {
|
|||||||
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
||||||
*/
|
*/
|
||||||
cancelable?: boolean;
|
cancelable?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional parameter specifying the windowSoftInputMode of the dialog window
|
||||||
|
*/
|
||||||
|
windowSoftInputMode?: number;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
|
||||||
|
@ -76,6 +76,7 @@ interface DialogOptions {
|
|||||||
animated: boolean;
|
animated: boolean;
|
||||||
stretched: boolean;
|
stretched: boolean;
|
||||||
cancelable: boolean;
|
cancelable: boolean;
|
||||||
|
windowSoftInputMode: number;
|
||||||
shownCallback: () => void;
|
shownCallback: () => void;
|
||||||
dismissCallback: () => void;
|
dismissCallback: () => void;
|
||||||
}
|
}
|
||||||
@ -168,6 +169,7 @@ function initializeDialogFragment() {
|
|||||||
class DialogFragmentImpl extends androidx.fragment.app.DialogFragment {
|
class DialogFragmentImpl extends androidx.fragment.app.DialogFragment {
|
||||||
public owner: View;
|
public owner: View;
|
||||||
private _fullscreen: boolean;
|
private _fullscreen: boolean;
|
||||||
|
private _windowSoftInputMode: number;
|
||||||
private _animated: boolean;
|
private _animated: boolean;
|
||||||
private _stretched: boolean;
|
private _stretched: boolean;
|
||||||
private _cancelable: boolean;
|
private _cancelable: boolean;
|
||||||
@ -192,6 +194,7 @@ function initializeDialogFragment() {
|
|||||||
this._stretched = options.stretched;
|
this._stretched = options.stretched;
|
||||||
this._dismissCallback = options.dismissCallback;
|
this._dismissCallback = options.dismissCallback;
|
||||||
this._shownCallback = options.shownCallback;
|
this._shownCallback = options.shownCallback;
|
||||||
|
this._windowSoftInputMode = options.windowSoftInputMode;
|
||||||
this.setStyle(androidx.fragment.app.DialogFragment.STYLE_NO_TITLE, 0);
|
this.setStyle(androidx.fragment.app.DialogFragment.STYLE_NO_TITLE, 0);
|
||||||
|
|
||||||
let theme = this.getTheme();
|
let theme = this.getTheme();
|
||||||
@ -243,8 +246,20 @@ function initializeDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const owner = this.owner;
|
const owner = this.owner;
|
||||||
if (owner && !owner.isLoaded) {
|
if (owner) {
|
||||||
owner.callLoaded();
|
if (!owner.isLoaded) {
|
||||||
|
owner.callLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const window = this.getDialog().getWindow();
|
||||||
|
if (this._windowSoftInputMode !== undefined) {
|
||||||
|
window.setSoftInputMode(this._windowSoftInputMode);
|
||||||
|
} else {
|
||||||
|
// the dialog seems to not follow the default activity softinputmode,
|
||||||
|
// thus set we set it here.
|
||||||
|
window.setSoftInputMode((<androidx.appcompat.app.AppCompatActivity>owner._context).getWindow().getAttributes().softInputMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._shownCallback();
|
this._shownCallback();
|
||||||
@ -672,10 +687,14 @@ export class View extends ViewCommon {
|
|||||||
df.setArguments(args);
|
df.setArguments(args);
|
||||||
|
|
||||||
let cancelable = true;
|
let cancelable = true;
|
||||||
|
let windowSoftInputMode: number;
|
||||||
|
|
||||||
if (options.android && (<any>options).android.cancelable !== undefined) {
|
if (options.android) {
|
||||||
cancelable = !!(<any>options).android.cancelable;
|
if ((<any>options).android.cancelable !== undefined) {
|
||||||
console.log('ShowModalOptions.android.cancelable is deprecated. Use ShowModalOptions.cancelable instead.');
|
cancelable = !!(<any>options).android.cancelable;
|
||||||
|
console.log('ShowModalOptions.android.cancelable is deprecated. Use ShowModalOptions.cancelable instead.');
|
||||||
|
}
|
||||||
|
windowSoftInputMode = (<any>options).android.windowSoftInputMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelable = options.cancelable !== undefined ? !!options.cancelable : cancelable;
|
cancelable = options.cancelable !== undefined ? !!options.cancelable : cancelable;
|
||||||
@ -686,6 +705,7 @@ export class View extends ViewCommon {
|
|||||||
animated: !!options.animated,
|
animated: !!options.animated,
|
||||||
stretched: !!options.stretched,
|
stretched: !!options.stretched,
|
||||||
cancelable: cancelable,
|
cancelable: cancelable,
|
||||||
|
windowSoftInputMode: windowSoftInputMode,
|
||||||
shownCallback: () => this._raiseShownModallyEvent(),
|
shownCallback: () => this._raiseShownModallyEvent(),
|
||||||
dismissCallback: () => this.closeModal(),
|
dismissCallback: () => this.closeModal(),
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user