This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/entities/entity_name.widget.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

2018-10-27 14:27:41 +03:00
part of '../main.dart';
class EntityName extends StatelessWidget {
2018-11-14 19:52:17 +02:00
final EdgeInsetsGeometry padding;
2018-11-15 16:13:54 +02:00
final TextOverflow textOverflow;
final bool wordsWrap;
final TextAlign textAlign;
2018-11-25 20:44:19 +02:00
final int maxLines;
final TextStyle textStyle;
2018-11-14 19:52:17 +02:00
const EntityName({Key key, this.maxLines, this.padding: const EdgeInsets.only(right: 10.0), this.textOverflow: TextOverflow.ellipsis, this.textStyle, this.wordsWrap: true, this.textAlign: TextAlign.left}) : super(key: key);
2018-11-14 19:52:17 +02:00
2018-10-27 14:27:41 +03:00
@override
Widget build(BuildContext context) {
2018-11-24 00:37:55 +02:00
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
TextStyle tStyle;
if (textStyle == null) {
if (entityWrapper.entity.statelessType == StatelessEntityType.WEBLINK) {
2020-04-07 00:39:16 +03:00
tStyle = HAClientTheme().getLinkTextStyle(context);
} else {
tStyle = Theme.of(context).textTheme.body1;
}
2019-03-13 14:08:54 +02:00
}
2018-11-24 00:37:55 +02:00
return Padding(
padding: padding,
child: Text(
"${entityWrapper.displayName}",
overflow: textOverflow,
softWrap: wordsWrap,
2018-11-25 20:44:19 +02:00
maxLines: maxLines,
style: tStyle,
2018-11-24 00:37:55 +02:00
textAlign: textAlign,
2018-10-27 14:27:41 +03:00
),
);
}
}