Hide entity history and attributes under expandepble card

This commit is contained in:
estevez-dev 2019-09-14 19:37:52 +03:00
parent 78dd7df686
commit a65f42d0fd
4 changed files with 71 additions and 11 deletions

View File

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

View File

@ -25,7 +25,8 @@ import 'package:in_app_purchase/in_app_purchase.dart';
import 'plugins/circular_slider/single_circular_slider.dart'; import 'plugins/circular_slider/single_circular_slider.dart';
import 'package:share/receive_share_state.dart'; import 'package:share/receive_share_state.dart';
import 'package:share/share.dart'; import 'package:share/share.dart';
import 'plugins/DynamicMultiColumnLayout.dart'; import 'plugins/dynamic_multi_column_layout.dart';
import 'plugins/spoiler_card.dart';
import 'utils/logger.dart'; import 'utils/logger.dart';

View File

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
class SpoilerCard extends StatefulWidget {
final String title;
final Widget body;
final bool isExpanded;
SpoilerCard({Key key, @required this.title, @required this.body, this.isExpanded: false}) : super(key: key);
@override
_SpoilerCardState createState() => _SpoilerCardState();
}
class _SpoilerCardState extends State<SpoilerCard> {
bool _expanded;
@override
void initState() {
super.initState();
_expanded = widget.isExpanded;
}
@override
Widget build(BuildContext context) {
return Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
title: Text("${widget.title}"),
trailing: Icon(
_expanded ? Icons.arrow_drop_up : Icons.arrow_drop_down,
size: 20,
),
onTap: () => setState((){_expanded = !_expanded;}),
),
_expanded ? widget.body : Container(height: 0,)
],
),
);
}
}