{"action":"created","issue":{"url":"https://api.github.com/repos/NativeScript/NativeScript/issues/6102","repository_url":"https://api.github.com/repos/NativeScript/NativeScript","labels_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/6102/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/6102/comments","events_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/6102/events","html_url":"https://github.com/NativeScript/NativeScript/pull/6102","id":343313738,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDAyNTYz","number":6102,"title":"refactor(text widgets and button): refactoring for easy plugin development","user":{"login":"farfromrefug","id":655344,"node_id":"MDQ6VXNlcjY1NTM0NA==","avatar_url":"https://avatars0.githubusercontent.com/u/655344?v=4","gravatar_id":"","url":"https://api.github.com/users/farfromrefug","html_url":"https://github.com/farfromrefug","followers_url":"https://api.github.com/users/farfromrefug/followers","following_url":"https://api.github.com/users/farfromrefug/following{/other_user}","gists_url":"https://api.github.com/users/farfromrefug/gists{/gist_id}","starred_url":"https://api.github.com/users/farfromrefug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farfromrefug/subscriptions","organizations_url":"https://api.github.com/users/farfromrefug/orgs","repos_url":"https://api.github.com/users/farfromrefug/repos","events_url":"https://api.github.com/users/farfromrefug/events{/privacy}","received_events_url":"https://api.github.com/users/farfromrefug/received_events","type":"User","site_admin":false},"labels":[{"id":203722174,"node_id":"MDU6TGFiZWwyMDM3MjIxNzQ=","url":"https://api.github.com/repos/NativeScript/NativeScript/labels/cla:%20yes","name":"cla: yes","color":"007241","default":false},{"id":203720953,"node_id":"MDU6TGFiZWwyMDM3MjA5NTM=","url":"https://api.github.com/repos/NativeScript/NativeScript/labels/in%20progress","name":"in progress","color":"ededed","default":false}],"state":"open","locked":false,"assignee":{"login":"MartoYankov","id":3806145,"node_id":"MDQ6VXNlcjM4MDYxNDU=","avatar_url":"https://avatars3.githubusercontent.com/u/3806145?v=4","gravatar_id":"","url":"https://api.github.com/users/MartoYankov","html_url":"https://github.com/MartoYankov","followers_url":"https://api.github.com/users/MartoYankov/followers","following_url":"https://api.github.com/users/MartoYankov/following{/other_user}","gists_url":"https://api.github.com/users/MartoYankov/gists{/gist_id}","starred_url":"https://api.github.com/users/MartoYankov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartoYankov/subscriptions","organizations_url":"https://api.github.com/users/MartoYankov/orgs","repos_url":"https://api.github.com/users/MartoYankov/repos","events_url":"https://api.github.com/users/MartoYankov/events{/privacy}","received_events_url":"https://api.github.com/users/MartoYankov/received_events","type":"User","site_admin":false},"assignees":[{"login":"MartoYankov","id":3806145,"node_id":"MDQ6VXNlcjM4MDYxNDU=","avatar_url":"https://avatars3.githubusercontent.com/u/3806145?v=4","gravatar_id":"","url":"https://api.github.com/users/MartoYankov","html_url":"https://github.com/MartoYankov","followers_url":"https://api.github.com/users/MartoYankov/followers","following_url":"https://api.github.com/users/MartoYankov/following{/other_user}","gists_url":"https://api.github.com/users/MartoYankov/gists{/gist_id}","starred_url":"https://api.github.com/users/MartoYankov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartoYankov/subscriptions","organizations_url":"https://api.github.com/users/MartoYankov/orgs","repos_url":"https://api.github.com/users/MartoYankov/repos","events_url":"https://api.github.com/users/MartoYankov/events{/privacy}","received_events_url":"https://api.github.com/users/MartoYankov/received_events","type":"User","site_admin":false}],"milestone":null,"comments":25,"created_at":"2018-07-21T09:37:43Z","updated_at":"2018-09-25T08:43:02Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/NativeScript/NativeScript/pulls/6102","html_url":"https://github.com/NativeScript/NativeScript/pull/6102","diff_url":"https://github.com/NativeScript/NativeScript/pull/6102.diff","patch_url":"https://github.com/NativeScript/NativeScript/pull/6102.patch"},"body":"This PR propose a simple refactoring to make life easier for plugin developers.\r\nI am writing a [plugin](https://github.com/Akylas/nativescript-material-components) which brings material components for iOS and Android.\r\n\r\nin [material-components](https://github.com/material-components), Google simply inherited native components to create material ones (UIButton, UITextField, ...)\r\nSo creating a nativescript component was pretty straight forward as I simply had to subclass the corresponding tns components and replace the ```createNativeView```\r\n\r\nExcept that It was not working for some reasons:\r\n- some native views were created in the tns constructor component. So if I was subclassing some native components were unnecessarily created  ([iOS label](https://github.com/Nativescript/NativeScript/blob/master/tns-core-modules/ui/label/label.ios.ts#L29) is an example)\r\n- delegate/listener were created in ```createNativeView```. So I subclassed ```createNativeView``` I was loosing the delegate/listener setup, I then had do it myself and also re-define those delegate/listener classes exactly the same way it was done in Nativescript (unnecessary)\r\n- in the case of the android textfield the material component was actually made of 2 components, the layout and text widget. Which means that, in nativescript, any layout operation is to be applied to the native layout widget. All text operations should be applied to the text widget. For now I had to use a dirty, not fully working working, overriding of the ```nativeViewProtected``` getter to either return the layout or the text widget. That PR actually defines a ```nativeTextViewProtected``` getter that is used for all text related operations. By default it returns ```nativeViewProtected``` That way a plugin can simply override it to use it's own widget. This has no performance consequences.\r\n\r\nAll those are really just refactoring which does not impact Nativescript performances. However they do make plugins more performant because the prevent redefining already defined Nativescript delegate/listener classes. But also because they prevent unused native widget creations for plugins subclassing some Nativescript widget classes like Label.\r\n\r\nThe only thing I am not sure about if is if ```createDelegate```  which I call in ```createNativeView``` could be called in ```initNativeView``` instead. I am waiting for some feedback from you on this.\r\n\r\n<!--\r\nWe, the rest of the NativeScript community, thank you for your\r\ncontribution! \r\nTo help the rest of the community review your change, please follow the instructions in the template.\r\n-->\r\n\r\n<!-- PULL REQUEST TEMPLATE -->\r\n<!-- (Update \"[ ]\" to \"[x]\" to check a box) -->\r\n\r\n## PR Checklist\r\n\r\n- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.\r\n- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.\r\n- [x] You have signed the [CLA](http://www.nativescript.org/cla).\r\n- [x] All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/DevelopmentWorkflow.md#running-unit-tests.\r\n- [ ] Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/WritingUnitTests.md.\r\n\r\n## What is the current behavior?\r\nnormal\r\n\r\n## What is the new behavior?\r\nunchanged"},"comment":{"url":"https://api.github.com/repos/NativeScript/NativeScript/issues/comments/424256666","html_url":"https://github.com/NativeScript/NativeScript/pull/6102#issuecomment-424256666","issue_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/6102","id":424256666,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDI1NjY2Ng==","user":{"login":"MartoYankov","id":3806145,"node_id":"MDQ6VXNlcjM4MDYxNDU=","avatar_url":"https://avatars3.githubusercontent.com/u/3806145?v=4","gravatar_id":"","url":"https://api.github.com/users/MartoYankov","html_url":"https://github.com/MartoYankov","followers_url":"https://api.github.com/users/MartoYankov/followers","following_url":"https://api.github.com/users/MartoYankov/following{/other_user}","gists_url":"https://api.github.com/users/MartoYankov/gists{/gist_id}","starred_url":"https://api.github.com/users/MartoYankov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartoYankov/subscriptions","organizations_url":"https://api.github.com/users/MartoYankov/orgs","repos_url":"https://api.github.com/users/MartoYankov/repos","events_url":"https://api.github.com/users/MartoYankov/events{/privacy}","received_events_url":"https://api.github.com/users/MartoYankov/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T08:43:02Z","updated_at":"2018-09-25T08:43:02Z","author_association":"CONTRIBUTOR","body":"test"}}
{"actor":{"display_login":"MartoYankov"}}