-
-
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
Changes from 5 commits
d8aed2f
43cdaab
234b88a
3ee60ab
34a0796
4cbea5f
e8081a0
4b7b140
36e226b
ee90a53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,23 +75,36 @@ class EditNewPackagingsHelper { | |
|
||
void addIfNotEmpty(final String text) { | ||
if (text.isNotEmpty) { | ||
result.add(text); | ||
result.add('$text '); | ||
} | ||
} | ||
|
||
addIfNotEmpty(controllerUnits.text); | ||
|
||
if (controllerUnits.text.isNotEmpty) { | ||
result.add('${controllerUnits.text} x '); | ||
} | ||
|
||
addIfNotEmpty(controllerShape.text); | ||
addIfNotEmpty(controllerMaterial.text); | ||
addIfNotEmpty(controllerRecycling.text); | ||
addIfNotEmpty(controllerWeight.text); | ||
addIfNotEmpty(controllerQuantity.text); | ||
|
||
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 (result.isEmpty) { | ||
return null; | ||
} | ||
return result.join(' '); | ||
return result.join(''); | ||
thomas-algo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// 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 commentThe 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 commentThe 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. |
||
} | ||
/// Returns the packaging from the controllers. | ||
ProductPackaging getPackaging() { | ||
final ProductPackaging packaging = ProductPackaging(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,16 +52,16 @@ class SimpleInputTextField extends StatelessWidget { | |
if (input.length < minLengthForSuggestions) { | ||
return <String>[]; | ||
} | ||
|
||
thomas-algo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return OpenFoodAPIClient.getSuggestions( | ||
tagType!, | ||
language: ProductQuery.getLanguage()!, | ||
country: ProductQuery.getCountry(), | ||
categories: categories, | ||
shape: shapeProvider?.call(), | ||
user: ProductQuery.getUser(), | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Why 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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. Therefore your answer is: " 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. 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
input: input, | ||
); | ||
}, | ||
fieldViewBuilder: (BuildContext context, | ||
|
@@ -109,17 +109,7 @@ class SimpleInputTextField extends StatelessWidget { | |
options: options, | ||
// Width = Row width - horizontal padding | ||
maxOptionsWidth: constraints.maxWidth - (LARGE_SPACE * 2), | ||
maxOptionsHeight: screenHeight - | ||
(keyboardHeight == 0 | ||
? kBottomNavigationBarHeight | ||
: keyboardHeight) - | ||
widgetPosition - | ||
// Vertical padding | ||
(LARGE_SPACE * 2) - | ||
// Height of the TextField | ||
(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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. You can see the result on the third screenshot |
||
); | ||
}, | ||
), | ||
|
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.
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.
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.
@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.
Maybe we can put a similar function in Smoothie, it's likely to be useful in other places.