How to implement auto complete in Smartface App Studio - smartface.io

I am developing an iOS app with Smartface App Studio. I need to implement an search with auto complete. Can any suggest to achieve this.
Ex: If user typing "Ho" then list of places starts with "Ho" like "Holland", "Hong Kong" need to show as suggestions(while typing).
I tried with pick() and label on page. But that is working as dropdown.
Thanks in advance.

After alot work around, i made my autocomplete functinlity. Here is the code.
function PrepareAutoComplete(page, pageName) {
try {
var label_for_repeatbox = new SMF.UI.Label({
height : '100%',
width : '100%',
horizontalGap : 10,
left : '0%',
top : '0%',
fontColor : SMF.UI.Color.black,
backgroundTransparent : true
});
var rBox = new SMF.UI.RepeatBox({
name : 'rptDestinations',
width : '100%',
height : '90%',
left : Pages.PlacesToGo.edtBoxSelectDestination.left,
top : Pages.PlacesToGo.edtBoxSelectDestination.top + Pages.PlacesToGo.edtBoxSelectDestination.height + 1,
borderWidth : 1,
dataSource : [],
showScrollbar : true,
onRowRender : function onRowRender(e) {
this.controls[0].text = e.rowData;
},
itemTemplate : {
height : '10%'
}
});
label_for_repeatbox.onTouchEnded = function (e) {
alert(this.text);
}
rBox.useActiveItem = true;
rBox.visible = false;
rBox.itemTemplate.add(label_for_repeatbox);
Pages.PlacesToGo.edtBoxSelectDestination.onChange = function (e) {
if (this.text.length > 1 && isFirstTime == false) {
var search_key = this.text.toLowerCase();
var results = [];
for (var i = 0; i < Sources.length; i++) {
if (Sources[i].toLowerCase().indexOf(search_key) == 0) {
results.push(Sources.[i]);
}
}
rBox.dataSource = results;
rBox.refresh();
page.remove(rBox);
page.add(rBox);
rBox.visible = true;
}
}
Pages.PlacesToGo.edtBoxSelectDestination.onExit = function () {
rBox.dataSource = [];
rBox.refresh();
rBox.visible = false;
}
page.add(rBox);
} catch (ex) {
log(ex);
}
}

Related

While horizontal scrolling the datalabels of charjs is overlapping to y-axis

To show all bars I have set the horizontal scrolling to chartjs in Ionic angular project , and i have used the DataLabelsPlugin constant for bars label. and while scrolling the datalabels is overlapping with y-axis its not hiding before y-axis like bars.
and also horizontal scroll is not happening smoothly.
graph working fine as a expected output
marked with issue about - after scrolling the datalabels went over the y-axis not hide below y-axis like bars
I have tried to add and used the custom datalabels but same issue i am getting and i didnt find any css or attribute on 'https://www.chartjs.org/docs/latest/' official site or not on any other sites -> to hide the datalabels from over the y-axis.
ts file code:
createBarChart() {
const footer = (tooltipItems) => {
let sum = 0;
tooltipItems.forEach(function(tooltipItem) {
sum += tooltipItem.parsed.y;
});
return this.util.getFormatValue(sum)+'%';
};
const toolLabel = (tooltipItems) => {
return "";
};
const toolTitle = (tooltipItems) => {
var string_to_array = function (str) {
return str.trim().split("#$#$");
};
var ss;
tooltipItems.forEach(function(tooltipItem) {
ss = string_to_array(tooltipItem.label.replace(/(.{40})/g, "$1#$#$"))
});
return ss;
};
let graphSize = Math.max(...this.daywise_occupancy);
if(graphSize == 0){
graphSize =1;
}
const plugin = {
id: 'customCanvasBackgroundColor',
beforeDraw: (chart, args, options) => {
const {ctx} = chart;
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
}
};
this.bars = new Chart(this.barchart6.nativeElement, {
type: 'bar',
data: {
labels: this.daywise_date,
datasets: [{
data: this.daywise_occupancy,
backgroundColor: function(context) {
var value = context.dataset.data[context.dataIndex];
return value <= 15 ? '#f95959'
: value > 15 && value <=60 ? '#F5A623'
: '#00ADB5'
},
borderColor: function(context) {
var value = context.dataset.data[context.dataIndex];
return value <= 15 ? '#f95959'
: value > 15 && value <=60 ? '#F5A623'
: '#00ADB5'
},
borderWidth: 1,
barThickness:30,
}]
},
plugins: [DataLabelsPlugin,plugin],
options: {
animations: {
tension: {
duration: 1000,
easing: 'linear',
from: 1,
to: 0,
loop: true
}
},
scales: {
x: {
min:0,
max:5,
ticks : {
maxRotation: 70,
minRotation: 70,
font:{
size:10,
},
callback: function(value : any, index, ticks_array) {
let characterLimit = 12;
let label = this.getLabelForValue(value);
if ( label.length >= characterLimit) {
return label.slice(0, label.length).substring(0, characterLimit -1).trim() + '..';
}
return label;
}
}
},
y: { // defining min and max so hiding the dataset does not change scale range
min: 0,
max: this.loader.getGraphsizeRound(graphSize),
title: { display: true, text: (this.titleSet)? '% of Branches Contribution' : '% of Seat Occupancy' },
beginAtZero: true,
display: true,
position: 'left',
// ticks: {
// stepSize: 6,
// },
}
},
plugins: {
legend: {
display: false
},
datalabels:{
anchor: 'end',
align: 'end',labels: {
value: {
color: '#2C3A45;',
formatter: function (value) {
// return Math.round(value) + '%';
return value + '%';
},
font:{
weight:700,
size:14
}
}
}
},
tooltip: {
callbacks: {
footer:footer,
label: toolLabel,
title:toolTitle
},
displayColors:false
}
}
}
});
this.bars.canvas.addEventListener('touchmove',(eve) => {
this.touchmove(eve,this.bars)
});
this.bars.canvas.addEventListener('touchstart',(eve) => {
this.touchstart(eve)
});
}
touchstart(e)
{
this.startX = e.touches[0].clientX;
this.startY = e.touches[0].clientY;
}
touchmove(e,chart)
{
var deltaX = e.touches[0].clientX - this.startX,
deltaY = e.touches[0].clientY - this.startY;
const dataLength = chart.data.labels.length;
let min = chart.options.scales.x.min;
if(deltaX < 0){
if( chart.options.scales.x.max >= dataLength ){
chart.options.scales.x.min = dataLength - 5;
chart.options.scales.x.max = dataLength;
}else{
chart.options.scales.x.min += 1;
chart.options.scales.x.max += 1;
}
// console.log( chart.options.scales.x.min);
// chart1line.options.scales.y.max = graphSize
}else if(deltaX > 0){
if( chart.options.scales.x.min <= 0 ){
chart.options.scales.x.min = 0;
chart.options.scales.x.max = 4;
}else{
chart.options.scales.x.min -= 1;
chart.options.scales.x.max -= 1;
}
}else{
}
chart.update();
}
HTML code:
<div class="chartWrapper">
<div class="chartAreaWrapper">
<canvas #barchart6 height="190" max-height="190" width="0"></canvas>
</div>
</div>
My expected output
horizontal scroll work smoothly.
after scrolling label should not overlap on y-axis.

How to ZoomOut MapView in Smartface?

How to ZoomOut MapView in Smartface. I tried with below lines. But, still zooming deeper to the pin.
Pages.MapPage.mapHotel.zoomLevel = -5;
Pages.MapPage.mapHotel.zoomLevel = -15;
Pages.MapPage.mapHotel.zoomLevel = 15;
Pages.MapPage.mapHotel.zoomLevel = 0;
Thanks in advance
Vijay, you can use this function :
function showPin() {
Pages.Page1.mapHotel.addPin({
id : "0",
title : "Kahya Hotel",
subtitle : "Alanya",
latitude : 36.546469,
longitude : 31.986703,
selectedImage : "pinSelected",
unSelectedImage : "pinUnselected",
draggable : false,
animate : true
});
}
And call it with interval as below :
function Page1_Self_OnShow() {
Pages.Page1.mapHotel.zoomLevel = 0;
Pages.Page1.mapHotel.centerLatitude = 36.546469;
Pages.Page1.mapHotel.centerLongitude = 31.986703;
var intervalID = setInterval(function () {
showPin();
}, 5000);
}

Getting Facebook profile Album without Iterating through every profile albums

function getAlbumCovers() {
//first check to see if profile pics already exist in user model
//create a collection
var usersCollection = Alloy.Collections.user;
facebookModule.requestWithGraphPath('me/albums', {
fields : 'id,name,cover_photo,count,created_time'
}, 'GET', function(graphResp) {
//show view indicator before data is fetched
//$.view_indicator.visible = true;
setViewIndicator(100, 100, levelColour, 10, true, '30%');
$.ind.top = '30';
if (graphResp.success) {
if (graphResp.result) {
var rows = [];
var data = JSON.parse(graphResp.result).data;
var i = 0;
var blob;
for (x in data) {
if (data[x].name == "Profile Pictures") {
Ti.API.debug(JSON.stringify(data[x]));
var numberPhotos = null;
var albumTitle = null;
//apply transformations
if (data[x].count == null) {
numberPhotos = 0;
} else {
numberPhotos = data[x].count;
if (numberPhotos > 10) {
numberPhotos = 10;
} else {
numberPhotos = numberPhotos;
}
}
albumTitle = data[x].name + ' (' + numberPhotos + ')';
console.log("https://graph.facebook.com/" + (data[x].cover_photo || 0) + "/picture?access_token=" + Alloy.Globals.facebookModule.accessToken + "&type=album");
//start
// Read the image as a blob
var url = "https://graph.facebook.com/" + (data[x].cover_photo || 0) + "/picture?access_token=" + Alloy.Globals.facebookModule.accessToken + "&type=album";
var imgView = Ti.UI.createImageView({
image : url,
width : 'auto',
height : 'auto'
});
var imgBlob = imgView.toBlob();
var height = imgBlob.height;
var width = imgBlob.width;
if (height > width) {
var pos = (height - width) / 2;
var dict = {
height : width,
width : width,
x : 0,
y : pos
};
var newImg = imgBlob.imageAsCropped(dict);
//alert(newImg.height);
} else if (height < width) {
var pos = (width - height) / 2;
var dict = {
height : height,
width : height,
x : pos,
y : 0
};
var newImg = imgBlob.imageAsCropped(dict);
//alert(newImg.width);
} else {
//alert(imgBlob.width + '-' + imgBlob.height);
var pos = (width - height) / 2;
var dict = {
height : height,
width : height,
x : pos,
y : 0
};
var newImg = imgBlob.imageAsCropped(dict);
}
imgBlob = null;
//end
var row = Titanium.UI.createTableViewRow({
titleAlb : data[x].name,
selectedBackgroundColor : 'transparent',
selectionStyle : 'Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE on createTableViewRow',
width : '100%',
height : '60'
});
var image = Titanium.UI.createImageView({
//image : "https://graph.facebook.com/" + (data[x].cover_photo || 0) + "/picture?access_token=" + Alloy.Globals.facebookModule.accessToken + "&type=album",
image : newImg,
top : 10,
borderColor : levelColour,
left : 30,
width : '40',
height : '40'
});
if (Alloy.Globals.Platform == 'old') {
var title = Titanium.UI.createLabel({
text : albumTitle,
font : {
visible : true,
color : '#888888',
fontFamily : 'Avenir-Roman',
size : 12,
},
width : 200,
top : 15,
color : levelColour,
right : '30dp',
height : 'auto'
});
} else if (Alloy.Globals.Platform == '6') {
var title = Titanium.UI.createLabel({
text : albumTitle,
font : {
visible : true,
color : '#888888',
fontFamily : 'Avenir-Roman',
size : 12,
},
width : 200,
top : 15,
color : levelColour,
right : '85dp',
height : 'auto'
});
} else if (Alloy.Globals.Platform == '6+') {
var title = Titanium.UI.createLabel({
text : albumTitle,
font : {
visible : true,
color : '#888888',
fontFamily : 'Avenir-Roman',
size : 12,
},
width : 200,
top : 15,
color : levelColour,
right : '105dp',
height : 'auto'
});
}
row.add(image);
row.add(title);
rows.push(row);
i++;
console.log(i);
//set table rows
$.tableview.setData(rows);
//end
$.view_indicator.visible = false;
break;
}
}
}
} else {
$.view_indicator.visible = false;
if (e.error) {
alert(e.error);
} else {
alert("Unkown result");
}
}
});
}
Here is my code, as you can see I am having calling the Facebook api graph iterating through every album, and then detecting the profile album. The problem with this approach is that if the user has a 1000 albums, the for loop can take forever to find the profile album.
Anyone know of a quicker way to do this?
Cheers
Currently there is no such mechanism available in Graph API.
Also, your proposed method is unreliable at best, since not everybody uses Facebook in the English language, and for those that don't, the album might not be called "Profile Pictures".
The best way to get a user's current profile picture (without the album) is by fetching /user/picture

Implicit downcast from 'UnityEngine.Component[]' to 'UnityEngine.ParticleEmitter[]'

#pragma strict
static var charge : int = 0;
var collectSound : AudioClip;
//HUD
var hudCharge : Texture2D[];
var chargeHudGUI : GUITexture;
//Generator
var meterCharge : Texture[];
var meter : Renderer;
//Matches
private var haveMatches : boolean = false;
var matchGUIprefab : GUITexture;
private var matchGUI : GUITexture;
var fireEmitters : ParticleEmitter[];
var TextHints : GUIText;
function Start ()
{
charge = 0;
}
function Update ()
{
}
function CellPickup()
{
AudioSource.PlayClipAtPoint(collectSound, transform.position);
charge++;
chargeHudGUI.texture = hudCharge[charge];
meter.material.mainTexture = meterCharge[charge];
HUDon();
}
function HUDon()
{
if(!chargeHudGUI.enabled)
{
chargeHudGUI.enabled = true;
}
}
function MatchPickup()
{
haveMatches = true;
AudioSource.PlayClipAtPoint(collectSound, transform.position);
var matchHUD : GUITexture = Instantiate(matchGUIprefab, Vector3(0.15,0.1,0),transform.rotation);
matchGUI = matchHUD;
}
function OnControllerColliderHit(col : ControllerColliderHit)
{
if(col.gameObject.name == "campfire")
{
if(haveMatches)
{
LightFire(col.gameObject);
}
else
{
TextHints.SendMessage("ShowHint", "i could use this campfire to signal for help... \n if only i could light it");
}
}
}
function LightFire(campfire : GameObject)
{
fireEmitters = campfire.GetComponentsInChildren(ParticleEmitter);
for(var emitter : ParticleEmitter in fireEmitters)
{
emitter.emit = true;
}
campfire.audio.Play();
Destroy(matchGUI);
haveMatches=false;
}
i was 1st having a problem saying can't cast from source type to destination type then i added pragma strict and now i'm getting the error in the title, now i'm writing more because the lovely website thinks that that didn't explain enough.
Ok, I'm not familiar with this apparently typed variant of javascript, but assuming it's something like the other Java-family languages and has C-style casts, I would try this in LightFire:
var emitters : Component[] = campfire.GetComponentsInChildren(ParticleEmitter);
for(var emitter : Component in fireEmitters)
{
((ParticleEmitter)emitter).emit = true;
}
If that's not the right syntax, then find out how to do a downcast.

Calendar view instead of UIDatePicker [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Does anyone know of a view controller for iPhone/iPad that shows a monthly calendar?
I Google a lot for showing Month View / Calendar View in my Titanium application but unable to find it out which work on IPhone and Android (Almost all the screens) Both.
After that I tried to implement it by my own and got the good implementation.
To achieve this, Create project which support Android & IPhone.
Open app.js and replace the following code with the existing code and after that Press Command + Shift + F to format the code.
// Taking Screen Width
var screenWidth = 322;
var needToChangeSize = false;
var screenWidthActual = Ti.Platform.displayCaps.platformWidth;
if (Ti.Platform.osname === 'android') {
if (screenWidthActual >= 641) {
screenWidth = screenWidthActual;
needToChangeSize = true;
}
}
// Main Window of the Month View.
var win = Ti.UI.createWindow({
backgroundColor : '#FF000000',
navBarHidden : true
});
// Button at the buttom side
var backButton = Ti.UI.createButton({
bottom : '20dp',
height : '40dp',
width : '200dp'
});
// Previous Button - Tool Bar
var prevMonth = Ti.UI.createButton({
left : '15dp',
width : 'auto',
height : 'auto',
title : '<'
});
// Next Button - Tool Bar
var nextMonth = Ti.UI.createButton({
right : '15dp',
width : 'auto',
height : 'auto',
title : '>'
});
// Month Title - Tool Bar
var monthTitle = Ti.UI.createLabel({
width : '200dp',
height : '24dp',
textAlign : 'center',
color : '#3a4756',
font : {
fontSize : 20,
fontWeight : 'bold'
}
});
// Tool Bar
var toolBar = Ti.UI.createView({
top : '0dp',
width : '322dp',
height : '50dp',
backgroundColor : '#FFFFD800',
layout : 'vertical'
});
// Tool Bar - View which contain Title Prev. & Next Button
var toolBarTitle = Ti.UI.createView({
top : '3dp',
width : '322dp',
height : '24dp'
});
toolBarTitle.add(prevMonth);
toolBarTitle.add(monthTitle);
toolBarTitle.add(nextMonth);
// Tool Bar - Day's
var toolBarDays = Ti.UI.createView({
top : '2dp',
width : '322dp',
height : '22dp',
layout : 'horizontal',
left : '-1dp'
});
toolBarDays.sunday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Sun',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.monday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Mon',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.tuesday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Tue',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.wednesday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Wed',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.thursday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Thu',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.friday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Fri',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.saturday = Ti.UI.createLabel({
left : '0dp',
height : '20dp',
text : 'Sat',
width : '46dp',
textAlign : 'center',
font : {
fontSize : 12,
fontWeight : 'bold'
},
color : '#3a4756'
});
toolBarDays.add(toolBarDays.sunday);
toolBarDays.add(toolBarDays.monday);
toolBarDays.add(toolBarDays.tuesday);
toolBarDays.add(toolBarDays.wednesday);
toolBarDays.add(toolBarDays.thursday);
toolBarDays.add(toolBarDays.friday);
toolBarDays.add(toolBarDays.saturday);
// Adding Tool Bar Title View & Tool Bar Days View
toolBar.add(toolBarTitle);
toolBar.add(toolBarDays);
// Function which create day view template
dayView = function(e) {
var label = Ti.UI.createLabel({
current : e.current,
width : '46dp',
height : '44dp',
backgroundColor : '#FFDCDCDF',
text : e.day,
textAlign : 'center',
color : e.color,
font : {
fontSize : 20,
fontWeight : 'bold'
}
});
return label;
};
monthName = function(e) {
switch(e) {
case 0:
e = 'January';
break;
case 1:
e = 'February';
break;
case 2:
e = 'March';
break;
case 3:
e = 'April';
break;
case 4:
e = 'May';
break;
case 5:
e = 'June';
break;
case 6:
e = 'July';
break;
case 7:
e = 'August';
break;
case 8:
e = 'September';
break;
case 9:
e = 'October';
break;
case 10:
e = 'November';
break;
case 11:
e = 'December';
break;
};
return e;
};
// Calendar Main Function
var calView = function(a, b, c) {
var nameOfMonth = monthName(b);
//create main calendar view
var mainView = Ti.UI.createView({
layout : 'horizontal',
width : '322dp',
height : 'auto',
top : '50dp'
});
//set the time
var daysInMonth = 32 - new Date(a, b, 32).getDate();
var dayOfMonth = new Date(a, b, c).getDate();
var dayOfWeek = new Date(a, b, 1).getDay();
var daysInLastMonth = 32 - new Date(a, b - 1, 32).getDate();
var daysInNextMonth = (new Date(a, b, daysInMonth).getDay()) - 6;
//set initial day number
var dayNumber = daysInLastMonth - dayOfWeek + 1;
//get last month's days
for ( i = 0; i < dayOfWeek; i++) {
mainView.add(new dayView({
day : dayNumber,
color : '#8e959f',
current : 'no',
dayOfMonth : ''
}));
dayNumber++;
};
// reset day number for current month
dayNumber = 1;
//get this month's days
for ( i = 0; i < daysInMonth; i++) {
var newDay = new dayView({
day : dayNumber,
color : '#3a4756',
current : 'yes',
dayOfMonth : dayOfMonth
});
mainView.add(newDay);
if (newDay.text == dayOfMonth) {
newDay.color = 'white';
// newDay.backgroundImage='../libraries/calendar/pngs/monthdaytiletoday_selected.png';
newDay.backgroundColor = '#FFFFF000';
var oldDay = newDay;
}
dayNumber++;
};
dayNumber = 1;
//get remaining month's days
for ( i = 0; i > daysInNextMonth; i--) {
mainView.add(new dayView({
day : dayNumber,
color : '#8e959f',
current : 'no',
dayOfMonth : ''
}));
dayNumber++;
};
// this is the new "clicker" function, although it doesn't have a name anymore, it just is.
mainView.addEventListener('click', function(e) {
if (e.source.current == 'yes') {
// reset last day selected
if (oldDay.text == dayOfMonth) {
oldDay.color = 'white';
// oldDay.backgroundImage='../libraries/calendar/pngs/monthdaytiletoday.png';
oldDay.backgroundColor = '#FFFFF000';
} else {
oldDay.color = '#3a4756';
// oldDay.backgroundImage='../libraries/calendar/pngs/monthdaytile-Decoded.png';
oldDay.backgroundColor = '#FFDCDCDF'
}
oldDay.backgroundPaddingLeft = '0dp';
oldDay.backgroundPaddingBottom = '0dp';
// set window title with day selected, for testing purposes only
backButton.title = nameOfMonth + ' ' + e.source.text + ', ' + a;
// set characteristic of the day selected
if (e.source.text == dayOfMonth) {
// e.source.backgroundImage='../libraries/calendar/pngs/monthdaytiletoday_selected.png';
e.source.backgroundColor = '#FFFF00FF';
} else {
// e.source.backgroundImage='../libraries/calendar/pngs/monthdaytile_selected.png';
e.source.backgroundColor = '#FFFF0000';
}
e.source.backgroundPaddingLeft = '1dp';
e.source.backgroundPaddingBottom = '1dp';
e.source.color = 'white';
//this day becomes old :(
oldDay = e.source;
}
});
return mainView;
};
// what's today's date?
var setDate = new Date();
a = setDate.getFullYear();
b = setDate.getMonth();
c = setDate.getDate();
// add the three calendar views to the window for changing calendars with animation later
var prevCalendarView = null;
if (b == 0) {
prevCalendarView = calView(a - 1, 11, c);
} else {
prevCalendarView = calView(a, b - 1, c);
}
prevCalendarView.left = (screenWidth * -1) + 'dp';
var nextCalendarView = null;
if (b == 0) {
nextCalendarView = calView(a + 1, 0, c);
} else {
nextCalendarView = calView(a, b + 1, c);
}
nextCalendarView.left = screenWidth + 'dp';
var thisCalendarView = calView(a, b, c);
if (needToChangeSize == false) {
thisCalendarView.left = '-1dp';
}
monthTitle.text = monthName(b) + ' ' + a;
backButton.title = monthName(b) + ' ' + c + ', ' + a;
// add everything to the window
win.add(toolBar);
win.add(thisCalendarView);
win.add(nextCalendarView);
win.add(prevCalendarView);
win.add(backButton);
// yeah, open the window, why not?
win.open({
modal : true
});
var slideNext = Titanium.UI.createAnimation({
// left : '-322',
duration : 500
});
slideNext.left = (screenWidth * -1);
var slideReset = Titanium.UI.createAnimation({
// left : '-1',
duration : 500
});
if (needToChangeSize == false) {
slideReset.left = '-1';
} else {
slideReset.left = ((screenWidth - 644) / 2);
}
var slidePrev = Titanium.UI.createAnimation({
// left : '322',
duration : 500
});
slidePrev.left = screenWidth;
// Next Month Click Event
nextMonth.addEventListener('click', function() {
if (b == 11) {
b = 0;
a++;
} else {
b++;
}
thisCalendarView.animate(slideNext);
nextCalendarView.animate(slideReset);
setTimeout(function() {
thisCalendarView.left = (screenWidth * -1) + 'dp';
if (needToChangeSize == false) {
nextCalendarView.left = '-1dp';
} else {
nextCalendarView.left = ((screenWidth - 644) / 2);
}
prevCalendarView = thisCalendarView;
thisCalendarView = nextCalendarView;
if (b == 11) {
nextCalendarView = calView(a + 1, 0, c);
} else {
nextCalendarView = calView(a, b + 1, c);
}
monthTitle.text = monthName(b) + ' ' + a;
nextCalendarView.left = screenWidth + 'dp';
win.add(nextCalendarView);
}, 500);
});
// Previous Month Click Event
prevMonth.addEventListener('click', function() {
if (b == 0) {
b = 11;
a--;
} else {
b--;
}
thisCalendarView.animate(slidePrev);
prevCalendarView.animate(slideReset);
setTimeout(function() {
thisCalendarView.left = screenWidth + 'dp';
if (needToChangeSize == false) {
prevCalendarView.left = '-1dp';
} else {
prevCalendarView.left = ((screenWidth - 644) / 2);
}
nextCalendarView = thisCalendarView;
thisCalendarView = prevCalendarView;
if (b == 0) {
prevCalendarView = calView(a - 1, 11, c);
} else {
prevCalendarView = calView(a, b - 1, c);
}
monthTitle.text = monthName(b) + ' ' + a;
prevCalendarView.left = (screenWidth * -1) + 'dp';
win.add(prevCalendarView);
}, 500);
});
Tested Environment
Titanium Studio - 2.1.2.201208301612
Titanium SDK - 2.1.0.GA
Android - 2.2 Emulator
iOS Version - 5.0
Reference - http://titaniumexplorers.blogspot.in/2012/09/titanium-calendar-month-view.html
There is no in-built view controller for that. You will need to create your own. There are projects in Github for that exact purpose.
Check these out.
Titanium Calendar
Klazuka
Check out the new calendar module which seems to do exactly what you're asking for.