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
Adds a fade in and out, rounds corners, fixes offset and fixes height of cursor on iOS #24876
Conversation
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.
Awesome work. General feedback is move aesthetic things out of widgets and rendering layers.
Let me know if you're ready for another look |
Waiting on #24265 to land before finishing this. |
…to cursor-fixes merge
LGTM. cc @HansMuller FYI |
@@ -1283,15 +1351,30 @@ class RenderEditable extends RenderBox { | |||
offset.applyContentDimensions(0.0, _maxScrollExtent); | |||
} | |||
|
|||
Offset _getPixelPerfectCursorOffset(Rect caretRect) { | |||
final Offset caretPosition = localToGlobal(caretRect.topLeft); | |||
final double pixelMultiple = 1.0 / _devicePixelRatio; |
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.
these divisions are a bit hard to read. Why not just
final Offset logicalCaretPosition = localToGlobal(caretRect.topLeft);
final int physicalCaretX = (caretPosition.dx * _devicePixelRatio).round();
final int physicalCaretY = (caretPosition.dy * _devicePixelRatio).round();
final double pixelPerfectLogicalX = globalToLocal(physicalCaretX / _devicePixelRatio); // I'm not sure what the - caretPosition.dx was for
final double pixelPerfectLogicalY = globalToLocal(physicalCaretY / _devicePixelRatio);
Otherwise, aliasing around the edge seems like 'working as intended'. Just have your test not land on .499999999-.5.
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 I'm just going to leave this logic as is? It's supposed to give the delta logical pixels to move the rect to be physically pixel perfectly aligned. So that logic isn't really going to work.
@@ -682,6 +699,22 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi | |||
@override | |||
bool get wantKeepAlive => _splashes != null && _splashes.isNotEmpty; | |||
|
|||
bool get _cursorOpacityAnimates => Theme.of(context).platform == TargetPlatform.iOS ? true : false; | |||
|
|||
Offset get _getCursorOffset => Offset(_iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio, 0); |
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.
This appears to be used unconditionally. It should only be used if the platform is iOS.
/// | ||
/// Defaults to a super ellipse with | ||
// final ShapeBorder shape; | ||
|
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.
@jslavitz looks like this bit was checked in by mistake -- please take a moment to clean it. Thanks!
… of cursor on iOS (flutter#24876) * Fixes cursor on iOS devices
Fixes #22879.