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: Spellchecker for OCR screens #5409

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

g123k
Copy link
Collaborator

@g123k g123k commented Jun 19, 2024

Hi everyone,

Here is the implementation for #5398, that is to say, a dev mode flag to enable spellchecker on ingredients.
In light mode, our theme defines an onSurface white color.

Unless we want to rewrite everything, the easier thing is just to redefine locally this color, to prevent a white-on-white color.

To investigate: I think the ThemeProvider still has issues.

Screenshots:
Screenshot_1718780020
Screenshot_1718781981
Screenshot_1718781984
Screenshot_1718782113

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 @g123k!
Please have a look at my comments.

false) &&
(Platform.isAndroid || Platform.isIOS)
? const SpellCheckConfiguration()
: const SpellCheckConfiguration.disabled(),
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
: const SpellCheckConfiguration.disabled(),
: null,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

null and SpellCheckConfiguration.disabled() have different meanings here:

  • null = inherits from the config
  • SpellCheckConfiguration.disabled() = I don't want it at all

Copy link
Contributor

Choose a reason for hiding this comment

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

null and SpellCheckConfiguration.disabled()

I understand your point.
The thing is that in the app we already have tons of TextField, with implicitly null spellCheckConfigurations (or "inherits from the config").
I would say that this field should behave as before and should behave as the other TextFields of the app. Unless the user selects the new dev mode switch. Therefore null.

),
maxLines: null,
textInputAction: TextInputAction.newline,
ConsumerFilter<UserPreferences>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks a bit complex to me. A context.watch<UserPreferences>() would do the job, wouldn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A context.watch redraws the full Widget (that's a giant flaw in the code right now).
Here, it will only rebuild the field.

Copy link
Contributor

Choose a reason for hiding this comment

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

A context.watch redraws the full Widget

In that specific case, every time the user preferences change, right? Doesn't happen that often.
If really that bothers you, what about a specific private class with a watch for the text field?

Tbh I'm getting confused with all that mix of provider, consumer, consumerfilter, changenotifier and so on.
Confusion leads to low maintainability and bugs. It wouldn't be a problem if there were many reviewers with expertise in flutter. If we want to be able to integrate more contributors, the less flutter-specific we code, the better we are. My 2 cents.

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

Could you also enable it on the Product Name field ?

@teolemon teolemon merged commit f6ec9df into openfoodfacts:develop Jun 19, 2024
6 checks passed
@g123k g123k deleted the spellchecker branch June 20, 2024 22:30
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.

Add an option to spellcheck and grammarcheck the OCR fields and product name using OS level systems
3 participants