Minor code cleaning
This commit is contained in:
@ -250,7 +250,7 @@ class HassioDataModel {
|
|||||||
}
|
}
|
||||||
List data = response["result"];
|
List data = response["result"];
|
||||||
TheLogger.log("Debug","Parsing ${data.length} Home Assistant entities");
|
TheLogger.log("Debug","Parsing ${data.length} Home Assistant entities");
|
||||||
List<String> uiGroups = [];
|
List<String> viewsList = [];
|
||||||
data.forEach((entity) {
|
data.forEach((entity) {
|
||||||
try {
|
try {
|
||||||
var composedEntity = _parseEntity(entity);
|
var composedEntity = _parseEntity(entity);
|
||||||
@ -258,7 +258,7 @@ class HassioDataModel {
|
|||||||
if (composedEntity["attributes"] != null) {
|
if (composedEntity["attributes"] != null) {
|
||||||
if ((composedEntity["domain"] == "group") &&
|
if ((composedEntity["domain"] == "group") &&
|
||||||
(composedEntity["attributes"]["view"] == true)) {
|
(composedEntity["attributes"]["view"] == true)) {
|
||||||
uiGroups.add(composedEntity["entity_id"]);
|
viewsList.add(composedEntity["entity_id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_entitiesData[entity["entity_id"]] = composedEntity;
|
_entitiesData[entity["entity_id"]] = composedEntity;
|
||||||
@ -270,7 +270,7 @@ class HassioDataModel {
|
|||||||
//Gethering information for UI
|
//Gethering information for UI
|
||||||
TheLogger.log("Debug","Gethering views");
|
TheLogger.log("Debug","Gethering views");
|
||||||
int viewCounter = 0;
|
int viewCounter = 0;
|
||||||
uiGroups.forEach((viewId) { //Each view
|
viewsList.forEach((viewId) { //Each view
|
||||||
try {
|
try {
|
||||||
Map viewStructure = {};
|
Map viewStructure = {};
|
||||||
viewCounter += 1;
|
viewCounter += 1;
|
||||||
|
@ -242,8 +242,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
spacing: 10.0,
|
spacing: 10.0,
|
||||||
runSpacing: 4.0,
|
runSpacing: 4.0,
|
||||||
//padding: new EdgeInsets.all(8.0),
|
|
||||||
//itemExtent: 40.0,
|
|
||||||
children: _buildBadges(structure["badges"]["children"]),
|
children: _buildBadges(structure["badges"]["children"]),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -639,57 +637,44 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
Scaffold _buildScaffold(bool empty) {
|
||||||
|
return Scaffold(
|
||||||
|
key: _scaffoldKey,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: _buildAppTitle(),
|
||||||
|
bottom: empty ? null : TabBar(tabs: buildUIViewTabs()),
|
||||||
|
),
|
||||||
|
drawer: _buildAppDrawer(),
|
||||||
|
body: empty ?
|
||||||
|
Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
MaterialDesignIcons.createIconDataFromIconName("mdi:home-assistant"),
|
||||||
|
size: 100.0,
|
||||||
|
color: _errorCodeToBeShown == 0 ? Colors.blue : Colors.redAccent,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
:
|
||||||
|
TabBarView(
|
||||||
|
children: _buildViews()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_checkShowInfo(context);
|
_checkShowInfo(context);
|
||||||
// This method is rerun every time setState is called.
|
// This method is rerun every time setState is called.
|
||||||
//
|
|
||||||
if (_entitiesData == null) {
|
if (_entitiesData == null) {
|
||||||
return new Scaffold(
|
return _buildScaffold(true);
|
||||||
key: _scaffoldKey,
|
|
||||||
appBar: new AppBar(
|
|
||||||
title: _buildAppTitle()
|
|
||||||
),
|
|
||||||
drawer: _buildAppDrawer(),
|
|
||||||
body: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
/*Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 10.0),
|
|
||||||
child: Text(
|
|
||||||
_fetchErrorCode > 0 ? "Well... no.\n\nThere was an error [$_fetchErrorCode]: ${_getErrorMessageByCode(_fetchErrorCode, false)}" : "Loading...",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 16.0),
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
Icon(
|
|
||||||
MaterialDesignIcons.createIconDataFromIconName("mdi:home-assistant"),
|
|
||||||
size: 100.0,
|
|
||||||
color: _errorCodeToBeShown == 0 ? Colors.blue : Colors.redAccent,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: _uiViewsCount,
|
length: _uiViewsCount,
|
||||||
child: new Scaffold(
|
child: _buildScaffold(false)
|
||||||
key: _scaffoldKey,
|
|
||||||
appBar: new AppBar(
|
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
|
||||||
// the App.build method, and use it to set our appbar title.
|
|
||||||
title: _buildAppTitle(),
|
|
||||||
bottom: TabBar(
|
|
||||||
tabs: buildUIViewTabs()
|
|
||||||
),
|
|
||||||
),
|
|
||||||
drawer: _buildAppDrawer(),
|
|
||||||
body: TabBarView(
|
|
||||||
children: _buildViews()
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user