Hide entity history and attributes under expandepble card
This commit is contained in:
parent
78dd7df686
commit
a65f42d0fd
@ -1,20 +1,29 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class EntityPageLayout extends StatelessWidget {
|
||||
class EntityPageLayout extends StatefulWidget {
|
||||
|
||||
final bool showClose;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return EntityModel(
|
||||
entityWrapper: EntityWrapper(entity: this.entity),
|
||||
entityWrapper: EntityWrapper(entity: widget.entity),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.all(0),
|
||||
children: <Widget>[
|
||||
showClose ?
|
||||
widget.showClose ?
|
||||
Container(
|
||||
color: Colors.blue[300],
|
||||
height: 36,
|
||||
@ -24,7 +33,7 @@ class EntityPageLayout extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 8),
|
||||
child: Text(
|
||||
this.entity.displayName,
|
||||
widget.entity.displayName,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
@ -48,17 +57,23 @@ class EntityPageLayout extends StatelessWidget {
|
||||
Container(height: 0, width: 0,),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: Sizes.rowPadding, left: Sizes.leftWidgetPadding),
|
||||
child: DefaultEntityContainer(state: this.entity._buildStatePartForPage(context)),
|
||||
child: DefaultEntityContainer(state: widget.entity._buildStatePartForPage(context)),
|
||||
),
|
||||
LastUpdatedWidget(),
|
||||
Divider(),
|
||||
this.entity._buildAdditionalControlsForPage(context),
|
||||
widget.entity._buildAdditionalControlsForPage(context),
|
||||
Divider(),
|
||||
EntityHistoryWidget(),
|
||||
EntityAttributesList()
|
||||
SpoilerCard(
|
||||
title: "State history",
|
||||
body: EntityHistoryWidget(),
|
||||
),
|
||||
SpoilerCard(
|
||||
title: "Attributes",
|
||||
body: EntityAttributesList(),
|
||||
),
|
||||
]
|
||||
),
|
||||
handleTap: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,7 +25,8 @@ import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'plugins/circular_slider/single_circular_slider.dart';
|
||||
import 'package:share/receive_share_state.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';
|
||||
|
||||
|
44
lib/plugins/spoiler_card.dart
Normal file
44
lib/plugins/spoiler_card.dart
Normal 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,)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user