Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created January 4, 2017 10:42
Show Gist options
  • Save AppWerft/6498b726bb00d642be63983c476a0ce9 to your computer and use it in GitHub Desktop.
Save AppWerft/6498b726bb00d642be63983c476a0ce9 to your computer and use it in GitHub Desktop.
module.exports = function(options, callbacks) {
var start = new Date().getTime();
if (!TouchId.isSupported()) {
alert("This device doesn't support fingerprint sensor");
return;
}
var dialog = null;
if (Ti.Platform.osname == "android") {
var timer = 0;
var cronHandler = function() {
timer++;
if (timer == 600) {
clearInterval(cron);
} else {
// fingerprintView.backgroundImage = "/assets/fingerprint"
// + timer % 9 + '.png';
progress.setValue(timer);
}
};
var cron = setInterval(cronHandler, 100);
var $ = Ti.UI.createWindow({
theme : "Theme.FingerprintDialog",
backgroundColor : 'transparent',
width : Ti.UI.FILL,
height : Ti.UI.FILL,
fullscreen : true
});
$.add(Ti.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
backgroundColor : "#c333"
}));
var container = Ti.UI.createView({
width : "75%",
height : 340
});
$.add(container);
var androidView = Ti.UI.createView({
top : 50,
backgroundColor : "#fff",
});
var fingerprintView = Ti.UI.createView({
width : 150,
top : 0,
height : 150,
zIndex : 9999,
backgroundImage : "/assets/fp.png"
});
container.add(fingerprintView);
androidView.add(Ti.UI.createLabel({
left : 20,
right : 20,
bottom : 100,
color : '#333',
text : options.message
}));
var progress = Ti.UI.createProgressBar({
width : Ti.UI.FILL,
bottom : 60,
left : 10,
right : 10,
min : 0,
max : 600
});
var cancel = Ti.UI.createButton({
width : 100,
bottom : 10,
title : "Abbruch",
right : 10,
});
var errormessage = Ti.UI.createLabel({
left : 20,
right : 20,
top : 135,
color : "#8c00",
textAlign : "center",
horizontalWrap : false,
wordWrap : false,
ellipsize : Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_MARQUEE,
height : 25
});
androidView.add(progress);
androidView.add(cancel);
cancel.addEventListener("click", function() {
$.close();
callbacks.onerror();
});
progress.show();
container.add(androidView);
$.open();
}
TouchId.authenticate({
reason : options.message,
callback : function(e) {
console.log("##########>>>>>>>>> Code=" + e.code);
if (e.error) {
Ti.UI.createNotification({
message : e.error
}).show();
} else if (e.success == true) {
$.close();
callbacks.onsuccess();
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment