WIP #55
This commit is contained in:
parent
d9790dedbb
commit
c85a9bbe27
@ -75,7 +75,7 @@ part 'ui_widgets/card_header_widget.dart';
|
|||||||
|
|
||||||
EventBus eventBus = new EventBus();
|
EventBus eventBus = new EventBus();
|
||||||
const String appName = "HA Client";
|
const String appName = "HA Client";
|
||||||
const appVersion = "0.3.8";
|
const appVersion = "0.3.8 internal build 61";
|
||||||
|
|
||||||
String homeAssistantWebHost;
|
String homeAssistantWebHost;
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ class MediaControlCardWidget extends StatelessWidget {
|
|||||||
return Container(width: 0.0, height: 0.0,);
|
return Container(width: 0.0, height: 0.0,);
|
||||||
}
|
}
|
||||||
List<Widget> body = [];
|
List<Widget> body = [];
|
||||||
if (homeAssistantWebHost != null) {
|
|
||||||
body.add(Stack(
|
body.add(Stack(
|
||||||
alignment: AlignmentDirectional.topEnd,
|
alignment: AlignmentDirectional.topEnd,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -29,9 +28,14 @@ class MediaControlCardWidget extends StatelessWidget {
|
|||||||
child: _buildState(),
|
child: _buildState(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 0.0,
|
||||||
|
left: 0.0,
|
||||||
|
right: 0.0,
|
||||||
|
child: _buildProgress(),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
|
||||||
return Card(
|
return Card(
|
||||||
child: Column(
|
child: Column(
|
||||||
//crossAxisAlignment: CrossAxisAlignment.center,
|
//crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@ -40,6 +44,36 @@ class MediaControlCardWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildProgress() {
|
||||||
|
double progress;
|
||||||
|
try {
|
||||||
|
DateTime lastUpdated = DateTime.parse(
|
||||||
|
card.linkedEntity.attributes["media_position_updated_at"]).toLocal();
|
||||||
|
Duration duration = Duration(seconds: card.linkedEntity._getIntAttributeValue("media_duration") ?? 1);
|
||||||
|
Duration position = Duration(seconds: card.linkedEntity._getIntAttributeValue("media_position") ?? 0);
|
||||||
|
int currentPosition = position.inSeconds;
|
||||||
|
if (card.linkedEntity.state == "playing") {
|
||||||
|
int differenceInSeconds = DateTime
|
||||||
|
.now()
|
||||||
|
.difference(lastUpdated)
|
||||||
|
.inSeconds;
|
||||||
|
currentPosition = currentPosition + differenceInSeconds;
|
||||||
|
}
|
||||||
|
progress = currentPosition / duration.inSeconds;
|
||||||
|
return LinearProgressIndicator(
|
||||||
|
value: progress,
|
||||||
|
backgroundColor: Colors.black45,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(EntityColors.stateColor("on")),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
progress = 0.0;
|
||||||
|
}
|
||||||
|
return LinearProgressIndicator(
|
||||||
|
value: progress,
|
||||||
|
backgroundColor: Colors.black45,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildState() {
|
Widget _buildState() {
|
||||||
TextStyle style = TextStyle(
|
TextStyle style = TextStyle(
|
||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
@ -57,7 +91,7 @@ class MediaControlCardWidget extends StatelessWidget {
|
|||||||
states.add(Text("${card.linkedEntity.attributes['media_artist'] ?? card.linkedEntity.attributes['app_name']}", style: style.apply(fontSizeDelta: 4.0),));
|
states.add(Text("${card.linkedEntity.attributes['media_artist'] ?? card.linkedEntity.attributes['app_name']}", style: style.apply(fontSizeDelta: 4.0),));
|
||||||
}
|
}
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(left: Entity.leftWidgetPadding, right: Entity.rightWidgetPadding),
|
padding: EdgeInsets.fromLTRB(Entity.leftWidgetPadding, Entity.rowPadding, Entity.rightWidgetPadding, Entity.rowPadding),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: states,
|
children: states,
|
||||||
@ -78,10 +112,20 @@ class MediaControlCardWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Container(
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
MaterialDesignIcons.createIconDataFromIconName("mdi:movie"),
|
||||||
|
size: 150.0,
|
||||||
|
color: EntityColors.stateColor("$state"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
/*return Container(
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
height: 80.0,
|
height: 80.0,
|
||||||
);
|
);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: hass_client
|
name: hass_client
|
||||||
description: Home Assistant Android Client
|
description: Home Assistant Android Client
|
||||||
|
|
||||||
version: 0.3.8+60
|
version: 0.3.8+61
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||||
|
Reference in New Issue
Block a user