Resolves #163 Location title

This commit is contained in:
Yegor Vialov
2018-11-04 21:02:12 +02:00
parent 04d8681656
commit bb17885b4a
2 changed files with 10 additions and 3 deletions

View File

@ -40,7 +40,13 @@ class HomeAssistant {
Duration fetchTimeout = Duration(seconds: 30);
Duration connectTimeout = Duration(seconds: 15);
String get locationName => _instanceConfig["location_name"] ?? "";
String get locationName {
if (_useLovelace) {
return ui?.title ?? "";
} else {
return _instanceConfig["location_name"] ?? "";
}
}
String get userName => _userName ?? locationName;
String get userAvatarText => userName.length > 0 ? userName[0] : "";
//int get viewsCount => entities.views.length ?? 0;
@ -376,8 +382,8 @@ class HomeAssistant {
}
void _parseLovelace() {
ui = HomeAssistantUI();
TheLogger.debug("--Title: ${_rawLovelaceData["title"]}");
ui.title = _rawLovelaceData["title"];
int viewCounter = 0;
TheLogger.debug("--Views count: ${_rawLovelaceData['views'].length}");
_rawLovelaceData["views"].forEach((rawView){
@ -437,12 +443,12 @@ class HomeAssistant {
}
void _createUI() {
ui = HomeAssistantUI();
if ((_useLovelace) && (_rawLovelaceData != null)) {
TheLogger.debug("Creating Lovelace UI");
_parseLovelace();
} else {
TheLogger.debug("Creating group-based UI");
ui = HomeAssistantUI();
int viewCounter = 0;
if (!entities.hasDefaultView) {
HAView view = HAView(

View File

@ -2,6 +2,7 @@ part of '../main.dart';
class HomeAssistantUI {
List<HAView> views;
String title;
HomeAssistantUI() {
views = [];