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: 4513 - user preferences pages simple refactoring #4620

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

monsieurtanuki
Copy link
Contributor

What

  • This is a preliminary refactoring PR towards Turn the Settings Screen into an "For Me" screen #4513.
  • This PR does not change anything to the current display.
  • The general idea of this PR is to clean the code a bit.
  • More specifically, the idea is to flatten the preference tree - especially in user_preferences_settings.dart that was too big a file.
  • The next steps would be to OOP a bit more the preference items we display, for instance attaching labels to them, so that a "preference search" would be able to filter only the items that involve "screen" or "mustard". But that would be in a next PR.

Part of

Files

New files:

  • user_preferences_advanced_settings.dart: used to be _AdvancedSettings in user_preferences_settings.dart
  • user_preferences_camera_sound.dart: used to be _CameraPlayScanSoundSetting in user_preferences_settings.dart
  • user_preferences_choose_accent_color.dart: used to be _ChooseAccentColor in user_preferences_settings.dart
  • user_preferences_choose_app_theme.dart: used to be more or less _ChooseAppTheme in user_preferences_settings.dart
  • user_preferences_choose_text_color_contrast.dart: used to be _ChooseTextColorContrast in user_preferences_settings.dart
  • user_preferences_country_selector.dart: used to be coded in user_preferences_settings.dart
  • user_preferences_crash_reporting.dart: used to be _CrashReportingSetting in user_preferences_settings.dart
  • user_preferences_haptic_feedback.dart: used to be _HapticFeedbackSetting in user_preferences_settings.dart
  • user_preferences_image_source.dart: used to be coded in user_preferences_settings.dart
  • user_preferences_language_selector.dart: used to be coded in user_preferences_settings.dart
  • user_preferences_rate_us.dart: used to be _RateUs in user_preferences_settings.dart
  • user_preferences_send_anonymous.dart: used to be _SendAnonymousDataSetting in user_preferences_settings.dart
  • user_preferences_share_with_friends.dart: used to be _ShareWithFriends in user_preferences_settings.dart

Impacted files:

  • abstract_user_preferences.dart: minor refactoring
  • preferences_page.dart: minor refactoring
  • user_preferences.dart: minor refactoring
  • user_preferences_account.dart: removed UserPreferencesSection and _UserPreferencesAccountSubTitleSignOut for simplification
  • user_preferences_attribute_group.dart: refactored as not AbstractUserPreferences
  • user_preferences_connect.dart: minor refactoring
  • user_preferences_contribute.dart: minor refactoring
  • user_preferences_dev_mode.dart: minor refactoring
  • user_preferences_faq.dart: minor refactoring
  • user_preferences_food.dart: minor refactoring
  • user_preferences_page.dart: minor refactoring
  • user_preferences_settings.dart: file was too big - moved code to new files+classes

New files:
* `user_preferences_advanced_settings.dart`: used to be `_AdvancedSettings` in `user_preferences_settings.dart`
* `user_preferences_camera_sound.dart`: used to be `_CameraPlayScanSoundSetting` in `user_preferences_settings.dart`
* `user_preferences_choose_accent_color.dart`: used to be `_ChooseAccentColor` in `user_preferences_settings.dart`
* `user_preferences_choose_app_theme.dart`: used to be more or less `_ChooseAppTheme` in `user_preferences_settings.dart`
* `user_preferences_choose_text_color_contrast.dart`: used to be `_ChooseTextColorContrast` in `user_preferences_settings.dart`
* `user_preferences_country_selector.dart`: used to be coded in `user_preferences_settings.dart`
* `user_preferences_crash_reporting.dart`: used to be `_CrashReportingSetting` in `user_preferences_settings.dart`
* `user_preferences_haptic_feedback.dart`: used to be `_HapticFeedbackSetting` in `user_preferences_settings.dart`
* `user_preferences_image_source.dart`: used to be coded in `user_preferences_settings.dart`
* `user_preferences_language_selector.dart`: used to be coded in `user_preferences_settings.dart`
* `user_preferences_rate_us.dart`: used to be `_RateUs` in `user_preferences_settings.dart`
* `user_preferences_send_anonymous.dart`: used to be `_SendAnonymousDataSetting` in `user_preferences_settings.dart`
* `user_preferences_share_with_friends.dart`: used to be `_ShareWithFriends` in `user_preferences_settings.dart`

Impacted files:
* `abstract_user_preferences.dart`: minor refactoring
* `preferences_page.dart`: minor refactoring
* `user_preferences.dart`: minor refactoring
* `user_preferences_account.dart`: removed `UserPreferencesSection` and `_UserPreferencesAccountSubTitleSignOut` for simplification
* `user_preferences_attribute_group.dart`: refactored as not `AbstractUserPreferences`
* `user_preferences_connect.dart`: minor refactoring
* `user_preferences_contribute.dart`: minor refactoring
* `user_preferences_dev_mode.dart`: minor refactoring
* `user_preferences_faq.dart`: minor refactoring
* `user_preferences_food.dart`: minor refactoring
* `user_preferences_page.dart`: minor refactoring
* `user_preferences_settings.dart`: file was too big - moved code to new files+classes
@monsieurtanuki monsieurtanuki requested a review from a team as a code owner September 4, 2023 11:36
@github-actions github-actions bot added the 🤗 Onboarding We need to onboard users on how the app works, but also on content like Nutri-Score, Eco-Score… label Sep 4, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #4620 (61e0f0b) into develop (0a64d60) will decrease coverage by 0.11%.
The diff coverage is 17.81%.

@@             Coverage Diff             @@
##           develop    #4620      +/-   ##
===========================================
- Coverage    10.13%   10.03%   -0.11%     
===========================================
  Files          299      312      +13     
  Lines        15692    15637      -55     
===========================================
- Hits          1591     1569      -22     
+ Misses       14101    14068      -33     
Files Changed Coverage Δ
.../lib/data_models/preferences/user_preferences.dart 20.14% <0.00%> (-0.16%) ⬇️
...oth_app/lib/pages/onboarding/preferences_page.dart 0.00% <ø> (ø)
.../preferences/user_preferences_attribute_group.dart 0.00% <0.00%> (ø)
...ib/pages/preferences/user_preferences_connect.dart 4.72% <ø> (ø)
...pages/preferences/user_preferences_contribute.dart 55.75% <ø> (ø)
...b/pages/preferences/user_preferences_dev_mode.dart 0.00% <0.00%> (ø)
...pp/lib/pages/preferences/user_preferences_faq.dart 4.87% <ø> (ø)
...p/lib/pages/preferences/user_preferences_food.dart 11.86% <0.00%> (ø)
...b/pages/preferences/user_preferences_settings.dart 12.06% <0.00%> (+3.40%) ⬆️
...ferences/user_preferences_choose_accent_color.dart 3.84% <3.84%> (ø)
... and 15 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

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

I don't think it's a necessary change, but smaller files are a good idea and I am certain it'll help your refactoring. Thanks @monsieurtanuki 👍🏼

@monsieurtanuki monsieurtanuki merged commit 05d0490 into openfoodfacts:develop Sep 12, 2023
6 checks passed
@monsieurtanuki
Copy link
Contributor Author

Thank you @M123-dev for your review!

We do need it, and you'll see how in the next PR! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤗 Onboarding We need to onboard users on how the app works, but also on content like Nutri-Score, Eco-Score…
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants