Skip to content

Commit

Permalink
fix: 5617 - share link to correct Oxf server
Browse files Browse the repository at this point in the history
Impacted files:
* `app_en.arb`: added labels for sharing an Oxf product
* `new_product_footer.dart`: now displaying a correct label for product sharing - in addition to correct url
* `product_query.dart`: added labels for sharing an Oxf product
* `pubspec.lock`: wtf
* `pubspec.yaml`: downgraded sentry_flutter from problematic version
  • Loading branch information
monsieurtanuki committed Nov 9, 2024
1 parent e06a4ac commit 17b75e9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
29 changes: 28 additions & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class _ProductShareButton extends StatelessWidget {
}

Future<void> _shareProduct(BuildContext context, Product product) async {
final ProductType productType = product.productType ?? ProductType.food;
AnalyticsHelper.trackEvent(
AnalyticsEvent.shareProduct,
barcode: product.barcode,
Expand All @@ -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,
);
Expand Down
19 changes: 19 additions & 0 deletions packages/smooth_app/lib/query/product_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
};
}
8 changes: 4 additions & 4 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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 @@ -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
Expand Down

0 comments on commit 17b75e9

Please sign in to comment.