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

View File

@ -2,34 +2,56 @@ 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 = [];
body.add(Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
_buildImage(entity),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.black45,
child: _buildState(entity),
),
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: MediaPlayerProgressWidget()
)
],
));
return Column( return Column(
children: body children: <Widget>[
Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
_buildImage(entity),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.black45,
child: _buildState(entity),
),
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: MediaPlayerProgressWidget()
)
],
),
_buildControls(entity)
]
);
}
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(
mainAxisAlignment: MainAxisAlignment.center, color: Colors.black,
children: <Widget>[ child: Row(
Image( mainAxisAlignment: MainAxisAlignment.center,
image: CachedNetworkImageProvider("$homeAssistantWebHost${entity.entityPicture}"), children: <Widget>[
height: 240.0, Image(
width: 320.0, image: CachedNetworkImageProvider("$homeAssistantWebHost${entity.entityPicture}"),
fit: BoxFit.fitHeight, height: 240.0,
) width: 320.0,
], fit: BoxFit.contain,
)
],
),
); );
} else { } else {
return Row( return Row(