Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Help debug KP by providing some debug info #4960

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
Expand Down Expand Up @@ -108,4 +109,11 @@ class KnowledgePanelActionCard extends StatelessWidget {
return false;
}
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('html', element.html));
properties.add(IterableProperty<String>('actions', element.actions));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -91,4 +92,11 @@ class KnowledgePanelCard extends StatelessWidget {
}
return false;
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('panelId', panelId));
properties.add(DiagnosticsProperty<bool>('clickable', isClickable));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
Expand Down Expand Up @@ -51,4 +52,14 @@ class KnowledgePanelExpandedCard extends StatelessWidget {
children: elementWidgets,
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('panelId', panelId));
properties.add(
DiagnosticsProperty<bool>('initiallyExpanded', isInitiallyExpanded),
);
properties.add(DiagnosticsProperty<bool>('clickable', isClickable));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -43,4 +44,12 @@ class KnowledgePanelGroupCard extends StatelessWidget {
),
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('groupElement', groupElement.title));
properties.add(DiagnosticsProperty<bool>('clickable', isClickable));
properties.add(IterableProperty<String>('panelIds', groupElement.panelIds));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';

Expand All @@ -16,4 +17,12 @@ class KnowledgePanelImageCard extends StatelessWidget {
width: imageElement.width?.toDouble(),
height: imageElement.height?.toDouble(),
);

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('url', imageElement.url));
properties.add(IntProperty('width', imageElement.width));
properties.add(IntProperty('height', imageElement.height));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:matomo_tracker/matomo_tracker.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -124,4 +125,10 @@ class _KnowledgePanelPageState extends State<KnowledgePanelPage>
}
return '';
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('panelId', widget.panelId));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/helpers/product_cards_helper.dart';
Expand Down Expand Up @@ -35,4 +36,10 @@ class KnowledgePanelProductCards extends StatelessWidget {
),
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(IntProperty('count', knowledgePanelWidgets.length));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
Expand Down Expand Up @@ -272,6 +273,14 @@ class _KnowledgePanelTableCardState extends State<KnowledgePanelTableCard> {

return buffer.toString();
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('tableElementId', widget.tableElement.id));
properties
.add(DiagnosticsProperty<bool>('expanded', widget.isInitiallyExpanded));
}
}

class TableCellWidget extends StatefulWidget {
Expand Down Expand Up @@ -404,4 +413,12 @@ class _TableCellWidgetState extends State<TableCellWidget> {
),
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
.add(DiagnosticsProperty<bool>('expanded', widget.isInitiallyExpanded));
properties.add(DoubleProperty('cellWidth', widget.cellWidth));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -56,4 +57,11 @@ class KnowledgePanelTextCard extends StatelessWidget {
bool get _hasSource =>
textElement.sourceText?.isNotEmpty == true &&
textElement.sourceUrl?.isNotEmpty == true;

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('text', textElement.sourceText));
properties.add(StringProperty('url', textElement.sourceUrl));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -182,4 +183,23 @@ class KnowledgePanelTitleCard extends StatelessWidget {

return buffer.toString();
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);

properties.add(
StringProperty('iconUrl', knowledgePanelTitleElement.iconUrl),
);
properties.add(
EnumProperty<TitleElementType>('type', knowledgePanelTitleElement.type),
);
properties.add(
EnumProperty<Grade>('grade', knowledgePanelTitleElement.grade),
);
properties.add(
DiagnosticsProperty<bool>('clickable', isClickable),
);
properties.add(EnumProperty<Evaluation>('evaluation', evaluation));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
Expand Down Expand Up @@ -85,4 +86,18 @@ class KnowledgePanelWorldMapCard extends StatelessWidget {
),
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(
IterableProperty<String?>(
'pointers',
mapElement.pointers.map(
(KnowledgePanelGeoPointer pointer) =>
pointer.geo?.toJson().toString(),
),
),
);
}
}