Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16507] iOS: Change pullView default background color in listView, tableView

GitHub Issuen/a
TypeImprovement
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2014-02-28T22:41:39.000+0000
Affected Version/sn/a
Fix Version/s2014 Sprint 05, 2014 Sprint 05 API, Release 3.3.0
ComponentsiOS
Labelslistview, module_listview, qe-closed-3.3.0, qe-testadded
Reporterlevani
AssigneeVishal Duggal
Created2014-02-21T19:31:36.000+0000
Updated2014-04-25T09:06:12.000+0000

Description

I'm using PullView to implement "Release to refresh" functionality, but the problem is that I can't change the background color above the PullView itself. When I scroll down more than the height of PullView some default grey background appears that I would like to change. See attached image for example. I'm also attaching a very simple app with listview only. The background color of pullview if pink, everything that appears above that pullview when you scroll down is always grey! P.S. If this area isn't a background and it has it's own name please change the title accordingly.

Attachments

FileDateSize
bg_color.png2014-02-21T19:31:36.000+0000326973
example.zip2014-02-21T19:31:36.000+00001823721
pink.png2014-02-21T19:31:36.000+0000356189

Comments

  1. Vishal Duggal 2014-02-26

    Sample code showing use of pullBackgroundColor on Ti.UI.View and noresults event in ListView
       var win = Ti.UI.createWindow({backgroundColor: 'white',fullscreen:true,layout:'vertical'});
       var listView = Ti.UI.createListView({keepSectionsInSearch:true});
       var sections = [];
       
       var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
       var fruitDataSet = [
           {properties: { title: 'Fig', searchableText: 'Fruits Apple'}},
           {properties: { title: 'Kiwi', searchableText: 'Fruits Banana'}},
       ];
       fruitSection.setItems(fruitDataSet);
       sections.push(fruitSection);
       
       var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'});
       var vegDataSet = [
           {properties: { title: 'Carrots', searchableText: 'Vegetables Carrots'}},
           {properties: { title: 'Potatoes', searchableText: 'Vegetables Potatoes'}},
       ];
       vegSection.setItems(vegDataSet);
       
       var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish'});
       var fishDataSet = [
           {properties: { title: 'Cod', searchableText: 'Fish Cod'}},
           {properties: { title: 'Haddock', searchableText: 'Fish Haddock'}},
       ];
       fishSection.setItems(fishDataSet);
       listView.sections = sections;
       var refreshCount = 0;
       
       function getFormattedDate(){
           var date = new Date();
           return date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear() + ' ' + date.getHours() + ':' + date.getMinutes();
       }
       
       function resetPullHeader(){
           actInd.hide();
           imageArrow.transform=Ti.UI.create2DMatrix();
           if (refreshCount < 2) {
               imageArrow.show();
               labelStatus.text = 'Pull down to refresh...';
               labelLastUpdated.text = 'Last Updated: ' + getFormattedDate();
           } else {
               labelStatus.text = 'Nothing To Refresh';
               labelLastUpdated.text = 'Last Updated: ' + getFormattedDate();
               listView.removeEventListener('pull', pullListener);
               listView.removeEventListener('pullend', pullendListener);
               eventStatus.text = 'Removed event listeners.';
           }
           listView.setContentInsets({top:0}, {animated:true});
       }
       
       function loadTableData()
       {
           if (refreshCount == 0) {
               listView.appendSection(vegSection);
           } else if (refreshCount == 1) {
               listView.appendSection(fishSection);
           } 
           refreshCount ++;
           resetPullHeader();
       }
       
       function pullListener(e){
           eventStatus.text = 'EVENT pull FIRED. e.active = '+e.active;
           if (e.active == false) {
               var unrotate = Ti.UI.create2DMatrix();
               imageArrow.animate({transform:unrotate, duration:180});
               labelStatus.text = 'Pull down to refresh...';
           } else {
               var rotate = Ti.UI.create2DMatrix().rotate(180);
               imageArrow.animate({transform:rotate, duration:180});
               if (refreshCount == 0) {
                   labelStatus.text = 'Release to get Vegetables...';
               } else {
                   labelStatus.text = 'Release to get Fish...';
               }
           }
       }
       
       function pullendListener(e){
           eventStatus.text = 'EVENT pullend FIRED.';
        
           if (refreshCount == 0) {
               labelStatus.text = 'Loading Vegetables...';        
           } else {
               labelStatus.text = 'Loading Fish...';
           }
           imageArrow.hide();
           actInd.show();
           listView.setContentInsets({top:80}, {animated:true});
           setTimeout(function(){
               loadTableData();
           }, 2000);
       }
       
       var tableHeader = Ti.UI.createView({
           backgroundColor:'#e2e7ed',
           pullBackgroundColor: 'cyan',
           width:320, height:80
       });
       
       var border = Ti.UI.createView({
           backgroundColor:'#576c89',
           bottom:0,
           height:2
       });
       tableHeader.add(border);
       
       var imageArrow = Ti.UI.createImageView({
           image:'https://github.com/appcelerator/titanium_mobile/raw/master/demos/KitchenSink/Resources/images/whiteArrow.png',
           left:20, bottom:10,
           width:23, height:60
       });
       tableHeader.add(imageArrow);
       
       var labelStatus = Ti.UI.createLabel({
           color:'#576c89',
           font:{fontSize:13, fontWeight:'bold'},
           text:'Pull down to refresh...',
           textAlign:'center',
           left:55, bottom:30,
           width:200
       });
       tableHeader.add(labelStatus);
       
       var labelLastUpdated = Ti.UI.createLabel({
           color:'#576c89',
           font:{fontSize:12},
           text:'Last Updated: ' + getFormattedDate(),
           textAlign:'center',
           left:55, bottom:15,
           width:200
       });
       tableHeader.add(labelLastUpdated);
       
       var actInd = Ti.UI.createActivityIndicator({
           left:20, bottom:13,
           width:30, height:30
       });
       tableHeader.add(actInd);
       listView.pullView = tableHeader;
       listView.addEventListener('pull', pullListener);
       listView.addEventListener('pullend',pullendListener);
       
       var eventStatus = Ti.UI.createLabel({
           font:{fontSize:13, fontWeight:'bold'},
           text: 'Event data will show here',
       })
       
       var searchbar = Ti.UI.createSearchBar({
           showCancel: true,
           hintText: 'Search'
       });
       
       searchbar.addEventListener('cancel',function(e){
           searchbar.value = '';
           searchbar.blur();
           listView.searchText = '';
       });
       
       searchbar.addEventListener('return',function(e){
           listView.searchText = searchbar.value;
           searchbar.blur();
       });
       
       listView.addEventListener('noresults',function(){
           alert('No results for searchText '+searchbar.value);
       })
       
       win.add(eventStatus);
       win.add(searchbar);
       win.add(listView);
       win.open();
       
  2. Vishal Duggal 2014-02-26

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/5391
  3. Paul Hamilton 2014-03-20

    Thanks for the update, As i am using the latest CI build, i was able to incorporate this functionality into my app. However the documentation is a little weird. The "pullBackgroundColor" is listed as a property of the listView itself. Trying to set it there doesn't work, as it must set on the view contained by the pullView property. Having it as part of of listView and View make sense in this circumstance. But perhaps the functionality should also be part of the listView rather then view. Both?
  4. Vishal Duggal 2014-03-24

    @[~paul h] pullBackgroundColor is a property of Ti.UI.View and so gets inherited by all UI components extending Ti.UI.View (ListView, TableView, Window, TabGroup etc). In theory you can assign a TableView or ListView as the pullView for another TableView/ListView (though I suspect it would not work as expected).
  5. Neha Mittal 2014-04-24

    Verified fix with below environment: Appc Studio: 3.3.0.201404211130 SDK build: 3.3.0.v20140423155715 acs: 1.0.14 npm: 1.3.2 alloy: 1.4.0-dev CLI: titanium-3.3.0-dev titanium-code-processor:1.1.1-beta1 Xcode: 5.1.1 Osx: Mavericks(10.9.2) Device: iPhone 5C(7.1) Able to change the color of area above the pullview through pullBackgroundColor property as expected. Hence Closing the issue.

JSON Source