Resolves #416 Vacuum support
This commit is contained in:
40
lib/entities/vacuum/widgets/vacuum_state_button.dart
Normal file
40
lib/entities/vacuum/widgets/vacuum_state_button.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user