-
Notifications
You must be signed in to change notification settings - Fork 168
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
Extend ListItem to support overrideTokens #2047
Extend ListItem to support overrideTokens #2047
Conversation
ios/FluentUI.Demo/FluentUI.Demo/Demos/ListItemDemoController_SwiftUI.swift
Show resolved
Hide resolved
ios/FluentUI.Demo/FluentUI.Demo/Demos/ListItemDemoController_SwiftUI.swift
Outdated
Show resolved
Hide resolved
} | ||
|
||
public var body: some View { | ||
let tokenSet = ListItemTokenSet(customViewSize: { leadingContentSize }) | ||
tokenSet.replaceAllOverrides(with: tokenOverrides) |
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.
Out of curiosity, what's the perf impact observed or expected here? We can't guarantee when body runs so hopefully can guarantee this is dirt cheap?
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.
We talked about this offline quite a bit, and yep, token set creation is dirt cheap. We'll work in the future to make it even cheaper, but performance should be totally acceptable right now.
Platforms Impacted
Description of changes
Extending
ListItem
to support.overrideTokens
so that consumers can customize tokens.ListItem
so that every time thebody
runs, thetokenSet
will be recreated with the currenttokenOverrides
ListItemDemoController_SwiftUI
to use the.overrideTokens
modifier.overrideTokens
requires thatlistItem
be mutable so move this to a separate var.ListItemDemoController
TableViewCellTokenSet
, which reflected in the list item demo controller. Since this is not the "right" way to override list item tokens, let's remove it so consumers don't try this as well.leadingContentSize
as a var inListItem
so that whenleadingContentSize
changes, we update our tokens that rely oncustomViewSize
..leadingContentSize
modifier was creating a brand new token set. This meant that any tokens that were overridden would be lost. Now we can ensure that whenleadingContentSize
, only the tokens dependent on that update.Binary change
Total increase: 1,344 bytes
Total decrease: -16,168 bytes
Full breakdown
Verification
Visual Verification
Pull request checklist
This PR has considered:
Microsoft Reviewers: Open in CodeFlow