Entity class refactoring
This commit is contained in:
		@@ -211,60 +211,6 @@ class Entity {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Widget buildEntityPageWidget(BuildContext context, {bool showClose: false}) {
 | 
			
		||||
    return EntityModel(
 | 
			
		||||
      entityWrapper: EntityWrapper(entity: this),
 | 
			
		||||
      child: ListView(
 | 
			
		||||
        padding: EdgeInsets.all(0),
 | 
			
		||||
          children: <Widget>[
 | 
			
		||||
            showClose ?
 | 
			
		||||
              Container(
 | 
			
		||||
                color: Colors.blue[300],
 | 
			
		||||
                height: 36,
 | 
			
		||||
                child: Row(
 | 
			
		||||
                  children: <Widget>[
 | 
			
		||||
                    Expanded(
 | 
			
		||||
                      child: Padding(
 | 
			
		||||
                        padding: EdgeInsets.only(left: 8),
 | 
			
		||||
                        child: Text(
 | 
			
		||||
                          this.displayName,
 | 
			
		||||
                          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: _buildStatePartForPage(context)),
 | 
			
		||||
            ),
 | 
			
		||||
            LastUpdatedWidget(),
 | 
			
		||||
            Divider(),
 | 
			
		||||
            _buildAdditionalControlsForPage(context),
 | 
			
		||||
            Divider(),
 | 
			
		||||
            buildHistoryWidget(),
 | 
			
		||||
            EntityAttributesList()
 | 
			
		||||
        ]
 | 
			
		||||
      ),
 | 
			
		||||
      handleTap: false,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Widget buildHistoryWidget() {
 | 
			
		||||
    return EntityHistoryWidget(
 | 
			
		||||
      config: historyConfig,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										64
									
								
								lib/entities/entity_page_layout.widget.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								lib/entities/entity_page_layout.widget.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
part of '../main.dart';
 | 
			
		||||
 | 
			
		||||
class EntityPageLayout extends StatelessWidget {
 | 
			
		||||
 | 
			
		||||
  final bool showClose;
 | 
			
		||||
  final Entity entity;
 | 
			
		||||
 | 
			
		||||
  const EntityPageLayout({Key key, @required this.entity, this.showClose: false}) : super(key: key);
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return EntityModel(
 | 
			
		||||
      entityWrapper: EntityWrapper(entity: this.entity),
 | 
			
		||||
      child: ListView(
 | 
			
		||||
          padding: EdgeInsets.all(0),
 | 
			
		||||
          children: <Widget>[
 | 
			
		||||
            showClose ?
 | 
			
		||||
            Container(
 | 
			
		||||
              color: Colors.blue[300],
 | 
			
		||||
              height: 36,
 | 
			
		||||
              child: Row(
 | 
			
		||||
                children: <Widget>[
 | 
			
		||||
                  Expanded(
 | 
			
		||||
                    child: Padding(
 | 
			
		||||
                      padding: EdgeInsets.only(left: 8),
 | 
			
		||||
                      child: Text(
 | 
			
		||||
                        this.entity.displayName,
 | 
			
		||||
                        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: this.entity._buildStatePartForPage(context)),
 | 
			
		||||
            ),
 | 
			
		||||
            LastUpdatedWidget(),
 | 
			
		||||
            Divider(),
 | 
			
		||||
            this.entity._buildAdditionalControlsForPage(context),
 | 
			
		||||
            Divider(),
 | 
			
		||||
            this.entity.buildHistoryWidget(),
 | 
			
		||||
            EntityAttributesList()
 | 
			
		||||
          ]
 | 
			
		||||
      ),
 | 
			
		||||
      handleTap: false,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -124,6 +124,7 @@ part 'types/event_bus_events.dart';
 | 
			
		||||
part 'cards/widgets/gauge_card_body.dart';
 | 
			
		||||
part 'cards/widgets/light_card_body.dart';
 | 
			
		||||
part 'pages/play_media.page.dart';
 | 
			
		||||
part 'entities/entity_page_layout.widget.dart';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EventBus eventBus = new EventBus();
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ class _EntityViewPageState extends State<EntityViewPage> {
 | 
			
		||||
      }
 | 
			
		||||
      body = PageLoadingIndicator();
 | 
			
		||||
    } else {
 | 
			
		||||
      body = entity.buildEntityPageWidget(context);
 | 
			
		||||
      body = EntityPageLayout(entity: entity);
 | 
			
		||||
    }
 | 
			
		||||
    return new Scaffold(
 | 
			
		||||
      appBar: new AppBar(
 | 
			
		||||
 
 | 
			
		||||
@@ -697,7 +697,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
 | 
			
		||||
            ),
 | 
			
		||||
            ConstrainedBox(
 | 
			
		||||
              constraints: BoxConstraints.tightFor(width: Sizes.entityPageMaxWidth),
 | 
			
		||||
              child: entity.buildEntityPageWidget(context, showClose: true),
 | 
			
		||||
              child: EntityPageLayout(entity: entity, showClose: true,),
 | 
			
		||||
            )
 | 
			
		||||
          ],
 | 
			
		||||
        );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user