getPanelSummaryWidget method
- Product product, {
- required bool isClickable,
- required bool simplified,
- bool ignoreEvaluation = false,
- TextStyle? textStyleOverride,
- EdgeInsetsGeometry? margin,
- EdgeInsetsGeometry? padding,
Title card of a knowledge panel, like a one-line score widget, or title.
Implementation
Widget? getPanelSummaryWidget(
Product product, {
required bool isClickable,
required bool simplified,
bool ignoreEvaluation = false,
TextStyle? textStyleOverride,
EdgeInsetsGeometry? margin,
EdgeInsetsGeometry? padding,
}) {
if (titleElement == null) {
if (simplified) {
for (final KnowledgePanelElement element
in elements ?? <KnowledgePanelElement>[]) {
if (element.elementType == KnowledgePanelElementType.PANEL_GROUP) {
final List<KnowledgePanel> squarePanels = element
.lookForSquarePanels(product);
if (squarePanels.isNotEmpty) {
return KnowledgePanelSquareCard(
panels: squarePanels,
panelsIds: element.panelGroupElement?.panelIds,
product: product,
);
}
}
}
}
return null;
}
switch (titleElement!.type) {
case TitleElementType.GRADE:
return simplified
? SimplifiedKnowledgePanelTitleCard(
title: titleElement?.title ?? '',
subtitle: titleElement!.subtitle,
iconUrl: titleElement!.iconUrl,
)
: ScoreCard.titleElement(
titleElement: titleElement!,
isClickable: isClickable,
margin: margin,
);
case null:
case TitleElementType.PERCENTAGE:
case TitleElementType.UNKNOWN:
if (simplified) {
for (final KnowledgePanelElement element
in elements ?? <KnowledgePanelElement>[]) {
if (element.elementType == KnowledgePanelElementType.PANEL_GROUP) {
final List<KnowledgePanel> squarePanels = element
.lookForSquarePanels(product);
if (squarePanels.isNotEmpty) {
return KnowledgePanelSquareCard(
panels: squarePanels,
panelsIds: element.panelGroupElement?.panelIds,
product: product,
);
}
}
}
}
return simplified && titleElement!.iconUrl != null
? SimplifiedKnowledgePanelTitleCard(
title: titleElement?.title ?? '',
subtitle: titleElement!.subtitle,
iconUrl: titleElement!.iconUrl,
)
: Padding(
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: BALANCED_SPACE,
).add(padding ?? EdgeInsetsDirectional.zero),
child: KnowledgePanelTitleCard(
knowledgePanelTitleElement: titleElement!,
evaluation: ignoreEvaluation ? null : evaluation,
textStyleOverride: textStyleOverride,
isClickable: isClickable,
),
);
}
}