-
Notifications
You must be signed in to change notification settings - Fork 15
feat: support adding words to dictionary with a callback #95
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
Open
andrew-bekhiet-solid
wants to merge
8
commits into
solid-software:main
Choose a base branch
from
andrew-bekhiet-solid:feat-support-adding-words-to-dictionary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c368843
style: run dart formatter
andrew-bekhiet-solid c376550
feat: add actions builder to allow adding actions
andrew-bekhiet-solid 3708476
refactor: avoid magic numbers
andrew-bekhiet-solid a6e9a65
feat: add "add to dictionary" feature
andrew-bekhiet-solid 85dbe56
doc: update changelog
andrew-bekhiet-solid 3e4a011
fix: add scroll view to scroll the ui
andrew-bekhiet-solid c2da5b6
reactor: allow changing language tool service and throttling duration
andrew-bekhiet-solid d2d1650
refactor: avoid widget returning methods
andrew-bekhiet-solid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,18 @@ class LanguageToolMistakePopup extends StatelessWidget { | |
| static const double _defaultVerticalMargin = 25.0; | ||
| static const double _defaultHorizontalMargin = 10.0; | ||
| static const double _defaultMaxWidth = 250.0; | ||
| static const _iconSize = 25.0; | ||
| static const double _logoSize = 25; | ||
| static const double _headerIconSize = 12; | ||
|
|
||
| static const double _borderRadius = 10.0; | ||
| static const double _mistakeNameFontSize = 11.0; | ||
| static const double _mistakeMessageFontSize = 13.0; | ||
| static const double _replacementButtonsSpacing = 4.0; | ||
| static const double _replacementButtonsSpacingMobile = -6.0; | ||
| static const double _paddingBetweenTitle = 14.0; | ||
| static const double _titleLetterSpacing = 0.56; | ||
| static const double _dismissSplashRadius = 2.0; | ||
| static const double _padding = 10.0; | ||
|
|
||
| /// Renderer used to display this window. | ||
| final PopupOverlayRenderer popupRenderer; | ||
|
|
@@ -84,9 +95,11 @@ class LanguageToolMistakePopup extends StatelessWidget { | |
| /// Mistake suggestion style. | ||
| final ButtonStyle? mistakeStyle; | ||
|
|
||
| /// [LanguageToolMistakePopup] constructor | ||
| /// Optional builder that adds additional actions to the header. | ||
| final Future<void> Function(String)? addWordToDictionary; | ||
|
|
||
| /// Creates a [LanguageToolMistakePopup]. | ||
| const LanguageToolMistakePopup({ | ||
| super.key, | ||
| required this.popupRenderer, | ||
| required this.mistake, | ||
| required this.controller, | ||
|
|
@@ -96,21 +109,12 @@ class LanguageToolMistakePopup extends StatelessWidget { | |
| this.horizontalMargin = _defaultHorizontalMargin, | ||
| this.verticalMargin = _defaultVerticalMargin, | ||
| this.mistakeStyle, | ||
| this.addWordToDictionary, | ||
| super.key, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| const _borderRadius = 10.0; | ||
| const _mistakeNameFontSize = 11.0; | ||
| const _mistakeMessageFontSize = 13.0; | ||
| const _replacementButtonsSpacing = 4.0; | ||
| const _replacementButtonsSpacingMobile = -6.0; | ||
| const _paddingBetweenTitle = 14.0; | ||
| const _titleLetterSpacing = 0.56; | ||
| const _dismissSplashRadius = 2.0; | ||
|
|
||
| const padding = 10.0; | ||
|
|
||
| final availableSpace = _calculateAvailableSpace(context); | ||
|
|
||
| final colorScheme = Theme.of(context).colorScheme; | ||
|
|
@@ -149,43 +153,58 @@ class LanguageToolMistakePopup extends StatelessWidget { | |
| children: [ | ||
| Padding( | ||
| padding: const EdgeInsets.only(left: 4), | ||
| child: Row( | ||
| children: [ | ||
| Expanded( | ||
| child: Row( | ||
| children: [ | ||
| Padding( | ||
| padding: const EdgeInsets.only(right: 5.0), | ||
| child: Image.asset( | ||
| LangToolImages.logo, | ||
| width: _iconSize, | ||
| height: _iconSize, | ||
| package: 'languagetool_textfield', | ||
| child: IconTheme( | ||
| data: const IconThemeData(size: _headerIconSize), | ||
| child: Row( | ||
| children: [ | ||
| Expanded( | ||
| child: Row( | ||
| children: [ | ||
| Padding( | ||
| padding: const EdgeInsets.only(right: 5.0), | ||
| child: Image.asset( | ||
| LangToolImages.logo, | ||
| width: _logoSize, | ||
| height: _logoSize, | ||
| package: 'languagetool_textfield', | ||
| ), | ||
| ), | ||
| ), | ||
| const Text('Correct'), | ||
| ], | ||
| const Text('Correct'), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| IconButton( | ||
| icon: const Icon( | ||
| Icons.close, | ||
| size: 12, | ||
| if (addWordToDictionary case final addWordToDictionary?) | ||
| IconButton( | ||
| icon: const Icon(Icons.menu_book), | ||
| constraints: const BoxConstraints(), | ||
| splashRadius: _dismissSplashRadius, | ||
| onPressed: () async { | ||
| final word = controller.text.substring( | ||
| mistake.offset, | ||
| mistake.endOffset, | ||
| ); | ||
|
|
||
| await addWordToDictionary(word); | ||
|
|
||
| _fixTheMistake(word); | ||
|
Comment on lines
+181
to
+189
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. Should we extract this to the private method? |
||
| }, | ||
|
andrew-bekhiet-solid marked this conversation as resolved.
|
||
| ), | ||
| IconButton( | ||
| icon: const Icon(Icons.close), | ||
| constraints: const BoxConstraints(), | ||
| splashRadius: _dismissSplashRadius, | ||
| onPressed: () { | ||
| _dismissDialog(); | ||
| controller.onClosePopup(); | ||
| }, | ||
| ), | ||
| constraints: const BoxConstraints(), | ||
| padding: EdgeInsets.zero, | ||
| splashRadius: _dismissSplashRadius, | ||
| onPressed: () { | ||
| _dismissDialog(); | ||
| controller.onClosePopup(); | ||
| }, | ||
| ), | ||
| ], | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| Container( | ||
| margin: const EdgeInsets.only(top: 8), | ||
| padding: const EdgeInsets.all(padding), | ||
| padding: const EdgeInsets.all(_padding), | ||
| decoration: BoxDecoration( | ||
| color: colorScheme.surface, | ||
| borderRadius: BorderRadius.circular(_borderRadius), | ||
|
|
@@ -210,7 +229,7 @@ class LanguageToolMistakePopup extends StatelessWidget { | |
| ), | ||
| ), | ||
| Padding( | ||
| padding: const EdgeInsets.only(bottom: padding), | ||
| padding: const EdgeInsets.only(bottom: _padding), | ||
| child: Text( | ||
| mistake.message, | ||
| style: const TextStyle( | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.