This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/entities/vacuum/widgets/vacuum_state_button.dart

38 lines
1.3 KiB
Dart
Raw Normal View History

2019-10-16 19:34:29 +03:00
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: Theme.of(context).textTheme.subhead);
2019-10-16 19:34:29 +03:00
}
return Padding(
padding: EdgeInsets.only(right: 15),
child: result,
);
}
}