Some refactoring

This commit is contained in:
estevez-dev 2019-09-14 19:53:39 +03:00
parent a65f42d0fd
commit c37313cf07
2 changed files with 6 additions and 16 deletions

View File

@ -1,29 +1,20 @@
part of '../main.dart'; part of '../main.dart';
class EntityPageLayout extends StatefulWidget { class EntityPageLayout extends StatelessWidget {
final bool showClose; final bool showClose;
final Entity entity; final Entity entity;
EntityPageLayout({Key key, this.showClose: false, this.entity}) : super(key: key); 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;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EntityModel( return EntityModel(
entityWrapper: EntityWrapper(entity: widget.entity), entityWrapper: EntityWrapper(entity: entity),
child: ListView( child: ListView(
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
children: <Widget>[ children: <Widget>[
widget.showClose ? showClose ?
Container( Container(
color: Colors.blue[300], color: Colors.blue[300],
height: 36, height: 36,
@ -33,7 +24,7 @@ class _EntityPageLayoutState extends State<EntityPageLayout> {
child: Padding( child: Padding(
padding: EdgeInsets.only(left: 8), padding: EdgeInsets.only(left: 8),
child: Text( child: Text(
widget.entity.displayName, entity.displayName,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.white, color: Colors.white,
@ -57,11 +48,11 @@ class _EntityPageLayoutState extends State<EntityPageLayout> {
Container(height: 0, width: 0,), Container(height: 0, width: 0,),
Padding( Padding(
padding: EdgeInsets.only(top: Sizes.rowPadding, left: Sizes.leftWidgetPadding), padding: EdgeInsets.only(top: Sizes.rowPadding, left: Sizes.leftWidgetPadding),
child: DefaultEntityContainer(state: widget.entity._buildStatePartForPage(context)), child: DefaultEntityContainer(state: entity._buildStatePartForPage(context)),
), ),
LastUpdatedWidget(), LastUpdatedWidget(),
Divider(), Divider(),
widget.entity._buildAdditionalControlsForPage(context), entity._buildAdditionalControlsForPage(context),
Divider(), Divider(),
SpoilerCard( SpoilerCard(
title: "State history", title: "State history",

View File

@ -127,7 +127,6 @@ part 'cards/widgets/light_card_body.dart';
part 'pages/play_media.page.dart'; part 'pages/play_media.page.dart';
part 'entities/entity_page_layout.widget.dart'; part 'entities/entity_page_layout.widget.dart';
EventBus eventBus = new EventBus(); EventBus eventBus = new EventBus();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();