Sound mode support for media player

This commit is contained in:
Yegor Vialov
2018-11-23 14:11:34 +02:00
parent efbe33f4e3
commit da15e880ec
7 changed files with 40 additions and 13 deletions

View File

@ -76,6 +76,15 @@ class Entity {
}
}
List<String> getStringListAttributeValue(String attribute) {
if (attributes["$attribute"] != null) {
List<String> result = (attributes["$attribute"] as List).cast<String>();
return result;
} else {
return null;
}
}
Widget buildDefaultWidget(BuildContext context) {
return DefaultEntityContainer(
state: _buildStatePart(context)

View File

@ -38,7 +38,7 @@ class LightEntity extends Entity {
double get minMireds => _getDoubleAttributeValue("min_mireds");
Color get color => _getColor();
bool get isAdditionalControls => ((attributes["supported_features"] != null) && (attributes["supported_features"] != 0));
List<String> get effectList => _getEffectList();
List<String> get effectList => getStringListAttributeValue("effect_list");
LightEntity(Map rawData) : super(rawData);
@ -55,15 +55,6 @@ class LightEntity extends Entity {
}
}
List<String> _getEffectList() {
if (attributes["effect_list"] != null) {
List<String> result = (attributes["effect_list"] as List).cast<String>();
return result;
} else {
return null;
}
}
@override
Widget _buildStatePart(BuildContext context) {
return SwitchStateWidget();

View File

@ -72,6 +72,8 @@ class MediaPlayerEntity extends Entity {
MediaPlayerEntity.SUPPORT_SELECT_SOUND_MODE) ==
MediaPlayerEntity.SUPPORT_SELECT_SOUND_MODE);
List<String> get soundModeList => getStringListAttributeValue("sound_mode_list");
@override
Widget _buildAdditionalControlsForPage(BuildContext context) {
return MediaPlayerControls();