Add icon support for entities card title
This commit is contained in:
parent
02bfaf7db6
commit
05c1427aa8
@ -7,6 +7,7 @@ class HACard {
|
|||||||
String name;
|
String name;
|
||||||
String id;
|
String id;
|
||||||
String type;
|
String type;
|
||||||
|
String icon;
|
||||||
bool showName;
|
bool showName;
|
||||||
bool showState;
|
bool showState;
|
||||||
bool showEmpty;
|
bool showEmpty;
|
||||||
@ -40,6 +41,7 @@ class HACard {
|
|||||||
this.max,
|
this.max,
|
||||||
this.depth: 1,
|
this.depth: 1,
|
||||||
this.severity,
|
this.severity,
|
||||||
|
this.icon,
|
||||||
@required this.type
|
@required this.type
|
||||||
}) {
|
}) {
|
||||||
if (this.columnsCount <= 0) {
|
if (this.columnsCount <= 0) {
|
||||||
|
@ -37,7 +37,12 @@ class EntitiesCard extends StatelessWidget {
|
|||||||
CardHeader(
|
CardHeader(
|
||||||
name: card.name,
|
name: card.name,
|
||||||
trailing: headerSwitch,
|
trailing: headerSwitch,
|
||||||
emptyPadding: Sizes.rowPadding
|
emptyPadding: Sizes.rowPadding,
|
||||||
|
leading: card.icon != null ? Icon(
|
||||||
|
MaterialDesignIcons.getIconDataFromIconName(card.icon),
|
||||||
|
size: Sizes.iconSize,
|
||||||
|
color: Theme.of(context).textTheme.headline.color
|
||||||
|
) : null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
body.addAll(
|
body.addAll(
|
||||||
|
@ -4,10 +4,11 @@ class CardHeader extends StatelessWidget {
|
|||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final Widget trailing;
|
final Widget trailing;
|
||||||
|
final Widget leading;
|
||||||
final Widget subtitle;
|
final Widget subtitle;
|
||||||
final double emptyPadding;
|
final double emptyPadding;
|
||||||
|
|
||||||
const CardHeader({Key key, this.name, this.emptyPadding: 0, this.trailing, this.subtitle}) : super(key: key);
|
const CardHeader({Key key, this.name, this.leading, this.emptyPadding: 0, this.trailing, this.subtitle}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -15,6 +16,7 @@ class CardHeader extends StatelessWidget {
|
|||||||
if ((name != null) && (name.trim().length > 0)) {
|
if ((name != null) && (name.trim().length > 0)) {
|
||||||
result = new ListTile(
|
result = new ListTile(
|
||||||
trailing: trailing,
|
trailing: trailing,
|
||||||
|
leading: leading,
|
||||||
subtitle: subtitle,
|
subtitle: subtitle,
|
||||||
title: Text("$name",
|
title: Text("$name",
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
|
@ -46,6 +46,7 @@ class HAView {
|
|||||||
id: "card",
|
id: "card",
|
||||||
name: rawCardInfo["title"] ?? rawCardInfo["name"],
|
name: rawCardInfo["title"] ?? rawCardInfo["name"],
|
||||||
type: rawCardInfo['type'] ?? CardType.ENTITIES,
|
type: rawCardInfo['type'] ?? CardType.ENTITIES,
|
||||||
|
icon: rawCardInfo['icon'],
|
||||||
columnsCount: rawCardInfo['columns'] ?? 4,
|
columnsCount: rawCardInfo['columns'] ?? 4,
|
||||||
showName: (rawCardInfo['show_name'] ?? rawCard['show_name']) ?? true,
|
showName: (rawCardInfo['show_name'] ?? rawCard['show_name']) ?? true,
|
||||||
showHeaderToggle: (rawCardInfo['show_header_toggle'] ?? rawCard['show_header_toggle']) ?? false,
|
showHeaderToggle: (rawCardInfo['show_header_toggle'] ?? rawCard['show_header_toggle']) ?? false,
|
||||||
|
Reference in New Issue
Block a user