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/entity_widgets/glance_entity_container.dart

54 lines
1.5 KiB
Dart
Raw Normal View History

2018-11-14 19:52:17 +02:00
part of '../main.dart';
class GlanceEntityContainer extends StatelessWidget {
2018-11-15 19:08:47 +02:00
final bool showName;
final bool showState;
2018-11-14 19:52:17 +02:00
GlanceEntityContainer({
2018-11-15 19:08:47 +02:00
Key key, @required this.showName, @required this.showState,
2018-11-14 19:52:17 +02:00
}) : super(key: key);
@override
Widget build(BuildContext context) {
2018-11-24 00:37:55 +02:00
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
2018-11-15 19:08:47 +02:00
List<Widget> result = [];
if (showName) {
result.add(EntityName(
padding: EdgeInsets.only(bottom: Sizes.rowPadding),
textOverflow: TextOverflow.ellipsis,
wordsWrap: false,
textAlign: TextAlign.center,
fontSize: Sizes.smallFontSize,
));
}
2018-11-24 00:37:55 +02:00
result.add(
EntityIcon(
padding: EdgeInsets.all(0.0),
iconSize: Sizes.iconSize,
)
);
2018-11-15 19:08:47 +02:00
if (showState) {
result.add(SimpleEntityState(
textAlign: TextAlign.center,
expanded: false,
padding: EdgeInsets.only(top: Sizes.rowPadding),
));
}
2018-11-24 00:37:55 +02:00
return Center(
2018-11-24 11:02:28 +02:00
child: InkResponse(
2018-11-24 00:37:55 +02:00
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: Sizes.iconSize*2),
child: Column(
mainAxisSize: MainAxisSize.min,
//mainAxisAlignment: MainAxisAlignment.start,
//crossAxisAlignment: CrossAxisAlignment.center,
children: result,
),
),
onTap: () => entityWrapper.handleTap(),
onLongPress: () => entityWrapper.handleHold(),
),
2018-11-14 19:52:17 +02:00
);
}
}