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"> <StackLayout backgroundColor="PaleGreen" margin="10">
<TextField hint="username" id="username" text="username"/> <TextField hint="username" id="username" text="username"/>
<TextField hint="password" id="password" text="password" secure="true"/> <TextField hint="password" id="password" text="password" secure="true"/>

View File

@ -143,9 +143,13 @@ function initializeDialogFragment() {
const dialog = new DialogImpl(this, this.getActivity(), this.getTheme()); const dialog = new DialogImpl(this, this.getActivity(), this.getTheme());
// adjust alignment based on fullscreen value. // do not override alignment unless fullscreen modal will be shown;
this.owner.horizontalAlignment = this._fullscreen ? "stretch" : "center"; // otherwise we might break component-level layout:
this.owner.verticalAlignment = this._fullscreen ? "stretch" : "middle"; // https://github.com/NativeScript/NativeScript/issues/5392
if (this._fullscreen) {
this.owner.horizontalAlignment = "stretch";
this.owner.verticalAlignment = "stretch";
}
return dialog; return dialog;
} }
@ -155,7 +159,7 @@ function initializeDialogFragment() {
owner._setupAsRootView(this.getActivity()); owner._setupAsRootView(this.getActivity());
owner._isAddedToNativeVisualTree = true; owner._isAddedToNativeVisualTree = true;
return this.owner.nativeViewProtected; return owner.nativeViewProtected;
} }
public onStart(): void { public onStart(): void {