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: added the "Help improve OFF in your country" tile on the contribute page #5510

Conversation

jnnabugwu
Copy link
Contributor

@jnnabugwu jnnabugwu commented Jul 23, 2024

What

  • Added the help improve OFF in your country tile on the contribution page.

Screenshot

Simulator Screenshot - iPhone 15 Pro Max - 2024-07-23 at 18 36 45

Fixes bug(s)

@jnnabugwu jnnabugwu requested a review from a team as a code owner July 23, 2024 22:37
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

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

Hi @jnnabugwu!
That's good but there are still things to address. Please read my comments for details.

() async => LaunchUrlHelper.launchURL(
'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'),
const IconData(0xf68d),
externalLink: true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
externalLink: true),
externalLink: true,),

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really optional.

'Help improve Open Food Facts in your country',
() async => LaunchUrlHelper.launchURL(
'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'),
const IconData(0xf68d),
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a globe icon you should reuse: the one used in the app country selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right ill look

_getListTile(
'Help improve Open Food Facts in your country',
() async => LaunchUrlHelper.launchURL(
'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'),
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not the way it works:

  • you need to maintain a Map of country/wiki-link, as stated in the issue, for the same limited list of countries, with the correct values
  • if the current country is not in the Map, you mustn't display that ListTile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay will do

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 7.05%. Comparing base (4d9c7fc) to head (03ac3dc).
Report is 267 commits behind head on develop.

Files Patch % Lines
...pages/preferences/user_preferences_contribute.dart 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #5510      +/-   ##
==========================================
- Coverage     9.54%   7.05%   -2.50%     
==========================================
  Files          325     397      +72     
  Lines        16411   20889    +4478     
==========================================
- Hits          1567    1473      -94     
- Misses       14844   19416    +4572     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@monsieurtanuki monsieurtanuki changed the title feat: added the help improve OFF in your country tile on the contribu… feat: added the help improve OFF in your country tile on the contribute page Jul 24, 2024
@teolemon teolemon changed the title feat: added the help improve OFF in your country tile on the contribute page feat: added the "Help improve OFF in your country" tile on the contribute page Aug 1, 2024
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

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

Hi @jnnabugwu!
Please have a look at my comments, and never forget to format the code.

@@ -0,0 +1,25 @@
class CountryWikiLinks {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please call it something like TmpCountryWikiLinks, and add a TODO saying that the code is to be moved to openfoodfacts-dart.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. Also why am i adding the TODO saying the code will be moved to openfoodfacts-dart?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also why am i adding the TODO saying the code will be moved to openfoodfacts-dart?

Because part of the code (in our case, the map) will eventually be moved to openfoodfacts-dart.
When we code for Smoothie, we sometimes code things that can be reused by other openfoodfacts-dart users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

),
_getListTile(
if(CountryWikiLinks().wikiLinks.containsKey(userPreferences.userCountryCode))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to put the wiki link in a String? variable before, and then to test if (wikiLinks != null)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How come?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me see if I understand are you saying put the TmpCountryWikiLinks()
.wikiLinks
.containsKey(userPreferences.userCountryCode) in a variable and test if this is going to be null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If so how would that be better? Trying to learn best coding practices :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's typically considered a best practice to avoid a code copy/paste.
Easier to maintain, easier to read, easier to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where would I put the code because if I put it around line 57 it says userPreferences can't be accessed

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sure you can put TmpCountryWikiLinks() .wikiLinks[userPreferences.userCountryCode] in a local String? variable.
If needed, have a look at tutorials specific to dart or flutter, for instance about the ways a method can return a value - something like => and return syntaxes.

() async => LaunchUrlHelper.launchURL(
'https://wiki.openfoodfacts.org/Country_Support_- ${userPreferences.userCountryCode ?? 'France'}'),
const IconData(0xf68d),
externalLink: true),
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really optional.

Comment on lines 21 to 22
// 'Belgium': 'https://wiki.openfoodfacts.org/Country_Support_-_Belgium',
// 'Bulgaria': 'https://wiki.openfoodfacts.org/Local_Communities/BulgarianTeam',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't put useless comments.

Copy link
Member

Choose a reason for hiding this comment

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

I have harmonized on the first pattern FYI

@jnnabugwu
Copy link
Contributor Author

@monsieurtanuki hey I was wondering what's the technical reason why we are using a map instead of just using strings is it just for organizing?

@monsieurtanuki
Copy link
Contributor

@monsieurtanuki hey I was wondering what's the technical reason why we are using a map instead of just using strings is it just for organizing?

I have no idea what you mean with "just using strings". Please use a Map for the moment: that's specifically something that would be refactored in openfoodfacts-dart anyway.

@teolemon
Copy link
Member

/lint

1 similar comment
@teolemon
Copy link
Member

/lint

@monsieurtanuki
Copy link
Contributor

@jnnabugwu Still working on it?

@jnnabugwu
Copy link
Contributor Author

jnnabugwu commented Sep 13, 2024 via email

@monsieurtanuki
Copy link
Contributor

@jnnabugwu No problem!

@teolemon teolemon requested a review from a team September 20, 2024 14:43
@jnnabugwu jnnabugwu closed this Nov 7, 2024
@jnnabugwu jnnabugwu force-pushed the contribute-to-your-country-link branch from b82769a to e3fa4f4 Compare November 7, 2024 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Create a "Contribute to your country" link
4 participants