mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-02 19:12:40 +08:00
BREAKING CHANGE: [Android] NativeScript no longer overwrites the horizontal/vertical alignment on the user-defined root visual element when opening it in modal dialog window (i.e. not fullscreen). If your application logic relied on the previous behavior you need to manually set `horizontalAlignment="center"` and `verticalAlignment="middle"` on the root visual element you are showing modally.
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally" loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red">
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally"
|
||||
loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red"
|
||||
horizontalAlignment="center" verticalAlignment="middle">
|
||||
<StackLayout backgroundColor="PaleGreen" margin="10">
|
||||
<TextField hint="username" id="username" text="username"/>
|
||||
<TextField hint="password" id="password" text="password" secure="true"/>
|
||||
|
||||
@ -142,11 +142,15 @@ function initializeDialogFragment() {
|
||||
this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0);
|
||||
|
||||
const dialog = new DialogImpl(this, this.getActivity(), this.getTheme());
|
||||
|
||||
// adjust alignment based on fullscreen value.
|
||||
this.owner.horizontalAlignment = this._fullscreen ? "stretch" : "center";
|
||||
this.owner.verticalAlignment = this._fullscreen ? "stretch" : "middle";
|
||||
|
||||
// do not override alignment unless fullscreen modal will be shown;
|
||||
// otherwise we might break component-level layout:
|
||||
// https://github.com/NativeScript/NativeScript/issues/5392
|
||||
if (this._fullscreen) {
|
||||
this.owner.horizontalAlignment = "stretch";
|
||||
this.owner.verticalAlignment = "stretch";
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@ -154,8 +158,8 @@ function initializeDialogFragment() {
|
||||
const owner = this.owner;
|
||||
owner._setupAsRootView(this.getActivity());
|
||||
owner._isAddedToNativeVisualTree = true;
|
||||
|
||||
return this.owner.nativeViewProtected;
|
||||
|
||||
return owner.nativeViewProtected;
|
||||
}
|
||||
|
||||
public onStart(): void {
|
||||
|
||||
Reference in New Issue
Block a user