mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-06-07 05:57:41 +00:00
Update Countdown.js
Add show Date option
This commit is contained in:
parent
11af274988
commit
3ebf8153ad
1 changed files with 17 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
||||||
// Variables used by Scriptable.
|
// Variables used by Scriptable.
|
||||||
// These must be at the very top of the file. Do not edit.
|
// These must be at the very top of the file. Do not edit.
|
||||||
// icon-color: orange; icon-glyph: hourglass-half;
|
// icon-color: orange; icon-glyph: hourglass-half;
|
||||||
// Version 1.1.0
|
// Version 1.2.0
|
||||||
|
|
||||||
let dateForCountdown = ''
|
let dateForCountdown = ''
|
||||||
let icon = ''
|
let icon = ''
|
||||||
|
let showDate = false
|
||||||
|
|
||||||
let widgetInputRAW = args.widgetParameter;
|
let widgetInputRAW = args.widgetParameter;
|
||||||
let widgetInput = null;
|
let widgetInput = null;
|
||||||
|
@ -16,6 +17,9 @@ if (widgetInputRAW !== null) {
|
||||||
}
|
}
|
||||||
dateForCountdown = widgetInput[0].trim()
|
dateForCountdown = widgetInput[0].trim()
|
||||||
icon = widgetInput[1] || '⏳';
|
icon = widgetInput[1] || '⏳';
|
||||||
|
if (widgetInput[2] && widgetInput[2].toLowerCase() === 'true') {
|
||||||
|
showDate = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('No Date set! Please set a Date via Widget parameter like 2020-12-31')
|
throw new Error('No Date set! Please set a Date via Widget parameter like 2020-12-31')
|
||||||
}
|
}
|
||||||
|
@ -86,10 +90,10 @@ textStack.layoutHorizontally()
|
||||||
textStack.addSpacer()
|
textStack.addSpacer()
|
||||||
textStack.centerAlignContent()
|
textStack.centerAlignContent()
|
||||||
|
|
||||||
let dayText = textStack.addText(`${remainingDays}`)
|
let daysText = textStack.addText(`${remainingDays}`)
|
||||||
dayText.font = Font.regularSystemFont(50)
|
daysText.font = Font.regularSystemFont(50)
|
||||||
dayText.textColor = new Color(textColor);
|
daysText.textColor = new Color(textColor);
|
||||||
dayText.minimumScaleFactor = 0.5;
|
daysText.minimumScaleFactor = 0.5;
|
||||||
|
|
||||||
textStack.addSpacer(5)
|
textStack.addSpacer(5)
|
||||||
|
|
||||||
|
@ -109,6 +113,14 @@ textStack.addSpacer()
|
||||||
|
|
||||||
widget.addSpacer()
|
widget.addSpacer()
|
||||||
|
|
||||||
|
if(showDate) {
|
||||||
|
const dateText = widget.addDate(new Date(dateForCountdown))
|
||||||
|
dateText.font = Font.lightSystemFont(10)
|
||||||
|
dateText.textColor = new Color(textColor);
|
||||||
|
dateText.centerAlignText()
|
||||||
|
widget.addSpacer(5)
|
||||||
|
}
|
||||||
|
|
||||||
if(!config.runsInWidget) {
|
if(!config.runsInWidget) {
|
||||||
await widget.presentSmall()
|
await widget.presentSmall()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue