-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Unify Text selection API #98073
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
Unify Text selection API #98073
Conversation
| if (selectionControls == null) | ||
| handle = Container(); | ||
| else { | ||
| handle = Visibility( |
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.
There are two ways to control the handle visibilities, first from TextSelectionOverlay.handlesVisible and second from renderEditable.selectionStartHandleInViewport. This pr creates a _effectiveStartHandleVisibility to merge both api and feed it directly into _SelectionHandleOverlay.
The difference is the _SelectionHandleOverlay use a fadeintransition instead of visibility widget. There might be a really minor visual difference.
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.
There is an issue (#52425) open about needing to do more fading to match native, so we probably need to make some changes there anyway.
| widget.glyphHeight, | ||
| widget.glyphHeight, | ||
| ); | ||
| final Size handleSize = widget.selectionControls.getHandleSize( |
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 think this should have used glyphHeight instead of lineHeight. The size is used to pad gesture rect to make it easier to tap. This refactor also fixes it because the preferredLineHeight now contains the glyphHeight
justinmc
left a comment
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.
LGTM, looks like a major win 👍
| if (selectionControls == null) | ||
| handle = Container(); | ||
| else { | ||
| handle = Visibility( |
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.
There is an issue (#52425) open about needing to do more fading to match native, so we probably need to make some changes there anyway.
| // If we are in build state, it will be too late to update visibility. | ||
| // We will need to schedule the build in next frame. | ||
| if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks) { | ||
| SchedulerBinding.instance.addPostFrameCallback(_markNeedsBuild); |
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's great that you could get rid of an addPostFrameCallback 👍
Renzo-Olivares
left a comment
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.
LGTM
* Unify Text selection API * fix test * further simplify * fix more tests * styling change
Unify lineHeight API and Visibility API.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.