WIP Themes: State colors from themes

This commit is contained in:
Yegor Vialov
2020-04-04 21:39:12 +00:00
parent d6f7096055
commit 379e1a4a7e
11 changed files with 98 additions and 58 deletions

View File

@ -7,8 +7,8 @@ class BadgeWidget extends StatelessWidget {
double iconSize = 26.0;
Widget badgeIcon;
String onBadgeTextValue;
Color iconColor = HAClientTheme().badgeColors[entityModel.entityWrapper.entity.domain] ??
HAClientTheme().badgeColors["default"];
Color iconColor = HAClientTheme.badgeColors[entityModel.entityWrapper.entity.domain] ??
HAClientTheme.badgeColors["default"];
switch (entityModel.entityWrapper.entity.domain) {
case "sun":
{

View File

@ -67,7 +67,7 @@ class EntityIcon extends StatelessWidget {
padding: padding,
child: buildIcon(
entityWrapper,
color ?? HAClientTheme().stateColor(entityWrapper.entity.state)
color ?? HAClientTheme().getColorByEntityState(entityWrapper.entity.state, context)
),
);
}

View File

@ -22,7 +22,7 @@ class EntityPicture extends StatelessWidget {
}
}
Widget buildIcon(EntityWrapper data) {
Widget buildIcon(EntityWrapper data, BuildContext context) {
if (data == null) {
return null;
}
@ -39,7 +39,7 @@ class EntityPicture extends StatelessWidget {
child: Icon(
IconData(iconCode, fontFamily: 'Material Design Icons'),
size: Sizes.largeIconSize,
color: HAClientTheme().defaultStateColor,
color: HAClientTheme().getOffStateColor(context),
)
)
);
@ -63,7 +63,8 @@ class EntityPicture extends StatelessWidget {
return Padding(
padding: padding,
child: buildIcon(
entityWrapper
entityWrapper,
context
),
);
}

View File

@ -33,7 +33,7 @@ class _MediaPlayerProgressBarState extends State<MediaPlayerProgressBar> {
return LinearProgressIndicator(
value: progress,
backgroundColor: Colors.black45,
valueColor: AlwaysStoppedAnimation<Color>(HAClientTheme().stateColor(EntityState.on)),
valueColor: AlwaysStoppedAnimation<Color>(HAClientTheme().getOnStateColor(context)),
);
}

View File

@ -12,7 +12,7 @@ class MediaPlayerWidget extends StatelessWidget {
Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
_buildImage(entity),
_buildImage(entity, context),
Positioned(
bottom: 0.0,
left: 0.0,
@ -68,7 +68,7 @@ class MediaPlayerWidget extends StatelessWidget {
);
}
Widget _buildImage(MediaPlayerEntity entity) {
Widget _buildImage(MediaPlayerEntity entity, BuildContext context) {
String state = entity.state;
if (entity.entityPicture != null && state != EntityState.off && state != EntityState.unavailable && state != EntityState.idle) {
return Container(
@ -94,7 +94,7 @@ class MediaPlayerWidget extends StatelessWidget {
Icon(
MaterialDesignIcons.getIconDataFromIconName("mdi:movie"),
size: 150.0,
color: HAClientTheme().stateColor("$state"),
color: HAClientTheme().getColorByEntityState("$state", context),
)
],
);