WIP #120 Random color for states

This commit is contained in:
Yegor Vialov
2018-10-28 21:02:38 +02:00
parent fcd4ac7292
commit c20200b609
6 changed files with 78 additions and 50 deletions

View File

@ -1,41 +1,5 @@
part of '../main.dart';
class EntityColors {
static const _stateColors = {
"on": Colors.amber,
"auto": Colors.amber,
"idle": Colors.amber,
"playing": Colors.amber,
"above_horizon": Colors.amber,
"home": Colors.amber,
"open": Colors.amber,
"off": Color.fromRGBO(68, 115, 158, 1.0),
"closed": Color.fromRGBO(68, 115, 158, 1.0),
"default": Color.fromRGBO(68, 115, 158, 1.0),
"heat": Colors.redAccent,
"cool": Colors.lightBlue,
"closing": Colors.cyan,
"opening": Colors.purple,
"unavailable": Colors.black26,
"unknown": Colors.black26,
};
static Color stateColor(String state) {
return _stateColors[state] ?? _stateColors["default"];
}
static charts.Color historyStateColor(String state) {
Color c = stateColor(state);
return charts.Color(
r: c.red,
g: c.green,
b: c.blue,
a: c.alpha
);
}
}
class Entity {
static const badgeColors = {