Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19394] Parity: Ti.UI.View.add should support array of views on Windows as iOS

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2015-11-12T04:40:31.000+0000
Affected Version/sRelease 4.1.0
Fix Version/sRelease 5.1.0
ComponentsWindows
Labelsn/a
ReporterFokke Zandbergen
AssigneeGary Mathews
Created2015-08-23T08:47:56.000+0000
Updated2015-11-17T01:15:03.000+0000

Description

On iOS Ti.UI.View.add() accepts an array of views: https://github.com/appcelerator/titanium_mobile/blob/0357b4796abf0032485018fac42614a94f826c9b/iphone/Classes/TiViewProxy.m#L148 On Android it does not: https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java#L159 This is a very useful feature and looking at the iOS code simple to implement for Android and Windows as well. Related question on Q&A: https://community.appcelerator.com/topic/3075/unable-to-add-array-of-views-to-parent-view-on-android

Comments

  1. Christopher Williams 2015-09-09

    It's not too hard to do this for Windows, but I should note that the iOS version also supports using an object to specify the view and the position to insert it. Both the array and the single/array of objects with a "view" and "position" key are undocumented. Do we fix the docs? Do we make all the platforms behave exactly like iOS? Do we only support the possible array of views, but not the objects specifying both a view and position for each view? cc [~cng][~hpham][~bhatfield][~rblalock][~ingo]
  2. Christopher Williams 2015-09-09

    Here's the PR for adding support for a single or array of views to Windows SDK: https://github.com/appcelerator/titanium_mobile_windows/pull/426 Doesn't add support for a single/array of objects with "view" and "position" keys.
  3. Chee Kiat Ng 2015-09-10

    [~penrique], fyi about this. Hopefully your native auto layout for iOS will continue to support this. Considering that we are having an overhaul on UI for iOS, we will keep iOS as it is for now and keep the "view" and "position" key undocumented. [~msamah], [~hpham], are we able to support this on Android?
  4. Ewan Harris 2015-11-11

    Reopening ticket: OS: Microsoft Windows 10 Pro 10.0.10240 Appc core: 5.1.0-43 Appc NPM: 4.2.1 Ti SDK: 5.1.0.v20151104190037 Using the code below the app crashes on launch on Windows, the code runs as expected on iOS
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       var win1 = Titanium.UI.createWindow({
       	title:'Tab 1',
       	backgroundColor:'#fff'
       });
       var data = [
           {
               'top':100,
               'text':'label 1'
           },
           {
               'top':200,
               'text':'label 2'
           }
       ];
        
       var lblArr = [];
       for(var i =0; i < data.length; i++){
           lblArr.push(createLabel(data[i]));
       }
       win1.add(lblArr);
        
       win1.open();
        
       function createLabel(lblData){
           var label = Ti.UI.createLabel({
               text:lblData.text,
               color:'#999',
               top:lblData.top
           });
           return label;
       }
       
  5. Gary Mathews 2015-11-11

    PR: https://github.com/appcelerator/titanium_mobile_windows/pull/473 5_1_X: https://github.com/appcelerator/titanium_mobile_windows/pull/474
  6. Ewan Harris 2015-11-17

    Verified using: OS: Microsoft Windows 10 Pro Appc core: 5.1.0-58 Appc NPM: 4.2.1 Ti SDK : 5.1.0.v20151116142031, 5.2.0.v20151116164440 Appc Studio: 4.4.0.201511130407 Using the code below the labels are now added to the window as expected
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       var win1 = Titanium.UI.createWindow({
       	title:'Tab 1',
       	backgroundColor:'#fff'
       });
       var data = [
           {
               'top':100,
               'text':'label 1'
           },
           {
               'top':200,
               'text':'label 2'
           }
       ];
        
       var lblArr = [];
       for(var i =0; i < data.length; i++){
           lblArr.push(createLabel(data[i]));
       }
       win1.add(lblArr);
        
       win1.open();
        
       function createLabel(lblData){
           var label = Ti.UI.createLabel({
               text:lblData.text,
               color:'#999',
               top:lblData.top
           });
           return label;
       }
       
    Closing ticket

JSON Source