Skip to content

Commit

Permalink
feat: #2573 - KP cells are expanded on detail pages (#2581)
Browse files Browse the repository at this point in the history
Impacted files:
* `knowledge_panel_card.dart`: no we are not initially expanded! (same as before)
* `knowledge_panel_element_card.dart`: refactored
* `knowledge_panel_expanded_card.dart`: refactored
* `knowledge_panel_page.dart`: yes we are initially expanded!
* `knowledge_panel_table_card.dart`: added an "initially expanded?" parameter to `TableCellWidget`
* `knowledge_panels_builder.dart`: no we are not initially expanded! (same as before)
  • Loading branch information
monsieurtanuki authored Jul 19, 2022
1 parent ca960ed commit 1eb6712
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class KnowledgePanelCard extends StatelessWidget {
panel: panel,
allPanels: allPanels,
product: product,
isInitiallyExpanded: false,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class KnowledgePanelElementCard extends StatelessWidget {
required this.knowledgePanelElement,
required this.allPanels,
required this.product,
required this.isInitiallyExpanded,
});

final KnowledgePanelElement knowledgePanelElement;
final KnowledgePanels allPanels;
final Product product;
final bool isInitiallyExpanded;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -54,6 +56,7 @@ class KnowledgePanelElementCard extends StatelessWidget {
case KnowledgePanelElementType.TABLE:
return KnowledgePanelTableCard(
tableElement: knowledgePanelElement.tableElement!,
isInitiallyExpanded: isInitiallyExpanded,
);
case KnowledgePanelElementType.MAP:
return KnowledgePanelWorldMapCard(knowledgePanelElement.mapElement!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class KnowledgePanelExpandedCard extends StatelessWidget {
required this.panel,
required this.allPanels,
required this.product,
required this.isInitiallyExpanded,
});

final KnowledgePanel panel;
final KnowledgePanels allPanels;
final Product product;
final bool isInitiallyExpanded;

@override
Widget build(BuildContext context) {
Expand All @@ -31,6 +33,7 @@ class KnowledgePanelExpandedCard extends StatelessWidget {
knowledgePanelElement: element,
allPanels: allPanels,
product: product,
isInitiallyExpanded: isInitiallyExpanded,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class _KnowledgePanelPageState extends State<KnowledgePanelPage>
panel: widget.panel,
allPanels: widget.allPanels,
product: widget.product,
isInitiallyExpanded: true,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ class TableCell {
class KnowledgePanelTableCard extends StatefulWidget {
const KnowledgePanelTableCard({
required this.tableElement,
required this.isInitiallyExpanded,
});

final KnowledgePanelTableElement tableElement;
final bool isInitiallyExpanded;

@override
State<KnowledgePanelTableCard> createState() =>
Expand Down Expand Up @@ -169,10 +171,12 @@ class _KnowledgePanelTableCardState extends State<KnowledgePanelTableCard> {
availableWidth / totalMaxColumnWidth * _columnsMaxLength[index++];
rowWidgets.add(
TableCellWidget(
cell: cell,
cellWidth: cellWidth,
tableElement: widget.tableElement,
rebuildTable: setState),
cell: cell,
cellWidth: cellWidth,
tableElement: widget.tableElement,
rebuildTable: setState,
isInitiallyExpanded: widget.isInitiallyExpanded,
),
);
}
rowsWidgets.add(rowWidgets);
Expand Down Expand Up @@ -250,19 +254,27 @@ class TableCellWidget extends StatefulWidget {
required this.cellWidth,
required this.tableElement,
required this.rebuildTable,
required this.isInitiallyExpanded,
});

final TableCell cell;
final double cellWidth;
final KnowledgePanelTableElement tableElement;
final void Function(VoidCallback fn) rebuildTable;
final bool isInitiallyExpanded;

@override
State<TableCellWidget> createState() => _TableCellWidgetState();
}

class _TableCellWidgetState extends State<TableCellWidget> {
bool _isExpanded = false;
late bool _isExpanded;

@override
void initState() {
super.initState();
_isExpanded = widget.isInitiallyExpanded;
}

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class KnowledgePanelWidget extends StatelessWidget {
knowledgePanelElement: knowledgePanelElement,
allPanels: knowledgePanels,
product: product,
isInitiallyExpanded: false,
),
);
}
Expand Down

0 comments on commit 1eb6712

Please sign in to comment.