An open API service indexing awesome lists of open source software.

https://github.com/caffeinalab/ti.passcode

Alloy+Titanium widget for an identical iPhone lock screen with passcode.
https://github.com/caffeinalab/ti.passcode

Last synced: 6 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# Ti.Passcode

### com.caffeinalab.titanium.passcode

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

![image](http://cl.ly/image/3r2y2y1b3n3G/lock.gif)

## Installation

#### Via Gittio (Stable)

```
gittio install com.caffeinalab.titanium.passcode
```

#### Via Github

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

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

#### Usage in Alloy Views

```xml

```

```javascript

// Set the success callback
$.PassCodeWidget.setOnSuccess(function() {
alert("Yeah!")
});

$.PassCodeWidget.setOnError(function(times) {
if (times > 4) {
alert("Shame on you!");
}
});
```

#### Usage in Controllers

```javascript

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:

```javascript
$.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*.