mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-04-19 15:27:40 +00:00
gradient added
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
bb094062f4
commit
37c2669e40
1 changed files with 25 additions and 0 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue