Swipe to back prototype

master
Kedlub 2023-01-20 08:32:08 +01:00
parent 57f5f92334
commit 5e87fc2bcf
4 changed files with 47 additions and 0 deletions

1
apps/backswipe/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New App!

BIN
apps/backswipe/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

33
apps/backswipe/boot.js Normal file
View File

@ -0,0 +1,33 @@
(function () {
// Overrride the default setUI method, so we can save the back button callback
var setUI = Bangle.setUI;
Bangle.setUI = function (mode, cb) {
var options = {};
if ("object"==typeof mode) {
options = mode;
}
print("Setting UI");
if(global.BACK) delete global.BACK;
if (options && options.back) {
print("Saving back callback");
global.BACK = options.back;
}
setUI(mode, cb);
};
function goBack(lr, ud) {
// if it is a left to right swipe
if (lr === 1) {
print("Back swipe detected");
// if we're in an app that has a back button, run the callback for it
if (global.BACK) {
print("Running back callback");
global.BACK();
}
}
}
// Listen to left to right swipe
Bangle.on("swipe", goBack);
})();

View File

@ -0,0 +1,13 @@
{ "id": "backswipe",
"name": "Back Swipe",
"shortName":"BackSwipe",
"version":"0.01",
"description": "Service that allows you to use an app's back button using left to right swipe gesture",
"icon": "app.png",
"tags": "back,gesture,swipe",
"supports" : ["BANGLEJS2"],
"type": "bootloader",
"storage": [
{"name":"backswipe.boot.js","url":"boot.js"}
]
}