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 32 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
edf1d8c
feat: make the help country links conditional
jnnabugwu Jan 15, 2025
aed2d2a
fix: formatted code
jnnabugwu Jan 15, 2025
9bc5bf8
fix: deleting unused ports
jnnabugwu Jan 15, 2025
43806d8
Merge branch 'develop' into contribute-to-your-country-link
jnnabugwu Jan 23, 2025
7872cef
chore: formatted and added golden test
jnnabugwu Jan 23, 2025
389f009
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu Jan 23, 2025
abc15e3
Merge branch 'develop' into contribute-to-your-country-link
monsieurtanuki Feb 4, 2025
c753c7b
Merge branch 'develop' into contribute-to-your-country-link
monsieurtanuki Feb 6, 2025
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
2 changes: 1 addition & 1 deletion packages/smooth_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 6ac49c02151268e5844d0422787205b7cbdd62d2

COCOAPODS: 1.16.2
COCOAPODS: 1.15.2
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 @@ -185,6 +185,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 @@ -21,6 +21,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 @@ -50,89 +51,107 @@ class UserPreferencesContribute extends AbstractUserPreferences {
Color? getHeaderColor() => const Color(0xFFFFF2DF);

@override
List<UserPreferencesItem> getChildren() => <UserPreferencesItem>[
_getListTile(
'Hunger Games',
() async => _hungerGames(),
Icons.games,
),
_getListTile(
appLocalizations.contribute_improve_header,
() async => _contribute(),
Icons.data_saver_on,
),
_getListTile(
appLocalizations.contribute_sw_development,
() async => _develop(),
Icons.app_shortcut,
),
_getListTile(
appLocalizations.contribute_translate_header,
() async => _translate(),
Icons.translate,
),
_getListTile(
appLocalizations.how_to_contribute,
() async => LaunchUrlHelper.launchURL(
ProductQuery.replaceSubdomain(
'https://world.openfoodfacts.org/contribute',
),
List<UserPreferencesItem> getChildren() {
final OpenFoodFactsCountry country = ProductQuery.getCountry();

final TmpCountryWikiLinks links = TmpCountryWikiLinks();
return <UserPreferencesItem>[
_getListTile(
'Hunger Games',
() async => _hungerGames(),
Icons.games,
),
_getListTile(
appLocalizations.contribute_improve_header,
() async => _contribute(),
Icons.data_saver_on,
),
_getListTile(
appLocalizations.contribute_sw_development,
() async => _develop(),
Icons.app_shortcut,
),
_getListTile(
appLocalizations.contribute_translate_header,
() async => _translate(),
Icons.translate,
),
_getListTile(
appLocalizations.how_to_contribute,
() async => LaunchUrlHelper.launchURL(
ProductQuery.replaceSubdomain(
'https://world.openfoodfacts.org/contribute',
),
Icons.volunteer_activism_outlined,
externalLink: true,
),
Icons.volunteer_activism_outlined,
externalLink: true,
),
_getListTile(
appLocalizations.contribute_join_skill_pool,
() async => LaunchUrlHelper.launchURL(
'https://connect.openfoodfacts.org/join-the-contributor-skill-pool-open-food-facts',
),
Icons.group,
externalLink: true,
),
_getListTile(
appLocalizations.contribute_share_header,
() async => _share(appLocalizations.contribute_share_content),
Icons.adaptive.share,
),
if (links.wikiLinks.containsKey(country))
_getListTile(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We display nothing if the country has no wiki links.

appLocalizations.contribute_join_skill_pool,
() async => LaunchUrlHelper.launchURL(
'https://connect.openfoodfacts.org/join-the-contributor-skill-pool-open-food-facts',
appLocalizations.help_improve_country,
() async {
LaunchUrlHelper.launchURL(links.wikiLinks[country]!);
},
Icons.language,
icon: UserPreferencesListTile.getTintedIcon(
Icons.open_in_new,
context,
),
Icons.group,
externalLink: true,
),
if (GlobalVars.appStore.getEnrollInBetaURL() != null)
_getListTile(
appLocalizations.contribute_share_header,
() async => _share(appLocalizations.contribute_share_content),
Icons.adaptive.share,
),
if (GlobalVars.appStore.getEnrollInBetaURL() != null)
_getListTile(
appLocalizations.contribute_enroll_alpha,
() async {
final bool? result = await showDialog<bool>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
title: appLocalizations.contribute_enroll_alpha,
body: Text(appLocalizations.contribute_enroll_alpha_warning),
negativeAction: SmoothActionButton(
text: appLocalizations.close,
onPressed: () => Navigator.pop(context, false),
),
positiveAction: SmoothActionButton(
text: appLocalizations.okay,
onPressed: () => Navigator.pop(context, true),
),
appLocalizations.contribute_enroll_alpha,
() async {
final bool? result = await showDialog<bool>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
title: appLocalizations.contribute_enroll_alpha,
body: Text(appLocalizations.contribute_enroll_alpha_warning),
negativeAction: SmoothActionButton(
text: appLocalizations.close,
onPressed: () => Navigator.pop(context, false),
),
positiveAction: SmoothActionButton(
text: appLocalizations.okay,
onPressed: () => Navigator.pop(context, true),
),
),
);
if (result == true) {
await LaunchUrlHelper.launchURL(
GlobalVars.appStore.getEnrollInBetaURL()!,
);
if (result == true) {
await LaunchUrlHelper.launchURL(
GlobalVars.appStore.getEnrollInBetaURL()!,
);
}
},
CupertinoIcons.lab_flask_solid,
icon: UserPreferencesListTile.getTintedIcon(
Icons.open_in_new,
context,
),
externalLink: true,
}
},
CupertinoIcons.lab_flask_solid,
icon: UserPreferencesListTile.getTintedIcon(
Icons.open_in_new,
context,
),
_getListTile(
appLocalizations.contributors_label,
() async => _contributors(),
Icons.emoji_people,
description: appLocalizations.contributors_description,
externalLink: true,
),
];
_getListTile(
appLocalizations.contributors_label,
() async => _contributors(),
Icons.emoji_people,
description: appLocalizations.contributors_description,
),
];
}

Future<void> _contribute() => showDialog<void>(
context: context,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// TODO(monsieurtanuki): the code is to be moved to openfoodfacts-dart
import 'package:openfoodfacts/openfoodfacts.dart';

class TmpCountryWikiLinks {
final Map<OpenFoodFactsCountry, String> wikiLinks =
<OpenFoodFactsCountry, String>{
OpenFoodFactsCountry.ARGENTINA:
'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',
};
}
Binary file modified packages/smooth_app/test/users/goldens/login_page-amoled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/login_page-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/login_page-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-amoled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading