-
Notifications
You must be signed in to change notification settings - Fork 845
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
Chore: move editor text elements into separate files when possible #2274
Draft
CatHood0
wants to merge
3
commits into
singerdmx:master
Choose a base branch
from
CatHood0:move_text_line_members
base: master
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.
+2,126
−2,044
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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 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
63 changes: 63 additions & 0 deletions
63
lib/src/editor/widgets/text/block_line/editable_text_block.dart
This file contains 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../../../../common/structs/horizontal_spacing.dart'; | ||
import '../../../../common/structs/vertical_spacing.dart'; | ||
import '../../../../document/nodes/block.dart'; | ||
import 'render_editable_text_block.dart'; | ||
|
||
//TODO: we need to document what does this and why we use it | ||
@internal | ||
@immutable | ||
class EditableBlock extends MultiChildRenderObjectWidget { | ||
const EditableBlock( | ||
{required this.block, | ||
required this.textDirection, | ||
required this.horizontalSpacing, | ||
required this.verticalSpacing, | ||
required this.scrollBottomInset, | ||
required this.decoration, | ||
required this.contentPadding, | ||
required super.children, | ||
super.key}); | ||
|
||
final Block block; | ||
final TextDirection textDirection; | ||
final HorizontalSpacing horizontalSpacing; | ||
final VerticalSpacing verticalSpacing; | ||
final double scrollBottomInset; | ||
final Decoration decoration; | ||
final EdgeInsets? contentPadding; | ||
|
||
EdgeInsets get _padding => EdgeInsets.only( | ||
left: horizontalSpacing.left, | ||
right: horizontalSpacing.right, | ||
top: verticalSpacing.top, | ||
bottom: verticalSpacing.bottom); | ||
|
||
EdgeInsets get _contentPadding => contentPadding ?? EdgeInsets.zero; | ||
|
||
@override | ||
RenderEditableTextBlock createRenderObject(BuildContext context) { | ||
return RenderEditableTextBlock( | ||
block: block, | ||
textDirection: textDirection, | ||
padding: _padding, | ||
scrollBottomInset: scrollBottomInset, | ||
decoration: decoration, | ||
contentPadding: _contentPadding, | ||
); | ||
} | ||
|
||
@override | ||
void updateRenderObject( | ||
BuildContext context, covariant RenderEditableTextBlock renderObject) { | ||
renderObject | ||
..setContainer(block) | ||
..textDirection = textDirection | ||
..scrollBottomInset = scrollBottomInset | ||
..setPadding(_padding) | ||
..decoration = decoration | ||
..contentPadding = _contentPadding; | ||
} | ||
} |
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.
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.
@AtlasAutocode @singerdmx Any idea?
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.
It looks like this was being used to separate the widget logic from the build and rendering logic.
For a StatefulWidget, we would use WidgetState to achieve the same purpose.
I guess I would leave it as a private class only callable from its parent EditableTextBlock. If we extract it as a separate public class, it could be mis-called from who knows where. (And people will ask 'why do we use this')
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 will add some documentation about what makes this class. We have some docs about this, but i have no much time. I will search and add it correctly as soon as possible.
I wrote that TODO to remember that i need to add 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.
Take as much time as you need.