From b82769a9162128b72fa953c00f5882b91885c033 Mon Sep 17 00:00:00 2001 From: Jordan Nnabugwu Date: Mon, 4 Nov 2024 17:33:03 -0600 Subject: [PATCH] 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',