Skip to content

Commit

Permalink
fix: openfoodfacts#1540 - duplicated panel title
Browse files Browse the repository at this point in the history
  • Loading branch information
cli1005 committed Apr 27, 2022
1 parent d0a2feb commit fc236d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ class KnowledgePanelSummaryCard extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand All @@ -75,7 +77,11 @@ class KnowledgePanelsBuilder {
if (panelId != panelElement.panelElement!.panelId) {
continue;
}
return _buildPanel(panelElement, knowledgePanels);
return _buildPanel(
panelElement,
knowledgePanels,
context: context,
);
}
return null;
}
Expand All @@ -91,6 +97,15 @@ class KnowledgePanelsBuilder {
knowledgePanels.panelIdToPanelMap[panelId]!;
// [knowledgePanelElementWidgets] are a set of widgets inside the root panel.
final List<Widget> knowledgePanelElementWidgets = <Widget>[];
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 ?? <KnowledgePanelElement>[]) {
knowledgePanelElementWidgets.add(KnowledgePanelElementCard(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class _KnowledgePanelPageTemplateState
const KnowledgePanelsBuilder().buildSingle(
_knowledgePanels,
widget.panelId,
context: context,
)!;
return Scaffold(
body: Stack(
Expand Down

0 comments on commit fc236d8

Please sign in to comment.