Alloy+Titanium widget for an identical iPhone lock screen with passcode.
JavaScript
Latest commit 10c7805 Jul 21, 2016 @kopiro kopiro Removed code
Permalink
Failed to load latest commit information.
controllers Removed code Jul 21, 2016
styles 1.2 Bump and closes #1 Sep 1, 2014
views L Jan 20, 2015
README.md GIF Oct 10, 2014
widget.json Fixed code length Jul 21, 2016

README.md

Ti.Passcode

com.caffeinalab.titanium.passcode

Alloy Titanium widget for an identical iPhone lock screen with passcode.

image

Installation

Via Gittio (Stable)

gittio install com.caffeinalab.titanium.passcode

Via Github

Download the latest release, and add in your config.json, under dependencies:

"dependencies": {
    "com.caffeinalab.titanium.passcode": "*"
}

Usage in Alloy Views

<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!");
    }
});

Usage in Controllers

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();
Prompt mode

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.

API

setCode(code: String)

Set a new code

setPromptMode(length: Number)

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.

setOnSuccess(cb: Function)

Define the callback to invoke when the user inserts the correct code.

setOnError(cb: Function)

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.

setOnSuccessPrompt(cb: Function)

Define the callback to invoke when at the end of the prompt mode.