View as widget refactoring
This commit is contained in:
@ -62,6 +62,7 @@ class Entity {
|
||||
String get unitOfMeasurement => attributes["unit_of_measurement"] ?? "";
|
||||
List get childEntityIds => attributes["entity_id"] ?? [];
|
||||
String get lastUpdated => _getLastUpdatedFormatted();
|
||||
bool get isHidden => attributes["hidden"] ?? false;
|
||||
|
||||
Entity(Map rawData) {
|
||||
update(rawData);
|
||||
|
@ -781,14 +781,12 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
Color _tmpColor;
|
||||
bool _changedHere = false;
|
||||
String _tmpEffect;
|
||||
String _tmpFlash;
|
||||
|
||||
void _resetState(LightEntity entity) {
|
||||
_tmpBrightness = entity.brightness;
|
||||
_tmpColorTemp = entity.colorTemp;
|
||||
_tmpColor = entity.color;
|
||||
_tmpEffect = null;
|
||||
_tmpFlash = null;
|
||||
}
|
||||
|
||||
void _setBrightness(LightEntity entity, double value) {
|
||||
@ -846,18 +844,6 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
void _setFlash(LightEntity entity, String value) {
|
||||
setState(() {
|
||||
_tmpFlash = value;
|
||||
_changedHere = true;
|
||||
if (_tmpFlash != null) {
|
||||
eventBus.fire(new ServiceCallEvent(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"flash": "$value"}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final entityModel = EntityModel.of(context);
|
||||
|
Reference in New Issue
Block a user