This commit is contained in:
parent
1d8527bcb9
commit
f9d03d2d19
21
incidence.js
21
incidence.js
@ -8,21 +8,24 @@ Script.setWidget(widget)
|
|||||||
Script.complete()
|
Script.complete()
|
||||||
|
|
||||||
async function createWidget(items) {
|
async function createWidget(items) {
|
||||||
Location.setAccuracyToKilometer()
|
Location.setAccuracyToThreeKilometers()
|
||||||
const location = await Location.current()
|
const location = await Location.current()
|
||||||
const data = await new Request(apiUrl(location)).loadJSON()
|
const data = await new Request(apiUrl(location)).loadJSON()
|
||||||
const attr = data.features[0].attributes
|
const attr = data.features[0].attributes
|
||||||
const incidence = attr.cases7_per_100k.toFixed(1)
|
const incidence = attr.cases7_per_100k.toFixed(1)
|
||||||
const cityName = attr.GEN
|
const cityName = attr.GEN
|
||||||
const gradient = new LinearGradient()
|
|
||||||
gradient.locations = [0, 1]
|
|
||||||
gradient.colors = [
|
|
||||||
new Color("111111"),
|
|
||||||
new Color("222222")
|
|
||||||
]
|
|
||||||
const list = new ListWidget()
|
const list = new ListWidget()
|
||||||
list.backgroundGradient = gradient
|
if(Device.isUsingDarkAppearance()){
|
||||||
list.addText("🦠 Inzidenz")
|
const gradient = new LinearGradient()
|
||||||
|
gradient.locations = [0, 1]
|
||||||
|
gradient.colors = [
|
||||||
|
new Color("111111"),
|
||||||
|
new Color("222222")
|
||||||
|
]
|
||||||
|
list.backgroundGradient = gradient
|
||||||
|
}
|
||||||
|
const header = list.addText("🦠 Inzidenz".toUpperCase())
|
||||||
|
header.font = Font.mediumSystemFont(13)
|
||||||
list.addSpacer()
|
list.addSpacer()
|
||||||
const label = list.addText(incidence+"")
|
const label = list.addText(incidence+"")
|
||||||
label.font = Font.boldSystemFont(24)
|
label.font = Font.boldSystemFont(24)
|
||||||
|
Loading…
Reference in New Issue
Block a user