fix-next(tabview): fix tab title layout in modal root tabview Fixes #5392 (#5435)

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:
Manol Donev
2018-03-02 13:27:21 +02:00
committed by GitHub
parent fb5c97cf57
commit 92148833d3
2 changed files with 13 additions and 7 deletions

View File

@ -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"/>

View File

@ -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 {