mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-06-07 05:57:41 +00:00
v1.2.0
- Large Widget: write percentage to the bar and show total numbers
This commit is contained in:
parent
d43b1d212c
commit
e82defda15
3 changed files with 13 additions and 10 deletions
|
@ -3,9 +3,11 @@
|
||||||
// icon-color: red; icon-glyph: syringe;
|
// icon-color: red; icon-glyph: syringe;
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
Version 1.1.1
|
Version 1.2.0
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
v1.2.0
|
||||||
|
- Large Widget: write percentage to the bar and show total numbers
|
||||||
v1.1.1
|
v1.1.1
|
||||||
- Cache path changed
|
- Cache path changed
|
||||||
- Allow force Update of the data
|
- Allow force Update of the data
|
||||||
|
@ -29,15 +31,12 @@ Changelog:
|
||||||
// How many minutes should the cache be valid
|
// How many minutes should the cache be valid
|
||||||
let cacheMinutes = 4 * 60
|
let cacheMinutes = 4 * 60
|
||||||
|
|
||||||
// Set to true to show total numbers in the large widget
|
|
||||||
const showTotalInLargeWidget = false
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////// Dev Settings ////////////////////////
|
////////////////////////// Dev Settings ////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const debug = false
|
const debug = false
|
||||||
config.widgetFamily = config.widgetFamily || 'medium'
|
config.widgetFamily = config.widgetFamily || 'large'
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////// System Settings /////////////////////
|
////////////////////////// System Settings /////////////////////
|
||||||
|
@ -91,7 +90,8 @@ function creatProgress(percentage) {
|
||||||
// Background Path
|
// Background Path
|
||||||
context.setFillColor(Color.gray())
|
context.setFillColor(Color.gray())
|
||||||
const path = new Path()
|
const path = new Path()
|
||||||
path.addRect(new Rect(0, 0, width, h))
|
const backgroundReact = new Rect(0, 0, width, h)
|
||||||
|
path.addRect(backgroundReact)
|
||||||
context.addPath(path)
|
context.addPath(path)
|
||||||
context.fillPath()
|
context.fillPath()
|
||||||
|
|
||||||
|
@ -112,6 +112,11 @@ function creatProgress(percentage) {
|
||||||
context.addPath(path1)
|
context.addPath(path1)
|
||||||
context.fillPath()
|
context.fillPath()
|
||||||
|
|
||||||
|
context.setTextAlignedCenter()
|
||||||
|
context.setTextColor(Color.white())
|
||||||
|
context.setFont(Font.systemFont(fontSize - 1))
|
||||||
|
context.drawTextInRect(`${percentage.toLocaleString(Device.language())}%`, backgroundReact)
|
||||||
|
|
||||||
return context.getImage()
|
return context.getImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,8 +271,7 @@ if (config.widgetFamily === 'large') {
|
||||||
stateText.lineLimit = 1
|
stateText.lineLimit = 1
|
||||||
|
|
||||||
row.addSpacer()
|
row.addSpacer()
|
||||||
const totalText = showTotalInLargeWidget ? `${parseInt(value.vaccinated).toLocaleString(Device.language())} / ` : ''
|
const quoteText = row.addText(`${parseInt(value.vaccinated).toLocaleString(Device.language())}`)
|
||||||
const quoteText = row.addText(`${totalText}${value.quote.toString().replace('.', ',')} %`)
|
|
||||||
quoteText.font = Font.systemFont(fontSize)
|
quoteText.font = Font.systemFont(fontSize)
|
||||||
|
|
||||||
row.addSpacer(4)
|
row.addSpacer(4)
|
||||||
|
@ -283,8 +287,7 @@ if (config.widgetFamily === 'large') {
|
||||||
stateText.font = Font.boldSystemFont(fontSize + 1)
|
stateText.font = Font.boldSystemFont(fontSize + 1)
|
||||||
|
|
||||||
row.addSpacer()
|
row.addSpacer()
|
||||||
const totalText = showTotalInLargeWidget ? `${parseInt(result.vaccinated).toLocaleString(Device.language())} / ` : ''
|
const quoteText = row.addText(`${parseInt(result.vaccinated).toLocaleString(Device.language())}`)
|
||||||
const quoteText = row.addText(`${totalText}${result.quote.toString().replace('.', ',')} %`)
|
|
||||||
quoteText.font = Font.boldSystemFont(fontSize + 1)
|
quoteText.font = Font.boldSystemFont(fontSize + 1)
|
||||||
|
|
||||||
row.addSpacer(4)
|
row.addSpacer(4)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
Loading…
Add table
Reference in a new issue