txtreader: hook up touch events to ui, implement bigger font

master
Pavel Machek 2025-02-14 22:14:29 +01:00
parent 38ef6b6a52
commit 39ac54842e
1 changed files with 18 additions and 12 deletions

View File

@ -125,10 +125,6 @@ function onFileSelected(file) {
return null; // No more lines to display return null; // No more lines to display
} }
// Initial display
var result = displayText(currentOffset, currentPage);
history.push({ offset: currentOffset, linesDisplayed: result.linesDisplayed });
function nextPage() { function nextPage() {
var nextOffset = displayText(currentOffset, currentPage + 1); var nextOffset = displayText(currentOffset, currentPage + 1);
if (nextOffset !== null) { if (nextOffset !== null) {
@ -157,16 +153,26 @@ function onFileSelected(file) {
function zoom() { function zoom() {
g.clear(); g.clear();
big = !big; big = !big;
firstDraw();
} }
// Handle touch events function firstDraw() {
Bangle.on('touch', function(button) { currentOffset = 0;
if (button === 2) { // Right side of the screen (next page) currentPage = 1;
nextPage(); history = [];
} else if (button === 1) { // Left side of the screen (previous page)
prevPage(); // Initial display
var result = displayText(currentOffset, currentPage);
history.push({ offset: currentOffset, linesDisplayed: result.linesDisplayed });
} }
});
ui.init();
ui.prevScreen = prevPage;
ui.nextScreen = nextPage;
ui.topLeft = zoom;
firstDraw();
Bangle.on("drag", (b) => ui.touchHandler(b));
} }
showFileSelector(); showFileSelector();