From fc236d8e6680bac35707202b2fd6759c595a89fe Mon Sep 17 00:00:00 2001 From: cli1005 Date: Wed, 27 Apr 2022 10:27:44 +0200 Subject: [PATCH] fix: #1540 - duplicated panel title --- .../knowledge_panel_summary_card.dart | 8 ------- .../knowledge_panels_builder.dart | 21 ++++++++++++++++--- .../knowledge_panel_page_template.dart | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_summary_card.dart b/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_summary_card.dart index 42d72dc98e4..ea59d28b3b9 100644 --- a/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_summary_card.dart +++ b/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_summary_card.dart @@ -21,14 +21,6 @@ class KnowledgePanelSummaryCard extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: VERY_SMALL_SPACE), - child: Text( - knowledgePanel.topics!.first.substring(0, 1).toUpperCase() + - knowledgePanel.topics!.first.substring(1), - style: themeData.textTheme.headline3, - ), - ), ScoreCard( iconUrl: knowledgePanel.titleElement!.iconUrl, description: knowledgePanel.titleElement!.title, diff --git a/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panels_builder.dart b/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panels_builder.dart index b103ce20f72..1e88591bfaf 100644 --- a/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panels_builder.dart +++ b/packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panels_builder.dart @@ -7,6 +7,7 @@ import 'package:openfoodfacts/openfoodfacts.dart'; import 'package:provider/provider.dart'; import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_element_card.dart'; import 'package:smooth_app/data_models/user_preferences.dart'; +import 'package:smooth_app/generic_lib/design_constants.dart'; import 'package:smooth_app/helpers/product_cards_helper.dart'; import 'package:smooth_app/pages/product/edit_ingredients_page.dart'; import 'package:smooth_app/pages/product/nutrition_page_loaded.dart'; @@ -59,8 +60,9 @@ class KnowledgePanelsBuilder { /// Typical use case so far: onboarding, where we focus on one panel only. Widget? buildSingle( final KnowledgePanels knowledgePanels, - final String panelId, - ) { + final String panelId, { + final BuildContext? context, + }) { if (knowledgePanels.panelIdToPanelMap['root'] == null) { return null; } @@ -75,7 +77,11 @@ class KnowledgePanelsBuilder { if (panelId != panelElement.panelElement!.panelId) { continue; } - return _buildPanel(panelElement, knowledgePanels); + return _buildPanel( + panelElement, + knowledgePanels, + context: context, + ); } return null; } @@ -91,6 +97,15 @@ class KnowledgePanelsBuilder { knowledgePanels.panelIdToPanelMap[panelId]!; // [knowledgePanelElementWidgets] are a set of widgets inside the root panel. final List knowledgePanelElementWidgets = []; + if (context != null) { + knowledgePanelElementWidgets.add(Padding( + padding: const EdgeInsets.symmetric(vertical: VERY_SMALL_SPACE), + child: Text( + rootPanel.titleElement!.title, + style: Theme.of(context).textTheme.headline3, + ), + )); + } for (final KnowledgePanelElement knowledgePanelElement in rootPanel.elements ?? []) { knowledgePanelElementWidgets.add(KnowledgePanelElementCard( diff --git a/packages/smooth_app/lib/pages/onboarding/knowledge_panel_page_template.dart b/packages/smooth_app/lib/pages/onboarding/knowledge_panel_page_template.dart index 412afb5c61d..7a9bcaf26b0 100644 --- a/packages/smooth_app/lib/pages/onboarding/knowledge_panel_page_template.dart +++ b/packages/smooth_app/lib/pages/onboarding/knowledge_panel_page_template.dart @@ -70,6 +70,7 @@ class _KnowledgePanelPageTemplateState const KnowledgePanelsBuilder().buildSingle( _knowledgePanels, widget.panelId, + context: context, )!; return Scaffold( body: Stack(