From 37c2669e40fd3b3a373f247f01b652c3cf56e883 Mon Sep 17 00:00:00 2001 From: Benny Samir Hierl <bennysamir@posteo.de> Date: Sun, 1 Nov 2020 18:17:23 +0100 Subject: [PATCH] gradient added Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de> --- Ecosia/Ecosia.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Ecosia/Ecosia.js b/Ecosia/Ecosia.js index 83baba4..94ea984 100644 --- a/Ecosia/Ecosia.js +++ b/Ecosia/Ecosia.js @@ -14,6 +14,20 @@ if (widgetInputRAW !== null) { throw new Error('No token set via widget parameter! You can request a token here: https://www.ecosia.org/account/login') } +//////////////////////////////////////////////////////////////////////////////// +let backColor; //Widget background color +let backColor2; //Widget background color +let textColor; //Widget text color + +if (Device.isUsingDarkAppearance()) { + backColor = '111111'; + backColor2 = '222222'; + textColor = 'EDEDED'; +} else { + backColor = 'D32D1F'; + backColor2 = '76150C'; + textColor = 'EDEDED'; +} //////////////////////////////////////////////////////////////////////////////// async function getTreeCounter(token) { let req = new Request("https://api.ecosia.org/v1/accounts/personalcounter?token=" + token) @@ -44,6 +58,15 @@ let treeCounter = await getTreeCounter(token); let ecosiaLogo = await getLogo() // Create Widget let widget = new ListWidget(); + +const gradient = new LinearGradient() +gradient.locations = [0, 1] +gradient.colors = [ + new Color(backColor), + new Color(backColor2) +] +widget.backgroundGradient = gradient + widget.url = 'https://ecosia.org/' widget.setPadding(10, 10, 10, 10) @@ -60,6 +83,7 @@ if (ecosiaLogo !== null) { } else { let title = widget.addText("Ecosia") title.font = Font.mediumSystemFont(12) + title.textColor = new Color(textColor) widget.addSpacer() } @@ -68,6 +92,7 @@ counterText.font = Font.regularSystemFont(36) counterText.minimumScaleFactor = 0.7; counterText.lineLimit = 1 counterText.centerAlignText() +counterText.textColor = new Color(textColor) widget.addSpacer()