Alloy Titanium widget for an identical iPhone lock screen with passcode.
gittio install com.caffeinalab.titanium.passcode
Download the latest release, and add in your config.json, under dependencies:
"dependencies": {
"com.caffeinalab.titanium.passcode": "*"
}
<Widget id="PassCodeWidget" src="com.caffeinalab.titanium.passcode" code="42424" />
// Set the success callback
$.PassCodeWidget.setOnSuccess(function() {
alert("Yeah!")
});
$.PassCodeWidget.setOnError(function(times) {
if (times > 4) {
alert("Shame on you!");
}
});
var $window = Ti.UI.createWindow({
backgroundColor: '#0000'
});
var $pc = Alloy.createWidget('com.caffeinalab.titanium.passcode', { code: "1234" });
$pc.setOnSuccess(function() {
$window.close();
// Do the next private things
});
$pc.setOnError(function(times) {
if (times > 4) {
alert("Shame on you!");
}
});
$window.add($pc.getView());
$window.open();
You can use the widget to prompt the user for a new code. Just call:
$.PassCodeWidget.setPromptMode(5);
$.PassCodeWidget.setOnPromptSuccess(function(newCode) {
console.log("The new code is" + newCode);
});
This ask to the user for a new code of 5
chars.
Set a new code
Set the prompt mode, that doesn't check for a code but prompt the user to enter a code.
The length
argument represents the code length.
Define the callback to invoke when the user inserts the correct code.
Define the callback to invoke when the user inserts the wrong code.
The first argument of the onError
callback represents the times that the user has typed the wrong code.
Define the callback to invoke when at the end of the prompt mode.