From 57d7df4346779211e377838050e5c7f1343e5e98 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Tue, 23 Jul 2024 18:34:48 -0400 Subject: [PATCH 01/15] feat: added the help improve OFF in your country tile on the contribute page --- packages/smooth_app/lib/l10n/app_en.arb | 4 ++++ .../lib/pages/preferences/user_preferences_contribute.dart | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index fac43512480..e86e1feedd5 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -177,6 +177,10 @@ "@sign_in_mandatory": { "description": "Error message: for some features like product edits you need to be signed in" }, + "help_improve_country":"Help improve Open Food Facts in your country", + "@help_improve_country": { + "description" : "label for a tile that is on the contribute tile" + } "sign_out": "Sign out", "@sign_out": { "description": "Button label: For sign out" diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 530c2e94062..d4bbf8f504a 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -108,6 +108,12 @@ class UserPreferencesContribute extends AbstractUserPreferences { UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), externalLink: true, ), + _getListTile( + 'Help improve Open Food Facts in your country', + () async => LaunchUrlHelper.launchURL( + 'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'), + const IconData(0xf68d), + externalLink: true), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, From e7add3a95de6d4fe110ddfb4e73e0f75973da19a Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Wed, 24 Jul 2024 07:27:58 +0200 Subject: [PATCH 02/15] Update packages/smooth_app/lib/l10n/app_en.arb --- packages/smooth_app/lib/l10n/app_en.arb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index e86e1feedd5..b6c9df2f7d9 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -180,7 +180,7 @@ "help_improve_country":"Help improve Open Food Facts in your country", "@help_improve_country": { "description" : "label for a tile that is on the contribute tile" - } + }, "sign_out": "Sign out", "@sign_out": { "description": "Button label: For sign out" From 1e06bcc0dea6381995dadc3f2813933709981121 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Tue, 30 Jul 2024 10:43:13 -0400 Subject: [PATCH 03/15] fix: fixing comma --- packages/smooth_app/lib/l10n/app_en.arb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index e86e1feedd5..b6c9df2f7d9 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -180,7 +180,7 @@ "help_improve_country":"Help improve Open Food Facts in your country", "@help_improve_country": { "description" : "label for a tile that is on the contribute tile" - } + }, "sign_out": "Sign out", "@sign_out": { "description": "Button label: For sign out" From 3f35b9143df04eacc296939a310c9877a8d131cc Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Thu, 1 Aug 2024 11:16:11 -0400 Subject: [PATCH 04/15] feat: added country wiki class and a check to show the listtile --- .../user_preferences_contribute.dart | 12 +++++---- .../product/common/country_wiki_links.dart | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 packages/smooth_app/lib/pages/product/common/country_wiki_links.dart diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index d4bbf8f504a..4bff4b82a12 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -20,6 +20,7 @@ import 'package:smooth_app/pages/preferences/user_preferences_item.dart'; import 'package:smooth_app/pages/preferences/user_preferences_list_tile.dart'; import 'package:smooth_app/pages/preferences/user_preferences_page.dart'; import 'package:smooth_app/pages/preferences/user_preferences_widgets.dart'; +import 'package:smooth_app/pages/product/common/country_wiki_links.dart'; import 'package:smooth_app/pages/product/common/product_query_page_helper.dart'; import 'package:smooth_app/query/paged_to_be_completed_product_query.dart'; import 'package:smooth_app/query/product_query.dart'; @@ -106,13 +107,14 @@ class UserPreferencesContribute extends AbstractUserPreferences { Icons.volunteer_activism, icon: UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), - externalLink: true, + externalLink: true ), - _getListTile( + if(CountryWikiLinks().wikiLinks.containsKey(userPreferences.userCountryCode)) + _getListTile( 'Help improve Open Food Facts in your country', () async => LaunchUrlHelper.launchURL( - 'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'), - const IconData(0xf68d), + CountryWikiLinks().wikiLinks[userPreferences.userCountryCode]!), + Icons.language, externalLink: true), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( @@ -317,7 +319,7 @@ class UserPreferencesContribute extends AbstractUserPreferences { leading: UserPreferencesListTile.getTintedIcon(leading, context), externalLink: externalLink, ); - + if (description != null) { return UserPreferencesItemSimple( labels: [title, description], diff --git a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart new file mode 100644 index 00000000000..6a5044a3682 --- /dev/null +++ b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart @@ -0,0 +1,25 @@ +class CountryWikiLinks { + + +final Map wikiLinks = { + 'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', + 'Australia':'https://wiki.openfoodfacts.org/Country_Support_-_Australia', + 'Canada': 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', + 'China' : 'https://wiki.openfoodfacts.org/Country_Support_-_China', + 'Europe': 'https://wiki.openfoodfacts.org/Country_Support_-_Europe', + 'France': 'https://wiki.openfoodfacts.org/Local_Communities/FrenchTeam/Country_Support', + 'Germany': 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', + 'India': 'https://wiki.openfoodfacts.org/Country_Support_-_India', + 'Italy': 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', + 'Japan': 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', + 'Mexico': 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', + 'Netherlands': 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', + 'Spain': 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', + 'Russia': 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', + 'South Korea': 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', + 'United States': 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', + // 'Belgium': 'https://wiki.openfoodfacts.org/Country_Support_-_Belgium', + // 'Bulgaria': 'https://wiki.openfoodfacts.org/Local_Communities/BulgarianTeam', + }; + +} \ No newline at end of file From 78646bb333cb384ae8376a021cc7e13fefcabcc7 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Mon, 5 Aug 2024 15:00:24 -0400 Subject: [PATCH 05/15] Update packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart Co-authored-by: monsieurtanuki --- .../lib/pages/preferences/user_preferences_contribute.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 4bff4b82a12..0df409c67a5 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -107,7 +107,7 @@ class UserPreferencesContribute extends AbstractUserPreferences { Icons.volunteer_activism, icon: UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), - externalLink: true + externalLink: true, ), if(CountryWikiLinks().wikiLinks.containsKey(userPreferences.userCountryCode)) _getListTile( From 29764bb984bb40baca642fa2c83bfa61b7dd1256 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Mon, 5 Aug 2024 15:16:46 -0400 Subject: [PATCH 06/15] feat: satisfying pr requests --- .../user_preferences_contribute.dart | 36 +++++++------ .../product/common/country_wiki_links.dart | 50 +++++++++---------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 4bff4b82a12..85d792407f8 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -100,22 +100,26 @@ class UserPreferencesContribute extends AbstractUserPreferences { Icons.adaptive.share, ), _getListTile( - appLocalizations.contribute_donate_header, - () async => LaunchUrlHelper.launchURL( - AppLocalizations.of(context).donate_url, - ), - Icons.volunteer_activism, - icon: - UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), - externalLink: true - ), - if(CountryWikiLinks().wikiLinks.containsKey(userPreferences.userCountryCode)) - _getListTile( - 'Help improve Open Food Facts in your country', + appLocalizations.contribute_donate_header, () async => LaunchUrlHelper.launchURL( - CountryWikiLinks().wikiLinks[userPreferences.userCountryCode]!), - Icons.language, - externalLink: true), + AppLocalizations.of(context).donate_url, + ), + Icons.volunteer_activism, + icon: UserPreferencesListTile.getTintedIcon( + Icons.open_in_new, context), + externalLink: true,), + if (TmpCountryWikiLinks() + .wikiLinks + .containsKey(userPreferences.userCountryCode)) + _getListTile( + 'Help improve Open Food Facts in your country', + () async => LaunchUrlHelper.launchURL(TmpCountryWikiLinks() + .wikiLinks[userPreferences.userCountryCode]!), + Icons.language, + icon: UserPreferencesListTile.getTintedIcon( + Icons.open_in_new, + context,), + externalLink: true), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, @@ -319,7 +323,7 @@ class UserPreferencesContribute extends AbstractUserPreferences { leading: UserPreferencesListTile.getTintedIcon(leading, context), externalLink: externalLink, ); - + if (description != null) { return UserPreferencesItemSimple( labels: [title, description], diff --git a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart index 6a5044a3682..5276296d780 100644 --- a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart +++ b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart @@ -1,25 +1,25 @@ -class CountryWikiLinks { - - -final Map wikiLinks = { - 'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', - 'Australia':'https://wiki.openfoodfacts.org/Country_Support_-_Australia', - 'Canada': 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', - 'China' : 'https://wiki.openfoodfacts.org/Country_Support_-_China', - 'Europe': 'https://wiki.openfoodfacts.org/Country_Support_-_Europe', - 'France': 'https://wiki.openfoodfacts.org/Local_Communities/FrenchTeam/Country_Support', - 'Germany': 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', - 'India': 'https://wiki.openfoodfacts.org/Country_Support_-_India', - 'Italy': 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', - 'Japan': 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', - 'Mexico': 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', - 'Netherlands': 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', - 'Spain': 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', - 'Russia': 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', - 'South Korea': 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', - 'United States': 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', - // 'Belgium': 'https://wiki.openfoodfacts.org/Country_Support_-_Belgium', - // 'Bulgaria': 'https://wiki.openfoodfacts.org/Local_Communities/BulgarianTeam', - }; - -} \ No newline at end of file + // TODO(monsieurtanuki): the code is to be moved to openfoodfacts-dart +class TmpCountryWikiLinks { + final Map wikiLinks = { + 'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', + 'Australia': 'https://wiki.openfoodfacts.org/Country_Support_-_Australia', + 'Canada': 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', + 'China': 'https://wiki.openfoodfacts.org/Country_Support_-_China', + 'Europe': 'https://wiki.openfoodfacts.org/Country_Support_-_Europe', + 'France': + 'https://wiki.openfoodfacts.org/Local_Communities/FrenchTeam/Country_Support', + 'Germany': 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', + 'India': 'https://wiki.openfoodfacts.org/Country_Support_-_India', + 'Italy': 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', + 'Japan': 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', + 'Mexico': 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', + 'Netherlands': + 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', + 'Spain': 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', + 'Russia': 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', + 'South Korea': + 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', + 'United States': + 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', + }; +} From de6967150c071a730d96f36aae0af754137c645c Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Wed, 14 Aug 2024 13:03:37 -0400 Subject: [PATCH 07/15] feat: refactored userPreferences.countyCode to be a part of UserPreferenceContribute --- .../preferences/user_preferences_contribute.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index c88091c146a..532333605e6 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:http/http.dart' as http; +import 'package:iso_countries/iso_countries.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart'; import 'package:smooth_app/data_models/github_contributors_model.dart'; @@ -27,18 +28,21 @@ import 'package:smooth_app/query/product_query.dart'; /// Display of "Contribute" for the preferences page. class UserPreferencesContribute extends AbstractUserPreferences { + UserPreferencesContribute({ required final BuildContext context, required final UserPreferences userPreferences, required final AppLocalizations appLocalizations, required final ThemeData themeData, - }) : super( + }) : countryCode = userPreferences.userCountryCode, + super( context: context, userPreferences: userPreferences, appLocalizations: appLocalizations, themeData: themeData, ); - + final String? countryCode; + @override PreferencePageType getPreferencePageType() => PreferencePageType.CONTRIBUTE; @@ -109,11 +113,11 @@ class UserPreferencesContribute extends AbstractUserPreferences { UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), externalLink: true, ), - if(CountryWikiLinks().wikiLinks.containsKey(userPreferences.userCountryCode)) + if(TmpCountryWikiLinks().wikiLinks.containsKey(IsoCountries.isoCountriesForLocale(countryCode))) _getListTile( 'Help improve Open Food Facts in your country', () async => LaunchUrlHelper.launchURL(TmpCountryWikiLinks() - .wikiLinks[userPreferences.userCountryCode]!), + .wikiLinks[IsoCountries.isoCountriesForLocale(countryCode)]!), Icons.language, icon: UserPreferencesListTile.getTintedIcon( Icons.open_in_new, From b82769a9162128b72fa953c00f5882b91885c033 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Mon, 4 Nov 2024 17:33:03 -0600 Subject: [PATCH 08/15] feat: adding map to country wiki links --- .../user_preferences_contribute.dart | 24 ++++++++++++------- .../product/common/country_wiki_links.dart | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 7646527cdc0..d117ba9fbf0 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -28,21 +28,20 @@ import 'package:smooth_app/query/product_query.dart'; /// Display of "Contribute" for the preferences page. class UserPreferencesContribute extends AbstractUserPreferences { - UserPreferencesContribute({ required final BuildContext context, required final UserPreferences userPreferences, required final AppLocalizations appLocalizations, required final ThemeData themeData, - }) : countryCode = userPreferences.userCountryCode, - super( + }) : countryCode = userPreferences.userCountryCode, + super( context: context, userPreferences: userPreferences, appLocalizations: appLocalizations, themeData: themeData, ); final String? countryCode; - + @override PreferencePageType getPreferencePageType() => PreferencePageType.CONTRIBUTE; @@ -113,15 +112,18 @@ class UserPreferencesContribute extends AbstractUserPreferences { UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context), externalLink: true, ), - if(TmpCountryWikiLinks().wikiLinks.containsKey(IsoCountries.isoCountriesForLocale(countryCode))) + if (TmpCountryWikiLinks() + .wikiLinks + .containsKey('United States')) _getListTile( 'Help improve Open Food Facts in your country', () async => LaunchUrlHelper.launchURL(TmpCountryWikiLinks() - .wikiLinks[IsoCountries.isoCountriesForLocale(countryCode)]!), + .wikiLinks['United States']!), Icons.language, icon: UserPreferencesListTile.getTintedIcon( - Icons.open_in_new, - context,), + Icons.open_in_new, + context, + ), externalLink: true), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( @@ -344,6 +346,12 @@ class UserPreferencesContribute extends AbstractUserPreferences { builder: (_) => tile, ); } + Future returnCountry() async { + print('Getting country'); + final Country country = await IsoCountries.isoCountryForCodeForLocale(countryCode); + print(country.name); + return country.name; + } } class _ContributorsDialog extends StatelessWidget { diff --git a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart index 5276296d780..a78fc351827 100644 --- a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart +++ b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart @@ -1,4 +1,4 @@ - // TODO(monsieurtanuki): the code is to be moved to openfoodfacts-dart +// TODO(monsieurtanuki): the code is to be moved to openfoodfacts-dart class TmpCountryWikiLinks { final Map wikiLinks = { 'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', From 4301e792b05ddc4bbd8062580fb07a8dff48e0fa Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Sun, 17 Nov 2024 16:16:54 -0600 Subject: [PATCH 09/15] feat: adding country wiki link to user prefs --- .../user_preferences_contribute.dart | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 7c1a9d32d40..f99a8880a70 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -96,6 +96,18 @@ class UserPreferencesContribute extends AbstractUserPreferences { () async => _share(appLocalizations.contribute_share_content), Icons.adaptive.share, ), + _getListTile( + appLocalizations.help_improve_country, + () async { + final String country = await returnCountry(context); + final TmpCountryWikiLinks links = TmpCountryWikiLinks(); + LaunchUrlHelper.launchURL( + links.wikiLinks[country] ?? 'France' + ); + }, + Icons.language, + externalLink: true, + ), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, @@ -321,11 +333,15 @@ class UserPreferencesContribute extends AbstractUserPreferences { builder: (_) => tile, ); } - Future returnCountry() async { - print('Getting country'); - final Country country = await IsoCountries.isoCountryForCodeForLocale(countryCode); - print(country.name); + Future returnCountry(BuildContext context) async { + final locale = Localizations.localeOf(context); + if(locale.countryCode == null){ + final Country country = await IsoCountries.isoCountryForCodeForLocale('FR'); + return country.name; + } else{ + final Country country = await IsoCountries.isoCountryForCodeForLocale(locale.countryCode); return country.name; + } } } From c6b2961d75c1c3b4ae12c49e9168ee05e42516e5 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Sun, 17 Nov 2024 17:01:00 -0600 Subject: [PATCH 10/15] feat: quick fix of adding the icon to the help improve country tile --- .../lib/pages/preferences/user_preferences_contribute.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index f99a8880a70..1f3c06a0d26 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -106,6 +106,10 @@ class UserPreferencesContribute extends AbstractUserPreferences { ); }, Icons.language, + icon: UserPreferencesListTile.getTintedIcon( + Icons.open_in_new, + context, + ), externalLink: true, ), if (GlobalVars.appStore.getEnrollInBetaURL() != null) @@ -334,7 +338,7 @@ class UserPreferencesContribute extends AbstractUserPreferences { ); } Future returnCountry(BuildContext context) async { - final locale = Localizations.localeOf(context); + final Locale locale = Localizations.localeOf(context); if(locale.countryCode == null){ final Country country = await IsoCountries.isoCountryForCodeForLocale('FR'); return country.name; From af59808cb1c86ede44936b0db21730dcfd424ff0 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Sun, 17 Nov 2024 17:56:38 -0600 Subject: [PATCH 11/15] feat: format --- .../user_preferences_contribute.dart | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 1f3c06a0d26..a3fe7794c8c 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -101,17 +101,15 @@ class UserPreferencesContribute extends AbstractUserPreferences { () async { final String country = await returnCountry(context); final TmpCountryWikiLinks links = TmpCountryWikiLinks(); - LaunchUrlHelper.launchURL( - links.wikiLinks[country] ?? 'France' - ); + LaunchUrlHelper.launchURL(links.wikiLinks[country] ?? 'France'); }, Icons.language, icon: UserPreferencesListTile.getTintedIcon( Icons.open_in_new, context, - ), + ), externalLink: true, - ), + ), if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, @@ -337,14 +335,17 @@ class UserPreferencesContribute extends AbstractUserPreferences { builder: (_) => tile, ); } - Future returnCountry(BuildContext context) async { + + Future returnCountry(BuildContext context) async { final Locale locale = Localizations.localeOf(context); - if(locale.countryCode == null){ - final Country country = await IsoCountries.isoCountryForCodeForLocale('FR'); + if (locale.countryCode == null) { + final Country country = + await IsoCountries.isoCountryForCodeForLocale('FR'); + return country.name; + } else { + final Country country = + await IsoCountries.isoCountryForCodeForLocale(locale.countryCode); return country.name; - } else{ - final Country country = await IsoCountries.isoCountryForCodeForLocale(locale.countryCode); - return country.name; } } } From eca3816ebf43499a4e7deafa1e4bfe6058a33ae9 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Sun, 17 Nov 2024 18:22:23 -0600 Subject: [PATCH 12/15] fix: organizing imports --- .../lib/pages/preferences/user_preferences_contribute.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index a3fe7794c8c..cc67002a166 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -4,8 +4,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:http/http.dart' as http; -import 'package:openfoodfacts/openfoodfacts.dart'; import 'package:iso_countries/iso_countries.dart'; +import 'package:openfoodfacts/openfoodfacts.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart'; import 'package:smooth_app/data_models/github_contributors_model.dart'; From edf1d8ce2edc9c6efcd4647c5fe0e16134f8edca Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Tue, 14 Jan 2025 18:10:34 -0600 Subject: [PATCH 13/15] feat: make the help country links conditional --- .../user_preferences_contribute.dart | 26 +++++-------- .../product/common/country_wiki_links.dart | 38 +++++++++---------- 2 files changed, 27 insertions(+), 37 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index cc67002a166..e35acfbd68d 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -51,6 +51,10 @@ class UserPreferencesContribute extends AbstractUserPreferences { @override Color? getHeaderColor() => const Color(0xFFFFF2DF); + OpenFoodFactsCountry country = ProductQuery.getCountry(); + + TmpCountryWikiLinks links = TmpCountryWikiLinks(); + @override List getChildren() => [ _getListTile( @@ -96,12 +100,11 @@ class UserPreferencesContribute extends AbstractUserPreferences { () async => _share(appLocalizations.contribute_share_content), Icons.adaptive.share, ), + if (links.wikiLinks.containsKey(country)) _getListTile( appLocalizations.help_improve_country, () async { - final String country = await returnCountry(context); - final TmpCountryWikiLinks links = TmpCountryWikiLinks(); - LaunchUrlHelper.launchURL(links.wikiLinks[country] ?? 'France'); + LaunchUrlHelper.launchURL(links.wikiLinks[country]!); }, Icons.language, icon: UserPreferencesListTile.getTintedIcon( @@ -109,7 +112,9 @@ class UserPreferencesContribute extends AbstractUserPreferences { context, ), externalLink: true, - ), + ) + + , if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, @@ -335,19 +340,6 @@ class UserPreferencesContribute extends AbstractUserPreferences { builder: (_) => tile, ); } - - Future returnCountry(BuildContext context) async { - final Locale locale = Localizations.localeOf(context); - if (locale.countryCode == null) { - final Country country = - await IsoCountries.isoCountryForCodeForLocale('FR'); - return country.name; - } else { - final Country country = - await IsoCountries.isoCountryForCodeForLocale(locale.countryCode); - return country.name; - } - } } class _ContributorsDialog extends StatelessWidget { diff --git a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart index a78fc351827..16ccd932190 100644 --- a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart +++ b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart @@ -1,25 +1,23 @@ // TODO(monsieurtanuki): the code is to be moved to openfoodfacts-dart +import 'package:openfoodfacts/openfoodfacts.dart'; + class TmpCountryWikiLinks { - final Map wikiLinks = { - 'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', - 'Australia': 'https://wiki.openfoodfacts.org/Country_Support_-_Australia', - 'Canada': 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', - 'China': 'https://wiki.openfoodfacts.org/Country_Support_-_China', - 'Europe': 'https://wiki.openfoodfacts.org/Country_Support_-_Europe', - 'France': + final Map wikiLinks = { + OpenFoodFactsCountry.ALGERIA : 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', + OpenFoodFactsCountry.AUSTRALIA : 'https://wiki.openfoodfacts.org/Country_Support_-_Australia', + OpenFoodFactsCountry.CANADA : 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', + OpenFoodFactsCountry.CHINA: 'https://wiki.openfoodfacts.org/Country_Support_-_China', + OpenFoodFactsCountry.FRANCE: 'https://wiki.openfoodfacts.org/Local_Communities/FrenchTeam/Country_Support', - 'Germany': 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', - 'India': 'https://wiki.openfoodfacts.org/Country_Support_-_India', - 'Italy': 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', - 'Japan': 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', - 'Mexico': 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', - 'Netherlands': - 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', - 'Spain': 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', - 'Russia': 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', - 'South Korea': - 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', - 'United States': - 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', + OpenFoodFactsCountry.GERMANY: 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', + OpenFoodFactsCountry.INDIA: 'https://wiki.openfoodfacts.org/Country_Support_-_India', + OpenFoodFactsCountry.ITALY: 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', + OpenFoodFactsCountry.JAPAN: 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', + OpenFoodFactsCountry.MEXICO: 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', + OpenFoodFactsCountry.NETHERLANDS: 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', + OpenFoodFactsCountry.SPAIN: 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', + OpenFoodFactsCountry.RUSSIA: 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', + OpenFoodFactsCountry.SOUTH_KOREA: 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', + OpenFoodFactsCountry.USA: 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', }; } From aed2d2af391385cf06338180fb2070d06b71e4c7 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Wed, 15 Jan 2025 14:32:41 -0600 Subject: [PATCH 14/15] fix: formatted code --- .../user_preferences_contribute.dart | 26 +++++------ .../product/common/country_wiki_links.dart | 45 ++++++++++++------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index e35acfbd68d..877e0570751 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -53,7 +53,7 @@ class UserPreferencesContribute extends AbstractUserPreferences { OpenFoodFactsCountry country = ProductQuery.getCountry(); - TmpCountryWikiLinks links = TmpCountryWikiLinks(); + TmpCountryWikiLinks links = TmpCountryWikiLinks(); @override List getChildren() => [ @@ -101,20 +101,18 @@ class UserPreferencesContribute extends AbstractUserPreferences { Icons.adaptive.share, ), if (links.wikiLinks.containsKey(country)) - _getListTile( - appLocalizations.help_improve_country, - () async { - LaunchUrlHelper.launchURL(links.wikiLinks[country]!); - }, - Icons.language, - icon: UserPreferencesListTile.getTintedIcon( - Icons.open_in_new, - context, + _getListTile( + appLocalizations.help_improve_country, + () async { + LaunchUrlHelper.launchURL(links.wikiLinks[country]!); + }, + Icons.language, + icon: UserPreferencesListTile.getTintedIcon( + Icons.open_in_new, + context, + ), + externalLink: true, ), - externalLink: true, - ) - - , if (GlobalVars.appStore.getEnrollInBetaURL() != null) _getListTile( appLocalizations.contribute_enroll_alpha, diff --git a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart index 16ccd932190..716d8635a3f 100644 --- a/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart +++ b/packages/smooth_app/lib/pages/product/common/country_wiki_links.dart @@ -2,22 +2,37 @@ import 'package:openfoodfacts/openfoodfacts.dart'; class TmpCountryWikiLinks { - final Map wikiLinks = { - OpenFoodFactsCountry.ALGERIA : 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', - OpenFoodFactsCountry.AUSTRALIA : 'https://wiki.openfoodfacts.org/Country_Support_-_Australia', - OpenFoodFactsCountry.CANADA : 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', - OpenFoodFactsCountry.CHINA: 'https://wiki.openfoodfacts.org/Country_Support_-_China', + final Map wikiLinks = + { + OpenFoodFactsCountry.ALGERIA: + 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina', + OpenFoodFactsCountry.AUSTRALIA: + 'https://wiki.openfoodfacts.org/Country_Support_-_Australia', + OpenFoodFactsCountry.CANADA: + 'https://wiki.openfoodfacts.org/Country_Support_-_Canada', + OpenFoodFactsCountry.CHINA: + 'https://wiki.openfoodfacts.org/Country_Support_-_China', OpenFoodFactsCountry.FRANCE: 'https://wiki.openfoodfacts.org/Local_Communities/FrenchTeam/Country_Support', - OpenFoodFactsCountry.GERMANY: 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', - OpenFoodFactsCountry.INDIA: 'https://wiki.openfoodfacts.org/Country_Support_-_India', - OpenFoodFactsCountry.ITALY: 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', - OpenFoodFactsCountry.JAPAN: 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', - OpenFoodFactsCountry.MEXICO: 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', - OpenFoodFactsCountry.NETHERLANDS: 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', - OpenFoodFactsCountry.SPAIN: 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', - OpenFoodFactsCountry.RUSSIA: 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', - OpenFoodFactsCountry.SOUTH_KOREA: 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', - OpenFoodFactsCountry.USA: 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', + OpenFoodFactsCountry.GERMANY: + 'https://wiki.openfoodfacts.org/Country_Support_-_Germany', + OpenFoodFactsCountry.INDIA: + 'https://wiki.openfoodfacts.org/Country_Support_-_India', + OpenFoodFactsCountry.ITALY: + 'https://wiki.openfoodfacts.org/Country_Support_-_Italy', + OpenFoodFactsCountry.JAPAN: + 'https://wiki.openfoodfacts.org/Country_Support_-_Japan', + OpenFoodFactsCountry.MEXICO: + 'https://wiki.openfoodfacts.org/Country_Support_-_Mexico', + OpenFoodFactsCountry.NETHERLANDS: + 'https://wiki.openfoodfacts.org/Country_Support_-_Netherlands', + OpenFoodFactsCountry.SPAIN: + 'https://wiki.openfoodfacts.org/Country_Support_-_Spain', + OpenFoodFactsCountry.RUSSIA: + 'https://wiki.openfoodfacts.org/Country_Support_-_Russia', + OpenFoodFactsCountry.SOUTH_KOREA: + 'https://wiki.openfoodfacts.org/Country_Support_-_South_Korea', + OpenFoodFactsCountry.USA: + 'https://wiki.openfoodfacts.org/Country_Support_-_United_States', }; } From 9bc5bf8400d910de97574679c154068818a566ae Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Wed, 15 Jan 2025 15:58:42 -0600 Subject: [PATCH 15/15] fix: deleting unused ports --- .../lib/pages/preferences/user_preferences_contribute.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index 877e0570751..25f21ce8c67 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:http/http.dart' as http; -import 'package:iso_countries/iso_countries.dart'; import 'package:openfoodfacts/openfoodfacts.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart';