Skip to content

Commit

Permalink
feat: adding map to country wiki links
Browse files Browse the repository at this point in the history
  • Loading branch information
jnnabugwu committed Nov 4, 2024
1 parent 49ac004 commit b82769a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -344,6 +346,12 @@ class UserPreferencesContribute extends AbstractUserPreferences {
builder: (_) => tile,
);
}
Future<String> returnCountry() async {
print('Getting country');
final Country country = await IsoCountries.isoCountryForCodeForLocale(countryCode);
print(country.name);
return country.name;
}
}

class _ContributorsDialog extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, String> wikiLinks = <String, String>{
'Argentina': 'https://wiki.openfoodfacts.org/Country_Support_-_Argentina',
Expand Down

0 comments on commit b82769a

Please sign in to comment.