-
-
Notifications
You must be signed in to change notification settings - Fork 287
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: Clearer 'Packaging components' preview and modified the maximum size of the autocomplete tab. #3744
feat: Clearer 'Packaging components' preview and modified the maximum size of the autocomplete tab. #3744
Conversation
Preview is now clearer and more coherent with what is shown on the product page.
…ght fixed - The autocomplete now gives the most common answers for the field before user start typing. (Useful for packaging material, recycling...) - Fixing _AssertionError 'maxOptionsHeight >= 0': is not true: The old formula could give negative values. It could also create an unreadable autocomplete if the field was too close to the keyboard.
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.
¡Hi @thomas-algo!
Please have a look at my comments.
I approve some of your UI/UX changes, but I cannot see the related issue.
if (controllerMaterial.text.isNotEmpty & controllerWeight.text.isNotEmpty) { | ||
result.add('(${controllerMaterial.text} : ${controllerWeight.text}g)'); | ||
} | ||
|
||
else if (controllerMaterial.text.isNotEmpty ) { // Therefore controllerWeight.text is empty | ||
result.add('(${controllerMaterial.text})'); | ||
} | ||
|
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.
if (controllerMaterial.text.isNotEmpty & controllerWeight.text.isNotEmpty) { | |
result.add('(${controllerMaterial.text} : ${controllerWeight.text}g)'); | |
} | |
else if (controllerMaterial.text.isNotEmpty ) { // Therefore controllerWeight.text is empty | |
result.add('(${controllerMaterial.text})'); | |
} | |
if (controllerMaterial.text.isNotEmpty) { | |
if (controllerWeight.text.isNotEmpty) { | |
result.add('(${controllerMaterial.text} : ${controllerWeight.text}g)'); | |
} else { | |
result.add('(${controllerMaterial.text})'); | |
} | |
} |
So you don't display the weight if the material is not specified, which is a bit strange.
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.
Yes, this is the same behavior as in the final product page. However, it might be interesting to have the mass in both cases (Nevertheless, the case where 'material' is empty and 'weight' is filled is quit rare).
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.
Again, I don't know where the changed display was suggested. And how rare the "the case where 'material' is empty and 'weight' is filled".
I would suggest at least to consider this very rare case with an additional test: "if weight is not empty and material is empty, let's display only weight".
By the way in English there's no space before a :
. In French it's an unbreakable space.
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.
if (controllerMaterial.text.isNotEmpty & controllerWeight.text.isNotEmpty) { | |
result.add('(${controllerMaterial.text} : ${controllerWeight.text}g)'); | |
} | |
else if (controllerMaterial.text.isNotEmpty ) { // Therefore controllerWeight.text is empty | |
result.add('(${controllerMaterial.text})'); | |
} | |
if (controllerMaterial.text.isNotEmpty & controllerWeight.text.isNotEmpty) { | |
result.add('(${controllerMaterial.text}: ${controllerWeight.text}g)'); | |
} | |
if (controllerMaterial.text.isNotEmpty & controllerWeight.text.isEmpty) { | |
result.add('(${controllerMaterial.text})'); | |
} | |
if (controllerMaterial.text.isEmpty & controllerWeight.text.isNotEmpty) { | |
result.add('(${controllerWeight.text}g)'); | |
} | |
// And nothing is added if they are both empty. |
Thanks for your advises, here is a version taking this case into account. I am not sure the display change was suggested elsewhere.
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.
By the way in English there's no space before a
:
. In French it's an unbreakable space.
@monsieurtanuki: on the server we have a translatable string 'sep' which is an empty string in English, and a space in French and other languages. Is this something already handled in some way in the app? I didn't see something equivalent in the lib/l10n/app_en.arb file
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.
@stephanegigandet We don't have this sep
in Smoothie.
Could you list all languages that do have a space, e.g. taken from the server?
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.
@monsieurtanuki I just checked, we only do it for French.
=head2 separator_before_colon( $l )
=head3 Arguments
=head4 language code $l
In some languages like French, colons have a space before them.
e.g. "Valeur : 500" in French, "Value: 500" in English
This function returns a non-breaking space character for those languages.
=cut
sub separator_before_colon ($l) {
if ($l eq 'fr') {
return "\N{U+00A0}";
}
else {
return '';
}
}
Maybe we can put a similar function in Smoothie, it's likely to be useful in other places.
return OpenFoodAPIClient.getSuggestions( | ||
tagType!, | ||
language: ProductQuery.getLanguage()!, | ||
limit: 1000000, // lower max count on the server anyway | ||
input: value.text.trim(), | ||
limit: 15, |
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.
Why 15
?
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.
The limit is 400 on the server. The autocomplete tab doesn't need to be that long. Moreover, if the maximum API limit on the server was increased, nothing would limit the number of items in the suggestions.
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.
Therefore your answer is: "15
is the best compromise according to me". Please add a comment about it.
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.
Yes, I believe that it is the best compromise, it is unnecessary to have more that 15 suggestions as approximately 5 can be seen at once on screen without scrolling.
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.
15 sounds reasonable, but yes a comment would be good 👍🏼
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.
Done!
packages/smooth_app/lib/pages/product/simple_input_text_field.dart
Outdated
Show resolved
Hide resolved
(DefaultTextStyle.of(context).style.fontSize ?? 0) - | ||
// Elevation | ||
4.0, | ||
maxOptionsHeight: screenHeight/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.
Just hoping it works.
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.
You can see the result on the third screenshot
} | ||
|
||
/// Returns the packaging subtitle from the controllers | ||
String getSubTitle() { | ||
return controllerRecycling.text; |
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.
Says who?
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 moved the packaging recycling info to the subtitle of the widget for readability (cf first screenshot). This function generate this subtitle.
@@ -40,19 +40,16 @@ class SimpleInputTextField extends StatelessWidget { | |||
optionsBuilder: (final TextEditingValue value) async { | |||
final String input = value.text.trim(); | |||
|
|||
if (input.isEmpty) { |
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 will be great for packaging shapes and packaging materials, in order to have the most popular suggestions available without having to type the first letter. But we probably should not do it for other tagType values than packaging_shapes and packaging_materials, as it probably would be confusing for things like categories and labels. Especially as currently we return suggestions in alphabetic order for them.
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.
Also addressed by @monsieurtanuki in #3750
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.
The solution provided in #3750 is indeed better, I removed mine from this PR.
Hi @thomas-algo, thanks a lot for this PR. This will definitely ease a lot the work to enter packaging data. As @monsieurtanuki suggests, it's best to first file issues about what you intend to change, so that others can comment, make suggestions etc. I'll file the corresponding issues for this PR. |
@monsieurtanuki as addressed the issue in openfoodfacts#3750 without disturbing old default behavior of the widget.
Phew, that were a lot of comments in a really short time. The automated tests are currently failing due to file formatting, please run |
This variables where previously used in the formula of maxOptionsHeight
Codecov Report
@@ Coverage Diff @@
## develop #3744 +/- ##
===========================================
- Coverage 10.41% 10.40% -0.02%
===========================================
Files 272 272
Lines 13824 13842 +18
===========================================
Hits 1440 1440
- Misses 12384 12402 +18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 good to me. Can we merge? cc @monsieurtanuki @M123-dev
packages/smooth_app/lib/pages/product/edit_new_packagings_helper.dart
Outdated
Show resolved
Hide resolved
I cannot say that I got all my answers but I see nothing too problematic in this PR. |
What
Updated the preview of the package in the 'Packaging components ' tab (cf two first screenshots)
Autocomplete now gives hints before anything is typed. (removed from this PR, implemented in feat: 3749 - improvements for packaging suggestions #3750)
Modified the maximum size of the autocomplete tab.
Screenshot
Old preview of the package in the 'Packaging components ' tab
New preview of the package in the 'Packaging components ' tab
Autocomplete now gives hints before anything is typed
Old behavior of the autocomplete max size
Stays small even when moved: