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