diff --git a/apps/cards/app.js b/apps/cards/app.js index 52eaa392c..a6d802352 100644 --- a/apps/cards/app.js +++ b/apps/cards/app.js @@ -47,27 +47,30 @@ function formatDay(date) { } function printSquareCode(binary, size) { - var ratio = g.getWidth()/size; + var padding = 5; + var ratio = (g.getWidth()-(2*padding))/size; + g.setColor(g.theme.fg).fillRect(0, 0, g.getWidth(), g.getHeight()); for (var y = 0; y < size; y++) { for (var x = 0; x < size; x++) { if (binary[x + y * size]) { - g.setColor(g.theme.bg).fillRect({x:x*ratio, y:y*ratio, w:ratio, h:ratio}); + g.setColor(g.theme.bg).fillRect({x:x*ratio+padding, y:y*ratio+padding, w:ratio, h:ratio}); } else { - g.setColor(g.theme.fg).fillRect({x:x*ratio, y:y*ratio, w:ratio, h:ratio}); + g.setColor(g.theme.fg).fillRect({x:x*ratio+padding, y:y*ratio+padding, w:ratio, h:ratio}); } } } } function printLinearCode(binary) { - var yFrom = 0; + var yFrom = 15; + var yTo = 28; var width = g.getWidth()/binary.length; for(var b = 0; b < binary.length; b++){ var x = b * width; if(binary[b] === "1"){ - g.setColor(g.theme.fg).fillRect({x:x, y:yFrom, w:width, h:g.getHeight()}); + g.setColor(g.theme.fg).fillRect({x:x, y:yFrom, w:width, h:g.getHeight() - (yTo+yFrom)}); } else if(binary[b]){ - g.setColor(g.theme.bg).fillRect({x:x, y:yFrom, w:width, h:g.getHeight()}); + g.setColor(g.theme.bg).fillRect({x:x, y:yFrom, w:width, h:g.getHeight() - (yTo+yFrom)}); } } } @@ -80,6 +83,8 @@ function showCode(card) { Bangle.removeListener("tap", listener); }; Bangle.on("tap", listener); + E.showScroller(); + g.clear(true); switch (card.type) { case "QR_CODE": const getBinaryQR = require("cards.qrcode.js"); @@ -87,18 +92,23 @@ function showCode(card) { printSquareCode(code.data, code.size); break; case "CODE_39": + g.setFont("Vector:20"); + g.setFontAlign(0,1); + g.drawString(card.value, g.getWidth()/2, g.getHeight()); const CODE39 = require("cards.code39.js"); code = new CODE39(card.value, {}); printLinearCode(code.encode().data); break; case "CODABAR": + g.setFont("Vector:20"); + g.setFontAlign(0,1); + g.drawString(card.value, g.getWidth()/2, g.getHeight()); const codabar = require("cards.codabar.js"); code = new codabar(card.value, {}); printLinearCode(code.encode().data); break; default: - g.clear(true); - g.setFont("Vector:15"); + g.setFont("Vector:30"); g.setFontAlign(0,0); g.drawString(card.value, g.getWidth()/2, g.getHeight()/2); } @@ -114,8 +124,7 @@ function showCard(card) { var titleCnt = lines.length; var start = getDate(card.expiration); var includeDay = true; - if (titleCnt) lines.push(""); // add blank line after name - lines = lines.concat("", /*LANG*/"Tap here to see the value"); + lines = lines.concat("", /*LANG*/"View code"); var valueLine = lines.length - 1; if (card.expiration) lines = lines.concat("",/*LANG*/"Expires"+": ", g.wrapString(formatDay(getDate(card.expiration)), g.getWidth()-10)); diff --git a/apps/cards/metadata.json b/apps/cards/metadata.json index 5f72a1c5b..0aa3249fb 100644 --- a/apps/cards/metadata.json +++ b/apps/cards/metadata.json @@ -4,7 +4,7 @@ "version": "0.1", "description": "Display loyalty cards", "icon": "app.png", - "screenshots": [{"url":"screenshot_cards_overview.png"}, {"url":"screenshot_cards_card1.png"}, {"url":"screenshot_cards_barcode.png"}, {"url":"screenshot_cards_qrcode.png"}], + "screenshots": [{"url":"screenshot_cards_overview.png"}, {"url":"screenshot_cards_card1.png"}, {"url":"screenshot_cards_card2.png"}, {"url":"screenshot_cards_barcode.png"}, {"url":"screenshot_cards_qrcode.png"}], "tags": "cards", "supports": ["BANGLEJS","BANGLEJS2"], "readme": "README.md", diff --git a/apps/cards/screenshot_cards_barcode.png b/apps/cards/screenshot_cards_barcode.png index 1910c173e..e57e9765a 100644 Binary files a/apps/cards/screenshot_cards_barcode.png and b/apps/cards/screenshot_cards_barcode.png differ diff --git a/apps/cards/screenshot_cards_card1.png b/apps/cards/screenshot_cards_card1.png index 30cb17fab..1c8c9514c 100644 Binary files a/apps/cards/screenshot_cards_card1.png and b/apps/cards/screenshot_cards_card1.png differ diff --git a/apps/cards/screenshot_cards_card2.png b/apps/cards/screenshot_cards_card2.png new file mode 100644 index 000000000..15ee1cac4 Binary files /dev/null and b/apps/cards/screenshot_cards_card2.png differ