diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index c473f6d0ec03..8fb621c82eab 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -2311,7 +2311,34 @@ }, "share_product_text": "Have a look at this product on Open Food Facts: {url}", "@share_product_text": { - "description": "The content which is send, when sharing a product", + "description": "The content which is send, when sharing a 'food' product", + "placeholders": { + "url": { + "type": "String" + } + } + }, + "share_product_text_beauty": "Have a look at this product on Open Beauty Facts: {url}", + "@share_product_text_beauty": { + "description": "The content which is send, when sharing a 'beauty' product", + "placeholders": { + "url": { + "type": "String" + } + } + }, + "share_product_text_pet_food": "Have a look at this product on Open PetFood Facts: {url}", + "@share_product_text_pet_food": { + "description": "The content which is send, when sharing a 'pet food' product", + "placeholders": { + "url": { + "type": "String" + } + } + }, + "share_product_text_product": "Have a look at this product on Open Products Facts: {url}", + "@share_product_text_product": { + "description": "The content which is send, when sharing a 'products' product", "placeholders": { "url": { "type": "String" diff --git a/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart b/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart index 5e1e6c6316ab..3715b582658d 100644 --- a/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart +++ b/packages/smooth_app/lib/pages/product/product_page/new_product_footer.dart @@ -333,6 +333,7 @@ class _ProductShareButton extends StatelessWidget { } Future _shareProduct(BuildContext context, Product product) async { + final ProductType productType = product.productType ?? ProductType.food; AnalyticsHelper.trackEvent( AnalyticsEvent.shareProduct, barcode: product.barcode, @@ -341,10 +342,10 @@ class _ProductShareButton extends StatelessWidget { // We need to provide a sharePositionOrigin to make the plugin work on ipad final RenderBox? box = context.findRenderObject() as RenderBox?; final String url = 'https://' - '${ProductQuery.getCountry().offTag}.${(product.productType ?? ProductType.food).getDomain()}.org' + '${ProductQuery.getCountry().offTag}.${productType.getDomain()}.org' '/product/${product.barcode}'; Share.share( - appLocalizations.share_product_text(url), + productType.getShareProductLabel(appLocalizations, url), sharePositionOrigin: box == null ? null : box.localToGlobal(Offset.zero) & box.size, ); diff --git a/packages/smooth_app/lib/query/product_query.dart b/packages/smooth_app/lib/query/product_query.dart index 76169110f7f6..8386ea5f22af 100644 --- a/packages/smooth_app/lib/query/product_query.dart +++ b/packages/smooth_app/lib/query/product_query.dart @@ -318,4 +318,23 @@ extension ProductTypeExtension on ProductType { ProductType.product => appLocalizations.hey_incomplete_product_message_product, }; + + String getShareProductLabel( + final AppLocalizations appLocalizations, + final String url, + ) => + switch (this) { + ProductType.food => appLocalizations.share_product_text( + url, + ), + ProductType.beauty => appLocalizations.share_product_text_beauty( + url, + ), + ProductType.petFood => appLocalizations.share_product_text_pet_food( + url, + ), + ProductType.product => appLocalizations.share_product_text_product( + url, + ), + }; } diff --git a/packages/smooth_app/pubspec.lock b/packages/smooth_app/pubspec.lock index 5941e7f39261..3cbc5bf41cb1 100644 --- a/packages/smooth_app/pubspec.lock +++ b/packages/smooth_app/pubspec.lock @@ -1354,18 +1354,18 @@ packages: dependency: transitive description: name: sentry - sha256: "2440763ae96fa8fd1bcdfc224f5232e1b7a09af76a72f4e626ee313a261faf6f" + sha256: "033287044a6644a93498969449d57c37907e56f5cedb17b88a3ff20a882261dd" url: "https://pub.dev" source: hosted - version: "8.10.1" + version: "8.9.0" sentry_flutter: dependency: "direct main" description: name: sentry_flutter - sha256: "3b30038b3b9303540a8b2c8b1c8f0bb93a207f8e4b25691c59d969ddeb4734fd" + sha256: "3780b5a0bb6afd476857cfbc6c7444d969c29a4d9bd1aa5b6960aa76c65b737a" url: "https://pub.dev" source: hosted - version: "8.10.1" + version: "8.9.0" share_plus: dependency: "direct main" description: diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index db5254800f54..e94f476bcd75 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: photo_view: 0.15.0 uuid: 4.5.1 provider: 6.1.2 - sentry_flutter: 8.10.1 + sentry_flutter: 8.9.0 sqflite: 2.4.1 sqflite_common_ffi: 2.3.4 url_launcher: 6.3.0