Skip to content

Commit

Permalink
feat: 5191 - knowledge panel image card now clickable (#5220)
Browse files Browse the repository at this point in the history
Impacted files:
* `knowledge_panel_image_card.dart`: now using the optional `linkUrl` field for click operation
* `pubspec.lock`: wtf
* `pubspec.yaml`: upgraded to off-dart 3.7.0
  • Loading branch information
monsieurtanuki authored May 5, 2024
1 parent 76095cb commit db20b51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';

/// Card that displays a Knowledge Panel _Image_ element.
class KnowledgePanelImageCard extends StatelessWidget {
Expand All @@ -12,11 +13,21 @@ class KnowledgePanelImageCard extends StatelessWidget {

// TODO(g123k): It would be nice to provide a Placeholder
@override
Widget build(BuildContext context) => Image.network(
imageElement.url,
width: imageElement.width?.toDouble(),
height: imageElement.height?.toDouble(),
);
Widget build(BuildContext context) {
final Widget image = Image.network(
imageElement.url,
width: imageElement.width?.toDouble(),
height: imageElement.height?.toDouble(),
);
final String? linkUrl = imageElement.linkUrl;
if (linkUrl == null) {
return image;
}
return InkWell(
onTap: () => LaunchUrlHelper.launchURL(linkUrl),
child: image,
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,10 @@ packages:
dependency: "direct main"
description:
name: openfoodfacts
sha256: "1b9954e093ead9c314e21e25a92e89540adae2212ae0535f6e69804b312ff972"
sha256: dd2e19905a00eba37f67b5c8a52612e93d0f6758a96986ee0afe3723da7e41d5
url: "https://pub.dev"
source: hosted
version: "3.6.1"
version: "3.7.0"
openfoodfacts_flutter_lints:
dependency: "direct dev"
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies:
path: ../scanner/zxing


openfoodfacts: 3.6.1
openfoodfacts: 3.7.0
# openfoodfacts:
# path: ../../../openfoodfacts-dart

Expand Down

0 comments on commit db20b51

Please sign in to comment.