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/flat_service_button.widget.dart

38 lines
906 B
Dart
Raw Normal View History

2019-09-09 18:50:35 +03:00
part of '../main.dart';
2019-01-25 23:48:31 +02:00
class FlatServiceButton extends StatelessWidget {
final String serviceDomain;
final String serviceName;
final String entityId;
2019-01-25 23:48:31 +02:00
final String text;
FlatServiceButton({
Key key,
@required this.serviceDomain,
@required this.serviceName,
@required this.entityId,
2019-01-25 23:48:31 +02:00
@required this.text,
}) : super(key: key);
void _setNewState() {
2019-11-08 21:37:41 +02:00
ConnectionManager().callService(domain: serviceDomain, service: serviceName, entityId: entityId);
2019-01-25 23:48:31 +02:00
}
@override
Widget build(BuildContext context) {
return SizedBox(
2020-04-04 15:47:40 +03:00
height: Theme.of(context).textTheme.subhead.fontSize*2.5,
2019-01-25 23:48:31 +02:00
child: FlatButton(
onPressed: (() {
_setNewState();
2019-01-25 23:48:31 +02:00
}),
child: Text(
text,
textAlign: TextAlign.right,
2020-04-07 00:39:16 +03:00
style: HAClientTheme().getActionTextStyle(context),
2019-01-25 23:48:31 +02:00
),
)
);
}
}