Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Last active October 3, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansemannn/0f654bcaee125e7df994625bedc6d840 to your computer and use it in GitHub Desktop.
Save hansemannn/0f654bcaee125e7df994625bedc6d840 to your computer and use it in GitHub Desktop.
TIMOB-23793 test-cases
var toggle = false;
var win = Ti.UI.createWindow();
var myTemplate = {
childTemplates: [{
type: 'Ti.UI.TextField',
bindId: 'field',
properties: {
width: 200,
height: 30,
left: 20,
backgroundColor: "#f0f0f0"
}
}, {
type: 'Ti.UI.View',
properties: {
right: 20,
width: 40,
height: 40,
borderRadius: 20,
borderWidth: 1,
borderColor: "#000"
},
childTemplates: [{
type: 'Ti.UI.ImageView',
bindId: 'image',
properties: {
width: 25,
height: 25
},
events: {
"click": handleImageClick
}
}]
}]
};
var list = Ti.UI.createListView({
defaultItemTemplate: "DefaultCellTemplate",
templates: {
"DefaultCellTemplate": myTemplate
},
allowsSelection: false,
sections: [Ti.UI.createListSection({
items: [{
properties: {
height: 50
},
field: {
hintText: "Enter value"
},
image: {
image: "images/cloud.png"
}
}, {
properties: {
height: 50
},
field: {
hintText: "Enter value"
},
image: {
image: "images/cloud.png"
}
}]
})]
});
function handleImageClick(e) {
toggle = !toggle;
var item = e.section.getItemAt(e.itemIndex);
item.image.image = "images/" + (toggle ? "cloud" : "chat") + ".png"; // Toggles the image on every click
e.section.updateItemAt(e.itemIndex, item);
};
win.add(list);
win.open();
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
function imageLoad(e) {
console.log("- imageLoad: ", e.source);
console.log("- state: " + e.state);
e.source.start();
}
function startAnimate(e) {
console.log("- startAnimate: ", e.source);
e.source.start();
}
var myTemplate = {
childTemplates: [{
type: 'Ti.UI.ImageView',
bindId: 'pic',
properties: {
width: '50dp',
height: '50dp',
left: 0
},
events: {
load: imageLoad,
click: startAnimate
}
}, {
type: 'Ti.UI.Label',
bindId: 'info',
properties: {
color: 'black',
font: {
fontFamily: 'Arial',
fontSize: '20dp',
fontWeight: 'bold'
},
left: '60dp',
top: 0,
}
}]
};
var listView = Ti.UI.createListView({
templates: {
'template': myTemplate
},
defaultItemTemplate: 'template'
});
var sections = [];
var fruitSection = Ti.UI.createListSection({
headerTitle: 'Fruits'
});
var fruitDataSet = [{
info: {
text: 'Apple'
},
pic: {
image: '/images/apple.png'
}
}, {
info: {
text: 'Durian'
},
pic: {
image: '/images/durian.png'
}
}, {
info: {
text: 'REMOTE'
},
pic: {
image: 'http://abload.de/img/defaultvzusy.jpg'
}
}, {
info: {
text: 'Boom'
},
pic: {
images: ['/images/apple.png', '/images/durian.png', '/images/orange.png', '/images/peach.png']
}
}];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);
win.add(listView);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment