(data)
| 139 | } |
| 140 | |
| 141 | async function createWidget(data) { |
| 142 | const attr = data.stations[0] |
| 143 | |
| 144 | const list = new ListWidget() |
| 145 | list.setPadding(0, 4, 1, 4) |
| 146 | |
| 147 | const gradient = new LinearGradient() |
| 148 | gradient.locations = [0, 1] |
| 149 | gradient.colors = [ |
| 150 | new Color("111111"), |
| 151 | new Color("222222") |
| 152 | ] |
| 153 | list.backgroundGradient = gradient |
| 154 | |
| 155 | let open = '🔴' |
| 156 | if (attr.isOpen) { |
| 157 | open = '🟢' |
| 158 | } |
| 159 | |
| 160 | let firstLineStack = list.addStack() |
| 161 | |
| 162 | let stationName = firstLineStack.addText(attr.brand) |
| 163 | stationName.font = Font.boldSystemFont(15) |
| 164 | stationName.textColor = Color.white() |
| 165 | |
| 166 | firstLineStack.addSpacer() |
| 167 | let stationOpen = firstLineStack.addText(open) |
| 168 | stationOpen.font = Font.mediumSystemFont(10) |
| 169 | stationOpen.rightAlignText() |
| 170 | |
| 171 | list.addSpacer(5) |
| 172 | |
| 173 | let dieselStack = list.addStack() |
| 174 | let dieselLabel = dieselStack.addText("Diesel:") |
| 175 | dieselLabel.font = Font.boldSystemFont(12) |
| 176 | dieselLabel.textColor = Color.white() |
| 177 | |
| 178 | dieselStack.addSpacer() |
| 179 | let dieselPrice = dieselStack.addText(formatValue(attr.diesel)) |
| 180 | dieselPrice.font = new Font('Menlo', 12) |
| 181 | dieselPrice.textColor = Color.white() |
| 182 | |
| 183 | list.addSpacer(1) |
| 184 | |
| 185 | let e5Stack = list.addStack() |
| 186 | let e5Label = e5Stack.addText("Benzin E5:") |
| 187 | e5Label.font = Font.boldSystemFont(12) |
| 188 | e5Label.textColor = Color.white() |
| 189 | |
| 190 | e5Stack.addSpacer() |
| 191 | let e5Price = e5Stack.addText(formatValue(attr.e5)) |
| 192 | e5Price.font = new Font('Menlo', 12) |
| 193 | e5Price.textColor = Color.white() |
| 194 | |
| 195 | list.addSpacer(1) |
| 196 | let e10Stack = list.addStack() |
| 197 | let e10Label = e10Stack.addText("Benzin E10:") |
| 198 | e10Label.font = Font.boldSystemFont(12) |
no test coverage detected