FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(view): introduce LayoutChanged event on every View component by ADjenkov · Pull Request #5825 · NativeScript/NativeScript · GitHub

feat(view): introduce LayoutChanged event on every View component - #5825

Merged
ADjenkov merged 5 commits into
masterfrom
djenkov/layout-changed-event
May 21, 2018
Merged

ADjenkov merged 5 commits into
masterfrom
djenkov/layout-changed-event

Conversation

Copy link
Copy Markdown
Contributor

LayoutChanged event should be invoked when the layout bounds of a view changes.

Fix #5687

super.initNativeView();
this._isClickable = this.nativeViewProtected.isClickable();

this.setOnLayoutChangeListener();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

ADjenkov force-pushed the djenkov/layout-changed-event branch from ebdabf2 to 2e45de7 Compare May 17, 2018 13:57
newPage.content = stackLayout;

TKUnit.waitUntilReady(() => stackLayoutChanged && buttonLayoutChanged);
TKUnit.assert(stackLayoutChanged);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not sure we need those explicit asserts -- waitUnitlReady(...) on previous line will time out if those booleans are not true.

ADjenkov May 18, 2018
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure too.
We do it in other tests

Copy link
Copy Markdown
Contributor

#5687 says that the main use case is to be able to use getActualSize() and be sure values are correct -- shouldn't we add a test for this?


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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

"string" ? -- two spaces instead of one.

super.initNativeView();
this._isClickable = this.nativeViewProtected.isClickable();

if (this.hasListeners(ViewCommon.layoutChangedEvent)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think we need to check for !this.layoutChangeListenerIsSet here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It should not be possible to initNativeView twice without disposeNativeView

ADjenkov force-pushed the djenkov/layout-changed-event branch from dd9f0b5 to dc1b36b Compare May 21, 2018 07:46

Copy link
Copy Markdown
Contributor Author

test

1 similar comment

Copy link
Copy Markdown
Contributor Author

test

ADjenkov dismissed vakrilov’s stale review May 21, 2018 14:21

I've talked with the runtime guys and the way we use the listener is ok

ADjenkov merged commit 0fc1547 into master May 21, 2018
ADjenkov deleted the djenkov/layout-changed-event branch May 21, 2018 14:26

lock Bot commented Aug 26, 2019

Copy link
Copy Markdown

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.

lock Bot locked and limited conversation to collaborators Aug 26, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Expose onLayout event on View

3 participants


Back | FazBrowse Home | New Git URL