Skip to content

Commit 9214883

Browse files
authored
fix-next(tabview): fix tab title layout in modal root tabview Fixes NativeScript#5392 (NativeScript#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.
1 parent fb5c97c commit 9214883

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

apps/app/ui-tests-app/modal-view/login-page.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally" loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red">
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally"
2+
loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red"
3+
horizontalAlignment="center" verticalAlignment="middle">
24
<StackLayout backgroundColor="PaleGreen" margin="10">
35
<TextField hint="username" id="username" text="username"/>
46
<TextField hint="password" id="password" text="password" secure="true"/>

tns-core-modules/ui/core/view/view.android.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,24 @@ function initializeDialogFragment() {
142142
this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0);
143143

144144
const dialog = new DialogImpl(this, this.getActivity(), this.getTheme());
145-
146-
// adjust alignment based on fullscreen value.
147-
this.owner.horizontalAlignment = this._fullscreen ? "stretch" : "center";
148-
this.owner.verticalAlignment = this._fullscreen ? "stretch" : "middle";
149145

146+
// do not override alignment unless fullscreen modal will be shown;
147+
// otherwise we might break component-level layout:
148+
// https://github.com/NativeScript/NativeScript/issues/5392
149+
if (this._fullscreen) {
150+
this.owner.horizontalAlignment = "stretch";
151+
this.owner.verticalAlignment = "stretch";
152+
}
153+
150154
return dialog;
151155
}
152156

153157
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View {
154158
const owner = this.owner;
155159
owner._setupAsRootView(this.getActivity());
156160
owner._isAddedToNativeVisualTree = true;
157-
158-
return this.owner.nativeViewProtected;
161+
162+
return owner.nativeViewProtected;
159163
}
160164

161165
public onStart(): void {

0 commit comments

Comments
 (0)