38 lines
777 B
Dart
38 lines
777 B
Dart
|
part of '../main.dart';
|
||
|
|
||
|
class Panel {
|
||
|
|
||
|
static const iconsByComponent = {
|
||
|
"config": "mdi:settings",
|
||
|
"history": "mdi:poll-box",
|
||
|
"map": "mdi:tooltip-account",
|
||
|
"logbook": "mdi:format-list-bulleted-type",
|
||
|
"custom": "mdi:home-assistant"
|
||
|
};
|
||
|
|
||
|
final String id;
|
||
|
final String type;
|
||
|
final String title;
|
||
|
final String urlPath;
|
||
|
final Map config;
|
||
|
String icon;
|
||
|
|
||
|
Panel({this.id, this.type, this.title, this.urlPath, this.icon, this.config}) {
|
||
|
if (icon == null || !icon.startsWith("mdi:")) {
|
||
|
icon = Panel.iconsByComponent[type];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Widget getWidget() {
|
||
|
switch (type) {
|
||
|
case "config": {
|
||
|
return ConfigPanelWidget();
|
||
|
}
|
||
|
|
||
|
default: {
|
||
|
return Text("Unsupported panel component: $type");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|