Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const date = new Date();
- async function createWidget() {
- const widget = new ListWidget();
- let backgroundImg = await new Request("https://i.imgur.com/9oDsSxt.jpeg").loadImage();
- widget.backgroundImage = backgroundImg
- // Blank text to align the "hello" image properly. I wasn't able to do it without this weird workaround.
- let txt = widget.addText(" ");
- widget.addSpacer(2);
- let helloImg = await new Request("https://i.imgur.com/7g7YbVB.png").loadImage();
- let stack = widget.addStack();
- stack.size = new Size(300,50);
- theImg = stack.addImage(helloImg);
- stack.centerAlignContent();
- // Format the date
- let df = new DateFormatter()
- df.dateFormat = "EEEE, MMMM d"
- widget.addSpacer();
- let dateText = widget.addText(df.string(date));
- dateText.font = Font.regularSystemFont(18);
- dateText.textColor = Color.white();
- dateText.centerAlignText();
- widget.addSpacer();
- return widget;
- } //createWidget
- //---[ main ]-------------------------------------
- if (config.runsInWidget) {
- let widget = await createWidget()
- Script.setWidget(widget)
- Script.complete()
- } else {
- let widget = await createWidget()
- await widget.presentMedium()
- }
- //------------------------------------------------
- function newLinearGradient(hexcolors, locations) {
- let gradient = new LinearGradient()
- gradient.locations = locations
- gradient.colors = hexcolors
- .map(color=>new Color(color))
- return gradient
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement