Skip to content
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

Merged
merged 3 commits into from
Jul 1, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions Resources/ui/common/baseui/list_views.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function list_views(_args) {
{properties: { title: 'Custom Backgrounds', itemId: 'list_v2_custom_backgrounds', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'Select & Deselect Item', itemId: 'list_v2_select_deselect', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'Misc UI', itemId: 'list_v2_ui_misc', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'Pull View', itemId: 'list_v2_ui_pull', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
]
uienhancementsSection.setItems(uienhancementsdataset);
sections.push(uienhancementsSection);
Expand All @@ -119,6 +120,17 @@ function list_views(_args) {
]
editingSection.setItems(editingdataset);
sections.push(editingSection);

var searchSection = Ti.UI.createListSection({ headerTitle: 'V2 Search & Index Support'});
var searchDataSet = [
{properties: { title: 'Index Bar (sectionIndexTitles) ', itemId: 'list_v2_index_bar', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'Basic Search (searchView)', itemId: 'list_v2_search_searchview', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'New Search API (searchText) ', itemId: 'list_v2_search_searchtext', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
{properties: { title: 'Fun with searchText ', itemId: 'list_v2_search_searchtext2', accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DETAIL, height:44}},
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; missing

searchSection.setItems(searchDataSet);
sections.push(searchSection);

} else {
//TODO Android Specific or remove above check
}
Expand Down
69 changes: 69 additions & 0 deletions Resources/ui/common/baseui/listview/list_v2_index_bar.js
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;
129 changes: 129 additions & 0 deletions Resources/ui/common/baseui/listview/list_v2_search_searchtext.js
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'
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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'
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


win.add(scrollView);

return win;

};
module.exports = list_v2_search_searchtext;
149 changes: 149 additions & 0 deletions Resources/ui/common/baseui/listview/list_v2_search_searchtext2.js
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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'
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


tf.addEventListener('change',function(e){
listView.searchText = e.value;
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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'
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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'
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
})
Copy link
Contributor

Choose a reason for hiding this comment

The 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;