fluentui-apple
fluentui-apple copied to clipboard
[Draft] Make `GlobalTokens` immutable
Note: this PR is paused for a future release, but is open for feedback now
Platforms Impacted
- [x] iOS
- [ ] macOS
Description of changes
In order to align with the broader goals of Fluent UI design customization, this change makes all global tokens fully immutable. I've done so via the following:
-
GlobalTokensis now a struct composed of only pure static functions that return prebaked token values. It cannot be initialized (initis marked asunavailable). -
brandColors, which can be customized, have been moved toAliasTokens. -
FluentTheme,AliasTokens, andControlTokensall lose their references to an instance ofGlobalTokensand instead will refer to the static global values. - All components that pulled values from an instance of
GlobalTokenshave been updated to use the new static lookup APIs.
Verification
Sanity pass of all tokenized controls demonstrates no changes in appearance or behavior. Existing customization continues as expected.
Additionally, we've got a big binary size savings!
| Before | After |
|---|---|
| 30,446,587 bytes (29,733 kB) | 30,304,923 bytes (29,595 kB) |
Improvement: 138 kB 🥳
Pull request checklist
This PR has considered:
- [ ] Light and Dark appearances
- [ ] iOS supported versions (all major versions greater than or equal current target deployment version)
- [ ] VoiceOver and Keyboard Accessibility
- [ ] Internationalization and Right to Left layouts
- [ ] Different resolutions (1x, 2x, 3x)
- [ ] Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
- [ ] iPad Pointer interaction
- [ ] SwiftUI consumption (validation or new demo scenarios needed)
- [ ] Objective-C exposure (provide it only if needed)