Cross-platform implementation of the iOS passcode screen for Titanium Mobile.
Installing Ti.Queue is straightforward, simply copy the ti.passcode.js file into your Titanium project.
Since Ti.Passcode is a CommonJS module, can you import the module anywhere in your app by simply using the require method.
For example:
var mod = require('Ti.Passcode');
First requre the module into our project
var mod = require('Ti.Passcode');
Next create some configuration options
var options = {
window:{
backgroundColor:'#ccc',
navBarHidden:true
},
view:{
title:'Enter application passcode',
errorColor:'yellow'
}
};
Then build our callback method
function onCompleted(d){
if(d.success){
var msg = Ti.UI.createAlertDialog({
title:'Information',
message:'Passcode entered is correct'
});
msg.addEventListener('click',function(t){
codeWindow.close();
});
msg.show();
}else{
var msg = Ti.UI.createAlertDialog({
title:'Information',
message:'Invalid passcode, please try again'
}).show();
}
};
Next create a new instance of the module
var passcode = new my.mod();
Finally, open the Passcode window
var codeWindow = passcode.createWindow(txtPasscode.value,onCompleted,options);
codeWindow.open({modal:true});
This module contains code forked from the following projects:
Pedro Enrique @pecdev https://gist.github.com/pec1985/1819804
Terry Martin @tzmartin https://github.com/tzmartin/TiUIExamples
This project is licensed under the OSI approved Apache Public License (version 2). For details please see the license associated with each project.
Developed by Ben Bahrenburg available on twitter @benCoding
Please consider following the @benCoding Twitter for updates and more about Titanium.
For module updates, Titanium tutorials and more please check out my blog at benCoding.Com.