| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6509efa commit 0138873
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | <Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally" | |
| 2 | - loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red" | ||
| 3 | - horizontalAlignment="center" verticalAlignment="middle"> | ||
| 2 | + loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red"> | ||
| 4 | 3 | <StackLayout backgroundColor="PaleGreen" margin="10"> | |
| 5 | 4 | <TextField hint="username" id="username" text="username"/> | |
| 6 | 5 | <TextField hint="password" id="password" text="password" secure="true"/> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,3 +10,15 @@ export function onTap(args) { | |||
| 10 | 10 | label.text = username + "/" + password; | |
| 11 | 11 | }, fullscreen); | |
| 12 | 12 | } | |
| 13 | + | ||
| 14 | + export function onTapStretched(args) { | ||
| 15 | + const page = <Page>args.object.page; | ||
| 16 | + const label = page.getViewById<Label>("label"); | ||
| 17 | + var fullscreen = false; | ||
| 18 | + var stretched = true; | ||
| 19 | + | ||
| 20 | + page.showModal("ui-tests-app/modal-view/login-page", "context", function (username: string, password: string) { | ||
| 21 | + console.log(username + "/" + password); | ||
| 22 | + label.text = username + "/" + password; | ||
| 23 | + }, fullscreen, false, stretched); | ||
| 24 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | <StackLayout backgroundColor="PaleGreen"> | |
| 3 | 3 | <Button text="Login (pop-up)" tap="onTap" /> | |
| 4 | 4 | <Button text="Login (full-screen)" tap="onTap" /> | |
| 5 | + <Button text="Login (pop-up-stretched)" tap="onTapStretched" /> | ||
| 5 | 6 | <Label id="label" text="Anonymous"/> | |
| 6 | 7 | </StackLayout> | |
| 7 | 8 | </Page> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -214,11 +214,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { | |||
| 214 | 214 | const closeCallback: Function = arguments[2]; | |
| 215 | 215 | const fullscreen: boolean = arguments[3]; | |
| 216 | 216 | const animated = arguments[4]; | |
| 217 | + const stretched = arguments[5]; | ||
| 217 | 218 | ||
| 218 | 219 | const view: ViewDefinition = firstAgrument instanceof ViewCommon | |
| 219 | 220 | ? firstAgrument : createViewFromEntry({ moduleName: firstAgrument }); | |
| 220 | 221 | ||
| 221 | - (<ViewCommon>view)._showNativeModalView(this, context, closeCallback, fullscreen, animated); | ||
| 222 | + (<ViewCommon>view)._showNativeModalView(this, context, closeCallback, fullscreen, animated, stretched); | ||
| 222 | 223 | return view; | |
| 223 | 224 | } | |
| 224 | 225 | } | |
@@ -239,7 +240,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { | |||
| 239 | 240 | return this._modal; | |
| 240 | 241 | } | |
| 241 | 242 | ||
| 242 | - protected _showNativeModalView(parent: ViewCommon, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean) { | ||
| 243 | + protected _showNativeModalView(parent: ViewCommon, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) { | ||
| 243 | 244 | _rootModalViews.push(this); | |
| 244 | 245 | ||
| 245 | 246 | parent._modal = this; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,7 @@ let Dialog: android.app.Dialog; | |||
| 38 | 38 | interface DialogOptions { | |
| 39 | 39 | owner: View; | |
| 40 | 40 | fullscreen: boolean; | |
| 41 | + stretched: boolean; | ||
| 41 | 42 | shownCallback: () => void; | |
| 42 | 43 | dismissCallback: () => void; | |
| 43 | 44 | } | |
@@ -123,6 +124,7 @@ function initializeDialogFragment() { | |||
| 123 | 124 | class DialogFragmentImpl extends android.app.DialogFragment { | |
| 124 | 125 | public owner: View; | |
| 125 | 126 | private _fullscreen: boolean; | |
| 127 | + private _stretched: boolean; | ||
| 126 | 128 | private _shownCallback: () => void; | |
| 127 | 129 | private _dismissCallback: () => void; | |
| 128 | 130 | ||
@@ -136,17 +138,21 @@ function initializeDialogFragment() { | |||
| 136 | 138 | const options = getModalOptions(ownerId); | |
| 137 | 139 | this.owner = options.owner; | |
| 138 | 140 | this._fullscreen = options.fullscreen; | |
| 141 | + this._stretched = options.stretched; | ||
| 139 | 142 | this._dismissCallback = options.dismissCallback; | |
| 140 | 143 | this._shownCallback = options.shownCallback; | |
| 141 | 144 | this.owner._dialogFragment = this; | |
| 142 | 145 | this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0); | |
| 143 | - | ||
| 146 | + | ||
| 144 | 147 | const dialog = new DialogImpl(this, this.getActivity(), this.getTheme()); | |
| 145 | - | ||
| 148 | + | ||
| 146 | 149 | // do not override alignment unless fullscreen modal will be shown; | |
| 147 | 150 | // otherwise we might break component-level layout: | |
| 148 | 151 | // https://github.com/NativeScript/NativeScript/issues/5392 | |
| 149 | - if (this._fullscreen) { | ||
| 152 | + if (!this._fullscreen && !this._stretched) { | ||
| 153 | + this.owner.horizontalAlignment = "center"; | ||
| 154 | + this.owner.verticalAlignment = "middle"; | ||
| 155 | + } else { | ||
| 150 | 156 | this.owner.horizontalAlignment = "stretch"; | |
| 151 | 157 | this.owner.verticalAlignment = "stretch"; | |
| 152 | 158 | } | |
@@ -179,7 +185,7 @@ function initializeDialogFragment() { | |||
| 179 | 185 | ||
| 180 | 186 | this._shownCallback(); | |
| 181 | 187 | } | |
| 182 | - | ||
| 188 | + | ||
| 183 | 189 | public onDismiss(dialog: android.content.IDialogInterface): void { | |
| 184 | 190 | super.onDismiss(dialog); | |
| 185 | 191 | const manager = this.getFragmentManager(); | |
@@ -455,8 +461,8 @@ export class View extends ViewCommon { | |||
| 455 | 461 | return result | (childMeasuredState & layout.MEASURED_STATE_MASK); | |
| 456 | 462 | } | |
| 457 | 463 | ||
| 458 | - protected _showNativeModalView(parent: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean) { | ||
| 459 | - super._showNativeModalView(parent, context, closeCallback, fullscreen); | ||
| 464 | + protected _showNativeModalView(parent: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) { | ||
| 465 | + super._showNativeModalView(parent, context, closeCallback, fullscreen, stretched); | ||
| 460 | 466 | if (!this.backgroundColor) { | |
| 461 | 467 | this.backgroundColor = new Color("White"); | |
| 462 | 468 | } | |
@@ -471,6 +477,7 @@ export class View extends ViewCommon { | |||
| 471 | 477 | const dialogOptions: DialogOptions = { | |
| 472 | 478 | owner: this, | |
| 473 | 479 | fullscreen: !!fullscreen, | |
| 480 | + stretched: !!stretched, | ||
| 474 | 481 | shownCallback: () => this._raiseShownModallyEvent(), | |
| 475 | 482 | dismissCallback: () => this.closeModal() | |
| 476 | 483 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -498,17 +498,19 @@ export abstract class View extends ViewBase { | |||
| 498 | 498 | * @param closeCallback - A function that will be called when the view is closed. | |
| 499 | 499 | * Any arguments provided when calling ShownModallyData.closeCallback will be available here. | |
| 500 | 500 | * @param fullscreen - An optional parameter specifying whether to show the modal page in full-screen mode. | |
| 501 | + * @param stretched - An optional parameter specifying whether to stretch the modal page when not in full-screen mode. | ||
| 501 | 502 | */ | |
| 502 | - showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean): View; | ||
| 503 | + showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean): View; | ||
| 503 | 504 | ||
| 504 | 505 | /** | |
| 505 | 506 | * Shows the view passed as parameter as a modal view. | |
| 506 | 507 | * @param view - View instance to be shown modally. | |
| 507 | 508 | * @param context - Any context you want to pass to the modally shown view. This same context will be available in the arguments of the shownModally event handler. | |
| 508 | 509 | * @param closeCallback - A function that will be called when the view is closed. Any arguments provided when calling ShownModallyData.closeCallback will be available here. | |
| 509 | 510 | * @param fullscreen - An optional parameter specifying whether to show the modal view in full-screen mode. | |
| 511 | + * @param stretched - An optional parameter specifying whether to stretch the modal page when not in full-screen mode. | ||
| 510 | 512 | */ | |
| 511 | - showModal(view: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean): View; | ||
| 513 | + showModal(view: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean): View; | ||
| 512 | 514 | ||
| 513 | 515 | /** | |
| 514 | 516 | * Deprecated. Showing view as modal is deprecated. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -311,10 +311,10 @@ export class View extends ViewCommon { | |||
| 311 | 311 | ||
| 312 | 312 | return view; | |
| 313 | 313 | } | |
| 314 | - protected _showNativeModalView(parent: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean) { | ||
| 314 | + protected _showNativeModalView(parent: View, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) { | ||
| 315 | 315 | let parentWithController = this.getParentWithViewController(parent); | |
| 316 | 316 | ||
| 317 | - super._showNativeModalView(parentWithController, context, closeCallback, fullscreen); | ||
| 317 | + super._showNativeModalView(parentWithController, context, closeCallback, fullscreen, stretched); | ||
| 318 | 318 | let controller = this.viewController; | |
| 319 | 319 | if (!controller) { | |
| 320 | 320 | controller = ios.UILayoutViewController.initWithOwner(new WeakRef(this)); | |
@@ -334,6 +334,9 @@ export class View extends ViewCommon { | |||
| 334 | 334 | controller.modalPresentationStyle = UIModalPresentationStyle.FormSheet; | |
| 335 | 335 | } | |
| 336 | 336 | ||
| 337 | + this.horizontalAlignment = "stretch"; | ||
| 338 | + this.verticalAlignment = "stretch"; | ||
| 339 | + | ||
| 337 | 340 | this._raiseShowingModallyEvent(); | |
| 338 | 341 | animated = animated === undefined ? true : !!animated; | |
| 339 | 342 | (<any>controller).animated = animated; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments