Resolves #416 Vacuum support

This commit is contained in:
estevez-dev
2019-10-16 19:34:29 +03:00
parent abd23e27ea
commit 3387ab2850
4 changed files with 206 additions and 19 deletions

View File

@ -0,0 +1,40 @@
part of '../../../main.dart';
class VacuumStateButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
Widget result;
VacuumEntity entity = EntityModel.of(context).entityWrapper.entity;
if (entity.supportTurnOn && entity.supportTurnOff) {
result = FlatServiceButton(
serviceDomain: "vacuum",
serviceName: entity.state == EntityState.on ? "turn_off" : "turn_on",
entityId: entity.entityId,
text: entity.state == EntityState.on ? "TURN OFF" : "TURN ON"
);
} else if (entity.supportStart && (entity.state == EntityState.docked || entity.state == EntityState.idle)) {
result = FlatServiceButton(
serviceDomain: "vacuum",
serviceName: "start",
entityId: entity.entityId,
text: "START CLEANING"
);
} else if (entity.supportReturnHome && entity.state == EntityState.cleaning) {
result = FlatServiceButton(
serviceDomain: "vacuum",
serviceName: "return_to_base",
entityId: entity.entityId,
text: "RETURN TO DOCK"
);
} else {
result = Text(entity.state.toUpperCase(), style: TextStyle(
fontSize: 16,
color: Colors.grey
));
}
return Padding(
padding: EdgeInsets.only(right: 15),
child: result,
);
}
}