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_page_layout.widget.dart

79 lines
2.4 KiB
Dart
Raw Normal View History

2019-09-14 19:07:21 +03:00
part of '../main.dart';
class EntityPageLayout extends StatefulWidget {
2019-09-14 19:07:21 +03:00
final bool showClose;
final Entity entity;
EntityPageLayout({Key key, this.showClose: false, this.entity}) : super(key: key);
@override
_EntityPageLayoutState createState() => _EntityPageLayoutState();
}
class _EntityPageLayoutState extends State<EntityPageLayout> {
bool _historyExpanded = false;
bool _attributesExpanded = false;
2019-09-14 19:07:21 +03:00
@override
Widget build(BuildContext context) {
return EntityModel(
entityWrapper: EntityWrapper(entity: widget.entity),
2019-09-14 19:07:21 +03:00
child: ListView(
padding: EdgeInsets.all(0),
children: <Widget>[
widget.showClose ?
2019-09-14 19:07:21 +03:00
Container(
color: Colors.blue[300],
height: 36,
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 8),
child: Text(
widget.entity.displayName,
2019-09-14 19:07:21 +03:00
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 22
),
),
),
),
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.close),
color: Colors.white,
iconSize: 30.0,
onPressed: () {
eventBus.fire(ShowEntityPageEvent());
},
)
],
),
) :
Container(height: 0, width: 0,),
Padding(
padding: EdgeInsets.only(top: Sizes.rowPadding, left: Sizes.leftWidgetPadding),
child: DefaultEntityContainer(state: widget.entity._buildStatePartForPage(context)),
2019-09-14 19:07:21 +03:00
),
LastUpdatedWidget(),
Divider(),
widget.entity._buildAdditionalControlsForPage(context),
2019-09-14 19:07:21 +03:00
Divider(),
SpoilerCard(
title: "State history",
body: EntityHistoryWidget(),
),
SpoilerCard(
title: "Attributes",
body: EntityAttributesList(),
),
2019-09-14 19:07:21 +03:00
]
),
handleTap: false,
);
}
}