Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Contribute to your country link #5874

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
57d7df4
feat: added the help improve OFF in your country tile on the contribu…
jnnabugwu Jul 23, 2024
e7add3a
Update packages/smooth_app/lib/l10n/app_en.arb
monsieurtanuki Jul 24, 2024
1e06bcc
fix: fixing comma
jnnabugwu Jul 30, 2024
c5f135b
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu Jul 30, 2024
03ac3dc
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu Jul 30, 2024
3f35b91
feat: added country wiki class and a check to show the listtile
jnnabugwu Aug 1, 2024
78646bb
Update packages/smooth_app/lib/pages/preferences/user_preferences_con…
jnnabugwu Aug 5, 2024
29764bb
feat: satisfying pr requests
jnnabugwu Aug 5, 2024
e7f854e
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu Aug 5, 2024
2ce990f
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu Aug 14, 2024
de69671
feat: refactored userPreferences.countyCode to be a part of UserPrefe…
jnnabugwu Aug 14, 2024
13b83a1
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu Aug 14, 2024
52ad2d8
Merge branch 'develop' into contribute-to-your-country-link
teolemon Aug 16, 2024
4db3747
Merge branch 'develop' into contribute-to-your-country-link
teolemon Aug 16, 2024
2a43f11
Merge branch 'develop' into contribute-to-your-country-link
teolemon Aug 16, 2024
b8b56a8
Merge branch 'develop' into contribute-to-your-country-link
teolemon Aug 17, 2024
49ac004
Merge branches 'contribute-to-your-country-link' and 'contribute-to-y…
jnnabugwu Aug 19, 2024
b82769a
feat: adding map to country wiki links
jnnabugwu Nov 4, 2024
1e1c795
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu Nov 7, 2024
73bd894
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu Nov 12, 2024
4301e79
feat: adding country wiki link to user prefs
jnnabugwu Nov 17, 2024
c6b2961
feat: quick fix of adding the icon to the help improve country tile
jnnabugwu Nov 17, 2024
af59808
feat: format
jnnabugwu Nov 17, 2024
eca3816
fix: organizing imports
jnnabugwu Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';
Expand All @@ -21,6 +22,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';
Expand Down Expand Up @@ -94,6 +96,20 @@ 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,
icon: UserPreferencesListTile.getTintedIcon(
Icons.open_in_new,
context,
),
externalLink: true,
),
if (GlobalVars.appStore.getEnrollInBetaURL() != null)
_getListTile(
appLocalizations.contribute_enroll_alpha,
Expand Down Expand Up @@ -319,6 +335,19 @@ class UserPreferencesContribute extends AbstractUserPreferences {
builder: (_) => tile,
);
}

Future<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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',
'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',
};
}
Loading