{"action":"closed","issue":{"url":"https://api.github.com/repos/NativeScript/NativeScript/issues/597","labels_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/597/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/597/comments","events_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/597/events","html_url":"https://github.com/NativeScript/NativeScript/issues/597","id":101293013,"number":597,"title":"Some Complex Properties are Inconsistent with rest of API - Discussion","user":{"login":"NathanaelA","id":850871,"avatar_url":"https://avatars.githubusercontent.com/u/850871?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanaelA","html_url":"https://github.com/NathanaelA","followers_url":"https://api.github.com/users/NathanaelA/followers","following_url":"https://api.github.com/users/NathanaelA/following{/other_user}","gists_url":"https://api.github.com/users/NathanaelA/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanaelA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanaelA/subscriptions","organizations_url":"https://api.github.com/users/NathanaelA/orgs","repos_url":"https://api.github.com/users/NathanaelA/repos","events_url":"https://api.github.com/users/NathanaelA/events{/privacy}","received_events_url":"https://api.github.com/users/NathanaelA/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NativeScript/NativeScript/labels/1%20-%20Backlog","name":"1 - Backlog","color":"bfdadc"},{"url":"https://api.github.com/repos/NativeScript/NativeScript/labels/S:Low","name":"S:Low","color":"bfd4f2"},{"url":"https://api.github.com/repos/NativeScript/NativeScript/labels/T:Feature","name":"T:Feature","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"nsndeck","id":5665150,"avatar_url":"https://avatars.githubusercontent.com/u/5665150?v=3","gravatar_id":"","url":"https://api.github.com/users/nsndeck","html_url":"https://github.com/nsndeck","followers_url":"https://api.github.com/users/nsndeck/followers","following_url":"https://api.github.com/users/nsndeck/following{/other_user}","gists_url":"https://api.github.com/users/nsndeck/gists{/gist_id}","starred_url":"https://api.github.com/users/nsndeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsndeck/subscriptions","organizations_url":"https://api.github.com/users/nsndeck/orgs","repos_url":"https://api.github.com/users/nsndeck/repos","events_url":"https://api.github.com/users/nsndeck/events{/privacy}","received_events_url":"https://api.github.com/users/nsndeck/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/NativeScript/NativeScript/milestones/8","html_url":"https://github.com/NativeScript/NativeScript/milestones/1.5","labels_url":"https://api.github.com/repos/NativeScript/NativeScript/milestones/8/labels","id":1310529,"number":8,"title":"1.5","description":"","creator":{"login":"valentinstoychev","id":4980822,"avatar_url":"https://avatars.githubusercontent.com/u/4980822?v=3","gravatar_id":"","url":"https://api.github.com/users/valentinstoychev","html_url":"https://github.com/valentinstoychev","followers_url":"https://api.github.com/users/valentinstoychev/followers","following_url":"https://api.github.com/users/valentinstoychev/following{/other_user}","gists_url":"https://api.github.com/users/valentinstoychev/gists{/gist_id}","starred_url":"https://api.github.com/users/valentinstoychev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valentinstoychev/subscriptions","organizations_url":"https://api.github.com/users/valentinstoychev/orgs","repos_url":"https://api.github.com/users/valentinstoychev/repos","events_url":"https://api.github.com/users/valentinstoychev/events{/privacy}","received_events_url":"https://api.github.com/users/valentinstoychev/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":19,"state":"open","created_at":"2015-09-17T14:20:41Z","updated_at":"2015-10-21T10:21:11Z","due_on":"2015-11-17T22:00:00Z","closed_at":null},"comments":3,"created_at":"2015-08-16T19:40:31Z","updated_at":"2015-10-21T10:21:11Z","closed_at":"2015-10-21T10:21:11Z","body":"I just noticed this and decided to bring this up as a discussion point.   I'm willing to start doing pull requests if you all agree with my logic.\r\n\r\nNormally in the Declarative XML you typically do:\r\n```\r\n<Page><StackLayout><Label/><Label/><Button/></StackLayout></Page>\r\n```\r\nand all the Labels and Buttons automatically become children of the StackLayout.  And the StackLayout becomes a child of the Page component.  Nice and clean and precise.\r\nEveryone is used to this; Behind the scenes children are automatically assigned to the parent via the _addChildFromBuilder function.\r\n\r\nWhile messing with the FormattedString I realized it (and several other components) are totally inconsistent with the above clean method of declaring the UI.  So lets take the following example:\r\n```xml\r\n<Label>\r\n  <Label.formattedText>\r\n    <FormattedString>\r\n       <FormattedString.spans>\r\n         <Span text=”We are” fontSize=”10”/>\r\n         <Span text=”Awesome” fontAttribute=”Bold”/>\r\n       </FormattedString.spans>\r\n    </FormattedString>\r\n  </Label.formattedText>\r\n</Label>\r\n```\r\n\r\nWhy do I need to create the \\<FormattedString.spans> element.   We know already that spans is the ONLY element that are children of the FormattedString.   So if we added a _addChildFromBuilder to both the Label and FormattedStrings\r\ncouldn't we then totally eliminate the \\<Label.formattedText> and \\<FormattedString.spans> and make it:\r\n```xml\r\n<Label>\r\n    <FormattedString>\r\n         <Span text=”We are” fontSize=”10”/>\r\n         <Span text=”Awesome” fontAttribute=”Bold”/>\r\n    </FormattedString>\r\n</Label>\r\n```\r\n\r\nWouldn't that be much more consistent with the clean Declarative UI. Since the only valid child component of a Label is a .formattedText and the only valid children of a FormattedString are Spans?   Technically, we could even detect if \\<Span> was being passed in as the \\<Label> child, and then dynamically create a FormattedString parent object.   So then:\r\n```xml\r\n<Label>\r\n         <Span text=”We are” fontSize=”10”/>\r\n         <Span text=”Awesome” fontAttribute=”Bold”/>\r\n</Label>\r\n```\r\nWould work.   :grinning:     Now, who doesn't think that is WAY simpler to code and read?\r\n\r\nPlease note; we would still leave the _addArrayFromBuilder on all these components so that you could do the Long hand version (and so all existing code would continue to work).  But looking at the code base I don't see any reason why we can't enhance most components that have only one child component type and/or one primary child component type.\r\n"}}