From c5a598d75e3e7557ba24ba9e44bdfd6a9f06b9fe Mon Sep 17 00:00:00 2001 From: lunctis-viribus <31998224+lunctis-viribus@users.noreply.github.com> Date: Sun, 12 Dec 2021 10:15:44 +0100 Subject: [PATCH] weatherClock Bangle.js 2 layout compatibility On Bangle.js 2 there still was a layout overlap issue for wind text. This commit fixes it. Tested for different input lengths in emulator, also for Bangle.js. --- apps/weatherClock/app.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/weatherClock/app.js b/apps/weatherClock/app.js index 9dd49427f..883f5f1a5 100644 --- a/apps/weatherClock/app.js +++ b/apps/weatherClock/app.js @@ -73,12 +73,10 @@ var clockLayout = new Layout( { {type: "img", filly: 1, id: "weatherIcon", src: sunIcon}, {type: "v", fillx:1, c: [ {type: "h", c: [ - {type: "txt", font: "10%", id: "temp", label: "000"}, - {type: "txt", font: "10%", id: "tempUnit", label: "°C"}, + {type: "txt", font: "10%", id: "temp", label: "000 °C"}, ]}, {type: "h", c: [ - {type: "txt", font: "10%", id: "wind", label: "00"}, - {type: "txt", font: "10%", id: "windUnit", label: "km/h"}, + {type: "txt", font: "10%", id: "wind", label: "00 km/h"}, ]} ] }, @@ -104,20 +102,17 @@ function draw() { clockLayout.dow.label = locale.dow(date, 1).toUpperCase() + " "; var weatherJson = getWeather(); if(weatherJson && weatherJson.weather){ - var currentWeather = weatherJson.weather; + var currentWeather = weatherJson.weather; const temp = locale.temp(currentWeather.temp-273.15).match(/^(\D*\d*)(.*)$/); - clockLayout.temp.label = temp[1]; - clockLayout.tempUnit.label = temp[2]; + clockLayout.temp.label = temp[1] + " " + temp[2]; clockLayout.weatherIcon.src = chooseIcon(currentWeather.txt); const wind = locale.speed(currentWeather.wind).match(/^(\D*\d*)(.*)$/); - clockLayout.wind.label = wind[1] + " ".repeat(wind[2].length-1); - clockLayout.windUnit.label = wind[2] + " " + (currentWeather.wrose||'').toUpperCase(); + clockLayout.wind.label = wind[1] + " " + wind[2] + " " + (currentWeather.wrose||'').toUpperCase(); + var currentWeather = weatherJson.weather; } else{ clockLayout.temp.label = "Err"; - clockLayout.tempUnit.label = ""; clockLayout.wind.label = "No Data"; - clockLayout.windUnit.label = ""; clockLayout.weatherIcon.src = errIcon; } clockLayout.clear();