This commit is contained in:
Yegor Vialov 2018-11-12 20:47:04 +02:00
parent 01090dc3b1
commit 5142391da2

View File

@ -2,12 +2,17 @@ part of '../../main.dart';
class MediaPlayerWidget extends StatelessWidget { class MediaPlayerWidget extends StatelessWidget {
void _setPower(MediaPlayerEntity entity) {
TheLogger.debug('WAT?');
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final EntityModel entityModel = EntityModel.of(context); final EntityModel entityModel = EntityModel.of(context);
final MediaPlayerEntity entity = entityModel.entity; final MediaPlayerEntity entity = entityModel.entity;
List<Widget> body = []; return Column(
body.add(Stack( children: <Widget>[
Stack(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
children: <Widget>[ children: <Widget>[
_buildImage(entity), _buildImage(entity),
@ -27,9 +32,26 @@ class MediaPlayerWidget extends StatelessWidget {
child: MediaPlayerProgressWidget() child: MediaPlayerProgressWidget()
) )
], ],
)); ),
return Column( _buildControls(entity)
children: body ]
);
}
Widget _buildControls(MediaPlayerEntity entity) {
List<Widget> result = [];
if (entity.supportTurnOn) {
result.add(
IconButton(
icon: Icon(Icons.power_settings_new),
onPressed: () => _setPower(entity),
iconSize: Sizes.iconSize,
)
);
}
return Row(
children: result,
mainAxisAlignment: MainAxisAlignment.center,
); );
} }
@ -66,16 +88,19 @@ class MediaPlayerWidget extends StatelessWidget {
Widget _buildImage(MediaPlayerEntity entity) { Widget _buildImage(MediaPlayerEntity entity) {
String state = entity.state; String state = entity.state;
if (homeAssistantWebHost != null && entity.entityPicture != null && state != "off" && state != "unavailable" && state != "idle") { if (homeAssistantWebHost != null && entity.entityPicture != null && state != "off" && state != "unavailable" && state != "idle") {
return Row( return Container(
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Image( Image(
image: CachedNetworkImageProvider("$homeAssistantWebHost${entity.entityPicture}"), image: CachedNetworkImageProvider("$homeAssistantWebHost${entity.entityPicture}"),
height: 240.0, height: 240.0,
width: 320.0, width: 320.0,
fit: BoxFit.fitHeight, fit: BoxFit.contain,
) )
], ],
),
); );
} else { } else {
return Row( return Row(