-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
jnnabugwu
wants to merge
27
commits into
openfoodfacts:develop
Choose a base branch
from
jnnabugwu:contribute-to-your-country-link
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−0
Open
Changes from 25 commits
Commits
Show all changes
27 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 e7add3a
Update packages/smooth_app/lib/l10n/app_en.arb
monsieurtanuki 1e06bcc
fix: fixing comma
jnnabugwu c5f135b
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu 03ac3dc
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu 3f35b91
feat: added country wiki class and a check to show the listtile
jnnabugwu 78646bb
Update packages/smooth_app/lib/pages/preferences/user_preferences_con…
jnnabugwu 29764bb
feat: satisfying pr requests
jnnabugwu e7f854e
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu 2ce990f
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu de69671
feat: refactored userPreferences.countyCode to be a part of UserPrefe…
jnnabugwu 13b83a1
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu 52ad2d8
Merge branch 'develop' into contribute-to-your-country-link
teolemon 4db3747
Merge branch 'develop' into contribute-to-your-country-link
teolemon 2a43f11
Merge branch 'develop' into contribute-to-your-country-link
teolemon b8b56a8
Merge branch 'develop' into contribute-to-your-country-link
teolemon 49ac004
Merge branches 'contribute-to-your-country-link' and 'contribute-to-y…
jnnabugwu b82769a
feat: adding map to country wiki links
jnnabugwu 1e1c795
Merge branch 'contribute-to-your-country-link' of https://github.com/…
jnnabugwu 73bd894
Merge branch 'openfoodfacts:develop' into contribute-to-your-country-…
jnnabugwu 4301e79
feat: adding country wiki link to user prefs
jnnabugwu c6b2961
feat: quick fix of adding the icon to the help improve country tile
jnnabugwu af59808
feat: format
jnnabugwu eca3816
fix: organizing imports
jnnabugwu edf1d8c
feat: make the help country links conditional
jnnabugwu aed2d2a
fix: formatted code
jnnabugwu 9bc5bf8
fix: deleting unused ports
jnnabugwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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'; | ||
|
@@ -49,6 +51,10 @@ class UserPreferencesContribute extends AbstractUserPreferences { | |
@override | ||
Color? getHeaderColor() => const Color(0xFFFFF2DF); | ||
|
||
OpenFoodFactsCountry country = ProductQuery.getCountry(); | ||
|
||
TmpCountryWikiLinks links = TmpCountryWikiLinks(); | ||
|
||
@override | ||
List<UserPreferencesItem> getChildren() => <UserPreferencesItem>[ | ||
_getListTile( | ||
|
@@ -94,6 +100,21 @@ class UserPreferencesContribute extends AbstractUserPreferences { | |
() async => _share(appLocalizations.contribute_share_content), | ||
Icons.adaptive.share, | ||
), | ||
if (links.wikiLinks.containsKey(country)) | ||
_getListTile( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We display nothing if the country has no wiki links. |
||
appLocalizations.help_improve_country, | ||
() async { | ||
LaunchUrlHelper.launchURL(links.wikiLinks[country]!); | ||
}, | ||
Icons.language, | ||
icon: UserPreferencesListTile.getTintedIcon( | ||
Icons.open_in_new, | ||
context, | ||
), | ||
externalLink: true, | ||
) | ||
|
||
, | ||
if (GlobalVars.appStore.getEnrollInBetaURL() != null) | ||
_getListTile( | ||
appLocalizations.contribute_enroll_alpha, | ||
|
23 changes: 23 additions & 0 deletions
23
packages/smooth_app/lib/pages/product/common/country_wiki_links.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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.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', | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
country
andlinks
should rather befinal
variables inside methodgetChildren
: nowhere else in the code will we need them, and we don't want to give a wrong impression to the next code maintainers.That means you'll have to switch
getChildren
from the=>
short syntax to thereturn
syntax.