-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from vishalduggal/timob-13417
[TIMOB-13417] Test cases for timob-13417
- Loading branch information
Showing
6 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
59 changes: 59 additions & 0 deletions
59
Resources/ui/common/baseui/listview/list_v2_custom_backgrounds.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function list_v2_custom_backgrounds(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Custom Backgrounds', | ||
layout:'vertical', | ||
}); | ||
|
||
var button = Ti.UI.createButton({ | ||
left:20, | ||
right:20, | ||
title:'Toggle ListView' | ||
}) | ||
win.add(button); | ||
|
||
var data = [ | ||
{properties:{title:'bgColor red, selectionStyle BLUE', backgroundColor:'red', selectionStyle:Ti.UI.iPhone.ListViewCellSelectionStyle.BLUE}}, | ||
{properties:{title:'bgColor green, selectionStyle GRAY', backgroundColor:'green', selectionStyle:Ti.UI.iPhone.ListViewCellSelectionStyle.GRAY}}, | ||
{properties:{title:'bgColor cyan, selectionStyle NONE', backgroundColor:'cyan', selectionStyle:Ti.UI.iPhone.ListViewCellSelectionStyle.NONE}}, | ||
{properties:{title:'bgColor white, selectedBgColor green', backgroundColor:'white', selectedBackgroundColor:'green'}}, | ||
{properties:{title:'bgImage corkboard, selectionStyle BLUE', backgroundImage:'/images/corkboard.jpg', selectionStyle:Ti.UI.iPhone.ListViewCellSelectionStyle.BLUE}}, | ||
{properties:{title:'bgImage corkboard, selectedBgImage orangeBar', backgroundImage:'/images/corkboard.jpg', selectedBackgroundImage:'/images/slider_orangebar.png'}}, | ||
] | ||
|
||
var actualData = []; | ||
var i; | ||
for (i=0; i<100; i++) { | ||
actualData.push(data[i%6]); | ||
} | ||
|
||
var section1 = Ti.UI.createListSection(); | ||
section1.setItems(actualData); | ||
|
||
var listView1 = Ti.UI.createListView({top:10}); | ||
listView1.setSections([section1]); | ||
|
||
var section2 = Ti.UI.createListSection(); | ||
section2.setItems(actualData); | ||
|
||
var listView2 = Ti.UI.createListView({style:Ti.UI.iPhone.ListViewStyle.GROUPED, top:10}); | ||
listView2.setSections([section2]); | ||
|
||
win.add(listView1); | ||
|
||
var isGrouped = false; | ||
|
||
button.addEventListener('click',function(){ | ||
if(isGrouped == false) { | ||
win.remove(listView1); | ||
win.add(listView2); | ||
} else { | ||
win.remove(listView2); | ||
win.add(listView1); | ||
} | ||
isGrouped = !isGrouped; | ||
}) | ||
|
||
return win; | ||
}; | ||
|
||
module.exports = list_v2_custom_backgrounds; |
73 changes: 73 additions & 0 deletions
73
Resources/ui/common/baseui/listview/list_v2_custom_header_footer.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
function list_v2_custom_header_footer(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Custom Headers & Footers', | ||
}); | ||
|
||
var listHeader = Ti.UI.createView({ | ||
layout:'horizontal', | ||
height:Ti.UI.SIZE | ||
}) | ||
var imageView = Ti.UI.createImageView({ | ||
left:5, | ||
width:50, | ||
height:50, | ||
image:'/images/flower.jpg' | ||
}) | ||
var label = Ti.UI.createLabel({ | ||
left:5, | ||
width:Ti.UI.FILL, | ||
text:'Custom header with an image and a label' | ||
}) | ||
|
||
listHeader.add(imageView); | ||
listHeader.add(label); | ||
|
||
var listFooter = Ti.UI.createLabel({ | ||
text:'I am a custom list footer (just a label) but with color', | ||
color:'red' | ||
}) | ||
|
||
var section = Ti.UI.createListSection(); | ||
var data = []; | ||
var i=1; | ||
for (i=1; i<10; i++) { | ||
data.push({properties:{title:'ROW '+i}}) | ||
} | ||
section.setItems(data); | ||
|
||
var sectionHeaderView = Ti.UI.createLabel({ | ||
backgroundColor:'magenta', | ||
text:'I am a section header', | ||
font:{ fontWeight: 'bold', size:'30' }, | ||
color: 'white', | ||
width:Ti.UI.FILL, | ||
height:'50 dp', | ||
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER | ||
}) | ||
|
||
var sectionFooterView = Ti.UI.createLabel({ | ||
backgroundColor:'green', | ||
text:'I am a section footer', | ||
font:{ fontStyle: 'italic', size:'15' }, | ||
color: 'white', | ||
width:Ti.UI.FILL, | ||
height:'30 dp', | ||
textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT | ||
}) | ||
|
||
section.headerView = sectionHeaderView; | ||
section.footerView = sectionFooterView; | ||
|
||
var listView = Ti.UI.createListView({ | ||
headerView:listHeader, | ||
footerView:listFooter | ||
}); | ||
|
||
listView.setSections([section]); | ||
|
||
win.add(listView); | ||
|
||
return win; | ||
}; | ||
|
||
module.exports = list_v2_custom_header_footer; |
94 changes: 94 additions & 0 deletions
94
Resources/ui/common/baseui/listview/list_v2_custom_separator.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
function list_v2_custom_separator(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Custom Separator', | ||
layout:'vertical' | ||
}); | ||
|
||
var platformName = Titanium.Platform.osname; | ||
var isIOS = (platformName == 'iphone' || platformName == 'ipad'); | ||
|
||
var container = Ti.UI.createView({ | ||
layout:'vertical', | ||
height:Ti.UI.SIZE | ||
}) | ||
|
||
var actionContainer = Ti.UI.createView({ | ||
layout:'horizontal', | ||
height:Ti.UI.SIZE | ||
}) | ||
|
||
var b1 = Ti.UI.createButton({ | ||
width:'45%', | ||
left:'2%', | ||
title:'Change Style' | ||
}) | ||
|
||
var b2 = Ti.UI.createButton({ | ||
width:'45%', | ||
left:'4%', | ||
title:'Change Color' | ||
}) | ||
|
||
actionContainer.add(b1); | ||
actionContainer.add(b2); | ||
|
||
var statusLabel = Ti.UI.createLabel({ | ||
width:Ti.UI.FILL, | ||
height:Ti.UI.SIZE | ||
}) | ||
|
||
container.add(actionContainer); | ||
container.add(statusLabel); | ||
|
||
win.add(container); | ||
|
||
var styleData = [Ti.UI.iPhone.ListViewSeparatorStyle.SINGLE_LINE, Ti.UI.iPhone.ListViewSeparatorStyle.NONE]; | ||
var colorData = ['gray','red','green','blue','yellow','transparent']; | ||
var styleCounter = 0; | ||
var colorCounter = 0; | ||
|
||
function updateLabel() | ||
{ | ||
var text = 'Separator Color is '+colorData[colorCounter]+' Separator Style is '; | ||
if (styleCounter == 0) { | ||
text += 'Single Line'; | ||
} else { | ||
text += 'None' | ||
} | ||
statusLabel.text = text; | ||
} | ||
|
||
var data = []; | ||
var i=1; | ||
for (i=1; i<100; i++) { | ||
data.push({properties:{title:'ROW '+i}}) | ||
} | ||
var listSection1 = Ti.UI.createListSection(); | ||
listSection1.setItems(data); | ||
|
||
var listView = Ti.UI.createListView({ | ||
separatorColor:colorData[colorCounter], | ||
separatorStyle:styleData[styleCounter] | ||
}); | ||
listView.setSections([listSection1]); | ||
updateLabel(); | ||
|
||
win.add(listView); | ||
|
||
b1.addEventListener('click',function(){ | ||
styleCounter = (styleCounter + 1) % styleData.length; | ||
listView.separatorStyle = styleData[styleCounter]; | ||
updateLabel(); | ||
}) | ||
|
||
b2.addEventListener('click',function(){ | ||
colorCounter = (colorCounter + 1) % colorData.length; | ||
listView.separatorColor = colorData[colorCounter]; | ||
updateLabel(); | ||
}) | ||
|
||
return win; | ||
|
||
}; | ||
|
||
module.exports = list_v2_custom_separator; |
85 changes: 85 additions & 0 deletions
85
Resources/ui/common/baseui/listview/list_v2_select_deselect.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
function genData(section) | ||
{ | ||
var data = []; | ||
for(i=0;i<10;i++){ | ||
data.push({properties:{title:'Section '+section+' Item '+i}}) | ||
} | ||
|
||
return data; | ||
} | ||
|
||
function genSections() | ||
{ | ||
var sections = []; | ||
for(j=0;j<10;j++){ | ||
var section = Ti.UI.createListSection({headerTitle:'Section '+j}); | ||
section.setItems(genData(j)); | ||
sections.push(section); | ||
} | ||
|
||
return sections; | ||
} | ||
|
||
|
||
function list_v2_select_deselect(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Select Deselect', | ||
layout:'vertical' | ||
}); | ||
|
||
var actionContainer = Ti.UI.createView({ | ||
layout:'horizontal', | ||
height:Ti.UI.SIZE | ||
}) | ||
|
||
var b1 = Ti.UI.createButton({ | ||
width:'45%', | ||
left:'2%', | ||
title:'Select Random' | ||
}) | ||
|
||
var b2 = Ti.UI.createButton({ | ||
width:'45%', | ||
left:'4%', | ||
title:'Deselect', | ||
enabled:false | ||
}) | ||
|
||
actionContainer.add(b1); | ||
actionContainer.add(b2); | ||
|
||
win.add(actionContainer); | ||
|
||
var listView = Ti.UI.createListView({ | ||
sections: genSections(), | ||
top:10 | ||
}) | ||
|
||
win.add(listView); | ||
|
||
var sectionIndex; | ||
var itemIndex; | ||
|
||
listView.addEventListener('itemclick',function(e){ | ||
sectionIndex = e.sectionIndex; | ||
itemIndex = e.itemIndex; | ||
b2.enabled = true; | ||
}); | ||
|
||
b1.addEventListener('click',function(){ | ||
sectionIndex = Math.floor(Math.random()*173)%10; | ||
itemIndex = Math.floor(Math.random()*83)%10; | ||
listView.selectItem(sectionIndex,itemIndex); | ||
b2.enabled = true; | ||
}) | ||
|
||
b2.addEventListener('click',function(){ | ||
listView.deselectItem(sectionIndex,itemIndex); | ||
b2.enabled = false; | ||
}) | ||
|
||
|
||
return win; | ||
} | ||
|
||
module.exports = list_v2_select_deselect; |
Oops, something went wrong.