| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2e45de7 commit dc1b36b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,22 @@ import * as helper from "../helper"; | |||
| 7 | 7 | import * as TKUnit from "../../TKUnit"; | |
| 8 | 8 | import * as utils from "tns-core-modules/utils/utils"; | |
| 9 | 9 | ||
| 10 | + export function test_event_LayoutChanged_GetActualSize() { | ||
| 11 | + const test = function (views: Array<View>) { | ||
| 12 | + let buttonLayoutChanged = false; | ||
| 13 | + | ||
| 14 | + views[1].on(View.layoutChangedEvent, (data) => { | ||
| 15 | + buttonLayoutChanged = true; | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + TKUnit.waitUntilReady(() => buttonLayoutChanged); | ||
| 19 | + TKUnit.assert(views[1].getActualSize().height > 0); | ||
| 20 | + TKUnit.assert(views[1].getActualSize().width > 0); | ||
| 21 | + }; | ||
| 22 | + | ||
| 23 | + helper.do_PageTest_WithStackLayout_AndButton(test); | ||
| 24 | + }; | ||
| 25 | + | ||
| 10 | 26 | export function test_event_LayoutChanged_Listeners() { | |
| 11 | 27 | const test = function (views: Array<View>) { | |
| 12 | 28 | let stackLayoutChanged = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ import { | |||
| 7 | 7 | ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, | |
| 8 | 8 | traceEnabled, traceWrite, traceCategories, traceNotifyEvent, | |
| 9 | 9 | paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, | |
| 10 | - Color | ||
| 10 | + Color, EventData | ||
| 11 | 11 | } from "./view-common"; | |
| 12 | 12 | ||
| 13 | 13 | import { | |
@@ -243,6 +243,26 @@ export class View extends ViewCommon { | |||
| 243 | 243 | } | |
| 244 | 244 | } | |
| 245 | 245 | ||
| 246 | + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any) { | ||
| 247 | + super.on(eventNames, callback, thisArg); | ||
| 248 | + const isLayoutEvent = typeof eventNames === "string" ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false; | ||
| 249 | + | ||
| 250 | + if (this.isLoaded && !this.layoutChangeListenerIsSet && isLayoutEvent) { | ||
| 251 | + this.setOnLayoutChangeListener(); | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + off(eventNames: string, callback?: any, thisArg?: any) { | ||
| 256 | + super.off(eventNames, callback, thisArg); | ||
| 257 | + const isLayoutEvent = typeof eventNames === "string" ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false; | ||
| 258 | + | ||
| 259 | + // Remove native listener only if there are no more user listeners for LayoutChanged event | ||
| 260 | + if (this.isLoaded && this.layoutChangeListenerIsSet && isLayoutEvent && !this.hasListeners(ViewCommon.layoutChangedEvent)) { | ||
| 261 | + this.nativeViewProtected.removeOnLayoutChangeListener(this.layoutChangeListener); | ||
| 262 | + this.layoutChangeListenerIsSet = false; | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + | ||
| 246 | 266 | public _getFragmentManager(): android.app.FragmentManager { | |
| 247 | 267 | let manager = this._manager; | |
| 248 | 268 | if (!manager) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments