From db20b51cb6dc968a87af2d48956a53fbbdc9536e Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sun, 5 May 2024 12:34:40 +0200 Subject: [PATCH] feat: 5191 - knowledge panel image card now clickable (#5220) 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 --- .../knowledge_panel_image_card.dart | 21 ++++++++++++++----- packages/smooth_app/pubspec.lock | 4 ++-- packages/smooth_app/pubspec.yaml | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_image_card.dart b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_image_card.dart index b44ee88d4816..263f8135df32 100644 --- a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_image_card.dart +++ b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_image_card.dart @@ -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 { @@ -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) { diff --git a/packages/smooth_app/pubspec.lock b/packages/smooth_app/pubspec.lock index b395b64c8378..ca7432e4846a 100644 --- a/packages/smooth_app/pubspec.lock +++ b/packages/smooth_app/pubspec.lock @@ -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: diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index d46be8521c93..be9404aef559 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -100,7 +100,7 @@ dependencies: path: ../scanner/zxing - openfoodfacts: 3.6.1 + openfoodfacts: 3.7.0 # openfoodfacts: # path: ../../../openfoodfacts-dart