-
Notifications
You must be signed in to change notification settings - Fork 206
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
Experimental Modifier.Node implementation of Modifier.tabIndicatorOffset #996
base: main
Are you sure you want to change the base?
Conversation
Hi @surajsau! Codes seem to be unformatted. To resolve this issue, please run |
Sorry for the delay! Your implementation is really cool. It's gonna take me a bit to get my head around the changes. I've got a few PRs to go through, so I'll get to yours after that. If you're in a rush for some reason, just let me know. 🙏 |
@takahirom Not in any kind of rush. 👍 This PR is more of a reference (also for my DroidKaigi session on Modifier.Node 😅) of how existing |
Overview
Experimental implementation of migrating Modifier.tabIndicatorOffset to Modifier.Node as an example for implementation for Modifier.Node.
Implementation
The Modifier.composed version of Modifier.tabIndicatorOffset looks like this,
fun InspectorInfo.inspectableProperties()
is overridden to the same as that of Modifier.composed version.animateDpAsState
states ofcurrentTabWidth
andindicatorOffset
. If we look at the implementation ofanimateDpAsState
, it basically has aAnimatable
instance which is animated to a newly set targetValue.Animatable
instances for currentTabWidth and indicatorOffset in the Modifier.Node and fireanimateTo
function when the target value is changed.mutableState
object in the Modifier.Node so that we can automatically trigger a Recomposition upon a new value gets set.shouldAutoInvalidate = true
flag is by default, LayoutModifierNode's invalidation method,measure()
is automatically called upon every Recomposition.measure()
.Movie
Screen_recording_20230829_000040.mp4