-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-13419][TIMOB-13418][TIMOB-13421] Test Cases #106
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function list_v2_index_bar(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Index Bar', | ||
}); | ||
|
||
var sections = []; | ||
|
||
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'}); | ||
var fruitDataSet = [ | ||
{properties: { title: 'Apple', searchableText:' Fruits Apple', itemId:'0 0'}}, | ||
{properties: { title: 'Banana', searchableText:'Fruits Banana', itemId:'0 1'}}, | ||
{properties: { title: 'Cantaloupe', searchableText:'Fruits Cantaloupe', itemId:'0 2'}}, | ||
{properties: { title: 'Fig', searchableText:'Fruits Fig', itemId:'0 3'}}, | ||
{properties: { title: 'Guava', searchableText:'Fruits Guava', itemId:'0 4'}}, | ||
{properties: { title: 'Kiwi', searchableText:'Fruits Kiwi', itemId:'0 5'}}, | ||
]; | ||
fruitSection.setItems(fruitDataSet); | ||
sections.push(fruitSection); | ||
|
||
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'}); | ||
var vegDataSet = [ | ||
{properties: { title: 'Carrots', searchableText:'Vegetables Carrots', itemId:'1 0'}}, | ||
{properties: { title: 'Potatoes', searchableText:'Vegetables Potatoes', itemId:'1 1'}}, | ||
{properties: { title: 'Corn', searchableText:'Vegetables Corn', itemId:'1 2'}}, | ||
{properties: { title: 'Beans', searchableText:'Vegetables Beans', itemId:'1 3'}}, | ||
{properties: { title: 'Tomato', searchableText:'Vegetables Tomato', itemId:'1 4'}}, | ||
]; | ||
vegSection.setItems(vegDataSet); | ||
sections.push(vegSection); | ||
|
||
|
||
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish'}); | ||
var fishDataSet = [ | ||
{properties: { title: 'Cod', searchableText:'Fish Cod', itemId:'2 0'}}, | ||
{properties: { title: 'Haddock', searchableText:'Fish Haddock', itemId:'2 1'}}, | ||
{properties: { title: 'Salmon', searchableText:'Fish Salmon', itemId:'2 2'}}, | ||
{properties: { title: 'Tuna', searchableText:'Fish Tuna', itemId:'2 3'}}, | ||
]; | ||
fishSection.setItems(fishDataSet); | ||
sections.push(fishSection); | ||
|
||
var animalsSection = Ti.UI.createListSection({ headerTitle: 'Animals'}); | ||
var animalsDataSet = [ | ||
{properties: { title: 'Deer', searchableText:'Animals Deer', itemId:'3 0'}}, | ||
{properties: { title: 'Dog', searchableText:'Animals Dog', itemId:'3 1'}}, | ||
{properties: { title: 'Cat', searchableText:'Animals Cat', itemId:'3 2'}}, | ||
{properties: { title: 'Elephant', searchableText:'Animals Elephant', itemId:'3 3'}}, | ||
]; | ||
animalsSection.setItems(animalsDataSet); | ||
sections.push(animalsSection); | ||
|
||
var listView = Ti.UI.createListView(); | ||
listView.sections = sections; | ||
|
||
var indices = [ | ||
{index:0,title:'Fru'}, | ||
{index:1,title:'Veg'}, | ||
{index:2,title:'Fis'}, | ||
{index:3,title:'Ani'} | ||
]; | ||
|
||
listView.sectionIndexTitles = indices; | ||
|
||
win.add(listView); | ||
|
||
return win; | ||
}; | ||
|
||
module.exports = list_v2_index_bar; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
function isValidVar(check){ | ||
if (check !== undefined && check !== null){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function clickHandler(e){ | ||
var message = 'Type:'+e.type+'\nSection title:'+e.section.headerTitle+'\nsectionIndex:'+e.sectionIndex+'\nitemIndex:'+e.itemIndex; | ||
if(isValidVar(e.bindId)){ | ||
message += '\nbindId:'+e.bindId; | ||
} | ||
if(isValidVar(e.itemId)){ | ||
message += '\nitemId:'+e.itemId; | ||
} | ||
alert(message); | ||
} | ||
|
||
function genTest(win) { | ||
var sections = []; | ||
|
||
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'}); | ||
var fruitDataSet = [ | ||
{properties: { title: 'Apple', searchableText:' Fruits Apple', itemId:'0 0'}}, | ||
{properties: { title: 'Banana', searchableText:'Fruits Banana', itemId:'0 1'}}, | ||
{properties: { title: 'Cantaloupe', searchableText:'Fruits Cantaloupe', itemId:'0 2'}}, | ||
{properties: { title: 'Fig', searchableText:'Fruits Fig', itemId:'0 3'}}, | ||
{properties: { title: 'Guava', searchableText:'Fruits Guava', itemId:'0 4'}}, | ||
{properties: { title: 'Kiwi', searchableText:'Fruits Kiwi', itemId:'0 5'}}, | ||
]; | ||
fruitSection.setItems(fruitDataSet); | ||
sections.push(fruitSection); | ||
|
||
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'}); | ||
var vegDataSet = [ | ||
{properties: { title: 'Carrots', searchableText:'Vegetables Carrots', itemId:'1 0'}}, | ||
{properties: { title: 'Potatoes', searchableText:'Vegetables Potatoes', itemId:'1 1'}}, | ||
{properties: { title: 'Corn', searchableText:'Vegetables Corn', itemId:'1 2'}}, | ||
{properties: { title: 'Beans', searchableText:'Vegetables Beans', itemId:'1 3'}}, | ||
{properties: { title: 'Tomato', searchableText:'Vegetables Tomato', itemId:'1 4'}}, | ||
]; | ||
vegSection.setItems(vegDataSet); | ||
sections.push(vegSection); | ||
|
||
|
||
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish'}); | ||
var fishDataSet = [ | ||
{properties: { title: 'Cod', searchableText:'Fish Cod', itemId:'2 0'}}, | ||
{properties: { title: 'Haddock', searchableText:'Fish Haddock', itemId:'2 1'}}, | ||
{properties: { title: 'Salmon', searchableText:'Fish Salmon', itemId:'2 2'}}, | ||
{properties: { title: 'Tuna', searchableText:'Fish Tuna', itemId:'2 3'}}, | ||
]; | ||
fishSection.setItems(fishDataSet); | ||
sections.push(fishSection); | ||
|
||
var animalsSection = Ti.UI.createListSection({ headerTitle: 'Animals'}); | ||
var animalsDataSet = [ | ||
{properties: { title: 'Deer', searchableText:'Animals Deer', itemId:'3 0'}}, | ||
{properties: { title: 'Dog', searchableText:'Animals Dog', itemId:'3 1'}}, | ||
{properties: { title: 'Cat', searchableText:'Animals Cat', itemId:'3 2'}}, | ||
{properties: { title: 'Elephant', searchableText:'Animals Elephant', itemId:'3 3'}}, | ||
]; | ||
animalsSection.setItems(animalsDataSet); | ||
sections.push(animalsSection); | ||
|
||
var listView = Ti.UI.createListView(); | ||
listView.sections = sections; | ||
|
||
var tf = Ti.UI.createTextField({ | ||
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED, | ||
color: '#336699', | ||
height: 40, | ||
top:10, | ||
bottom:10, | ||
left:10, | ||
right:10, | ||
font:{fontSize:20,fontWeight:'bold'}, | ||
hintText: 'Search' | ||
}) | ||
|
||
tf.addEventListener('change',function(e){ | ||
listView.searchText = e.value; | ||
}) | ||
|
||
//The textfield must be a subview of the tableView to | ||
//calculate correct contentInsets when keyboard is visible. | ||
listView.headerView = tf; | ||
|
||
win.add(listView); | ||
|
||
listView.addEventListener('itemclick', clickHandler); | ||
|
||
} | ||
|
||
function list_v2_search_searchtext(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'New Search API', | ||
}); | ||
|
||
var scrollView = Ti.UI.createScrollView({layout:'vertical'}); | ||
|
||
var desc = Ti.UI.createLabel({ | ||
text:'This test shows the new search api in ListView. This is supported by the searchText property of ListView.\n\n'+ | ||
'The searchable content is defined by the searchableText property of the ListItem.\n\n'+ | ||
'This property can not be used when the searchView property is set.\n\n'+ | ||
'This example searches using a TextField which is set as a headerView on the ListView\n\n'+ | ||
'The searchableText in the following example is set to headerTitle+ +title.\n\n' | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
|
||
scrollView.add(desc); | ||
|
||
var button = Ti.UI.createButton({ | ||
top:10, | ||
title:'I understand' | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
scrollView.add(button); | ||
|
||
button.addEventListener('click',function(){ | ||
win.remove(scrollView); | ||
genTest(win); | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
win.add(scrollView); | ||
|
||
return win; | ||
|
||
}; | ||
module.exports = list_v2_search_searchtext; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
function isValidVar(check){ | ||
if (check !== undefined && check !== null){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function clickHandler(e){ | ||
var message = 'Type:'+e.type+'\nSection title:'+e.section.headerTitle+'\nsectionIndex:'+e.sectionIndex+'\nitemIndex:'+e.itemIndex; | ||
if(isValidVar(e.bindId)){ | ||
message += '\nbindId:'+e.bindId; | ||
} | ||
if(isValidVar(e.itemId)){ | ||
message += '\nitemId:'+e.itemId; | ||
} | ||
alert(message); | ||
} | ||
|
||
function genTest(win) { | ||
var sections = []; | ||
|
||
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'}); | ||
var fruitDataSet = [ | ||
{properties: { title: 'Apple', searchableText:' Fruits Apple', itemId:'0 0'}}, | ||
{properties: { title: 'Banana', searchableText:'Fruits Banana', itemId:'0 1'}}, | ||
{properties: { title: 'Cantaloupe', searchableText:'Fruits Cantaloupe', itemId:'0 2'}}, | ||
{properties: { title: 'Fig', searchableText:'Fruits Fig', itemId:'0 3'}}, | ||
{properties: { title: 'Guava', searchableText:'Fruits Guava', itemId:'0 4'}}, | ||
{properties: { title: 'Kiwi', searchableText:'Fruits Kiwi', itemId:'0 5'}}, | ||
]; | ||
fruitSection.setItems(fruitDataSet); | ||
sections.push(fruitSection); | ||
|
||
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'}); | ||
var vegDataSet = [ | ||
{properties: { title: 'Carrots', searchableText:'Vegetables Carrots', itemId:'1 0'}}, | ||
{properties: { title: 'Potatoes', searchableText:'Vegetables Potatoes', itemId:'1 1'}}, | ||
{properties: { title: 'Corn', searchableText:'Vegetables Corn', itemId:'1 2'}}, | ||
{properties: { title: 'Beans', searchableText:'Vegetables Beans', itemId:'1 3'}}, | ||
{properties: { title: 'Tomato', searchableText:'Vegetables Tomato', itemId:'1 4'}}, | ||
]; | ||
vegSection.setItems(vegDataSet); | ||
sections.push(vegSection); | ||
|
||
|
||
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish'}); | ||
var fishDataSet = [ | ||
{properties: { title: 'Cod', searchableText:'Fish Cod', itemId:'2 0'}}, | ||
{properties: { title: 'Haddock', searchableText:'Fish Haddock', itemId:'2 1'}}, | ||
{properties: { title: 'Salmon', searchableText:'Fish Salmon', itemId:'2 2'}}, | ||
{properties: { title: 'Tuna', searchableText:'Fish Tuna', itemId:'2 3'}}, | ||
]; | ||
fishSection.setItems(fishDataSet); | ||
sections.push(fishSection); | ||
|
||
var animalsSection = Ti.UI.createListSection({ headerTitle: 'Animals'}); | ||
var animalsDataSet = [ | ||
{properties: { title: 'Deer', searchableText:'Animals Deer', itemId:'3 0'}}, | ||
{properties: { title: 'Dog', searchableText:'Animals Dog', itemId:'3 1'}}, | ||
{properties: { title: 'Cat', searchableText:'Animals Cat', itemId:'3 2'}}, | ||
{properties: { title: 'Elephant', searchableText:'Animals Elephant', itemId:'3 3'}}, | ||
]; | ||
animalsSection.setItems(animalsDataSet); | ||
sections.push(animalsSection); | ||
|
||
var listView = Ti.UI.createListView(); | ||
listView.style=Ti.UI.iPhone.ListViewStyle.GROUPED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
listView.sections = sections; | ||
listView.keepSectionsInSearch = true; | ||
|
||
var container = Ti.UI.createView({ | ||
height:40, | ||
top:0, | ||
right:30 | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
var tf = Ti.UI.createTextField({ | ||
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED, | ||
color: '#336699', | ||
height:Ti.UI.FILL, | ||
width:Ti.UI.FILL, | ||
left:5, | ||
font:{fontSize:20,fontWeight:'bold'}, | ||
hintText: 'Search' | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
tf.addEventListener('change',function(e){ | ||
listView.searchText = e.value; | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
container.add(tf); | ||
|
||
//The textfield must be a subview of the tableView to | ||
//calculate correct contentInsets when keyboard is visible. | ||
listView.add(container); | ||
|
||
listView.headerView = Ti.UI.createView({height:40}); | ||
|
||
var indices = [ | ||
{index:0,title:'Fru'}, | ||
{index:1,title:'Veg'}, | ||
{index:2,title:'Fis'}, | ||
{index:3,title:'Ani'} | ||
]; | ||
|
||
listView.sectionIndexTitles = indices; | ||
|
||
win.add(listView); | ||
|
||
listView.addEventListener('itemclick', clickHandler); | ||
|
||
} | ||
|
||
function list_v2_search_searchtext(_args) { | ||
var win = Ti.UI.createWindow({ | ||
title:'Search API', | ||
}); | ||
|
||
var scrollView = Ti.UI.createScrollView({layout:'vertical'}); | ||
|
||
var desc = Ti.UI.createLabel({ | ||
text:'This is an extension to the previous example. The ListView has its style set to Grouped.\n\n'+ | ||
'The textField is added as a child of the ListView with the listView headerView set to an dummy container of the same height as the textField.'+ | ||
'This keeps the textField visible at all times.\n\n'+ | ||
'This example also shows the functionality of the property keepSectionsInSearch (boolean default is false).\n\n'+ | ||
'When set to true the search results retain section headers and footers.\n\n'+ | ||
'Also notice the index bar which is automatically updated with search results.\n\n'+ | ||
'The searchableText in the following example is set to headerTitle+ +title.\n\n' | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
scrollView.add(desc); | ||
|
||
var button = Ti.UI.createButton({ | ||
top:10, | ||
title:'I understand' | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
scrollView.add(button); | ||
|
||
button.addEventListener('click',function(){ | ||
win.remove(scrollView); | ||
genTest(win); | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
win.add(scrollView); | ||
|
||
return win; | ||
|
||
}; | ||
module.exports = list_v2_search_searchtext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;
missing