Skip to content

Instantly share code, notes, and snippets.

@simonbs
Last active February 17, 2024 11:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonbs/a2a0e9ff70640905fc4d688af6ba2f69 to your computer and use it in GitHub Desktop.
Save simonbs/a2a0e9ff70640905fc4d688af6ba2f69 to your computer and use it in GitHub Desktop.
Countdown to Apple's "One More Thing" event on November 10th, 2020
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-purple; icon-glyph: apple-alt;
const TITLE = "One More Thing"
const DATE = "2020-11-10T17:00:00Z"
const IMG_URL = "https://i.ibb.co/f2SN2Wb/bg.png"
let widget = await createWidget()
if (config.runsInWidget) {
Script.setWidget(widget)
Script.complete()
} else {
await widget.presentMedium()
}
async function createWidget() {
let eventDate = createEventDate()
let bgImg = await loadBgImage()
let widget = new ListWidget()
widget.backgroundImage = bgImg
widget.addSpacer()
let wtitle = widget.addText(TITLE)
wtitle.font = Font.boldSystemFont(20)
wtitle.textColor = Color.white()
widget.addSpacer(2)
let wdate = widget.addDate(eventDate)
wdate.applyRelativeStyle()
wdate.font = Font.mediumSystemFont(18)
wdate.textColor = Color.white()
return widget
}
function createEventDate() {
let dateFormatter = new DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
return dateFormatter.date(DATE)
}
async function loadBgImage() {
let req = new Request(IMG_URL)
return await req.loadImage()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment