diff --git a/lib/entities/entity_page_layout.widget.dart b/lib/entities/entity_page_layout.widget.dart index b3a01d4..d383323 100644 --- a/lib/entities/entity_page_layout.widget.dart +++ b/lib/entities/entity_page_layout.widget.dart @@ -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 { + + 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: [ - 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, ); } -} +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index dda6121..cd75270 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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'; diff --git a/lib/plugins/DynamicMultiColumnLayout.dart b/lib/plugins/dynamic_multi_column_layout.dart similarity index 100% rename from lib/plugins/DynamicMultiColumnLayout.dart rename to lib/plugins/dynamic_multi_column_layout.dart diff --git a/lib/plugins/spoiler_card.dart b/lib/plugins/spoiler_card.dart new file mode 100644 index 0000000..340de62 --- /dev/null +++ b/lib/plugins/spoiler_card.dart @@ -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 { + + bool _expanded; + + @override + void initState() { + super.initState(); + _expanded = widget.isExpanded; + } + + @override + Widget build(BuildContext context) { + return Card( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + 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,) + ], + ), + ); + } +} \ No newline at end of file