-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(view): introduce LayoutChanged event on every View component #5825
Conversation
@@ -305,6 +307,17 @@ export class View extends ViewCommon { | |||
public initNativeView(): void { | |||
super.initNativeView(); | |||
this._isClickable = this.nativeViewProtected.isClickable(); | |||
|
|||
this.setOnLayoutChangeListener(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create a LayoutChangeListener only if someone has attached to this event. Currently listeners will be created for all views and will be triggered unnecessary.
We are doing something similar with the touch listener here. For the onLayout
we should probably override another method as it is not attached trough observe()
(observe is for gestures). Probably on()/off()
events
ebdabf2
to
2e45de7
Compare
newPage.content = stackLayout; | ||
|
||
TKUnit.waitUntilReady(() => stackLayoutChanged && buttonLayoutChanged); | ||
TKUnit.assert(stackLayoutChanged); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need those explicit asserts -- waitUnitlReady(...) on previous line will time out if those booleans are not true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure too.
We do it in other tests
#5687 says that the main use case is to be able to use |
@@ -241,6 +243,26 @@ export class View extends ViewCommon { | |||
} | |||
} | |||
|
|||
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any) { | |||
super.on(eventNames, callback, thisArg); | |||
const isLayoutEvent = typeof eventNames === "string" ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"string" ?
-- two spaces instead of one.
@@ -305,6 +327,19 @@ export class View extends ViewCommon { | |||
public initNativeView(): void { | |||
super.initNativeView(); | |||
this._isClickable = this.nativeViewProtected.isClickable(); | |||
|
|||
if (this.hasListeners(ViewCommon.layoutChangedEvent)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check for !this.layoutChangeListenerIsSet
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be possible to initNativeView
twice without disposeNativeView
…m OnLayoutChangeListener
dd9f0b5
to
dc1b36b
Compare
test |
1 similar comment
test |
I've talked with the runtime guys and the way we use the listener is ok
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
LayoutChanged
event should be invoked when the layout bounds of a view changes.Fix #5687