Unlock Screen
Unlock Screen mimics the iPhone's/iPad's lock screen. You can use it to code-protect your entire app or just some screens with a few lines of clean code. This module comes with plenty of examples, themes, free support and free updates! Adapts itself to the screen size, so it works on iPhone and iPad. You can get this module at the Appcelerator Marketplace
The basic configuration for this module will look exactly like the following snippet:
// load the module var unlockScreen = require('com.qbset.unlockscreen'); Ti.API.info("module is => " + unlockScreen); // load the unlockCode window var unlockWindow = unlockScreen.loadWindow({ configLockScreen: { // main properties for the module passCode: '1234', // set the passcode (string) attempts: 3, // zero for infinite attempts and no timeout (int) timeOut: 5000, // time out in miliseconds after amount of incorrect attempts. Only when attempts is bigger then zero (int) timeOutMultiplier: 2, // after each set of attempts the time out is multiplied with this property (int) vibrateOnIncorrect: true // vibrate phone on incorrect passcode input (bool) } });
The following snippet is a more extended configuration with a custom made background image:
// open a single window var window = Ti.UI.createWindow({ backgroundColor: 'white' }); var button = Ti.UI.createButton({ height: 40, width: Ti.Platform.displayCaps.platformWidth-40, top: 20, left: 20, title: 'Open Unlock Window' }); button.addEventListener('click',function() { unlockWindow.open(); }); window.add(button); window.open(); // load the module var unlockScreen = require('com.qbset.unlockscreen'); Ti.API.info("module is => " + unlockScreen); // load the unlockScreen window var unlockWindow = unlockScreen.loadWindow({ // main properties for the module configLockScreen: { passCode: '1234', // set the passcode (string) attempts: 3, // zero for infinite attempts and no timeout (int) timeOut: 5000, // time out in miliseconds after amount of incorrect attempts. Only when attempts is bigger then zero (int) timeOutMultiplier: 2, // after each set of attempts the time out is multiplied with this property (int) vibrateOnIncorrect: true // vibrate phone on incorrect passcode input (bool) }, // properties for the window mainWindow: { backgroundImage: 'bg.png' }, // properties for the messageBox messageBox: { text: 'Enter Unlock Code', textCorrect: 'Unlock Code Accepted', textIncorrect: 'Wrong Unlock Code', textColorCorrect: '#ffffff', textColorIncorrect: '#ff0000', vibrateOnIncorrect: true, borderColor: '#ffffff', backgroundColor: 'gray', font: { fontFamily: 'Helvetica Neue', fontWeight: 'bold', fontSize: 20 }, }, // properties for the passwordBox passwordBox: { top: 145, width: 50, gapWidth: 20 }, // properties for the timeOutBox timeOutBox: { text: 'Please try again in', top: 185, color: '#ffffff', font: { fontFamily: 'Helvetica Neue', fontWeight: 'bold', fontSize: 18 }, }, // do something on correct passcode correct: function() { // for instance set your own custom alert alert('Yes, your passcode is correct!'); }, // do something on incorrect passcode incorrect: function() { // for instance set your own custom alert alert('Ooops, looks like the insert code is incorrect...Please try again'); } });

