-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Disable cursor opacity animation on macOS, make iOS cursor animation discrete #104335
Disable cursor opacity animation on macOS, make iOS cursor animation discrete #104335
Conversation
_DiscreteKeyFrameSimulation.iOSBlinkingCaret() : this._(_KeyFrame.iOSBlinkingCaretKeyFrames); | ||
_DiscreteKeyFrameSimulation._(this._keyFrames) | ||
: assert(_keyFrames.isNotEmpty), | ||
assert(_keyFrames.last.time < maxDuration); |
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.
Should we also make sure _keyFrames
is sorted in an assert?
|
||
@override | ||
double x(double time) { | ||
time = time % maxDuration; |
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.
Reuse the time
parameter is a little hard to comprehend. What does the new "time" mean? Maybe create a new variable with a different name to better describe what is time % maxDuration
? Or maybe add a comment to explain. (I'd still have a new variable for it)
@@ -3489,7 +3543,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien | |||
text = widget.obscuringCharacter * text.length; | |||
// Reveal the latest character in an obscured field only on mobile. |
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 comment has to be updated. Also a good place to explain why iOS is excluded, maybe add the issue link?
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.
@LongCatIsLooong is this affected by your brieflyShowPassword
thing, or was that Android only?
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.
Oh I see you moved around a test related to this below.
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.
Yeah that was for Android only.
await verifyKeyFrame(opacity: 0.5, at: 925000); | ||
await verifyKeyFrame(opacity: 0.75, at: 962500); | ||
await verifyKeyFrame(opacity: 1.0, at: 1000000); | ||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS })); |
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.
Didn't we need to keep the macOS version of the test?
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.
Changed the simulation to no longer wrap around when the input time
becomes >= maxDuration. EditableTextState
ends the animation anyways.
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
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 👍
// A time-value pair that represents a key frame in an animation. | ||
class _KeyFrame { | ||
const _KeyFrame(this.time, this.value); | ||
// Values extracted from iOS 15.4 UIKit. |
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.
How did you actually extract these values? Just out of my own curiosity.
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); | ||
|
||
// Regression test for https://github.com/flutter/flutter/issues/78918. | ||
// Regression test for https://github.com/flutter/flutter/issues/78918. |
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 you accidentally removed a space here if I'm reading the diff right.
@@ -3489,7 +3543,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien | |||
text = widget.obscuringCharacter * text.length; | |||
// Reveal the latest character in an obscured field only on mobile. |
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.
@LongCatIsLooong is this affected by your brieflyShowPassword
thing, or was that Android only?
// verifies the opacity immediately *before* each key frame to avoid | ||
// fp precision issues. |
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.
Nice 👍
lastVerifiedOpacity = opacity; | ||
} | ||
|
||
await verifyKeyFrame(opacity: 1.0, at: 500000); |
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.
Nit: Is it possible to reference the values in iOSBlinkingCaretKeyFrames instead of hardcoding them?
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'd prefer not to expose that animation, otherwise we would have to maintain that as a public API I think?
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.
Oh right, I didn't realize it was in a private class. Sounds good as-is.
await tester.pump(const Duration(milliseconds: 100)); | ||
expect(tester.hasRunningAnimations, false); | ||
} | ||
}, variant: TargetPlatformVariant(TargetPlatform.values.toSet()..remove(TargetPlatform.iOS))); |
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.
Nice way to exclude a platform. See also #106216 CC @antholeole.
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.
Almost exactly how 106216 is implemented! Depending on what gets in first, I’ll either change this to use the new API or this should use the new API.
Another good use case :).
@@ -956,4 +970,40 @@ void main() { | |||
); | |||
EditableText.debugDeterministicCursor = false; | |||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); | |||
|
|||
testWidgets('password briefly does not show last character on Android if turned off', (WidgetTester tester) async { |
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 mentions Android but it's run on the current platform? Shouldn't it fail on iOS?
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.
Renamed the test
@@ -3489,7 +3543,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien | |||
text = widget.obscuringCharacter * text.length; | |||
// Reveal the latest character in an obscured field only on mobile. |
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.
Oh I see you moved around a test related to this below.
…imation discrete (flutter#104335)"
animation discrete (flutter#104335)" (reverted in flutter#106762) This reverts commit 8124191.
NSView
that gets removed/added back periodically in AppKit text input views, its opacity doesn't change. This fixes Too much CPU usage with TextField caret on macOS #85781, CPU usage stays below/around 1% in my test app.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.