This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS keyboard animation synchronization #37604
Merged
Merged
Changes from 38 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
8472d6d
first keyboard commit
CoolDude53 c6dab59
first keyboard commit
CoolDude53 11bab51
Merge branch 'main' of github.com:CoolDude53/engine into ios-keyboard…
CoolDude53 6e64b0d
cleaned up from initial testing
CoolDude53 142a133
added keyboard animation stop calculation
CoolDude53 96c4c5d
added keyboard animation stop calculation
CoolDude53 eff2b16
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 cc31006
lucky updates :)
CoolDude53 b1f484e
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 ad15be4
type change
CoolDude53 3e1a279
Merge branch 'ios-keyboard-animation' of github.com:CoolDude53/engine…
CoolDude53 a5027d3
final touches
CoolDude53 84d7b8e
final touches
CoolDude53 1e208d1
final touches
CoolDude53 756ae31
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 2b3743e
removed KeyboardAnimationView class
CoolDude53 b38cad0
removed KeyboardAnimationView class
CoolDude53 489bd1d
Merge branch 'ios-keyboard-animation' of github.com:CoolDude53/engine…
CoolDude53 0aeccc9
dynamic keyboard spring curve implementation
CoolDude53 1cd784a
broke out spring curve to own objc files
CoolDude53 ef8481c
broke out spring curve to own objc files
CoolDude53 582f2e0
simplified and added test
CoolDude53 3179417
modified spring formula to use damping
CoolDude53 467e1ce
added logic for compounding simultaneous animation calls
CoolDude53 98ee432
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 7436731
remove unnecessary code
CoolDude53 ace0211
cleanup
CoolDude53 c285ad9
cleanup
CoolDude53 49abfc3
update springCurveIos file
CoolDude53 0fb7a03
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 3cc8638
cleaning up
CoolDude53 b6b8747
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 20ffdc9
simple optimizations
CoolDude53 1abe18d
comment update
CoolDude53 3e5ef3f
bool update
CoolDude53 7c335d5
Merge remote-tracking branch 'upstream/main' into ios-keyboard-animation
CoolDude53 d764770
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 328b166
credit spring calculation project
CoolDude53 99f5d15
improved setupKeyboardAnimationCureveIfNeeded tests
CoolDude53 03c1f75
Optimized compounding animation checks and added new tests
CoolDude53 c143f19
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 c03d642
changed viewport update logic
CoolDude53 fd2eaee
Update FlutterViewControllerTest.mm
CoolDude53 33ca106
Updated license
CoolDude53 934bcf8
Updated tests
CoolDude53 5f7d563
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 76245e7
Cleanup
CoolDude53 d5a506f
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 e70e1bc
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 73062e7
Migrated spring class based on React
CoolDude53 b2a92dd
Updated syntax
CoolDude53 61b70f6
Update shell/platform/darwin/ios/framework/Source/spring_curve_ios.mm
CoolDude53 059bb70
Update shell/platform/darwin/ios/framework/Source/spring_curve_ios.h
CoolDude53 9c78679
Updated naming
CoolDude53 ebcb722
Updated naming
CoolDude53 3728335
Optimized spring model calculations
CoolDude53 6d02512
Improved interpolation accuracy
CoolDude53 3530db3
Revert "Improved interpolation accuracy"
CoolDude53 fb497a4
Updated comment
CoolDude53 3dcb341
Updated spring curve comments
CoolDude53 bc22eef
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 b797c91
updated to work with third_party spring animation
CoolDude53 f4556a8
updated to use SpringAnimation to/from values
CoolDude53 b9d0d78
updated license (removed old files)
CoolDude53 f35a1e8
updates
CoolDude53 4ed2380
allow updating springanimation position values
CoolDude53 29b8ace
updated test
CoolDude53 13faeec
update
CoolDude53 4682d80
fixes
CoolDude53 bc298b3
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 2fe2cf6
Merge branch 'flutter:main' into ios-keyboard-animation
CoolDude53 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
24 changes: 24 additions & 0 deletions
24
shell/platform/darwin/ios/framework/Source/spring_curve_ios.h
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_CURVE_IOS_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_CURVE_IOS_H_ | ||
|
|
||
| #include <Foundation/NSObject.h> | ||
|
|
||
| @interface KeyboardSpringCurve : NSObject | ||
CoolDude53 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - (instancetype)initWithStiffness:(double)stiffness | ||
| damping:(double)damping | ||
| mass:(double)mass | ||
| initialVelocity:(double)initialVelocity; | ||
|
|
||
| - (double)curveFunc:(double)t; | ||
|
|
||
| @property(nonatomic, assign) double initialVelocity; | ||
| @property(nonatomic, assign) double dampingRatio; | ||
| @property(nonatomic, assign) double omega; | ||
| @end | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_CURVE_IOS_H_ | ||
53 changes: 53 additions & 0 deletions
53
shell/platform/darwin/ios/framework/Source/spring_curve_ios.mm
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 |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #import "flutter/shell/platform/darwin/ios/framework/Source/spring_curve_ios.h" | ||
|
|
||
| #include <Foundation/Foundation.h> | ||
|
|
||
| // Spring calculation adapted from Pan Yusheng's research project. | ||
| // See: https://github.com/CosynPa/RevealSpringAnimation. | ||
luckysmg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @implementation KeyboardSpringCurve | ||
| - (instancetype)initWithStiffness:(double)stiffness | ||
| damping:(double)damping | ||
| mass:(double)mass | ||
| initialVelocity:(double)initialVelocity { | ||
| self = [super init]; | ||
| if (self) { | ||
| _dampingRatio = MIN(1.0, damping / 2 / sqrt(stiffness * mass)); | ||
| _initialVelocity = initialVelocity; | ||
|
|
||
| double response = MAX(1e-5, 2 * M_PI / sqrt(stiffness / mass)); | ||
| _omega = 2 * M_PI / response; | ||
| } | ||
| return self; | ||
| } | ||
|
|
||
| - (double)curveFunc:(double)t { | ||
| double v0 = self.initialVelocity; | ||
| double zeta = self.dampingRatio; | ||
|
|
||
| double y; | ||
| if (abs(zeta - 1.0) < 1e-8) { | ||
| double c1 = -1.0; | ||
| double c2 = v0 - self.omega; | ||
| y = (c1 + c2 * t) * exp(-self.omega * t); | ||
| } else if (zeta > 1) { | ||
| double s1 = self.omega * (-zeta + sqrt(zeta * zeta - 1)); | ||
| double s2 = self.omega * (-zeta - sqrt(zeta * zeta - 1)); | ||
| double c1 = (-s2 - v0) / (s2 - s1); | ||
| double c2 = (s1 + v0) / (s2 - s1); | ||
| y = c1 * exp(s1 * t) + c2 * exp(s2 * t); | ||
| } else { | ||
| double a = -self.omega * zeta; | ||
| double b = self.omega * sqrt(1 - zeta * zeta); | ||
| double c2 = (v0 + a) / b; | ||
| double theta = atan(c2); | ||
| // Alternatively y = (-cos(b * t) + c2 * sin(b * t)) * exp(a * t) | ||
| y = sqrt(1 + c2 * c2) * exp(a * t) * cos(b * t + theta + M_PI); | ||
| } | ||
|
|
||
| return y + 1; | ||
| } | ||
| @end | ||
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.