
Diego Graziano
Emprendedor compulsivo
© 2023 Todos los derechos reservados.

Widget con valor del Dolar Blue en vivo para dispositivos iOS
Basado en el tweet de @ImAgustinF y el código de @NicoWickersheim hice este widget para iOS con el valor del Dolar Blue en Argentina. Grande, claro y conciso. Para los que estamos con ese tipo de cambio en la cabeza todo el día. Para realizarlo es necesario utilizar la app Scriptable (totalmente gratuita).
Se puede ver la documentación, instalación y changelog en este repositorio de Github.
Instalación
- Descargar la aplicación Scriptable desde el AppStore (si aún no se descargó).
- Dentro de la aplicación: Crear nuevo script.
- Copiar código desde el repositorio o bien desde aca:
- Crear un nuevo widget en la pantalla de inicio y elegir el script creado con Scriptable.
/* -------------------------------------------------------------- Script: scriptable-dolar-blue.js Author: Diego Graziano Version: 1.0.1 Description: Displays the current "Dolar Blue" currency rate to Argentine Peso (ARS). Changelog: 1.0.0: Initialization 1.0.1: When touching the widget it opens URL "dolarito.ar" with all dollar types of currency rates. 1.0.2: Through slice function it removes last 3 chracters from value string to round number. -------------------------------------------------------------- */ const url = `https://api-dolar-argentina.herokuapp.com/api/dolarblue` const req = new Request(url) const res = await req.loadJSON() const valor = res.venta; const valorRound = valor.slice(0. -3); const fecha = res.fecha; const i = new Request('https://github.com/diegograziano/scriptable-dolar-blue.js/raw/main/img/dollar-icon.png') const img = await i.loadImage() const timeFormatter = new DateFormatter(); timeFormatter.dateFormat = 'dd/MM/yyyy HH:mm'; let widget = createWidget(valor, fecha, img) if (config.runsInWidget) { // create and show widget Script.setWidget(widget) Script.complete() } else { widget.presentSmall() } // Assemble widget layout function createWidget(valor, fecha, img) { let w = new ListWidget() w.backgroundColor = new Color("#1A1A1A") w.url = 'https://dolarito.ar'; let image = w.addImage(img) image.imageSize = new Size(45, 45) image.centerAlignImage() w.addSpacer(8) let staticText = w.addText("Valor Dolar Blue:") staticText.textColor = Color.white() staticText.font = Font.boldSystemFont(12) staticText.centerAlignText() w.addSpacer(8) let valorTxt = w.addText(valorRound) valorTxt.textColor = Color.blue() valorTxt.font = Font.systemFont(18) valorTxt.centerAlignText() w.addSpacer(8) // Show last Update of dolar blue let lastDate = w.addText(timeFormatter.string(new Date())); lastDate.textColor = Color.gray() lastDate.font = Font.mediumSystemFont(10) lastDate.centerAlignText(); w.setPadding(0, 0, 0, 0) return w }
Links utilizados
- Valor del Dólar Blue: Api Dolar Argentina
- Link a URL con todos los tipos de cambios en relación Dolar / Peso Argentino: Dolarito.
Eso es todo. Espero que lo disfruten.