icons: add dark theme colors

This commit is contained in:
Dag Heyman 2019-10-07 12:28:17 +02:00
parent 932c680d02
commit 4b1b537f57

View File

@ -13,7 +13,7 @@ Rectangle {
radius: width * 0.5
color: getIconColor()
readonly property var iconColors: [
readonly property var lightThemeIconColors: [
'#EF5350',
'#F44336',
'#E53935',
@ -122,13 +122,177 @@ Rectangle {
'#263238'
]
readonly property var darkThemeIconColors: [
'#FFEBEE',
'#FFCDD2',
'#EF9A9A',
'#E57373',
'#FF8A80',
'#FCE4EC',
'#F8BBD0',
'#F48FB1',
'#F06292',
'#FF80AB',
'#F3E5F5',
'#E1BEE7',
'#CE93D8',
'#EA80FC',
'#EDE7F6',
'#D1C4E9',
'#B39DDB',
'#B388FF',
'#E8EAF6',
'#C5CAE9',
'#9FA8DA',
'#8C9EFF',
'#E3F2FD',
'#BBDEFB',
'#90CAF9',
'#64B5F6',
'#42A5F5',
'#2196F3',
'#82B1FF',
'#E1F5FE',
'#B3E5FC',
'#81D4FA',
'#4FC3F7',
'#29B6F6',
'#03A9F4',
'#039BE5',
'#80D8FF',
'#40C4FF',
'#00B0FF',
'#E0F7FA',
'#B2EBF2',
'#80DEEA',
'#4DD0E1',
'#26C6DA',
'#00BCD4',
'#00ACC1',
'#84FFFF',
'#18FFFF',
'#00E5FF',
'#00B8D4',
'#E0F2F1',
'#B2DFDB',
'#80CBC4',
'#4DB6AC',
'#26A69A',
'#A7FFEB',
'#64FFDA',
'#1DE9B6',
'#00BFA5',
'#E8F5E9',
'#C8E6C9',
'#A5D6A7',
'#81C784',
'#66BB6A',
'#4CAF50',
'#B9F6CA',
'#69F0AE',
'#00E676',
'#00C853',
'#F1F8E9',
'#DCEDC8',
'#C5E1A5',
'#AED581',
'#9CCC65',
'#8BC34A',
'#7CB342',
'#689F38',
'#CCFF90',
'#B2FF59',
'#76FF03',
'#64DD17',
'#F9FBE7',
'#F0F4C3',
'#E6EE9C',
'#DCE775',
'#D4E157',
'#CDDC39',
'#C0CA33',
'#AFB42B',
'#9E9D24',
'#F4FF81',
'#EEFF41',
'#C6FF00',
'#AEEA00',
'#FFFDE7',
'#FFF9C4',
'#FFF59D',
'#FFF176',
'#FFEE58',
'#FFEB3B',
'#FDD835',
'#FBC02D',
'#F9A825',
'#F57F17',
'#FFFF8D',
'#FFFF00',
'#FFEA00',
'#FFD600',
'#FFF8E1',
'#FFECB3',
'#FFE082',
'#FFD54F',
'#FFCA28',
'#FFC107',
'#FFB300',
'#FFA000',
'#FF8F00',
'#FF6F00',
'#FFE57F',
'#FFD740',
'#FFC400',
'#FFAB00',
'#FFF3E0',
'#FFE0B2',
'#FFCC80',
'#FFB74D',
'#FFA726',
'#FF9800',
'#FB8C00',
'#F57C00',
'#EF6C00',
'#FFD180',
'#FFAB40',
'#FF9100',
'#FF6D00',
'#FBE9E7',
'#FFCCBC',
'#FFAB91',
'#FF8A65',
'#FF7043',
'#FF5722',
'#FF9E80',
'#FF6E40',
'#EFEBE9',
'#D7CCC8',
'#BCAAA4',
'#FAFAFA',
'#F5F5F5',
'#EEEEEE',
'#E0E0E0',
'#BDBDBD',
'#9E9E9E',
'#ECEFF1',
'#CFD8DC',
'#B0BEC5',
'#90A4AE',
]
/*
This is a copy of the icon color picker algorithm found in the current Android version of YA.
See: https://github.com/Yubico/yubioath-android/blob/master/app/src/main/kotlin/com/yubico/yubioath/ui/main/IconManager.kt#L67
*/
function getIconColor() {
let iconKey = _credential.issuer ? _credential.issuer : ":" + _credential.name
return iconColors[Math.abs(Utils.hashCode(iconKey)) % iconColors.length]
let hashCode = Utils.hashCode(iconKey)
if (app.isDark()) {
return darkThemeIconColors[Math.abs(hashCode) % darkThemeIconColors.length]
} else {
return lightThemeIconColors[Math.abs(hashCode) % lightThemeIconColors.length]
}
}
function getIconLetter() {
@ -141,6 +305,6 @@ Rectangle {
font.pixelSize: 24
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: yubicoWhite
color: credentialCardNormal
}
}