-
-
Notifications
You must be signed in to change notification settings - Fork 306
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: #798 - now a unique page for preferences, in accordion #820
feat: #798 - now a unique page for preferences, in accordion #820
Conversation
…dion Deleted file: * `settings_page.dart`: all the code was moved to `user_preferences_page.dart` Impacted files: * `labeler.yml`: removed reference to `settings_page.dart` * `user_preferences.dart`: added bool flags getter and setter * `user_preferences_page.dart`: now displays in accordion the same preferences, plus the former settings_page, plus the former action bar
That's great @monsieurtanuki 👍 |
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.
First of all (again?) happy new year @monsieurtanuki and @teolemon 🎉
And to the PR there are a few things that I have to put out, see the comments but in general I think the code is much more complex than it needs to be, as can be seen by the fact that even you made a mistake (in profile are the settings items and in vrac are the user things).
ListView(
children: <Widget>[
_getGroupTitle(0, userPreferences, themeData);
if(!_isCollapsed(0, userPreferences)) ..._getListItemsUser(...);
_getGroupTitle(1, userPreferences, themeData);
if(!_isCollapsed(1, userPreferences)) ..._getListItemsUser(...);
_getGroupTitle(2, userPreferences, themeData);
if(!_isCollapsed(2, userPreferences)) ..._getListItemsUser(...);
],
);
List<Widget> _getListItemsUser(){
return <Widget>[
];
};
throw Exception('unknown group index: $groupIndex'); | ||
} | ||
|
||
int _getTotalSize( |
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.
Suggestion: _getTotalLength
_getTotalSize(groups, userPreferences), | ||
(int index) { | ||
for (int groupIndex = 0; groupIndex < 3; groupIndex++) { | ||
if (index-- == 0) { |
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.
This syntax works but it's not so easy to understand, I would prefer something like this but feel free to ignore that
index--;
if(index == 0){
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.
There are indeed things to fix in my code.
But here your suggestion is wrong:
if(index-- == 0){
// do something with index before subtracting 1
}
means
if(index == 0){
index --;
// do something
} else {
index--;
}
if (extra) { | ||
title = Row( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
title, | ||
Container( | ||
width: 15, | ||
height: 15, | ||
child: Center( | ||
child: Text( | ||
'1', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontSize: 8, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
decoration: BoxDecoration( | ||
color: Colors.red, | ||
shape: BoxShape.circle, | ||
), | ||
), | ||
], | ||
); |
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.
I don't think we need this red dot from the mocks, it does look good, but only a hardcoded one is confusing. We currently have nothing to display with this so we don't need the additional code.
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.
Fair enough, it was just for the screenshot. Removing it...
return 5; | ||
case 1: | ||
return groups.length; | ||
case 2: | ||
return 3; |
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.
A user items length and settings items length int would certainly be nice for later additions
); | ||
} | ||
|
||
int _getCollapsedSize( |
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.
_getExpandedLength
case 1: | ||
return 'food'; | ||
case 2: | ||
return 'vrac'; |
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.
Had to use the translator to understand this, would be good to stick with english
) { | ||
switch (groupIndex) { | ||
case 0: | ||
return _getListItemSettings( |
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.
_getListItemVrac
themeData, | ||
); | ||
case 2: | ||
return _getListItemVrac(index, appLocalizations); |
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.
_getListItemSettings
New files: * `abstract_user_preferences.dart`: Abstraction of a collapsed/expanded display for the preferences page. * `user_preferences_attribute_group.dart`: Collapsed/expanded display of attributes for the preferences page. * `user_preferences_profile.dart`: Collapsed/expanded display of profile for the preferences page. * `user_preferences_settings.dart`: Collapsed/expanded display of settings for the preferences page. Impacted file: * `user_preferences_page.dart`: huge simplification through the use of instances of new class `AbstractUserPreferences`
@monsieurtanuki there are conflicts to solve |
…e.dart part 2/2 so far so good
Conflict resolved. |
|
@@ -0,0 +1,168 @@ | |||
import 'package:flutter/cupertino.dart'; |
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.
import 'package:flutter/cupertino.dart'; |
I added 3 suggestions to 🟢 the CI @monsieurtanuki @M123-dev |
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.
Looks great, thanks @monsieurtanuki, maybe it would be an idea to move the preferences pages to their own subfolder but it's not that important
abstract class AbstractUserPreferences { | ||
AbstractUserPreferences(this.setState); |
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.
Just a suggestion I think AppPreferences is easier to otherwise it could be mistakely seen as the real user manangement setting, but feel free to ignore that
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.
I added 3 suggestions to 🟢 the CI @monsieurtanuki @M123-dev
I'll do that. Is there a way we can put the same level of lint checks in dev (Android Studio) and in CI?
UserPreferencesSettings(setState), | ||
UserPreferencesAttributeGroup( | ||
setState, | ||
productPreferences, |
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.
Shouldn't UserPreferencesProfile be the first one here?
New file: * `user_preferences_food.dart`: Collapsed/expanded display of attribute groups for the preferences page. Impacted files: * `abstract_user_preferences.dart`: refactored for localization * `app_en.arb`: added 6 labels for preferences titles and subtitles * `app_fr.arb`: added 6 labels for preferences titles and subtitles * `user_preferences_attribute_group.dart`: now we manage here only one group at a time, to make it collapsable * `user_preferences_page.dart`: refactored for localization * `user_preferences_profile.dart`: refactored for localization * `user_preferences_settings.dart`: refactored for localization
Impacted file: * `user_preferences_food.dart`
Impacted files: * `user_preferences_page-blue-dark.png` * `user_preferences_page-blue-light.png` * `user_preferences_page-brown-dark.png` * `user_preferences_page-brown-light.png` * `user_preferences_page-green-dark.png` * `user_preferences_page-green-light.png`
Btw how is "labeler" supposed to work? Every time it fails - is there something to fix, and what? |
labeler works if you PR on the main repo, but not on forks :-( |
Deleted file:
settings_page.dart
: all the code was moved touser_preferences_page.dart
Impacted files:
labeler.yml
: removed reference tosettings_page.dart
user_preferences.dart
: added bool flags getter and setteruser_preferences_page.dart
: now displays in accordion the same preferences, plus the former settings_page, plus the former action barIt's ugly (in the code and on the screen), but it's a start
![Simulator Screen Shot - iPhone 8 Plus - 2022-01-02 at 13 11 40](https://user-images.githubusercontent.com/11576431/147875309-c21e814f-a992-4a3c-b016-cd1a91d1c502.png)