Android: Fixed the Deep Timeline zoom/pan "snap back" issue - #2382
Conversation
|
Reviewed at 5237b59. Correct, complete, and well diagnosed. Thank you for filing #2368 and then tracking it down yourself. Checked
On testing"Tested on a real Android device" is the right answer here and I am not going to ask for a unit test. This repository has no One housekeeping item, which I will handleThe last line of the description pairs a linking verb with the issue number. A description acts on merge whatever the squash message says, so I will rewrite it to a plain reference before taking this in, and retire the issue separately once this lands. Nothing for you to do. Merging. |
What this PR does
In TimelineChart (
Charts.kt:1232), the gesture handler capturedwindowStartandwindowEndvalues from the closure at composition time. When a zoom/pan gesture updated the window viaonWindowChange, it triggered a recomposition with new values, but the gesture handler still referenced the stale captured values. This caused the graph to snap back because each gesture event computed the new window relative to outdated values.Used rememberUpdatedState to create stable references that always hold the latest window values:
The gesture handler now reads from these state objects instead of capturing the values directly. This is the standard Compose pattern for accessing current state in long-lived closures like gesture handlers.
Type of change
How it was tested
Was tested on a real Android Device using real Whoop MG data.
Checklist
swift testinPackages/<name>)android/(./gradlew testFullDebugUnitTest)StrandDesigntokens — no hardcoded colors, fonts, or spacingdocs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystoresRelated issues
Refs #2368