Updated Design Tokens (markdown)

Mike Schreiber 2024-02-16 16:49:31 -08:00
Родитель ec4f938788
Коммит a57294e99e
1 изменённых файлов: 0 добавлений и 44 удалений

@ -202,47 +202,3 @@ However, there is another way to set properties more globally: `FluentTheme`.
`FluentUI` also supports applying both at once, so you can have a standard custom theme for your application, with one or more additional custom themes for specific windows or views.
For more details, see [Overriding Tokens](https://github.com/microsoft/fluentui-apple/wiki/Overriding-Tokens).
## Global Theme
The `FluentUI` library exposes a writeable static property, `FluentTheme.shared`.
This static `FluentTheme` instance will normally return the default token values associated with Fluent. However, it is also available for overriding in cases where a single custom theme is desired for the app linking this library.
```swift
let customTheme: FluentTheme = // a FluentTheme instance initialized with custom values
FluentTheme.shared = customTheme
```
Note that any custom themes set on a `UIView` hierarchy or via a SwiftUI view modifier will take precedence over this value. This value provides the fallback theme for cases where those overrides are not provided. See below for more information about per-view overriding.
## View-Specific Theme
In addition to, or instead of, global themes, a custom theme can be applied to a specific `UIView` or SwiftUI `View` hierarchy, as detailed below.
### SwiftUI
Our framework provides a simple `ViewModifier` called `fluentTheme(_:)` which takes a `FluentTheme` instance as its only argument. Simply add this view modifier to the highest point in your view hierarchy in which youd like the custom theme to apply, and the theme will be detected and applied by any Fluent component in its subview hierarchy.
```swift
public var body: some View {
VStack {
// ...
// some views that contain Fluent components
// ...
}
.fluentTheme(myCustomFluentTheme)
}
```
If you'd like to use tokens from the `FluentTheme` in the environment for your own controls, you can retrieve the `FluentTheme` from the environment via [EnvironmentValues](https://developer.apple.com/documentation/swiftui/environmentvalues) by adding `@Environment(\.fluentTheme) var fluentTheme: FluentTheme` to your view.
### UIKit
When importing `FluentUI`, a new public property on `UIView` will be available: `fluentTheme`. Simply set a customized instance of `FluentTheme` on the `fluentTheme` property on the view or window you wish to host your components in, and all views in its subview hierarchy will be styled with this theme.
```swift
let customTheme: FluentTheme = // a FluentTheme instance initialized with custom values
let view = // ... any UIView or UIWindow in your app
view.fluentTheme = customTheme
```