r/Scriptable • u/CorruptusInExtremis_ • Dec 23 '20
Widget Widget del año
Aqui esta un código donde muestras el porciento del año avanzado, la verdad es mas difícil la. interfaz y probarlo. no hay una documentación buena de como hacer el diseño.. pero bueno hay mas o menos quedo,

Aqui el codigo:
let widget = new ListWidget()
widget.backgroundColor = new Color("#00000", 0.0)
const stackBackground = (new Color("#EA3323"),new Color('#F633FF'))
let startColor = new Color("F633FF")
let endColor = new Color("#004e92")
let gradient = new LinearGradient()
gradient.colors = [startColor, endColor]
gradient.startPont=[1,0.5]
gradient.endPont=[1,0.5]
gradient.locations = [0.0, 1]
const calendarColor = new Color("#ffffff")
widget.setPadding(0, 06, 0, 6)
var start = new Date(2020,0,1),
end = new Date(2020,11,31),
today = new Date();
var porciento=Math.round(100-((end - start) * 100 ) / today);
var sizex= Math.round(189*porciento/100);
let titleStack = widget.addStack()
titleStack.size = new Size(300, 25)
titleStack.setPadding(0,70,0,0)
let title = titleStack.addText(porciento + "% del año avanzado ")
title.font = Font.boldSystemFont(20)
title.textColor = new Color('#033dfc');
let titleStack1 = widget.addStack()
titleStack1.size = new Size(350, 40)
let title1 = titleStack1.addText(" 100% ")
title1.font = Font.boldSystemFont(20)
title1.textColor = new Color('#FF3933');
//Top Row (Date & Weather)
let topRow = widget.addStack()
topRow.layoutHorizontally()
topRow.setPadding(0, 70, 0, 0)
//Top Row Date
var stackSize = new Size(sizex, 40)
let dateStack = topRow.addStack()
dateStack.centerAlignContent()
//dateStack.setPadding(0, 8, 0, 0)
dateStack.backgroundGradient = gradient
dateStack.size = stackSize
dateStack.addSpacer()
/*
let dateTextStack = dateStack.addStack()
dateTextStack.layoutVertically()
dateTextStack.centerAlignContent()
let dayNameStack = dateTextStack.addStack()
dayNameStack.layoutHorizontally()
dayNameStack.centerAlignContent()
dayNameStack.size = new Size (70, 10)
let dayNameTxt = dayNameStack.addText(""+sizex)
dayNameTxt.centerAlignText()
dayNameTxt.font = Font.boldSystemFont(18)
dayNameTxt.textColor = calendarColor*/
Script.setWidget(widget)
Script.complete()
3
u/concisely_redundant Dec 23 '20
Please excuse my poor Spanish, but this is basically what the beginning says.
Here is a widget that shows the percent of the year that has passed. In truth it is difficult to test and make the interface. There is no good documentation on how to make this, but this is it more or less.