WIP #102 Moving all colors to theme
This commit is contained in:
parent
524d195800
commit
007d12719c
@ -7,8 +7,7 @@ class BadgeWidget extends StatelessWidget {
|
|||||||
double iconSize = 26.0;
|
double iconSize = 26.0;
|
||||||
Widget badgeIcon;
|
Widget badgeIcon;
|
||||||
String onBadgeTextValue;
|
String onBadgeTextValue;
|
||||||
Color iconColor = HAClientTheme.badgeColors[entityModel.entityWrapper.entity.domain] ??
|
Color iconColor = HAClientTheme().getBadgeColor(entityModel.entityWrapper.entity.domain);
|
||||||
HAClientTheme.badgeColors["default"];
|
|
||||||
switch (entityModel.entityWrapper.entity.domain) {
|
switch (entityModel.entityWrapper.entity.domain) {
|
||||||
case "sun":
|
case "sun":
|
||||||
{
|
{
|
||||||
@ -80,7 +79,7 @@ class BadgeWidget extends StatelessWidget {
|
|||||||
padding: EdgeInsets.fromLTRB(6.0, 2.0, 6.0, 2.0),
|
padding: EdgeInsets.fromLTRB(6.0, 2.0, 6.0, 2.0),
|
||||||
child: Text("$onBadgeTextValue",
|
child: Text("$onBadgeTextValue",
|
||||||
style: Theme.of(context).textTheme.overline.copyWith(
|
style: Theme.of(context).textTheme.overline.copyWith(
|
||||||
color: Colors.white
|
color: HAClientTheme().getOnBadgeTextColor()
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
|
@ -151,7 +151,7 @@ class _CameraStreamViewState extends State<CameraStreamView> {
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon((_videoPlayerController != null && _videoPlayerController.value.isPlaying) ? Icons.pause_circle_outline : Icons.play_circle_outline),
|
icon: Icon((_videoPlayerController != null && _videoPlayerController.value.isPlaying) ? Icons.pause_circle_outline : Icons.play_circle_outline),
|
||||||
iconSize: 60,
|
iconSize: 60,
|
||||||
color: Colors.amberAccent,
|
color: Theme.of(context).accentColor,
|
||||||
onPressed: (_videoPlayerController == null || _videoPlayerController.value.hasError || !_isLoaded) ? null :
|
onPressed: (_videoPlayerController == null || _videoPlayerController.value.hasError || !_isLoaded) ? null :
|
||||||
() {
|
() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -175,7 +175,7 @@ class _CameraStreamViewState extends State<CameraStreamView> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.refresh),
|
icon: Icon(Icons.refresh),
|
||||||
iconSize: 40,
|
iconSize: 40,
|
||||||
color: Colors.amberAccent,
|
color: Theme.of(context).accentColor,
|
||||||
onPressed: _isLoaded ? () {
|
onPressed: _isLoaded ? () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoaded = false;
|
_isLoaded = false;
|
||||||
@ -188,7 +188,7 @@ class _CameraStreamViewState extends State<CameraStreamView> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.fullscreen),
|
icon: Icon(Icons.fullscreen),
|
||||||
iconSize: 40,
|
iconSize: 40,
|
||||||
color: Colors.amberAccent,
|
color: Theme.of(context).accentColor,
|
||||||
onPressed: _isLoaded ? () {
|
onPressed: _isLoaded ? () {
|
||||||
_videoPlayerController?.pause();
|
_videoPlayerController?.pause();
|
||||||
eventBus.fire(ShowEntityPageEvent());
|
eventBus.fire(ShowEntityPageEvent());
|
||||||
|
@ -15,22 +15,18 @@ class DefaultEntityContainer extends StatelessWidget {
|
|||||||
return MissedEntityWidget();
|
return MissedEntityWidget();
|
||||||
}
|
}
|
||||||
if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.DIVIDER) {
|
if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.DIVIDER) {
|
||||||
return Divider(
|
return Divider();
|
||||||
color: Colors.black45,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.SECTION) {
|
if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.SECTION) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Divider(
|
Divider(),
|
||||||
color: Colors.black45,
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
"${entityModel.entityWrapper.entity.displayName}",
|
"${entityModel.entityWrapper.entity.displayName}",
|
||||||
style: Theme.of(context).textTheme.body1.copyWith(
|
style: Theme.of(context).textTheme.body1.copyWith(
|
||||||
color: Colors.blue
|
color: Theme.of(context).primaryColor
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -16,9 +16,10 @@ class EntityName extends StatelessWidget {
|
|||||||
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
||||||
TextStyle tStyle;
|
TextStyle tStyle;
|
||||||
if (textStyle == null) {
|
if (textStyle == null) {
|
||||||
tStyle = Theme.of(context).textTheme.body1;
|
|
||||||
if (entityWrapper.entity.statelessType == StatelessEntityType.WEBLINK) {
|
if (entityWrapper.entity.statelessType == StatelessEntityType.WEBLINK) {
|
||||||
tStyle = tStyle.apply(color: Colors.blue, decoration: TextDecoration.underline);
|
tStyle = HAClientTheme().getLinkTextStyle(context);
|
||||||
|
} else {
|
||||||
|
tStyle = Theme.of(context).textTheme.body1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Padding(
|
return Padding(
|
||||||
|
@ -16,7 +16,7 @@ class EntityPageLayout extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
showClose ?
|
showClose ?
|
||||||
Container(
|
Container(
|
||||||
color: Theme.of(context).primaryColorLight,
|
color: Theme.of(context).primaryColor,
|
||||||
height: 40,
|
height: 40,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -25,16 +25,14 @@ class EntityPageLayout extends StatelessWidget {
|
|||||||
padding: EdgeInsets.only(left: 8),
|
padding: EdgeInsets.only(left: 8),
|
||||||
child: Text(
|
child: Text(
|
||||||
entity.displayName,
|
entity.displayName,
|
||||||
style: Theme.of(context).textTheme.headline.copyWith(
|
style: Theme.of(context).primaryTextTheme.headline
|
||||||
color: Colors.white
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
icon: Icon(Icons.close),
|
icon: Icon(Icons.close),
|
||||||
color: Colors.white,
|
color: Theme.of(context).primaryTextTheme.headline.color,
|
||||||
iconSize: 36.0,
|
iconSize: 36.0,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
eventBus.fire(ShowEntityPageEvent());
|
eventBus.fire(ShowEntityPageEvent());
|
||||||
|
@ -30,9 +30,7 @@ class FlatServiceButton extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: Theme.of(context).textTheme.subhead.copyWith(
|
style: HAClientTheme().getActionTextStyle(context),
|
||||||
color: Colors.blue
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -224,7 +224,7 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
color: savedColor?.toColor() ?? Colors.transparent,
|
color: savedColor?.toColor() ?? Theme.of(context).backgroundColor,
|
||||||
child: Text('Paste color'),
|
child: Text('Paste color'),
|
||||||
onPressed: savedColor == null ? null : () {
|
onPressed: savedColor == null ? null : () {
|
||||||
_setColor(entity, savedColor);
|
_setColor(entity, savedColor);
|
||||||
|
@ -28,9 +28,7 @@ class LockStateWidget extends StatelessWidget {
|
|||||||
onPressed: () => _unlock(entity),
|
onPressed: () => _unlock(entity),
|
||||||
child: Text("UNLOCK",
|
child: Text("UNLOCK",
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: Theme.of(context).textTheme.subhead.copyWith(
|
style: HAClientTheme().getActionTextStyle(context)
|
||||||
color: Colors.blue
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -40,9 +38,7 @@ class LockStateWidget extends StatelessWidget {
|
|||||||
onPressed: () => _lock(entity),
|
onPressed: () => _lock(entity),
|
||||||
child: Text("LOCK",
|
child: Text("LOCK",
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: Theme.of(context).textTheme.subhead.copyWith(
|
style: HAClientTheme().getActionTextStyle(context),
|
||||||
color: Colors.blue
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -58,9 +54,7 @@ class LockStateWidget extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
entity.isLocked ? "UNLOCK" : "LOCK",
|
entity.isLocked ? "UNLOCK" : "LOCK",
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: Theme.of(context).textTheme.subhead.copyWith(
|
style: HAClientTheme().getActionTextStyle(context),
|
||||||
color: Colors.blue
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -47,8 +47,7 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
|||||||
buttons.add(
|
buttons.add(
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
child: Text("Jump to ${Duration(seconds: _savedPosition).toString().split('.')[0]}"),
|
child: Text("Jump to ${Duration(seconds: _savedPosition).toString().split('.')[0]}"),
|
||||||
color: Colors.orange,
|
color: Theme.of(context).accentColor,
|
||||||
focusColor: Colors.white,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ConnectionManager().callService(
|
ConnectionManager().callService(
|
||||||
domain: "media_player",
|
domain: "media_player",
|
||||||
@ -87,8 +86,7 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
|||||||
Container(height: 10,),
|
Container(height: 10,),
|
||||||
Slider(
|
Slider(
|
||||||
min: 0,
|
min: 0,
|
||||||
activeColor: Colors.amber,
|
activeColor: Theme.of(context).accentColor,
|
||||||
inactiveColor: Colors.black26,
|
|
||||||
max: entity.durationSeconds.toDouble(),
|
max: entity.durationSeconds.toDouble(),
|
||||||
value: _currentPosition,
|
value: _currentPosition,
|
||||||
onChangeStart: (val) {
|
onChangeStart: (val) {
|
||||||
|
@ -154,6 +154,30 @@ class HAClientTheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextStyle getLinkTextStyle(BuildContext context) {
|
||||||
|
ThemeData theme = Theme.of(context);
|
||||||
|
return theme.textTheme.body1.copyWith(
|
||||||
|
color: Colors.blue,
|
||||||
|
decoration: TextDecoration.underline
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextStyle getActionTextStyle(BuildContext context) {
|
||||||
|
ThemeData theme = Theme.of(context);
|
||||||
|
return theme.textTheme.subhead.copyWith(
|
||||||
|
color: Colors.blue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getBadgeColor(String entityDomain) {
|
||||||
|
return badgeColors[entityDomain] ??
|
||||||
|
badgeColors["default"];
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getOnBadgeTextColor() {
|
||||||
|
return Colors.white;
|
||||||
|
}
|
||||||
|
|
||||||
charts.Color chartHistoryStateColor(String state, int id, BuildContext context) {
|
charts.Color chartHistoryStateColor(String state, int id, BuildContext context) {
|
||||||
Color c = getColorByEntityState(state, context);
|
Color c = getColorByEntityState(state, context);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
|
Reference in New Issue
Block a user