diff --git a/MicrosoftFluentUI.podspec b/MicrosoftFluentUI.podspec index f68592e739..73687decef 100644 --- a/MicrosoftFluentUI.podspec +++ b/MicrosoftFluentUI.podspec @@ -134,11 +134,12 @@ fi', :execution_position => :before_compile } "ios/FluentUI/Extensions/**/*.{swift,h}"] end - s.subspec 'Divider_ios' do |divider_ios| - divider_ios.platform = :ios - divider_ios.dependency 'MicrosoftFluentUI/Core_ios' - divider_ios.source_files = ["ios/FluentUI/Divider/**/*.{swift,h}"] - end + # Temporarily removed while this is not part of our main project + # s.subspec 'Divider_ios' do |divider_ios| + # divider_ios.platform = :ios + # divider_ios.dependency 'MicrosoftFluentUI/Core_ios' + # divider_ios.source_files = ["ios/FluentUI/Divider/**/*.{swift,h}"] + # end s.subspec 'DotView_ios' do |dotview_ios| dotview_ios.platform = :ios diff --git a/ios/FluentUI.Demo/FluentUI.Demo/DemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/DemoController.swift index 6a4effa7ea..dbdba91626 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/DemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/DemoController.swift @@ -137,7 +137,7 @@ class DemoController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background1)) + view.backgroundColor = view.fluentTheme.color(.background1) if allowsContentToScroll { view.addSubview(scrollingContainer) diff --git a/ios/FluentUI.Demo/FluentUI.Demo/DemoListViewController.swift b/ios/FluentUI.Demo/FluentUI.Demo/DemoListViewController.swift index 1034e0ffeb..e4f5e642a3 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/DemoListViewController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/DemoListViewController.swift @@ -32,7 +32,7 @@ class DemoListViewController: DemoTableViewController { if let provider = self.provider { window.setColorProvider(provider) let fluentTheme = self.view.fluentTheme - let primaryColor = UIColor(dynamicColor: fluentTheme.color(.brandBackground1)) + let primaryColor = fluentTheme.color(.brandBackground1) FluentUIFramework.initializeAppearance(with: primaryColor, whenContainedInInstancesOf: [type(of: window)]) } else { FluentUIFramework.initializeAppearance(with: UIColor(light: UIColor(colorValue: GlobalTokens.brandColors(.comm80)), dark: UIColor(colorValue: GlobalTokens.brandColors(.comm90)))) diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift index c0f2951f1e..ebf7e71565 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift @@ -278,14 +278,14 @@ extension ActivityIndicatorDemoController: DemoAppearanceDelegate { private var themeWideOverrideActivityIndicatorTokens: [ActivityIndicatorTokenSet.Tokens: ControlTokenValue] { return [ - .defaultColor: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.red, .primary)) }, + .defaultColor: .uiColor { GlobalTokens.sharedColor(.red, .primary) }, .thickness: .float { 20.0 } ] } private var perControlOverrideActivityIndicatorTokens: [ActivityIndicatorTokenSet.Tokens: ControlTokenValue] { return [ - .defaultColor: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.green, .primary)) }, + .defaultColor: .uiColor { GlobalTokens.sharedColor(.green, .primary) }, .thickness: .float { 10.0 } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/AliasColorTokensDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/AliasColorTokensDemoController.swift index a53aeaf219..f1ded58057 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/AliasColorTokensDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/AliasColorTokensDemoController.swift @@ -30,7 +30,7 @@ class AliasColorTokensDemoController: DemoTableViewController { let section = AliasColorTokensDemoSection.allCases[indexPath.section] let row = section.rows[indexPath.row] - cell.backgroundConfiguration?.backgroundColor = UIColor(dynamicColor: fluentTheme.color(row)) + cell.backgroundConfiguration?.backgroundColor = fluentTheme.color(row) cell.selectionStyle = .none var contentConfiguration = cell.defaultContentConfiguration() @@ -81,7 +81,7 @@ class AliasColorTokensDemoController: DemoTableViewController { .successBackground1, .warningBackground1, .severeBackground1: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) case .foreground1, .foreground2, .foreground3, @@ -103,12 +103,12 @@ class AliasColorTokensDemoController: DemoTableViewController { .severeBackground2, .severeForeground1, .severeForeground2: - return UIColor(dynamicColor: fluentTheme.color(.foregroundOnColor)) + return fluentTheme.color(.foregroundOnColor) case .foregroundLightStatic, .backgroundLightStatic, .backgroundLightStaticDisabled, .warningBackground2: - return UIColor(dynamicColor: fluentTheme.color(.foregroundDarkStatic)) + return fluentTheme.color(.foregroundDarkStatic) case .brandForeground1, .brandForeground1Selected, .brandForegroundDisabled1, @@ -126,7 +126,7 @@ class AliasColorTokensDemoController: DemoTableViewController { .presenceDnd, .presenceAvailable, .presenceOof: - return UIColor(dynamicColor: fluentTheme.color(.foregroundLightStatic)) + return fluentTheme.color(.foregroundLightStatic) } } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift index 0ef2ea0978..499660feec 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift @@ -271,7 +271,7 @@ class BottomCommandingDemoController: UIViewController { private lazy var customPopoverViewController: UIViewController = { let viewController = UIViewController() - viewController.view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + viewController.view.backgroundColor = view.fluentTheme.color(.background3) viewController.preferredContentSize = CGSize(width: 300, height: 300) viewController.modalPresentationStyle = .popover diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomSheetDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomSheetDemoController.swift index dd7b984de4..b98b9a8fe8 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomSheetDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomSheetDemoController.swift @@ -420,16 +420,16 @@ extension BottomSheetDemoController: DemoAppearanceDelegate { // MARK: - Custom tokens private var themeWideOverrideBottomSheetTokens: [BottomSheetTokenSet.Tokens: ControlTokenValue] { return [ - .backgroundColor: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.plum, .tint40), - dark: GlobalTokens.sharedColors(.plum, .shade30)) + .backgroundColor: .uiColor { UIColor(light: GlobalTokens.sharedColor(.plum, .tint40), + dark: GlobalTokens.sharedColor(.plum, .shade30)) } ] } private var perControlOverrideBottomSheetTokens: [BottomSheetTokenSet.Tokens: ControlTokenValue] { return [ - .backgroundColor: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.forest, .tint40), - dark: GlobalTokens.sharedColors(.forest, .shade30)) + .backgroundColor: .uiColor { UIColor(light: GlobalTokens.sharedColor(.forest, .tint40), + dark: GlobalTokens.sharedColor(.forest, .shade30)) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ButtonDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ButtonDemoController.swift index 67c20c45b7..595ecc5b79 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ButtonDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ButtonDemoController.swift @@ -181,30 +181,36 @@ extension ButtonDemoController: DemoAppearanceDelegate { private var themeWideOverrideButtonTokens: [ButtonTokenSet.Tokens: ControlTokenValue] { return [ - .titleFont: .fontInfo { FontInfo(name: "Times", size: 20.0, weight: .regular) }, - .backgroundColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.marigold, .shade30), - dark: GlobalTokens.sharedColors(.marigold, .tint40)) + .titleFont: .uiFont { + return UIFont(descriptor: .init(name: "Times", size: 20.0), + size: 20.0) }, - .borderColor: .dynamicColor { DynamicColor(light: .clear) }, - .foregroundColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.marigold, .tint40), - dark: GlobalTokens.sharedColors(.marigold, .shade30)) + .backgroundColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.marigold, .shade30), + dark: GlobalTokens.sharedColor(.marigold, .tint40)) + }, + .borderColor: .uiColor { .clear }, + .foregroundColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.marigold, .tint40), + dark: GlobalTokens.sharedColor(.marigold, .shade30)) } ] } private var perControlOverrideButtonTokens: [ButtonTokenSet.Tokens: ControlTokenValue] { return [ - .titleFont: .fontInfo { FontInfo(name: "Papyrus", size: 20.0, weight: .regular) }, - .backgroundColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.orchid, .shade30), - dark: GlobalTokens.sharedColors(.orchid, .tint40)) + .titleFont: .uiFont { + return UIFont(descriptor: .init(name: "Papyrus", size: 20.0), + size: 20.0) + }, + .backgroundColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.orchid, .shade30), + dark: GlobalTokens.sharedColor(.orchid, .tint40)) }, - .borderColor: .dynamicColor { DynamicColor(light: .clear) }, - .foregroundColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.orchid, .tint40), - dark: GlobalTokens.sharedColors(.orchid, .shade30)) + .borderColor: .uiColor { .clear }, + .foregroundColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.orchid, .tint40), + dark: GlobalTokens.sharedColor(.orchid, .shade30)) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/CardNudgeDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/CardNudgeDemoController.swift index e28633f087..7cd5894bc2 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/CardNudgeDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/CardNudgeDemoController.swift @@ -255,25 +255,25 @@ extension CardNudgeDemoController: DemoAppearanceDelegate { private var themeWideOverrideCardNudgeTokens: [CardNudgeTokenSet.Tokens: ControlTokenValue] { return [ - .backgroundColor: .dynamicColor { - DynamicColor(light: GlobalTokens.sharedColors(.hotPink, .tint50), - dark: GlobalTokens.sharedColors(.hotPink, .shade40)) + .backgroundColor: .uiColor { + UIColor(light: GlobalTokens.sharedColor(.hotPink, .tint50), + dark: GlobalTokens.sharedColor(.hotPink, .shade40)) }, .outlineWidth: .float { 10.0 }, - .outlineColor: .dynamicColor { - DynamicColor(light: GlobalTokens.sharedColors(.darkRed, .tint50), - dark: GlobalTokens.sharedColors(.darkRed, .shade40)) + .outlineColor: .uiColor { + UIColor(light: GlobalTokens.sharedColor(.darkRed, .tint50), + dark: GlobalTokens.sharedColor(.darkRed, .shade40)) } ] } private var perControlOverrideCardNudgeTokens: [CardNudgeTokenSet.Tokens: ControlTokenValue] { return [ - .backgroundColor: .dynamicColor { - DynamicColor(light: GlobalTokens.sharedColors(.seafoam, .tint50), - dark: GlobalTokens.sharedColors(.seafoam, .shade40)) + .backgroundColor: .uiColor { + UIColor(light: GlobalTokens.sharedColor(.seafoam, .tint50), + dark: GlobalTokens.sharedColor(.seafoam, .shade40)) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/CommandBarDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/CommandBarDemoController.swift index 6426a59471..ada25e1dd7 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/CommandBarDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/CommandBarDemoController.swift @@ -163,7 +163,7 @@ class CommandBarDemoController: DemoController { lazy var textField: UITextField = { let textField = UITextField() textField.translatesAutoresizingMaskIntoConstraints = false - textField.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + textField.backgroundColor = view.fluentTheme.color(.background3) textField.placeholder = "Text Field" return textField @@ -176,21 +176,21 @@ class CommandBarDemoController: DemoController { container.layoutMargins.right = 0 container.layoutMargins.left = 0 - view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background4)) + view.backgroundColor = view.fluentTheme.color(.background4) container.addArrangedSubview(createLabelWithText("Default")) let commandBar = CommandBar(itemGroups: createItemGroups(), leadingItemGroups: [[newItem(for: .keyboard)]]) commandBar.delegate = self commandBar.translatesAutoresizingMaskIntoConstraints = false - commandBar.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + commandBar.backgroundColor = view.fluentTheme.color(.background3) container.addArrangedSubview(commandBar) defaultCommandBar = commandBar let itemCustomizationContainer = UIStackView() itemCustomizationContainer.spacing = CommandBarDemoController.verticalStackViewSpacing itemCustomizationContainer.axis = .vertical - itemCustomizationContainer.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + itemCustomizationContainer.backgroundColor = view.fluentTheme.color(.background3) itemCustomizationContainer.addArrangedSubview(UIView()) //Spacer @@ -278,13 +278,13 @@ class CommandBarDemoController: DemoController { let fixedButtonCommandBar = CommandBar(itemGroups: createItemGroups(), leadingItemGroups: [[newItem(for: .copy)]], trailingItemGroups: [[newItem(for: .keyboard)]]) fixedButtonCommandBar.translatesAutoresizingMaskIntoConstraints = false - fixedButtonCommandBar.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + fixedButtonCommandBar.backgroundColor = view.fluentTheme.color(.background3) container.addArrangedSubview(fixedButtonCommandBar) container.addArrangedSubview(createLabelWithText("In Input Accessory View")) let textFieldContainer = UIView() - textFieldContainer.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + textFieldContainer.backgroundColor = view.fluentTheme.color(.background3) textFieldContainer.addSubview(textField) NSLayoutConstraint.activate([ textField.topAnchor.constraint(equalTo: textFieldContainer.topAnchor, constant: 16.0), @@ -376,7 +376,7 @@ class CommandBarDemoController: DemoController { ) commandBarItem.accentImage = command.accentImage - commandBarItem.accentImageTintColor = UIColor(dynamicColor: view.fluentTheme.color(.brandForeground1)) + commandBarItem.accentImageTintColor = view.fluentTheme.color(.brandForeground1) if command == .customView { commandBarItem.customControlView = { () -> UIView in @@ -517,13 +517,13 @@ extension CommandBarDemoController: DemoAppearanceDelegate { private var themeWideOverrideCommandBarTokens: [CommandBarTokenSet.Tokens: ControlTokenValue] { return [ - .itemBackgroundColorRest: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.red, .primary)) } + .itemBackgroundColorRest: .uiColor { GlobalTokens.sharedColor(.red, .primary) } ] } private var perControlOverrideCommandBarTokens: [CommandBarTokenSet.Tokens: ControlTokenValue] { return [ - .itemBackgroundColorRest: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.grape, .primary)) } + .itemBackgroundColorRest: .uiColor { GlobalTokens.sharedColor(.grape, .primary) } ] } } @@ -534,7 +534,7 @@ extension CommandBarDemoController: CommandBarDelegate { let originalBackgroundColor = commandBar.backgroundColor UIView.animate(withDuration: 1.0, delay: 0.0, options: [.allowUserInteraction]) { - commandBar.backgroundColor = UIColor(dynamicColor: self.view.fluentTheme.color(.brandBackground1)) + commandBar.backgroundColor = self.view.fluentTheme.color(.brandBackground1) } completion: { _ in commandBar.backgroundColor = originalBackgroundColor } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/DividerDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/DividerDemoController.swift index 8cd8729fcf..86dcf200c7 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/DividerDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/DividerDemoController.swift @@ -112,7 +112,7 @@ class DividerDemoController: DemoTableViewController { private func makeDivider(orientation: MSFDividerOrientation = .horizontal, spacing: MSFDividerSpacing, customColor: Bool) -> MSFDivider { let divider = MSFDivider(orientation: orientation, spacing: spacing) if customColor, let color = self.view.window?.fluentTheme.brandColors(.primary) { - divider.tokenSet[.color] = .dynamicColor({ color }) + divider.tokenSet[.color] = .color({ color }) } dividers.append(divider) @@ -212,13 +212,13 @@ extension DividerDemoController: DemoAppearanceDelegate { private var themeWideOverrideDividerTokens: [DividerTokenSet.Tokens: ControlTokenValue] { return [ - .color: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.red, .primary)) } + .color: .uiColor { GlobalTokens.sharedColors(.red, .primary) } ] } private var perControlOverrideDividerTokens: [DividerTokenSet.Tokens: ControlTokenValue] { return [ - .color: .dynamicColor { DynamicColor(light: GlobalTokens.sharedColors(.green, .primary)) } + .color: .uiColor { GlobalTokens.sharedColors(.green, .primary) } ] } } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/DrawerDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/DrawerDemoController.swift index 2bc98800b5..063d44f091 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/DrawerDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/DrawerDemoController.swift @@ -134,7 +134,7 @@ class DrawerDemoController: DemoController { UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) ] - let backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + let backgroundColor = view.fluentTheme.color(.background3) controller.view.addSubview(content) content.frame = controller.view.bounds @@ -285,7 +285,7 @@ class DrawerDemoController: DemoController { contentController: contentController, resizingBehavior: .dismissOrExpand) - drawer.resizingHandleViewBackgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + drawer.resizingHandleViewBackgroundColor = view.fluentTheme.color(.background3) drawer.contentScrollView = personaListView } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/HUDDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/HUDDemoController.swift index 4d8d2e1cfa..463ecc3bc4 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/HUDDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/HUDDemoController.swift @@ -290,7 +290,7 @@ extension HUDDemoController: DemoAppearanceDelegate { private var themeWideOverrideActivityHeadsUpDisplayTokens: [HeadsUpDisplayTokenSet.Tokens: ControlTokenValue] { let fluentTheme = self.view.fluentTheme return [ - .backgroundColor: .dynamicColor { fluentTheme.color(.brandBackground1) } + .backgroundColor: .uiColor { fluentTheme.color(.brandBackground1) } ] } @@ -298,7 +298,7 @@ extension HUDDemoController: DemoAppearanceDelegate { let fluentTheme = self.view.fluentTheme return [ .cornerRadius: .float { GlobalTokens.corner(.radius120) }, - .labelColor: .dynamicColor { fluentTheme.color(.brandForeground1) } + .labelColor: .uiColor { fluentTheme.color(.brandForeground1) } ] } } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/LabelDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/LabelDemoController.swift index 755362dd9c..a0c07bdbf2 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/LabelDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/LabelDemoController.swift @@ -17,9 +17,9 @@ class LabelDemoController: DemoController { addLabel(text: "Text Styles", style: .body1Strong, colorStyle: .regular).textAlignment = .center for style in FluentTheme.TypographyToken.allCases { - let fontInfo = view.fluentTheme.typography(style) - let fontWeight = UIFont.fluent(fontInfo).fontDescriptor.weightDescriptor - let detailedDescription = "\(style.description) is \(fontWeight) \(Int(fontInfo.size))pt" + let font = view.fluentTheme.typography(style) + let fontWeight = font.fontDescriptor.weightDescriptor + let detailedDescription = "\(style.description) is \(fontWeight) \(Int(font.pointSize))pt" dynamicLabels.append(addLabel(text: detailedDescription, style: style, colorStyle: .regular)) } @@ -49,9 +49,9 @@ class LabelDemoController: DemoController { @objc private func handleContentSizeCategoryDidChange() { for label in dynamicLabels { - let fontInfo = view.fluentTheme.typography(label.textStyle) - let fontWeight = UIFont.fluent(fontInfo).fontDescriptor.weightDescriptor - let detailedDescription = "\(label.textStyle.description) is \(fontWeight) \(Int(fontInfo.size))pt" + let font = view.fluentTheme.typography(label.textStyle) + let fontWeight = font.fontDescriptor.weightDescriptor + let detailedDescription = "\(label.textStyle.description) is \(fontWeight) \(Int(font.pointSize))pt" label.text = detailedDescription } } @@ -161,23 +161,25 @@ extension LabelDemoController: DemoAppearanceDelegate { private var themeWideOverrideLabelTokens: [LabelTokenSet.Tokens: ControlTokenValue] { return [ - .font: .fontInfo { - return FontInfo(name: "Times", size: 20.0, weight: .regular) + .font: .uiFont { + return UIFont(descriptor: .init(name: "Times", size: 20.0), + size: 20.0) }, - .textColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.marigold, .shade30), - dark: GlobalTokens.sharedColors(.marigold, .tint40)) + .textColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.marigold, .shade30), + dark: GlobalTokens.sharedColor(.marigold, .tint40)) } ] } private var perControlOverrideLabelTokens: [LabelTokenSet.Tokens: ControlTokenValue] { return [ - .font: .fontInfo { - return FontInfo(name: "Papyrus", size: 20.0, weight: .regular) + .font: .uiFont { + return UIFont(descriptor: .init(name: "Papyrus", size: 20.0), + size: 20.0) }, - .textColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.orchid, .shade30)) + .textColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.orchid, .shade30)) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NavigationControllerDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NavigationControllerDemoController.swift index 745ec629fe..58270abd2f 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NavigationControllerDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NavigationControllerDemoController.swift @@ -199,7 +199,7 @@ class NavigationControllerDemoController: DemoController { stackView.alignment = .center let button = UIButton(type: .system) button.setImage(UIImage(named: "ic_fluent_filter_28"), for: .normal) - button.tintColor = UIColor(dynamicColor: view.fluentTheme.color(.foregroundLightStatic)) + button.tintColor = view.fluentTheme.color(.foregroundLightStatic) stackView.addArrangedSubview(button) return stackView } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController.swift index c42af14771..3ffbf4df0e 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController.swift @@ -66,7 +66,7 @@ class NotificationViewDemoController: DemoController { override func viewDidLoad() { super.viewDidLoad() readmeString = "Notifications deliver helpful messages related to the action someone is taking. They should communicate information people can use right away.\n\nNotifications are great for giving people feedback or communicating a task’s status. If you need to show recommendations or upsell features of your app, try a card nudge instead." - view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background4)) + view.backgroundColor = view.fluentTheme.color(.background4) addTitle(text: "SwiftUI Demo") container.addArrangedSubview(createButton(title: "Show", action: #selector(showSwiftUIDemo))) @@ -180,9 +180,10 @@ class NotificationViewDemoController: DemoController { return notification case .neutralBarWithFontAttribute: let notification = MSFNotification(style: .neutralBar) + let font = UIFont(descriptor: .init(name: "Papyrus", size: 30.0), + size: 30.0) notification.state.attributedMessage = NSAttributedString(string: "This is a bar with red Papyrus font attribute.", - attributes: [.font: UIFont.init(name: "Papyrus", - size: 30.0)!, + attributes: [.font: font, .foregroundColor: UIColor.red]) notification.state.actionButtonAction = { [weak self] in self?.showMessage("`Dismiss` tapped") @@ -213,10 +214,10 @@ class NotificationViewDemoController: DemoController { notification.state.message = "The background of this notification has been customized with a gradient." notification.state.image = UIImage(named: "play-in-circle-24x24") // It's a lovely blue-to-pink gradient - let colors: [DynamicColor] = [DynamicColor(light: GlobalTokens.sharedColors(.pink, .tint50), - dark: GlobalTokens.sharedColors(.pink, .shade40)), - DynamicColor(light: GlobalTokens.sharedColors(.cyan, .tint50), - dark: GlobalTokens.sharedColors(.cyan, .shade40))] + let colors: [UIColor] = [UIColor(light: GlobalTokens.sharedColor(.pink, .tint50), + dark: GlobalTokens.sharedColor(.pink, .shade40)), + UIColor(light: GlobalTokens.sharedColor(.cyan, .tint50), + dark: GlobalTokens.sharedColor(.cyan, .shade40))] notification.state.backgroundGradient = LinearGradientInfo(colors: colors, startPoint: .init(x: 0.0, y: 1.0), endPoint: .init(x: 1.0, y: 0.0)) @@ -240,15 +241,15 @@ class NotificationViewDemoController: DemoController { private var notificationOverrideTokens: [NotificationTokenSet.Tokens: ControlTokenValue] { return [ - .imageColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.orange, .primary)) + .imageColor: .uiColor { + return UIColor(light: GlobalTokens.sharedColor(.orange, .primary)) }, .shadow: .shadowInfo { - return ShadowInfo(keyColor: DynamicColor(light: GlobalTokens.sharedColors(.hotPink, .primary)), + return ShadowInfo(keyColor: GlobalTokens.sharedColor(.hotPink, .primary), keyBlur: 10.0, xKey: 10.0, yKey: 10.0, - ambientColor: DynamicColor(light: GlobalTokens.sharedColors(.teal, .primary)), + ambientColor: GlobalTokens.sharedColor(.teal, .primary), ambientBlur: 100.0, xAmbient: -10.0, yAmbient: -10.0) diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController_SwiftUI.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController_SwiftUI.swift index 10e258bd39..4fd835a799 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController_SwiftUI.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/NotificationViewDemoController_SwiftUI.swift @@ -41,11 +41,26 @@ struct NotificationDemoView: View { @State var showBackgroundGradient: Bool = false public var body: some View { + let font = UIFont(descriptor: .init(name: "Papyrus", size: 30.0), size: 30.0) let hasAttribute = hasBlueStrikethroughAttribute || hasLargeRedPapyrusFontAttribute - let bothAttributes = [NSAttributedString.Key.strikethroughStyle: 1, NSAttributedString.Key.strikethroughColor: UIColor.blue, .font: UIFont.init(name: "Papyrus", size: 30.0)!, .foregroundColor: UIColor.red] as [NSAttributedString.Key: Any] - let blueStrikethroughAttribute = [.font: UIFont.preferredFont(forTextStyle: .body), NSAttributedString.Key.strikethroughStyle: 1, NSAttributedString.Key.strikethroughColor: UIColor.blue] as [NSAttributedString.Key: Any] - let redPapyrusFontAttribute = [.font: UIFont.init(name: "Papyrus", size: 30.0)!, .foregroundColor: UIColor.red] as [NSAttributedString.Key: Any] + + let bothAttributes = [ + NSAttributedString.Key.strikethroughStyle: 1, + NSAttributedString.Key.strikethroughColor: UIColor.blue, + .font: font, + .foregroundColor: UIColor.red + ] as [NSAttributedString.Key: Any] + + let blueStrikethroughAttribute = [ + .font: UIFont.preferredFont(forTextStyle: .body), + NSAttributedString.Key.strikethroughStyle: 1, + NSAttributedString.Key.strikethroughColor: UIColor.blue + ] as [NSAttributedString.Key: Any] + + let redPapyrusFontAttribute = [.font: font, .foregroundColor: UIColor.red] as [NSAttributedString.Key: Any] + let attributedMessage = NSMutableAttributedString(string: message, attributes: (hasLargeRedPapyrusFontAttribute && hasBlueStrikethroughAttribute) ? bothAttributes : (hasLargeRedPapyrusFontAttribute ? redPapyrusFontAttribute : blueStrikethroughAttribute)) + let attributedTitle = NSMutableAttributedString(string: title, attributes: (hasLargeRedPapyrusFontAttribute && hasBlueStrikethroughAttribute) ? bothAttributes : (hasLargeRedPapyrusFontAttribute ? redPapyrusFontAttribute : blueStrikethroughAttribute)) let image = showImage ? UIImage(named: "play-in-circle-24x24") : nil @@ -244,10 +259,10 @@ struct NotificationDemoView: View { private var backgroundGradient: LinearGradientInfo { // It's a lovely blue-to-pink gradient - let colors: [DynamicColor] = [DynamicColor(light: GlobalTokens.sharedColors(.pink, .tint50), - dark: GlobalTokens.sharedColors(.pink, .shade40)), - DynamicColor(light: GlobalTokens.sharedColors(.cyan, .tint50), - dark: GlobalTokens.sharedColors(.cyan, .shade40))] + let colors: [UIColor] = [UIColor(light: GlobalTokens.sharedColor(.pink, .tint50), + dark: GlobalTokens.sharedColor(.pink, .shade40)), + UIColor(light: GlobalTokens.sharedColor(.cyan, .tint50), + dark: GlobalTokens.sharedColor(.cyan, .shade40))] return LinearGradientInfo(colors: colors, startPoint: .init(x: 0.0, y: 1.0), endPoint: .init(x: 1.0, y: 0.0)) @@ -255,15 +270,15 @@ struct NotificationDemoView: View { private var notificationOverrideTokens: [NotificationTokenSet.Tokens: ControlTokenValue] { return [ - .imageColor: .dynamicColor { - return DynamicColor(light: GlobalTokens.sharedColors(.orange, .primary)) + .imageColor: .uiColor { + return GlobalTokens.sharedColor(.orange, .primary) }, .shadow: .shadowInfo { - return ShadowInfo(keyColor: DynamicColor(light: GlobalTokens.sharedColors(.hotPink, .primary)), + return ShadowInfo(keyColor: GlobalTokens.sharedColor(.hotPink, .primary), keyBlur: 10.0, xKey: 10.0, yKey: 10.0, - ambientColor: DynamicColor(light: GlobalTokens.sharedColors(.teal, .primary)), + ambientColor: GlobalTokens.sharedColor(.teal, .primary), ambientBlur: 100.0, xAmbient: -10.0, yAmbient: -10.0) diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoColorProviding.m b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoColorProviding.m index e42c746e8b..990c3fdbc6 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoColorProviding.m +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoColorProviding.m @@ -14,39 +14,27 @@ @interface ObjectiveCDemoColorProviding () @implementation ObjectiveCDemoColorProviding - (UIColor *)brandBackgroundColor { - MSFColorValue *lightColor = [MSFGlobalTokens sharedColorForColorSet:MSFSharedColorSetsOrchid - token:MSFSharedColorsTokensTint40]; - MSFColorValue *darkColor = [MSFGlobalTokens sharedColorForColorSet:MSFSharedColorSetsOrchid - token:MSFSharedColorsTokensShade30]; + UIColor *lightColor = [MSFGlobalTokens colorForSharedColorSet:MSFGlobalTokensSharedColorSetOrchid + token:MSFGlobalTokensSharedColorTint40]; + UIColor *darkColor = [MSFGlobalTokens colorForSharedColorSet:MSFGlobalTokensSharedColorSetOrchid + token:MSFGlobalTokensSharedColorShade30]; - MSFDynamicColor *dynamicColor = [[MSFDynamicColor alloc] initWithLight:lightColor - lightHighContrast:nil - lightElevated:nil - lightElevatedHighContrast:nil - dark:darkColor - darkHighContrast:nil - darkElevated:nil - darkElevatedHighContrast:nil]; + UIColor *dynamicColor = [[UIColor alloc] initWithLight:lightColor + dark:darkColor]; - return [[UIColor alloc] initWithDynamicColor:dynamicColor]; + return dynamicColor; } - (UIColor *)brandForegroundColor { - MSFColorValue *lightColor = [MSFGlobalTokens sharedColorForColorSet:MSFSharedColorSetsOrchid - token:MSFSharedColorsTokensShade30]; - MSFColorValue *darkColor = [MSFGlobalTokens sharedColorForColorSet:MSFSharedColorSetsOrchid - token:MSFSharedColorsTokensTint40]; - - MSFDynamicColor *dynamicColor = [[MSFDynamicColor alloc] initWithLight:lightColor - lightHighContrast:nil - lightElevated:nil - lightElevatedHighContrast:nil - dark:darkColor - darkHighContrast:nil - darkElevated:nil - darkElevatedHighContrast:nil]; - - return [[UIColor alloc] initWithDynamicColor:dynamicColor]; + UIColor *lightColor = [MSFGlobalTokens colorForSharedColorSet:MSFGlobalTokensSharedColorSetOrchid + token:MSFGlobalTokensSharedColorShade30]; + UIColor *darkColor = [MSFGlobalTokens colorForSharedColorSet:MSFGlobalTokensSharedColorSetOrchid + token:MSFGlobalTokensSharedColorTint40]; + + UIColor *dynamicColor = [[UIColor alloc] initWithLight:lightColor + dark:darkColor]; + + return dynamicColor; } - (UIColor *)brandStrokeColor { diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoController.m b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoController.m index cbba767471..9b092681fe 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoController.m +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ObjectiveCDemoController.m @@ -30,8 +30,8 @@ - (void)viewDidLoad { self.container = [self createVerticalContainer]; self.scrollingContainer = [[UIScrollView alloc] initWithFrame:CGRectZero]; - MSFDynamicColor *primaryColor = [[[self view] fluentTheme] colorForToken:MSFColorTokenBackground1]; - self.view.backgroundColor = [[UIColor alloc] initWithDynamicColor:primaryColor]; + UIColor *primaryColor = [[[self view] fluentTheme] colorForToken:MSFColorTokenBackground1]; + self.view.backgroundColor = primaryColor; [self setupTitleView]; [self.view addSubview:self.scrollingContainer]; @@ -75,7 +75,8 @@ - (void)resetAddedLabels { - (void)addLabelWithText:(NSString *)text textColor:(UIColor *)textColor { - MSFLabel *label = [[MSFLabel alloc] initWithStyle:MSFTypographyTokenBody1 colorStyle:MSFTextColorStyleRegular]; + MSFLabel *label = [[MSFLabel alloc] initWithTextStyle:MSFTypographyTokenBody1 + colorStyle:MSFTextColorStyleRegular]; [label setTextAlignment:NSTextAlignmentCenter]; [label setText:text]; [label setTextColor:textColor]; @@ -92,31 +93,31 @@ - (void)tokensButtonPressed:(id)sender { // Add alias-colored label too MSFFluentTheme *fluentTheme = [[self view] fluentTheme]; - MSFDynamicColor *primaryColor = [fluentTheme colorForToken:MSFColorTokenBrandForeground1]; + UIColor *primaryColor = [fluentTheme colorForToken:MSFColorTokenBrandForeground1]; [self addLabelWithText:@"Test label with alias color" - textColor:[[UIColor alloc] initWithDynamicColor:primaryColor]]; + textColor:primaryColor]; // Finally, add a shared-theme brand color (should be comm blue) MSFFluentTheme *sharedTheme = [MSFFluentTheme sharedTheme]; - MSFDynamicColor *sharedPrimaryColor = [sharedTheme colorForToken:MSFColorTokenBrandForeground1]; + UIColor *sharedPrimaryColor = [sharedTheme colorForToken:MSFColorTokenBrandForeground1]; [self addLabelWithText:@"Test label with shared alias color" - textColor:[[UIColor alloc] initWithDynamicColor:sharedPrimaryColor]]; + textColor:sharedPrimaryColor]; } - (void)overridesButtonPressed:(id)sender { [[self view] setColorProvider:[[ObjectiveCDemoColorProviding alloc] init]]; - MSFDynamicColor *primaryColor = [[[self view] fluentTheme] colorForToken:MSFColorTokenBrandForeground1]; + UIColor *primaryColor = [[[self view] fluentTheme] colorForToken:MSFColorTokenBrandForeground1]; [self addLabelWithText:@"Test label with override brand color" - textColor:[[UIColor alloc] initWithDynamicColor:primaryColor]]; + textColor:primaryColor]; // Remove the overrides [[self view] resetFluentTheme]; primaryColor = [[[self view] fluentTheme] colorForToken:MSFColorTokenBrandForeground1]; [self addLabelWithText:@"Test label with override color removed" - textColor:[[UIColor alloc] initWithDynamicColor:primaryColor]]; + textColor:primaryColor]; } - (UIStackView *)createVerticalContainer { @@ -144,7 +145,8 @@ - (MSFButton *)createButtonWithTitle:(NSString *)title action:(SEL)action { } - (void)addTitleWithText:(NSString*)text { - MSFLabel* titleLabel = [[MSFLabel alloc] initWithStyle:MSFTypographyTokenBody1 colorStyle:MSFTextColorStyleRegular]; + MSFLabel* titleLabel = [[MSFLabel alloc] initWithTextStyle:MSFTypographyTokenBody1 + colorStyle:MSFTextColorStyleRegular]; titleLabel.text = text; titleLabel.textAlignment = NSTextAlignmentCenter; [self.container addArrangedSubview:titleLabel]; diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/OtherCellsDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/OtherCellsDemoController.swift index fd4d4784ea..76c06fd0fb 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/OtherCellsDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/OtherCellsDemoController.swift @@ -28,7 +28,7 @@ class OtherCellsDemoController: DemoController { tableView.dataSource = self tableView.delegate = self tableView.backgroundColor = TableViewCell.tableBackgroundGroupedColor - tableView.separatorColor = UIColor(dynamicColor: view.fluentTheme.color(.stroke2)) + tableView.separatorColor = view.fluentTheme.color(.stroke2) tableView.tableFooterView = UIView(frame: .zero) view.addSubview(tableView) } @@ -56,35 +56,35 @@ extension OtherCellsDemoController: DemoAppearanceDelegate { // MARK: - Custom tokens private var themeWideOverrideTableViewCellTokenSet: [TableViewCellTokenSet.Tokens: ControlTokenValue] { return [ - .brandTextColor: .dynamicColor { + .brandTextColor: .uiColor { // "Charcoal" - return DynamicColor(light: GlobalTokens.sharedColors(.charcoal, .tint50), - dark: GlobalTokens.sharedColors(.charcoal, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.charcoal, .tint50), + dark: GlobalTokens.sharedColor(.charcoal, .shade40)) }, - .booleanCellBrandColor: .dynamicColor { + .booleanCellBrandColor: .uiColor { // "Charcoal" - return DynamicColor(light: GlobalTokens.sharedColors(.charcoal, .tint50), - dark: GlobalTokens.sharedColors(.charcoal, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.charcoal, .tint50), + dark: GlobalTokens.sharedColor(.charcoal, .shade40)) } ] } private var themeWideOverrideOtherCellTokens: [TableViewCellTokenSet.Tokens: ControlTokenValue] { return [ - .cellBackgroundGroupedColor: .dynamicColor { + .cellBackgroundGroupedColor: .uiColor { // "Charcoal" - return DynamicColor(light: GlobalTokens.sharedColors(.charcoal, .tint50), - dark: GlobalTokens.sharedColors(.charcoal, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.charcoal, .tint50), + dark: GlobalTokens.sharedColor(.charcoal, .shade40)) } ] } private var perControlOverrideTableViewCellTokens: [TableViewCellTokenSet.Tokens: ControlTokenValue] { return [ - .cellBackgroundGroupedColor: .dynamicColor { + .cellBackgroundGroupedColor: .uiColor { // "Burgundy" - return DynamicColor(light: GlobalTokens.sharedColors(.burgundy, .tint50), - dark: GlobalTokens.sharedColors(.burgundy, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.burgundy, .tint50), + dark: GlobalTokens.sharedColor(.burgundy, .shade40)) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/PillButtonBarDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/PillButtonBarDemoController.swift index 6daa460cdf..a321e847da 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/PillButtonBarDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/PillButtonBarDemoController.swift @@ -78,8 +78,8 @@ class PillButtonBarDemoController: DemoController { } func createBar(items: [PillButtonBarItem], style: PillButtonStyle = .primary, centerAligned: Bool = false, disabledItems: Bool = false, useCustomPillsColors: Bool = false) -> UIView { - let accentColor = UIColor(dynamicColor: view.fluentTheme.color(.foregroundOnColor)) - let textColor = UIColor(dynamicColor: view.fluentTheme.color(.foreground1)) + let accentColor = view.fluentTheme.color(.foregroundOnColor) + let textColor = view.fluentTheme.color(.foreground1) let pillButtonBackgroundColor = useCustomPillsColors ? accentColor : nil let pillSelectedButtonBackgroundColor = useCustomPillsColors ? textColor : nil let pillButtonTextColor = useCustomPillsColors ? textColor : nil diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/PopupMenuObjCDemoController.m b/ios/FluentUI.Demo/FluentUI.Demo/Demos/PopupMenuObjCDemoController.m index 67d0b40036..f09a8e0aee 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/PopupMenuObjCDemoController.m +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/PopupMenuObjCDemoController.m @@ -29,8 +29,8 @@ - (void)loadView { UIView *view = [self view]; [view addSubview:stack]; - MSFDynamicColor *primaryColor = [[view fluentTheme] colorForToken:MSFColorTokenBackground1]; - [view setBackgroundColor:[[UIColor alloc] initWithDynamicColor:primaryColor]]; + UIColor *primaryColor = [[view fluentTheme] colorForToken:MSFColorTokenBackground1]; + [view setBackgroundColor:primaryColor]; UILayoutGuide *safeArea = [view safeAreaLayoutGuide]; [NSLayoutConstraint activateConstraints:@[ diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/SegmentedControlDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/SegmentedControlDemoController.swift index 60720ff3c1..0d00e21716 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/SegmentedControlDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/SegmentedControlDemoController.swift @@ -28,7 +28,7 @@ class SegmentedControlDemoController: DemoController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background1)) + view.backgroundColor = view.fluentTheme.color(.background1) readmeString = "A segmented control lets someone select one option from a set of two or more segments in a single, horizontal container.\n\nSegmented controls work well for changing states of elements or views within a single context, like filtering search results. It’s best not to use them to initiate actions or navigate to a new page. To let people navigate between the main sections of an app, use the tab bar." @@ -172,16 +172,18 @@ extension SegmentedControlDemoController: DemoAppearanceDelegate { private var themeWideOverrideSegmentedControlTokens: [SegmentedControlTokenSet.Tokens: ControlTokenValue] { return [ - .font: .fontInfo { - return FontInfo(name: "Times", size: 20.0, weight: .regular) + .font: .uiFont { + return UIFont(descriptor: .init(name: "Times", size: 20.0), + size: 20.0) } ] } private var perControlOverrideSegmentedControlTokens: [SegmentedControlTokenSet.Tokens: ControlTokenValue] { return [ - .font: .fontInfo { - return FontInfo(name: "Papyrus", size: 10.0, weight: .regular) + .font: .uiFont { + return UIFont(descriptor: .init(name: "Papyrus", size: 10.0), + size: 10.0) } ] } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ShadowTokensDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ShadowTokensDemoController.swift index 30c0725f09..c91a871fe3 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ShadowTokensDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ShadowTokensDemoController.swift @@ -11,7 +11,7 @@ class ShadowTokensDemoController: DemoController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.stencil2)) + view.backgroundColor = view.fluentTheme.color(.stencil2) container.alignment = .center container.spacing = 120 @@ -41,11 +41,11 @@ private class ShadowView: UIView, Shadowable { layer.borderWidth = Constants.borderWidth layer.cornerRadius = Constants.cornerRadius - backgroundColor = UIColor(dynamicColor: fluentTheme.color(.background2)) + backgroundColor = fluentTheme.color(.background2) label.text = title label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground1)) + label.textColor = fluentTheme.color(.foreground1) addSubview(label) setupLayoutConstraints() diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/SideTabBarDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/SideTabBarDemoController.swift index c7b3cc691a..ecbe9e73ba 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/SideTabBarDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/SideTabBarDemoController.swift @@ -81,7 +81,7 @@ class SideTabBarDemoController: DemoController { sideTabBar.topItems[2].isUnreadDotVisible = true var premiumImage = UIImage(named: "ic_fluent_premium_24_regular")! - let primaryColor = UIColor(dynamicColor: view.fluentTheme.color(.brandForegroundTint)) + let primaryColor = view.fluentTheme.color(.brandForegroundTint) premiumImage = premiumImage.withTintColor(primaryColor, renderingMode: .alwaysOriginal) sideTabBar.bottomItems = [ diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewCellDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewCellDemoController.swift index 5cbb2e6561..07708c7396 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewCellDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewCellDemoController.swift @@ -119,25 +119,25 @@ extension TableViewCellDemoController: DemoAppearanceDelegate { // MARK: - Custom tokens private var themeWideOverrideTableViewCellTokens: [TableViewCellTokenSet.Tokens: ControlTokenValue] { return [ - .cellBackgroundColor: .dynamicColor { + .cellBackgroundColor: .uiColor { // "Berry" - return DynamicColor(light: GlobalTokens.sharedColors(.berry, .tint50), - dark: GlobalTokens.sharedColors(.berry, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.berry, .tint50), + dark: GlobalTokens.sharedColor(.berry, .shade40)) } ] } private var perControlOverrideTableViewCellTokens: [TableViewCellTokenSet.Tokens: ControlTokenValue] { return [ - .cellBackgroundColor: .dynamicColor { + .cellBackgroundColor: .uiColor { // "Brass" - return DynamicColor(light: GlobalTokens.sharedColors(.brass, .tint50), - dark: GlobalTokens.sharedColors(.brass, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.brass, .tint50), + dark: GlobalTokens.sharedColor(.brass, .shade40)) }, - .accessoryDisclosureIndicatorColor: .dynamicColor { + .accessoryDisclosureIndicatorColor: .uiColor { // "Forest" - return DynamicColor(light: GlobalTokens.sharedColors(.forest, .tint10), - dark: GlobalTokens.sharedColors(.forest, .shade40)) + return UIColor(light: GlobalTokens.sharedColor(.forest, .tint10), + dark: GlobalTokens.sharedColor(.forest, .shade40)) }, .customViewTrailingMargin: .float { return 0 @@ -167,10 +167,10 @@ extension TableViewCellDemoController { if section.title == "Inverted double line cell" { cell.setup( attributedTitle: NSAttributedString(string: item.text1, - attributes: [.font: UIFont.fluent(fluentTheme.typography(.body1)), + attributes: [.font: fluentTheme.typography(.body1), .foregroundColor: UIColor.purple]), attributedSubtitle: NSAttributedString(string: item.text2, - attributes: [.font: UIFont.fluent(fluentTheme.typography(.caption1)), + attributes: [.font: fluentTheme.typography(.caption1), .foregroundColor: UIColor.red]), footer: TableViewCellSampleData.hasFullLengthLabelAccessoryView(at: indexPath) ? "" : item.text3, customView: TableViewSampleData.createCustomView(imageName: item.image), diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewHeaderFooterViewDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewHeaderFooterViewDemoController.swift index 73e91fa862..12eff53f4c 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewHeaderFooterViewDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TableViewHeaderFooterViewDemoController.swift @@ -49,7 +49,7 @@ extension TableViewHeaderFooterViewDemoController: UITableViewDataSource { return UITableViewCell() } cell.backgroundStyleType = TableViewCellBackgroundStyleType.custom - cell.backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background2)) + cell.backgroundColor = view.fluentTheme.color(.background2) cell.setup(title: TableViewHeaderFooterSampleData.itemTitle) var isLastInSection = indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 if tableView.style == .grouped { diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldDemoController.swift index aa68f90a08..9d34e43cef 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldDemoController.swift @@ -112,44 +112,47 @@ extension TextFieldDemoController: DemoAppearanceDelegate { // MARK: - Custom tokens private var themeWideOverrideTextFieldTokens: [TextFieldTokenSet.Tokens: ControlTokenValue] { - let foreground = DynamicColor(light: GlobalTokens.sharedColors(.cornflower, .tint40), - dark: GlobalTokens.sharedColors(.cornflower, .shade30)) - let background = DynamicColor(light: GlobalTokens.sharedColors(.cornflower, .shade30), - dark: GlobalTokens.sharedColors(.cornflower, .tint40)) - let font = FontInfo(name: "Times", size: 20.0, weight: .regular) + let foreground = UIColor(light: GlobalTokens.sharedColor(.cornflower, .tint40), + dark: GlobalTokens.sharedColor(.cornflower, .shade30)) + let background = UIColor(light: GlobalTokens.sharedColor(.cornflower, .shade30), + dark: GlobalTokens.sharedColor(.cornflower, .tint40)) + let font = UIFont(descriptor: .init(name: "Times", size: 20.0), + size: 20.0) + return [ - .assistiveTextColor: .dynamicColor { foreground }, - .assistiveTextFont: .fontInfo { font }, - .backgroundColor: .dynamicColor { background }, - .inputTextColor: .dynamicColor { foreground }, - .inputTextFont: .fontInfo { font }, - .leadingIconColor: .dynamicColor { foreground }, - .placeholderColor: .dynamicColor { foreground }, - .strokeColor: .dynamicColor { foreground }, - .titleLabelColor: .dynamicColor { foreground }, - .titleLabelFont: .fontInfo { font }, - .trailingIconColor: .dynamicColor { foreground } + .assistiveTextColor: .uiColor { foreground }, + .assistiveTextFont: .uiFont { font }, + .backgroundColor: .uiColor { background }, + .inputTextColor: .uiColor { foreground }, + .inputTextFont: .uiFont { font }, + .leadingIconColor: .uiColor { foreground }, + .placeholderColor: .uiColor { foreground }, + .strokeColor: .uiColor { foreground }, + .titleLabelColor: .uiColor { foreground }, + .titleLabelFont: .uiFont { font }, + .trailingIconColor: .uiColor { foreground } ] } private var perControlOverrideTextFieldTokens: [TextFieldTokenSet.Tokens: ControlTokenValue] { - let foreground = DynamicColor(light: GlobalTokens.sharedColors(.lilac, .tint40), - dark: GlobalTokens.sharedColors(.lilac, .shade30)) - let background = DynamicColor(light: GlobalTokens.sharedColors(.lilac, .shade30), - dark: GlobalTokens.sharedColors(.lilac, .tint40)) - let font = FontInfo(name: "Papyrus", size: 20.0, weight: .regular) + let foreground = UIColor(light: GlobalTokens.sharedColor(.lilac, .tint40), + dark: GlobalTokens.sharedColor(.lilac, .shade30)) + let background = UIColor(light: GlobalTokens.sharedColor(.lilac, .shade30), + dark: GlobalTokens.sharedColor(.lilac, .tint40)) + let font = UIFont(descriptor: .init(name: "Papyrus", size: 20.0), + size: 20.0) return [ - .assistiveTextColor: .dynamicColor { foreground }, - .assistiveTextFont: .fontInfo { font }, - .backgroundColor: .dynamicColor { background }, - .inputTextColor: .dynamicColor { foreground }, - .inputTextFont: .fontInfo { font }, - .leadingIconColor: .dynamicColor { foreground }, - .placeholderColor: .dynamicColor { foreground }, - .strokeColor: .dynamicColor { foreground }, - .titleLabelColor: .dynamicColor { foreground }, - .titleLabelFont: .fontInfo { font }, - .trailingIconColor: .dynamicColor { foreground } + .assistiveTextColor: .uiColor { foreground }, + .assistiveTextFont: .uiFont { font }, + .backgroundColor: .uiColor { background }, + .inputTextColor: .uiColor { foreground }, + .inputTextFont: .uiFont { font }, + .leadingIconColor: .uiColor { foreground }, + .placeholderColor: .uiColor { foreground }, + .strokeColor: .uiColor { foreground }, + .titleLabelColor: .uiColor { foreground }, + .titleLabelFont: .uiFont { font }, + .trailingIconColor: .uiColor { foreground } ] } } diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldObjCDemoController.m b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldObjCDemoController.m index e35f8de101..ecb475c429 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldObjCDemoController.m +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TextFieldObjCDemoController.m @@ -45,8 +45,8 @@ - (void)loadView { UIView *view = [self view]; [view addSubview:stack]; - MSFDynamicColor *background1 = [[view fluentTheme] colorForToken:MSFColorTokenBackground1]; - [view setBackgroundColor:[[UIColor alloc] initWithDynamicColor:background1]]; + UIColor *background1 = [[view fluentTheme] colorForToken:MSFColorTokenBackground1]; + [view setBackgroundColor:background1]; UILayoutGuide *safeArea = [view safeAreaLayoutGuide]; [NSLayoutConstraint activateConstraints:@[ diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TooltipDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TooltipDemoController.swift index 1e94638720..812b679349 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TooltipDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TooltipDemoController.swift @@ -174,25 +174,25 @@ extension TooltipDemoController: DemoAppearanceDelegate { // MARK: - Custom tokens private var themeWideOverrideTooltipTokens: [TooltipTokenSet.Tokens: ControlTokenValue] { return [ - .tooltipColor: .dynamicColor { + .tooltipColor: .uiColor { // "Berry" - return DynamicColor(light: GlobalTokens.sharedColors(.berry, .shade30), - dark: GlobalTokens.sharedColors(.berry, .tint20)) + return UIColor(light: GlobalTokens.sharedColor(.berry, .shade30), + dark: GlobalTokens.sharedColor(.berry, .tint20)) } ] } private var perControlOverrideTooltipTokens: [TooltipTokenSet.Tokens: ControlTokenValue] { return [ - .tooltipColor: .dynamicColor { + .tooltipColor: .uiColor { // "Brass" - return DynamicColor(light: GlobalTokens.sharedColors(.brass, .tint40), - dark: GlobalTokens.sharedColors(.brass, .shade30)) + return UIColor(light: GlobalTokens.sharedColor(.brass, .tint40), + dark: GlobalTokens.sharedColor(.brass, .shade30)) }, - .textColor: .dynamicColor { + .textColor: .uiColor { // "Forest" - return DynamicColor(light: GlobalTokens.sharedColors(.forest, .shade30), - dark: GlobalTokens.sharedColors(.forest, .tint40)) + return UIColor(light: GlobalTokens.sharedColor(.forest, .shade30), + dark: GlobalTokens.sharedColor(.forest, .tint40)) }, .backgroundCornerRadius: .float { return 0 diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TypographyTokensDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TypographyTokensDemoController.swift index 90b9b7c848..5741965f0f 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/TypographyTokensDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/TypographyTokensDemoController.swift @@ -31,7 +31,7 @@ class TypographyTokensDemoController: DemoTableViewController { let text = "\(typographyToken.text)" contentConfiguration.attributedText = NSAttributedString(string: text, attributes: [ - .font: UIFont.fluent(view.fluentTheme.typography(typographyToken)) + .font: view.fluentTheme.typography(typographyToken) ]) contentConfiguration.textProperties.alignment = .center cell.contentConfiguration = contentConfiguration diff --git a/ios/FluentUI.Demo/FluentUI.Demo/TableViewCellSampleData.swift b/ios/FluentUI.Demo/FluentUI.Demo/TableViewCellSampleData.swift index 119c70b64f..583e30a304 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/TableViewCellSampleData.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/TableViewCellSampleData.swift @@ -172,7 +172,7 @@ class TableViewCellSampleData: TableViewSampleData { stackView.axis = .vertical let label = Label(style: .caption1) - label.textColor = UIColor(dynamicColor: stackView.fluentTheme.color(.foreground3)) + label.textColor = stackView.fluentTheme.color(.foreground3) label.text = text stackView.addArrangedSubview(label) @@ -189,7 +189,7 @@ class TableViewCellSampleData: TableViewSampleData { if withBorder { container.layer.borderWidth = 0.5 - container.layer.borderColor = UIColor(dynamicColor: stackView.fluentTheme.color(.foreground3)).cgColor + container.layer.borderColor = stackView.fluentTheme.color(.foreground3).cgColor container.layer.cornerRadius = 3 } diff --git a/ios/FluentUI/ActivityIndicator/ActivityIndicator.swift b/ios/FluentUI/ActivityIndicator/ActivityIndicator.swift index c7da1c2f79..90e6cbce91 100644 --- a/ios/FluentUI/ActivityIndicator/ActivityIndicator.swift +++ b/ios/FluentUI/ActivityIndicator/ActivityIndicator.swift @@ -43,7 +43,7 @@ public struct ActivityIndicator: View, TokenizedControlView { let side = ActivityIndicatorTokenSet.sideLength(size: state.size) let color: Color = { guard let stateUIColor = state.color else { - return Color(dynamicColor: tokenSet[.defaultColor].dynamicColor) + return Color(tokenSet[.defaultColor].uiColor) } return Color(stateUIColor) diff --git a/ios/FluentUI/ActivityIndicator/ActivityIndicatorTokenSet.swift b/ios/FluentUI/ActivityIndicator/ActivityIndicatorTokenSet.swift index fdb130806a..630eef84d7 100644 --- a/ios/FluentUI/ActivityIndicator/ActivityIndicatorTokenSet.swift +++ b/ios/FluentUI/ActivityIndicator/ActivityIndicatorTokenSet.swift @@ -30,9 +30,9 @@ public class ActivityIndicatorTokenSet: ControlTokenSet DynamicColor { + static func backgroundColor(hashCode: Int) -> UIColor { let colorSet = colors[hashCode % colors.count] - return DynamicColor(light: GlobalTokens.sharedColors(colorSet, .tint40), - dark: GlobalTokens.sharedColors(colorSet, .shade30)) + return UIColor(light: GlobalTokens.sharedColor(colorSet, .tint40), + dark: GlobalTokens.sharedColor(colorSet, .shade30)) } - static func foregroundColor(hashCode: Int) -> DynamicColor { + static func foregroundColor(hashCode: Int) -> UIColor { let colorSet = colors[hashCode % colors.count] - return DynamicColor(light: GlobalTokens.sharedColors(colorSet, .shade30), - dark: GlobalTokens.sharedColors(colorSet, .tint40)) + return UIColor(light: GlobalTokens.sharedColor(colorSet, .shade30), + dark: GlobalTokens.sharedColor(colorSet, .tint40)) } - static func ringColor(hashCode: Int) -> DynamicColor { + static func ringColor(hashCode: Int) -> UIColor { let colorSet = colors[hashCode % colors.count] - return DynamicColor(light: GlobalTokens.sharedColors(colorSet, .primary), - dark: GlobalTokens.sharedColors(colorSet, .tint30)) + return UIColor(light: GlobalTokens.sharedColor(colorSet, .primary), + dark: GlobalTokens.sharedColor(colorSet, .tint30)) } static func initialsHashCode(fromPrimaryText primaryText: String?, secondaryText: String?) -> Int { @@ -509,7 +509,7 @@ public struct Avatar: View, TokenizedControlView { return hash } - private static var colors: [GlobalTokens.SharedColorSets] = [ + private static var colors: [GlobalTokens.SharedColorSet] = [ .darkRed, .cranberry, .red, diff --git a/ios/FluentUI/Avatar/AvatarTokenSet.swift b/ios/FluentUI/Avatar/AvatarTokenSet.swift index 8db9220edb..45fa139a1a 100644 --- a/ios/FluentUI/Avatar/AvatarTokenSet.swift +++ b/ios/FluentUI/Avatar/AvatarTokenSet.swift @@ -75,25 +75,25 @@ public class AvatarTokenSet: ControlTokenSet { }) case .textFont: - return .fontInfo({ + return .uiFont({ switch size() { case .size16, .size20: - return .init(size: 9, weight: GlobalTokens.fontWeight(.regular)) + return .systemFont(ofSize: 9, weight: .regular) case .size24: - return theme.typography(.caption2) + return theme.typography(.caption2, adjustsForContentSizeCategory: false) case .size32: - return theme.typography(.caption1) + return theme.typography(.caption1, adjustsForContentSizeCategory: false) case .size40: - return theme.typography(.body2) + return theme.typography(.body2, adjustsForContentSizeCategory: false) case .size56: - return .init(size: GlobalTokens.fontSize(.size500), weight: GlobalTokens.fontWeight(.regular)) + return .systemFont(ofSize: GlobalTokens.fontSize(.size500), weight: .regular) case .size72: - return .init(size: GlobalTokens.fontSize(.size700), weight: GlobalTokens.fontWeight(.semibold)) + return .systemFont(ofSize: GlobalTokens.fontSize(.size700), weight: .semibold) } }) case .ringDefaultColor: - return .dynamicColor({ + return .uiColor({ switch style() { case .default, .group, .accent, .outlinedPrimary: return theme.color(.brandStroke1) @@ -103,7 +103,7 @@ public class AvatarTokenSet: ControlTokenSet { }) case .ringGapColor: - return .dynamicColor({ + return .uiColor({ theme.color(.background1) }) @@ -150,22 +150,22 @@ public class AvatarTokenSet: ControlTokenSet { }) case .borderColor: - return .dynamicColor({ + return .uiColor({ theme.color(.background1) }) case .activityForegroundColor: - return .dynamicColor({ + return .uiColor({ theme.color(.foreground1) }) case .activityBackgroundColor: - return .dynamicColor({ + return .uiColor({ theme.color(.background5) }) case .backgroundDefaultColor: - return .dynamicColor({ + return .uiColor({ switch style() { case .default, .group: return theme.color(.background1) @@ -179,7 +179,7 @@ public class AvatarTokenSet: ControlTokenSet { }) case .foregroundDefaultColor: - return .dynamicColor({ + return .uiColor({ switch style() { case .default, .group: return theme.color(.brandForeground1) diff --git a/ios/FluentUI/Avatar/MSFAvatarPresence.swift b/ios/FluentUI/Avatar/MSFAvatarPresence.swift index cb32f3f6ec..0c3b78dcd0 100644 --- a/ios/FluentUI/Avatar/MSFAvatarPresence.swift +++ b/ios/FluentUI/Avatar/MSFAvatarPresence.swift @@ -34,7 +34,7 @@ import SwiftUI colorToken = .foreground3 } - return Color(dynamicColor: fluentTheme.color(colorToken)) + return Color(fluentTheme.color(colorToken)) } func image(isOutOfOffice: Bool) -> Image { diff --git a/ios/FluentUI/Badge Field/BadgeField.swift b/ios/FluentUI/Badge Field/BadgeField.swift index 5b4f589483..fa8e47bac1 100644 --- a/ios/FluentUI/Badge Field/BadgeField.swift +++ b/ios/FluentUI/Badge Field/BadgeField.swift @@ -210,7 +210,7 @@ open class BadgeField: UIView { } private func updateBackgroundColor() { - backgroundColor = UIColor(dynamicColor: fluentTheme.color(.background1)) + backgroundColor = fluentTheme.color(.background1) } public required init?(coder aDecoder: NSCoder) { @@ -246,7 +246,7 @@ open class BadgeField: UIView { } private func setupTextField(_ textField: UITextField) { - textField.font = UIFont.fluent(fluentTheme.typography(.body1)) + textField.font = fluentTheme.typography(.body1) textField.autocapitalizationType = .none textField.autocorrectionType = .no textField.keyboardType = .emailAddress diff --git a/ios/FluentUI/Badge Field/BadgeView.swift b/ios/FluentUI/Badge Field/BadgeView.swift index eacd5fd8dd..9844ad6456 100644 --- a/ios/FluentUI/Badge Field/BadgeView.swift +++ b/ios/FluentUI/Badge Field/BadgeView.swift @@ -144,17 +144,17 @@ open class BadgeView: UIView, TokenizedControlInternal { } switch style { case .default: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandForegroundTint)) + return tokenSet.fluentTheme.color(.brandForegroundTint) case .warning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.warningForeground1)) + return tokenSet.fluentTheme.color(.warningForeground1) case .error: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.dangerForeground1)) + return tokenSet.fluentTheme.color(.dangerForeground1) case .neutral: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) + return tokenSet.fluentTheme.color(.foreground2) case .severeWarning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.severeForeground1)) + return tokenSet.fluentTheme.color(.severeForeground1) case .success: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.successForeground1)) + return tokenSet.fluentTheme.color(.successForeground1) } } set { @@ -174,15 +174,15 @@ open class BadgeView: UIView, TokenizedControlInternal { switch style { case .default: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundOnColor)) + return tokenSet.fluentTheme.color(.foregroundOnColor) case .warning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundDarkStatic)) + return tokenSet.fluentTheme.color(.foregroundDarkStatic) case .error, .severeWarning, .success: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundLightStatic)) + return tokenSet.fluentTheme.color(.foregroundLightStatic) case .neutral: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground1)) + return tokenSet.fluentTheme.color(.foreground1) } } set { @@ -200,9 +200,10 @@ open class BadgeView: UIView, TokenizedControlInternal { return customDisabledLabelTextColor } - let textDisabledColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundDisabled1)) + let textDisabledColor = tokenSet.fluentTheme.color(.foregroundDisabled1) if style == .default { - return UIColor(light: UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandForegroundDisabled1)), dark: textDisabledColor) + return UIColor(light: tokenSet.fluentTheme.color(.brandForegroundDisabled1), + dark: textDisabledColor) } else { return textDisabledColor } @@ -223,17 +224,17 @@ open class BadgeView: UIView, TokenizedControlInternal { } switch style { case .default: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandBackgroundTint)) + return tokenSet.fluentTheme.color(.brandBackgroundTint) case .warning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.warningBackground1)) + return tokenSet.fluentTheme.color(.warningBackground1) case .error: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.dangerBackground1)) + return tokenSet.fluentTheme.color(.dangerBackground1) case .neutral: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.background5)) + return tokenSet.fluentTheme.color(.background5) case .severeWarning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.severeBackground1)) + return tokenSet.fluentTheme.color(.severeBackground1) case .success: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.successBackground1)) + return tokenSet.fluentTheme.color(.successBackground1) } } set { @@ -252,17 +253,17 @@ open class BadgeView: UIView, TokenizedControlInternal { } switch style { case .default: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandBackground1)) + return tokenSet.fluentTheme.color(.brandBackground1) case .warning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.warningBackground2)) + return tokenSet.fluentTheme.color(.warningBackground2) case .error: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.dangerBackground2)) + return tokenSet.fluentTheme.color(.dangerBackground2) case .neutral: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.background5Selected)) + return tokenSet.fluentTheme.color(.background5Selected) case .severeWarning: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.severeBackground2)) + return tokenSet.fluentTheme.color(.severeBackground2) case .success: - return UIColor(dynamicColor: tokenSet.fluentTheme.color(.successBackground2)) + return tokenSet.fluentTheme.color(.successBackground2) } } set { @@ -289,9 +290,9 @@ open class BadgeView: UIView, TokenizedControlInternal { return customDisabledBackgroundColor } - let backgroundDisabledColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.background5)) + let backgroundDisabledColor = tokenSet.fluentTheme.color(.background5) if style == .default { - return UIColor(light: UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandBackground3)), dark: backgroundDisabledColor) + return UIColor(light: tokenSet.fluentTheme.color(.brandBackground3), dark: backgroundDisabledColor) } else { return backgroundDisabledColor } @@ -414,9 +415,9 @@ open class BadgeView: UIView, TokenizedControlInternal { private func updateFonts() { switch size { case .small: - label.font = UIFont.fluent(tokenSet.fluentTheme.typography(.caption1)) + label.font = tokenSet.fluentTheme.typography(.caption1) case .medium: - label.font = UIFont.fluent(tokenSet.fluentTheme.typography(.body2)) + label.font = tokenSet.fluentTheme.typography(.body2) } } diff --git a/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift b/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift index 5d537382b8..3ebda96953 100644 --- a/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift +++ b/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift @@ -871,9 +871,9 @@ open class BottomCommandingController: UIViewController { } } - private lazy var tableViewIconTintColor: UIColor = UIColor(colorValue: GlobalTokens.neutralColors(.grey50)) - private lazy var tableViewBackgroundColor: UIColor = UIColor(dynamicColor: view.fluentTheme.color(.background2)) - private lazy var bottomBarBackgroundColor: UIColor = UIColor(dynamicColor: view.fluentTheme.color(.background2)) + private lazy var tableViewIconTintColor: UIColor = GlobalTokens.neutralColor(.grey50) + private lazy var tableViewBackgroundColor: UIColor = view.fluentTheme.color(.background2) + private lazy var bottomBarBackgroundColor: UIColor = view.fluentTheme.color(.background2) private struct Constants { static let defaultHeroButtonHeight: CGFloat = 40 diff --git a/ios/FluentUI/Bottom Sheet/BottomSheetController.swift b/ios/FluentUI/Bottom Sheet/BottomSheetController.swift index 0094b3f663..66f68f1740 100644 --- a/ios/FluentUI/Bottom Sheet/BottomSheetController.swift +++ b/ios/FluentUI/Bottom Sheet/BottomSheetController.swift @@ -460,7 +460,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr } private func updateBackgroundColor() { - let backgroundColor = UIColor(dynamicColor: tokenSet[.backgroundColor].dynamicColor) + let backgroundColor = tokenSet[.backgroundColor].uiColor bottomSheetView.subviews[0].backgroundColor = backgroundColor overflowView.backgroundColor = backgroundColor } @@ -545,7 +545,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr contentView.clipsToBounds = true // We need to set the background color of the embedding view otherwise the shadows will not display - bottomSheetView.backgroundColor = UIColor(dynamicColor: tokenSet[.backgroundColor].dynamicColor) + bottomSheetView.backgroundColor = tokenSet[.backgroundColor].uiColor bottomSheetView.layer.cornerRadius = tokenSet[.cornerRadius].float bottomSheetView.addSubview(contentView) diff --git a/ios/FluentUI/Bottom Sheet/BottomSheetTokenSet.swift b/ios/FluentUI/Bottom Sheet/BottomSheetTokenSet.swift index 07639476d3..d5d8b1fef7 100644 --- a/ios/FluentUI/Bottom Sheet/BottomSheetTokenSet.swift +++ b/ios/FluentUI/Bottom Sheet/BottomSheetTokenSet.swift @@ -16,8 +16,8 @@ public class BottomSheetTokenSet: ControlTokenSet { super.init { token, theme in switch token { case .backgroundColor: - return .dynamicColor { DynamicColor(light: theme.color(.background2).light, - dark: theme.color(.background2).dark) + return .uiColor { UIColor(light: theme.color(.background2).light, + dark: theme.color(.background2).dark) } case .cornerRadius: return .float { GlobalTokens.corner(.radius120) } diff --git a/ios/FluentUI/Button/Button.swift b/ios/FluentUI/Button/Button.swift index 481ae75b4b..fc989727a3 100644 --- a/ios/FluentUI/Button/Button.swift +++ b/ios/FluentUI/Button/Button.swift @@ -109,7 +109,7 @@ open class Button: UIButton, TokenizedControlInternal { layer.cornerRadius = tokenSet[.cornerRadius].float layer.cornerCurve = .continuous - titleLabel?.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) + titleLabel?.font = tokenSet[.titleFont].uiFont titleLabel?.adjustsFontForContentSizeCategory = true if #available(iOS 15, *) { @@ -117,7 +117,7 @@ open class Button: UIButton, TokenizedControlInternal { configuration.contentInsets = edgeInsets let titleTransformer = UIConfigurationTextAttributesTransformer { incoming in var outgoing = incoming - outgoing.font = UIFont.fluent(self.tokenSet[.titleFont].fontInfo) + outgoing.font = self.tokenSet[.titleFont].uiFont return outgoing } configuration.titleTextAttributesTransformer = titleTransformer @@ -214,15 +214,15 @@ open class Button: UIButton, TokenizedControlInternal { }) private func updateTitle() { - let foregroundColor = UIColor(dynamicColor: tokenSet[.foregroundColor].dynamicColor) + let foregroundColor = tokenSet[.foregroundColor].uiColor setTitleColor(foregroundColor, for: .normal) setTitleColor(foregroundColor, for: .focused) - setTitleColor(UIColor(dynamicColor: tokenSet[.foregroundPressedColor].dynamicColor), for: .highlighted) - setTitleColor(UIColor(dynamicColor: tokenSet[.foregroundDisabledColor].dynamicColor), for: .disabled) + setTitleColor(tokenSet[.foregroundPressedColor].uiColor, for: .highlighted) + setTitleColor(tokenSet[.foregroundDisabledColor].uiColor, for: .disabled) if #available(iOS 15.0, *) { } else { - titleLabel?.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) + titleLabel?.font = tokenSet[.titleFont].uiFont } updateProposedTitleLabelWidth() @@ -231,9 +231,9 @@ open class Button: UIButton, TokenizedControlInternal { private func updateImage() { let isDisplayingImage = image != nil - let normalColor = UIColor(dynamicColor: tokenSet[.foregroundColor].dynamicColor) - let highlightedColor = UIColor(dynamicColor: tokenSet[.foregroundPressedColor].dynamicColor) - let disabledColor = UIColor(dynamicColor: tokenSet[.foregroundDisabledColor].dynamicColor) + let normalColor = tokenSet[.foregroundColor].uiColor + let highlightedColor = tokenSet[.foregroundPressedColor].uiColor + let disabledColor = tokenSet[.foregroundDisabledColor].uiColor let needsSetImage = isDisplayingImage && image(for: .normal) == nil if needsSetImage || !normalColor.isEqual(normalImageTintColor) { @@ -329,36 +329,36 @@ open class Button: UIButton, TokenizedControlInternal { } private func updateBackground() { - let backgroundColor: DynamicColor + let backgroundColor: UIColor if !isEnabled { - backgroundColor = tokenSet[.backgroundDisabledColor].dynamicColor + backgroundColor = tokenSet[.backgroundDisabledColor].uiColor } else if isHighlighted { - backgroundColor = tokenSet[.backgroundPressedColor].dynamicColor + backgroundColor = tokenSet[.backgroundPressedColor].uiColor } else if isFocused { - backgroundColor = tokenSet[.backgroundPressedColor].dynamicColor + backgroundColor = tokenSet[.backgroundPressedColor].uiColor } else { - backgroundColor = tokenSet[.backgroundColor].dynamicColor + backgroundColor = tokenSet[.backgroundColor].uiColor } - self.backgroundColor = UIColor(dynamicColor: backgroundColor) + self.backgroundColor = backgroundColor layer.cornerRadius = tokenSet[.cornerRadius].float } private func updateBorder() { - let borderColor: DynamicColor + let borderColor: UIColor if !isEnabled { - borderColor = tokenSet[.borderDisabledColor].dynamicColor + borderColor = tokenSet[.borderDisabledColor].uiColor } else if isHighlighted { - borderColor = tokenSet[.borderPressedColor].dynamicColor + borderColor = tokenSet[.borderPressedColor].uiColor } else if isFocused { - borderColor = tokenSet[.borderFocusedColor].dynamicColor + borderColor = tokenSet[.borderFocusedColor].uiColor } else { - borderColor = tokenSet[.borderColor].dynamicColor + borderColor = tokenSet[.borderColor].uiColor } - layer.borderColor = UIColor(dynamicColor: borderColor).resolvedColor(with: traitCollection).cgColor + layer.borderColor = borderColor.resolvedColor(with: traitCollection).cgColor layer.borderWidth = tokenSet[.borderWidth].float } diff --git a/ios/FluentUI/Button/ButtonTokenSet.swift b/ios/FluentUI/Button/ButtonTokenSet.swift index 2125bbd0e6..f51f6d9426 100644 --- a/ios/FluentUI/Button/ButtonTokenSet.swift +++ b/ios/FluentUI/Button/ButtonTokenSet.swift @@ -79,52 +79,52 @@ public class ButtonTokenSet: ControlTokenSet { super.init { [style, size] token, theme in switch token { case .backgroundColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent: return theme.color(.brandBackground1) case .outline, .subtle, .dangerOutline, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .danger: return theme.color(.dangerBackground2) } } case .backgroundFocusedColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent: return theme.color(.brandBackground1Selected) case .outline, .subtle, .dangerOutline, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .danger: return theme.color(.dangerBackground2) } } case .backgroundDisabledColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent, .danger: return theme.color(.background5) case .outline, .subtle, .dangerOutline, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear } } case .backgroundPressedColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent: return theme.color(.brandBackground1Pressed) case .outline, .subtle, .dangerOutline, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .danger: return theme.color(.dangerBackground2) } } case .borderColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent, .subtle, .danger, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .outline: return theme.color(.brandStroke1) case .dangerOutline: @@ -132,28 +132,28 @@ public class ButtonTokenSet: ControlTokenSet { } } case .borderFocusedColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent, .subtle, .danger, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .outline, .dangerOutline: return theme.color(.strokeFocus2) } } case .borderDisabledColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent, .subtle, .danger, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .outline, .dangerOutline: return theme.color(.strokeDisabled) } } case .borderPressedColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent, .subtle, .danger, .dangerSubtle: - return DynamicColor(light: ColorValue.clear) + return .clear case .outline: return theme.color(.brandStroke1Pressed) case .dangerOutline: @@ -179,7 +179,7 @@ public class ButtonTokenSet: ControlTokenSet { } } case .foregroundColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent: return theme.color(.foregroundOnColor) @@ -192,9 +192,9 @@ public class ButtonTokenSet: ControlTokenSet { } } case .foregroundDisabledColor: - return .dynamicColor { theme.color(.foregroundDisabled1) } + return .uiColor { theme.color(.foregroundDisabled1) } case .foregroundPressedColor: - return .dynamicColor { + return .uiColor { switch style() { case .accent: return theme.color(.foregroundOnColor) @@ -207,7 +207,7 @@ public class ButtonTokenSet: ControlTokenSet { } } case .titleFont: - return .fontInfo { + return .uiFont { switch size() { case .large: return theme.typography(.body1Strong) diff --git a/ios/FluentUI/Calendar/CalendarView.swift b/ios/FluentUI/Calendar/CalendarView.swift index 821099bc87..48246fb631 100644 --- a/ios/FluentUI/Calendar/CalendarView.swift +++ b/ios/FluentUI/Calendar/CalendarView.swift @@ -68,7 +68,7 @@ class CalendarView: UIView { } private func updateCollectionViewBackgroundColor() { - collectionView.backgroundColor = UIColor(dynamicColor: fluentTheme.color(.background2)) + collectionView.backgroundColor = fluentTheme.color(.background2) } required init?(coder aDecoder: NSCoder) { diff --git a/ios/FluentUI/Calendar/Views/CalendarViewDayCell.swift b/ios/FluentUI/Calendar/Views/CalendarViewDayCell.swift index 7aa4724c6d..6621814609 100644 --- a/ios/FluentUI/Calendar/Views/CalendarViewDayCell.swift +++ b/ios/FluentUI/Calendar/Views/CalendarViewDayCell.swift @@ -105,9 +105,9 @@ class CalendarViewDayCell: UICollectionViewCell, TokenizedControlInternal { super.init(frame: frame) - dateLabel.font = UIFont.fluent(fluentTheme.typography(.body1)) - dotView.color = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground3)) - dateLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground3)) + dateLabel.font = fluentTheme.typography(.body1) + dotView.color = tokenSet.fluentTheme.color(.foreground3) + dateLabel.textColor = tokenSet.fluentTheme.color(.foreground3) contentView.addSubview(selectionOverlayView) contentView.addSubview(dateLabel) @@ -120,8 +120,8 @@ class CalendarViewDayCell: UICollectionViewCell, TokenizedControlInternal { func updateAppearance() { updateViews() - dotView.color = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground3)) - dateLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground3)) + dotView.color = tokenSet.fluentTheme.color(.foreground3) + dateLabel.textColor = tokenSet.fluentTheme.color(.foreground3) } required init?(coder aDecoder: NSCoder) { @@ -209,26 +209,28 @@ class CalendarViewDayCell: UICollectionViewCell, TokenizedControlInternal { private func updateViews() { switch textStyle { case .primary: - dateLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground1)) + dateLabel.textColor = tokenSet.fluentTheme.color(.foreground1) case .secondary: - dateLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) + dateLabel.textColor = tokenSet.fluentTheme.color(.foreground2) } switch backgroundStyle { case .primary: - contentView.backgroundColor = UIColor(dynamicColor: DynamicColor(light: tokenSet.fluentTheme.color(.background2).light, dark: tokenSet.fluentTheme.color(.background2).dark)) + contentView.backgroundColor = UIColor(light: tokenSet.fluentTheme.color(.background2).light, + dark: tokenSet.fluentTheme.color(.background2).dark) case .secondary: - contentView.backgroundColor = UIColor(dynamicColor: DynamicColor(light: tokenSet.fluentTheme.color(.backgroundCanvas).light, dark: tokenSet.fluentTheme.color(.backgroundCanvas).dark)) + contentView.backgroundColor = UIColor(light: tokenSet.fluentTheme.color(.backgroundCanvas).light, + dark: tokenSet.fluentTheme.color(.backgroundCanvas).dark) } if isHighlighted || isSelected { dotView.isHidden = true - dateLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundOnColor)) + dateLabel.textColor = tokenSet.fluentTheme.color(.foregroundOnColor) } else { dotView.isHidden = false } - selectionOverlayView.activeColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandBackground1)) + selectionOverlayView.activeColor = tokenSet.fluentTheme.color(.brandBackground1) setNeedsLayout() } diff --git a/ios/FluentUI/Calendar/Views/CalendarViewDayMonthCell.swift b/ios/FluentUI/Calendar/Views/CalendarViewDayMonthCell.swift index a071b87565..9ea6804a0a 100644 --- a/ios/FluentUI/Calendar/Views/CalendarViewDayMonthCell.swift +++ b/ios/FluentUI/Calendar/Views/CalendarViewDayMonthCell.swift @@ -35,7 +35,7 @@ class CalendarViewDayMonthCell: CalendarViewDayCell { super.init(frame: frame) - monthLabel.font = UIFont.fluent(fluentTheme.typography(.caption2)) + monthLabel.font = fluentTheme.typography(.caption2) updateMonthLabelColor() contentView.addSubview(monthLabel) } @@ -46,7 +46,7 @@ class CalendarViewDayMonthCell: CalendarViewDayCell { } private func updateMonthLabelColor() { - monthLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + monthLabel.textColor = fluentTheme.color(.foreground2) } required init?(coder aDecoder: NSCoder) { diff --git a/ios/FluentUI/Calendar/Views/CalendarViewDayMonthYearCell.swift b/ios/FluentUI/Calendar/Views/CalendarViewDayMonthYearCell.swift index ef9fb8a75e..0b9225d89c 100644 --- a/ios/FluentUI/Calendar/Views/CalendarViewDayMonthYearCell.swift +++ b/ios/FluentUI/Calendar/Views/CalendarViewDayMonthYearCell.swift @@ -30,8 +30,8 @@ class CalendarViewDayMonthYearCell: CalendarViewDayMonthCell { super.init(frame: frame) - yearLabel.font = UIFont.fluent(fluentTheme.typography(.caption2)) - yearLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground3)) + yearLabel.font = fluentTheme.typography(.caption2) + yearLabel.textColor = fluentTheme.color(.foreground3) contentView.addSubview(yearLabel) } @@ -64,9 +64,9 @@ class CalendarViewDayMonthYearCell: CalendarViewDayMonthCell { private func updateYearLabelColor(textStyle: CalendarViewDayCellTextStyle) { switch textStyle { case .primary: - yearLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground3)) + yearLabel.textColor = fluentTheme.color(.foreground3) case .secondary: - yearLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground1)) + yearLabel.textColor = fluentTheme.color(.foreground1) } } diff --git a/ios/FluentUI/Calendar/Views/CalendarViewDayTodayCell.swift b/ios/FluentUI/Calendar/Views/CalendarViewDayTodayCell.swift index 667bd95b45..ce2ac6860f 100644 --- a/ios/FluentUI/Calendar/Views/CalendarViewDayTodayCell.swift +++ b/ios/FluentUI/Calendar/Views/CalendarViewDayTodayCell.swift @@ -46,21 +46,22 @@ class CalendarViewDayTodayCell: CalendarViewDayCell { } private func configureBackgroundColor() { - contentView.backgroundColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, dark: fluentTheme.color(.background2).dark)) + contentView.backgroundColor = UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } private func configureFontColor() { - dateLabel.font = UIFont.fluent(fluentTheme.typography(.body1)) + dateLabel.font = fluentTheme.typography(.body1) if isHighlighted || isSelected { - dateLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foregroundOnColor)) + dateLabel.textColor = fluentTheme.color(.foregroundOnColor) dateLabel.showsLargeContentViewer = true } else { switch textStyle { case .primary: - dateLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground1)) + dateLabel.textColor = fluentTheme.color(.foreground1) case .secondary: - dateLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground3)) + dateLabel.textColor = fluentTheme.color(.foreground3) } } } diff --git a/ios/FluentUI/Calendar/Views/CalendarViewWeekdayHeadingView.swift b/ios/FluentUI/Calendar/Views/CalendarViewWeekdayHeadingView.swift index 0206fd53c7..6468ef2983 100644 --- a/ios/FluentUI/Calendar/Views/CalendarViewWeekdayHeadingView.swift +++ b/ios/FluentUI/Calendar/Views/CalendarViewWeekdayHeadingView.swift @@ -44,7 +44,8 @@ class CalendarViewWeekdayHeadingView: UIView { } private func updateBackgroundColor() { - backgroundColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, dark: fluentTheme.color(.background2).dark)) + backgroundColor = UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } required init?(coder aDecoder: NSCoder) { @@ -109,9 +110,9 @@ class CalendarViewWeekdayHeadingView: UIView { let label = UILabel() label.textAlignment = .center label.text = weekdaySymbol - label.font = UIFont.fluent(fluentTheme.typography(.caption2)) + label.font = fluentTheme.typography(.caption2) label.showsLargeContentViewer = true - label.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + label.textColor = fluentTheme.color(.foreground2) headingLabels.append(label) addSubview(label) } diff --git a/ios/FluentUI/Card Nudge/CardNudge.swift b/ios/FluentUI/Card Nudge/CardNudge.swift index aa8154409e..a9ca43cfff 100644 --- a/ios/FluentUI/Card Nudge/CardNudge.swift +++ b/ios/FluentUI/Card Nudge/CardNudge.swift @@ -57,11 +57,11 @@ public struct CardNudge: View, TokenizedControlView { ZStack { RoundedRectangle(cornerRadius: tokenSet[.circleRadius].float) .frame(width: CardNudgeTokenSet.circleSize, height: CardNudgeTokenSet.circleSize) - .foregroundColor(Color(dynamicColor: tokenSet[.buttonBackgroundColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.buttonBackgroundColor].uiColor)) Image(uiImage: icon) .renderingMode(.template) .frame(width: CardNudgeTokenSet.iconSize, height: CardNudgeTokenSet.iconSize, alignment: .center) - .foregroundColor(Color(dynamicColor: tokenSet[.buttonForegroundColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.buttonForegroundColor].uiColor)) } .padding(.trailing, CardNudgeTokenSet.horizontalPadding) .showsLargeContentViewer(text: state.title, image: state.mainIcon) @@ -77,9 +77,9 @@ public struct CardNudge: View, TokenizedControlView { VStack(alignment: .leading, spacing: CardNudgeTokenSet.interTextVerticalPadding) { Text(state.title) .lineLimit(1) - .foregroundColor(Color(dynamicColor: tokenSet[.textColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.textColor].uiColor)) .showsLargeContentViewer(text: state.title, image: state.mainIcon) - .font(.fluent(tokenSet[.titleFont].fontInfo)) + .font(.init(tokenSet[.titleFont].uiFont)) if hasSecondTextRow { HStack(spacing: CardNudgeTokenSet.accentPadding) { @@ -87,22 +87,22 @@ public struct CardNudge: View, TokenizedControlView { Image(uiImage: accentIcon) .renderingMode(.template) .frame(width: CardNudgeTokenSet.accentIconSize, height: CardNudgeTokenSet.accentIconSize) - .foregroundColor(Color(dynamicColor: tokenSet[.accentColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.accentColor].uiColor)) } if let accent = state.accentText { Text(accent) .layoutPriority(1) .lineLimit(1) - .foregroundColor(Color(dynamicColor: tokenSet[.accentColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.accentColor].uiColor)) .showsLargeContentViewer(text: accent, image: state.accentIcon) - .font(.fluent(tokenSet[.subtitleFont].fontInfo)) + .font(.init(tokenSet[.subtitleFont].uiFont)) } if let subtitle = state.subtitle { Text(subtitle) .lineLimit(1) - .foregroundColor(Color(dynamicColor: tokenSet[.subtitleTextColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.subtitleTextColor].uiColor)) .showsLargeContentViewer(text: subtitle) - .font(.fluent(tokenSet[.subtitleFont].fontInfo)) + .font(.init(tokenSet[.subtitleFont].uiFont)) } } } @@ -120,11 +120,11 @@ public struct CardNudge: View, TokenizedControlView { .lineLimit(1) .padding(.horizontal, CardNudgeTokenSet.buttonInnerPaddingHorizontal) .padding(.vertical, CardNudgeTokenSet.verticalPadding) - .foregroundColor(Color(dynamicColor: tokenSet[.buttonForegroundColor].dynamicColor)) - .font(.fluent(tokenSet[.titleFont].fontInfo)) + .foregroundColor(Color(tokenSet[.buttonForegroundColor].uiColor)) + .font(.init(tokenSet[.titleFont].uiFont)) .background( RoundedRectangle(cornerRadius: tokenSet[.circleRadius].float) - .foregroundColor(Color(dynamicColor: tokenSet[.buttonBackgroundColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.buttonBackgroundColor].uiColor)) ) .showsLargeContentViewer(text: actionTitle) } @@ -141,7 +141,7 @@ public struct CardNudge: View, TokenizedControlView { .padding(.horizontal, CardNudgeTokenSet.buttonInnerPaddingHorizontal) .padding(.vertical, CardNudgeTokenSet.verticalPadding) .accessibility(identifier: dismissLabel) - .foregroundColor(Color(dynamicColor: tokenSet[.subtitleTextColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.subtitleTextColor].uiColor)) .showsLargeContentViewer(text: dismissLabel, image: dismissImage) } } @@ -204,9 +204,9 @@ public struct CardNudge: View, TokenizedControlView { .background( RoundedRectangle(cornerRadius: tokenSet[.cornerRadius].float) .strokeBorder(lineWidth: tokenSet[.outlineWidth].float) - .foregroundColor(Color(dynamicColor: tokenSet[.outlineColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.outlineColor].uiColor)) .background( - Color(dynamicColor: tokenSet[.backgroundColor].dynamicColor) + Color(tokenSet[.backgroundColor].uiColor) .cornerRadius(tokenSet[.cornerRadius].float) ) #if DEBUG diff --git a/ios/FluentUI/Card Nudge/CardNudgeTokenSet.swift b/ios/FluentUI/Card Nudge/CardNudgeTokenSet.swift index 2bf010ed83..df1e9534c4 100644 --- a/ios/FluentUI/Card Nudge/CardNudgeTokenSet.swift +++ b/ios/FluentUI/Card Nudge/CardNudgeTokenSet.swift @@ -59,29 +59,29 @@ public class CardNudgeTokenSet: ControlTokenSet { super.init { [style] token, theme in switch token { case .accentColor: - return .dynamicColor { + return .uiColor { theme.color(.brandForeground1) } case .backgroundColor: switch style() { case .standard: - return .dynamicColor { + return .uiColor { theme.color(.backgroundCanvas) } case .outline: - return .dynamicColor { + return .uiColor { theme.color(.background1) } } case .buttonBackgroundColor: - return .dynamicColor { + return .uiColor { theme.color(.brandBackgroundTint) } case .buttonForegroundColor: - return .dynamicColor { + return .uiColor { theme.color(.brandForegroundTint) } @@ -98,11 +98,11 @@ public class CardNudgeTokenSet: ControlTokenSet { case .outlineColor: switch style() { case .standard: - return .dynamicColor { + return .uiColor { theme.color(.backgroundCanvas) } case .outline: - return .dynamicColor { + return .uiColor { theme.color(.stroke2) } } @@ -113,22 +113,22 @@ public class CardNudgeTokenSet: ControlTokenSet { } case .subtitleTextColor: - return .dynamicColor { + return .uiColor { theme.color(.foreground2) } case .textColor: - return .dynamicColor { + return .uiColor { theme.color(.foreground1) } case .titleFont: - return .fontInfo { + return .uiFont { theme.typography(.body2Strong) } case .subtitleFont: - return .fontInfo { + return .uiFont { theme.typography(.caption1) } } diff --git a/ios/FluentUI/Card/CardView.swift b/ios/FluentUI/Card/CardView.swift index 6417cbce4d..1e8daecac0 100644 --- a/ios/FluentUI/Card/CardView.swift +++ b/ios/FluentUI/Card/CardView.swift @@ -209,7 +209,7 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { } /// Set `customBackgroundColor` in order to set the background color when using the custom color style - @objc open lazy var customBackgroundColor: UIColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.background2)) { + @objc open lazy var customBackgroundColor: UIColor = tokenSet.fluentTheme.color(.background2) { didSet { if customBackgroundColor != oldValue { setupColors() @@ -218,7 +218,7 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { } /// Set `customTitleColor` in order to set the title's text color when using the custom color style - @objc open lazy var customTitleColor: UIColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground1)) { + @objc open lazy var customTitleColor: UIColor = tokenSet.fluentTheme.color(.foreground1) { didSet { if customTitleColor != oldValue { setupColors() @@ -227,7 +227,7 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { } /// Set `customSubtitleColor` in order to set the subtitle's text color when using the custom color style - @objc open lazy var customSubtitleColor: UIColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) { + @objc open lazy var customSubtitleColor: UIColor = tokenSet.fluentTheme.color(.foreground2) { didSet { if customSubtitleColor != oldValue { setupColors() @@ -236,7 +236,7 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { } /// Set `customIconTintColor` in order to set the icon's tint color when using the custom color style - @objc open lazy var customIconTintColor: UIColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) { + @objc open lazy var customIconTintColor: UIColor = tokenSet.fluentTheme.color(.foreground2) { didSet { if customIconTintColor != oldValue { setupColors() @@ -245,7 +245,7 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { } /// Set `customBorderColor` in order to set the border's color when using the custom color style - @objc open lazy var customBorderColor: UIColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.stroke1)) { + @objc open lazy var customBorderColor: UIColor = tokenSet.fluentTheme.color(.stroke1) { didSet { if customBorderColor != oldValue { setupColors() @@ -391,9 +391,9 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { // Update border color switch colorStyle { case .appColor: - layer.borderColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.stroke1)).cgColor + layer.borderColor = tokenSet.fluentTheme.color(.stroke1).cgColor case .neutral: - layer.borderColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.stroke1)).cgColor + layer.borderColor = tokenSet.fluentTheme.color(.stroke1).cgColor case .custom: layer.borderColor = customBorderColor.cgColor } @@ -414,17 +414,17 @@ open class CardView: UIView, Shadowable, TokenizedControlInternal { private func setupColors() { switch colorStyle { case .appColor: - primaryLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground1)) - secondaryLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) - iconView.tintColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandForeground1)) - backgroundColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.background2)) - layer.borderColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.stroke1)).cgColor + primaryLabel.textColor = tokenSet.fluentTheme.color(.foreground1) + secondaryLabel.textColor = tokenSet.fluentTheme.color(.foreground2) + iconView.tintColor = tokenSet.fluentTheme.color(.brandForeground1) + backgroundColor = tokenSet.fluentTheme.color(.background2) + layer.borderColor = tokenSet.fluentTheme.color(.stroke1).cgColor case .neutral: - backgroundColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.background2)) - primaryLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground1)) - secondaryLabel.textColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) - iconView.tintColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) - layer.borderColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.stroke1)).cgColor + backgroundColor = tokenSet.fluentTheme.color(.background2) + primaryLabel.textColor = tokenSet.fluentTheme.color(.foreground1) + secondaryLabel.textColor = tokenSet.fluentTheme.color(.foreground2) + iconView.tintColor = tokenSet.fluentTheme.color(.foreground2) + layer.borderColor = tokenSet.fluentTheme.color(.stroke1).cgColor case .custom: backgroundColor = customBackgroundColor primaryLabel.textColor = customTitleColor diff --git a/ios/FluentUI/Command Bar/CommandBarButton.swift b/ios/FluentUI/Command Bar/CommandBarButton.swift index 0d2c52a49d..7b7335b83f 100644 --- a/ios/FluentUI/Command Bar/CommandBarButton.swift +++ b/ios/FluentUI/Command Bar/CommandBarButton.swift @@ -157,15 +157,15 @@ class CommandBarButton: UIButton { func updateStyle() { // TODO: Once iOS 14 support is dropped, this should be converted to a constant (let) that will be initialized by the logic below. var resolvedBackgroundColor: UIColor = .clear - let resolvedTintColor = UIColor(dynamicColor: isSelected ? tokenSet[.itemIconColorSelected].dynamicColor : tokenSet[.itemIconColorRest].dynamicColor) + let resolvedTintColor = isSelected ? tokenSet[.itemIconColorSelected].uiColor : tokenSet[.itemIconColorRest].uiColor if isPersistSelection { if isSelected { - resolvedBackgroundColor = UIColor(dynamicColor: tokenSet[.itemBackgroundColorSelected].dynamicColor) + resolvedBackgroundColor = tokenSet[.itemBackgroundColorSelected].uiColor } else if isHighlighted { - resolvedBackgroundColor = UIColor(dynamicColor: tokenSet[.itemBackgroundColorPressed].dynamicColor) + resolvedBackgroundColor = tokenSet[.itemBackgroundColorPressed].uiColor } else { - resolvedBackgroundColor = UIColor(dynamicColor: tokenSet[.itemBackgroundColorRest].dynamicColor) + resolvedBackgroundColor = tokenSet[.itemBackgroundColorRest].uiColor } } @@ -203,8 +203,8 @@ class CommandBarButton: UIButton { extension CommandBarButton: UIPointerInteractionDelegate { public func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) { - backgroundColor = UIColor(dynamicColor: isSelected ? tokenSet[.itemBackgroundColorSelected].dynamicColor : tokenSet[.itemBackgroundColorHover].dynamicColor) - tintColor = UIColor(dynamicColor: isSelected ? tokenSet[.itemIconColorSelected].dynamicColor : tokenSet[.itemIconColorHover].dynamicColor) + backgroundColor = isSelected ? tokenSet[.itemBackgroundColorSelected].uiColor : tokenSet[.itemBackgroundColorHover].uiColor + tintColor = isSelected ? tokenSet[.itemIconColorSelected].uiColor : tokenSet[.itemIconColorHover].uiColor } public func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) { diff --git a/ios/FluentUI/Command Bar/CommandBarTokenSet.swift b/ios/FluentUI/Command Bar/CommandBarTokenSet.swift index d390510f19..360bc6233e 100644 --- a/ios/FluentUI/Command Bar/CommandBarTokenSet.swift +++ b/ios/FluentUI/Command Bar/CommandBarTokenSet.swift @@ -49,43 +49,43 @@ public class CommandBarTokenSet: ControlTokenSet { super.init { token, theme in switch token { case .backgroundColor: - return .dynamicColor { - DynamicColor(light: GlobalTokens.neutralColors(.grey98), - dark: GlobalTokens.neutralColors(.grey8)) + return .uiColor { + UIColor(light: GlobalTokens.neutralColor(.grey98), + dark: GlobalTokens.neutralColor(.grey8)) } case .groupBorderRadius: return .float { GlobalTokens.corner(.radius120) } case .itemBackgroundColorRest: - return .dynamicColor { theme.color(.background5) } + return .uiColor { theme.color(.background5) } case .itemBackgroundColorHover: - return .dynamicColor { theme.color(.background5) } + return .uiColor { theme.color(.background5) } case .itemBackgroundColorPressed: - return .dynamicColor { theme.color(.background5Pressed) } + return .uiColor { theme.color(.background5Pressed) } case .itemBackgroundColorSelected: - return .dynamicColor { theme.color(.brandBackgroundTint) } + return .uiColor { theme.color(.brandBackgroundTint) } case .itemBackgroundColorDisabled: - return .dynamicColor { theme.color(.background5) } + return .uiColor { theme.color(.background5) } case .itemIconColorRest: - return .dynamicColor { theme.color(.foreground1) } + return .uiColor { theme.color(.foreground1) } case .itemIconColorHover: - return .dynamicColor { theme.color(.foreground1) } + return .uiColor { theme.color(.foreground1) } case .itemIconColorPressed: - return .dynamicColor { theme.color(.foreground1) } + return .uiColor { theme.color(.foreground1) } case .itemIconColorSelected: - return .dynamicColor { theme.color(.brandForegroundTint) } + return .uiColor { theme.color(.brandForegroundTint) } case .itemIconColorDisabled: - return .dynamicColor { theme.color(.foregroundDisabled1) } + return .uiColor { theme.color(.foregroundDisabled1) } } } } diff --git a/ios/FluentUI/Core/ColorProviding.swift b/ios/FluentUI/Core/ColorProviding.swift index 078a5001bf..423a6b36a2 100644 --- a/ios/FluentUI/Core/ColorProviding.swift +++ b/ios/FluentUI/Core/ColorProviding.swift @@ -32,27 +32,27 @@ public protocol ColorProviding { @objc var brandStroke1Selected: UIColor { get } } -private func brandColorOverrides(provider: ColorProviding) -> [FluentTheme.ColorToken: DynamicColor] { - var brandColors: [FluentTheme.ColorToken: DynamicColor] = [:] +private func brandColorOverrides(provider: ColorProviding) -> [FluentTheme.ColorToken: UIColor] { + var brandColors: [FluentTheme.ColorToken: UIColor] = [:] - brandColors[.brandBackground1] = provider.brandBackground1.dynamicColor - brandColors[.brandBackground1Pressed] = provider.brandBackground1Pressed.dynamicColor - brandColors[.brandBackground1Selected] = provider.brandBackground1Selected.dynamicColor - brandColors[.brandBackground2] = provider.brandBackground2.dynamicColor - brandColors[.brandBackground2Pressed] = provider.brandBackground2Pressed.dynamicColor - brandColors[.brandBackground2Selected] = provider.brandBackground2Selected.dynamicColor - brandColors[.brandBackground3] = provider.brandBackground3.dynamicColor - brandColors[.brandBackgroundTint] = provider.brandBackgroundTint.dynamicColor - brandColors[.brandBackgroundDisabled] = provider.brandBackgroundDisabled.dynamicColor - brandColors[.brandForeground1] = provider.brandForeground1.dynamicColor - brandColors[.brandForeground1Pressed] = provider.brandForeground1Pressed.dynamicColor - brandColors[.brandForeground1Selected] = provider.brandForeground1Selected.dynamicColor - brandColors[.brandForegroundTint] = provider.brandForegroundTint.dynamicColor - brandColors[.brandForegroundDisabled1] = provider.brandForegroundDisabled1.dynamicColor - brandColors[.brandForegroundDisabled2] = provider.brandForegroundDisabled2.dynamicColor - brandColors[.brandStroke1] = provider.brandStroke1.dynamicColor - brandColors[.brandStroke1Pressed] = provider.brandStroke1Pressed.dynamicColor - brandColors[.brandStroke1Selected] = provider.brandStroke1Selected.dynamicColor + brandColors[.brandBackground1] = provider.brandBackground1 + brandColors[.brandBackground1Pressed] = provider.brandBackground1Pressed + brandColors[.brandBackground1Selected] = provider.brandBackground1Selected + brandColors[.brandBackground2] = provider.brandBackground2 + brandColors[.brandBackground2Pressed] = provider.brandBackground2Pressed + brandColors[.brandBackground2Selected] = provider.brandBackground2Selected + brandColors[.brandBackground3] = provider.brandBackground3 + brandColors[.brandBackgroundTint] = provider.brandBackgroundTint + brandColors[.brandBackgroundDisabled] = provider.brandBackgroundDisabled + brandColors[.brandForeground1] = provider.brandForeground1 + brandColors[.brandForeground1Pressed] = provider.brandForeground1Pressed + brandColors[.brandForeground1Selected] = provider.brandForeground1Selected + brandColors[.brandForegroundTint] = provider.brandForegroundTint + brandColors[.brandForegroundDisabled1] = provider.brandForegroundDisabled1 + brandColors[.brandForegroundDisabled2] = provider.brandForegroundDisabled2 + brandColors[.brandStroke1] = provider.brandStroke1 + brandColors[.brandStroke1Pressed] = provider.brandStroke1Pressed + brandColors[.brandStroke1Selected] = provider.brandStroke1Selected return brandColors } diff --git a/ios/FluentUI/Core/FluentUIFramework.swift b/ios/FluentUI/Core/FluentUIFramework.swift index 09a4e17c33..8a3c992e37 100644 --- a/ios/FluentUI/Core/FluentUIFramework.swift +++ b/ios/FluentUI/Core/FluentUIFramework.swift @@ -32,7 +32,7 @@ public class FluentUIFramework: NSObject { @available(*, deprecated, renamed: "initializeAppearance(with:whenContainedInInstancesOf:)") @objc public static func initializeAppearance() { - let primaryColor = UIColor(dynamicColor: FluentTheme.shared.color(.brandBackground1)) + let primaryColor = FluentTheme.shared.color(.brandBackground1) initializeAppearance(with: primaryColor) } @@ -43,9 +43,10 @@ public class FluentUIFramework: NSObject { func backgroundColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .normal: - return UIColor(dynamicColor: fluentTheme.color(.background3)) + return fluentTheme.color(.background3) case .dateTimePicker: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, dark: fluentTheme.color(.background2).dark)) + return UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } } } @@ -70,13 +71,13 @@ public class FluentUIFramework: NSObject { let fluentTheme = fluentTheme ?? FluentTheme.shared - toolbar.barTintColor = UIColor(dynamicColor: fluentTheme.color(.background3)) - toolbar.tintColor = UIColor(dynamicColor: fluentTheme.color(.foreground3)) + toolbar.barTintColor = fluentTheme.color(.background3) + toolbar.tintColor = fluentTheme.color(.foreground3) // UIBarButtonItem let barButtonItem = UIBarButtonItem.appearance() var titleAttributes = barButtonItem.titleTextAttributes(for: .normal) ?? [:] - titleAttributes[.font] = UIFont.fluent(fluentTheme.typography(.body1)) + titleAttributes[.font] = fluentTheme.typography(.body1) barButtonItem.setTitleTextAttributes(titleAttributes, for: .normal) let switchAppearance = containerTypes != nil ? UISwitch.appearance(whenContainedInInstancesOf: containerTypes!) : UISwitch.appearance() @@ -84,7 +85,7 @@ public class FluentUIFramework: NSObject { let progressViewAppearance = containerTypes != nil ? UIProgressView.appearance(whenContainedInInstancesOf: containerTypes!) : UIProgressView.appearance() progressViewAppearance.progressTintColor = primaryColor - progressViewAppearance.trackTintColor = UIColor(dynamicColor: fluentTheme.color(.stroke1)) + progressViewAppearance.trackTintColor = fluentTheme.color(.stroke1) } static func initializeUINavigationBarAppearance(_ navigationBar: UINavigationBar, traits: UITraitCollection? = nil, navigationBarStyle: NavigationBarStyle = .normal, fluentTheme: FluentTheme? = nil) { @@ -95,15 +96,15 @@ public class FluentUIFramework: NSObject { let fluentTheme = fluentTheme ?? FluentTheme.shared navigationBar.standardAppearance.backgroundColor = navigationBarStyle.backgroundColor(fluentTheme: fluentTheme) - navigationBar.tintColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + navigationBar.tintColor = fluentTheme.color(.foreground2) let traits = traits ?? navigationBar.traitCollection // Removing built-in shadow for Dark Mode navigationBar.shadowImage = traits.userInterfaceStyle == .dark ? UIImage() : nil var titleAttributes = standardAppearance.titleTextAttributes - titleAttributes[.font] = UIFont.fluent(fluentTheme.typography(.body1Strong)) - titleAttributes[.foregroundColor] = UIColor(dynamicColor: fluentTheme.color(.foreground1)) + titleAttributes[.font] = fluentTheme.typography(.body1Strong) + titleAttributes[.foregroundColor] = fluentTheme.color(.foreground1) standardAppearance.titleTextAttributes = titleAttributes diff --git a/ios/FluentUI/Core/FocusRingView.swift b/ios/FluentUI/Core/FocusRingView.swift index a66960f28c..3f57c7d04c 100644 --- a/ios/FluentUI/Core/FocusRingView.swift +++ b/ios/FluentUI/Core/FocusRingView.swift @@ -9,7 +9,7 @@ class FocusRingView: UIView { super.init(frame: frame) isUserInteractionEnabled = false - layer.borderColor = UIColor(dynamicColor: FluentTheme.shared.color(.strokeFocus2)).cgColor + layer.borderColor = FluentTheme.shared.color(.strokeFocus2).cgColor layer.borderWidth = GlobalTokens.stroke(.width20) addSubview(innerFocusRing) @@ -49,7 +49,7 @@ class FocusRingView: UIView { private var innerFocusRing: UIView = { let view = UIView() view.translatesAutoresizingMaskIntoConstraints = false - view.layer.borderColor = UIColor(dynamicColor: FluentTheme.shared.color(.strokeFocus1)).cgColor + view.layer.borderColor = FluentTheme.shared.color(.strokeFocus1).cgColor view.layer.borderWidth = GlobalTokens.stroke(.width30) return view diff --git a/ios/FluentUI/Core/SwiftUI+ViewModifiers.swift b/ios/FluentUI/Core/SwiftUI+ViewModifiers.swift index 472a41e180..62f19e7ccc 100644 --- a/ios/FluentUI/Core/SwiftUI+ViewModifiers.swift +++ b/ios/FluentUI/Core/SwiftUI+ViewModifiers.swift @@ -117,11 +117,11 @@ struct ShadowModifier: ViewModifier { func body(content: Content) -> some View { content - .shadow(color: Color(dynamicColor: shadowInfo.ambientColor), + .shadow(color: Color(shadowInfo.ambientColor), radius: shadowInfo.ambientBlur, x: shadowInfo.xAmbient, y: shadowInfo.yAmbient) - .shadow(color: Color(dynamicColor: shadowInfo.keyColor), + .shadow(color: Color(shadowInfo.keyColor), radius: shadowInfo.keyBlur, x: shadowInfo.xKey, y: shadowInfo.yKey) diff --git a/ios/FluentUI/Core/Theme/FluentTheme+Tokens.swift b/ios/FluentUI/Core/Theme/FluentTheme+Tokens.swift index 6fb7728f78..6801a4bb34 100644 --- a/ios/FluentUI/Core/Theme/FluentTheme+Tokens.swift +++ b/ios/FluentUI/Core/Theme/FluentTheme+Tokens.swift @@ -3,7 +3,7 @@ // Licensed under the MIT License. // -import Foundation +import UIKit public extension FluentTheme { @objc(MSFColorToken) @@ -131,10 +131,10 @@ public extension FluentTheme { /// Returns the color value for the given token. /// /// - Parameter token: The `ColorsTokens` value to be retrieved. - /// - Returns: A `DynamicColor` for the given token. + /// - Returns: A `UIColor` for the given token. @objc(colorForToken:) - func color(_ token: ColorToken) -> DynamicColor { - return aliasTokens.colors[AliasTokens.ColorsTokens(rawValue: token.rawValue)!] + func color(_ token: ColorToken) -> UIColor { + return UIColor(dynamicColor: aliasTokens.colors[AliasTokens.ColorsTokens(rawValue: token.rawValue)!]) } /// Returns the shadow value for the given token. @@ -150,8 +150,9 @@ public extension FluentTheme { /// /// - Parameter token: The `TypographyTokens` value to be retrieved. /// - Returns: A `FontInfo` for the given token. - @objc(typographyForToken:) - func typography(_ token: TypographyToken) -> FontInfo { - return aliasTokens.typography[AliasTokens.TypographyTokens(rawValue: token.rawValue)!] + @objc(typographyForToken:adjustsForContentSizeCategory:) + func typography(_ token: TypographyToken, adjustsForContentSizeCategory: Bool = true) -> UIFont { + return UIFont.fluent(aliasTokens.typography[AliasTokens.TypographyTokens(rawValue: token.rawValue)!], + shouldScale: adjustsForContentSizeCategory) } } diff --git a/ios/FluentUI/Core/Theme/FluentTheme.swift b/ios/FluentUI/Core/Theme/FluentTheme.swift index d3ea84a70f..4a050571bd 100644 --- a/ios/FluentUI/Core/Theme/FluentTheme.swift +++ b/ios/FluentUI/Core/Theme/FluentTheme.swift @@ -9,6 +9,16 @@ import SwiftUI /// Base class that allows for customization of global, alias, and control tokens. @objc(MSFFluentTheme) public class FluentTheme: NSObject, ObservableObject { + /// Initializes and returns a new `FluentTheme`. + /// + /// Control tokens can be customized via `register(controlType:tokens:) `; + /// see that method's description for additional information. + /// + /// - Returns: An initialized `FluentTheme` instance, with optional overrides. + @objc public convenience override init() { + self.init(colorOverrides: nil, shadowOverrides: nil, typographyOverrides: nil) + } + /// Initializes and returns a new `FluentTheme`. /// /// A `FluentTheme` receives any custom alias tokens on initialization via arguments here. @@ -21,12 +31,13 @@ public class FluentTheme: NSObject, ObservableObject { /// - typographyOverrides: A `Dictionary` of override values mapped to `TypographyTokens`. /// /// - Returns: An initialized `FluentTheme` instance, with optional overrides. - public init(colorOverrides: [ColorToken: DynamicColor]? = nil, + public init(colorOverrides: [ColorToken: UIColor]? = nil, shadowOverrides: [ShadowToken: ShadowInfo]? = nil, - typographyOverrides: [TypographyToken: FontInfo]? = nil) { - let fixedColorOverrides = colorOverrides?.map({ (key: ColorToken, value: DynamicColor) in + typographyOverrides: [TypographyToken: UIFont]? = nil) { + let fixedColorOverrides = colorOverrides?.map({ (key: ColorToken, value: UIColor) in let newKey = AliasTokens.ColorsTokens(rawValue: key.rawValue)! - return (newKey, value) + let newValue = value.dynamicColor! + return (newKey, newValue) }) ?? [(AliasTokens.ColorsTokens, DynamicColor)]() let fixedShadowOverrides = shadowOverrides?.map({ (key: ShadowToken, value: ShadowInfo) in @@ -34,9 +45,10 @@ public class FluentTheme: NSObject, ObservableObject { return (newKey, value) }) ?? [(AliasTokens.ShadowTokens, ShadowInfo)]() - let fixedTypographyOverrides = typographyOverrides?.map({ (key: TypographyToken, value: FontInfo) in + let fixedTypographyOverrides = typographyOverrides?.map({ (key: TypographyToken, value: UIFont) in let newKey = AliasTokens.TypographyTokens(rawValue: key.rawValue)! - return (newKey, value) + let newValue = FontInfo(name: value.fontName, size: value.pointSize) + return (newKey, newValue) }) ?? [(AliasTokens.TypographyTokens, FontInfo)]() // Pass overrides to AliasTokens diff --git a/ios/FluentUI/Core/Theme/Tokens/AliasTokens.swift b/ios/FluentUI/Core/Theme/Tokens/AliasTokens.swift index af05785e6b..f14ffd6b37 100644 --- a/ios/FluentUI/Core/Theme/Tokens/AliasTokens.swift +++ b/ios/FluentUI/Core/Theme/Tokens/AliasTokens.swift @@ -5,6 +5,9 @@ import SwiftUI +/// Alias Tokens represent a unified set of semantic values to be used by Fluent UI. +/// +/// Values are derived from the Fluent UI design token system at https://github.com/microsoft/fluentui-design-tokens. @objc(MSFAliasTokens) public final class AliasTokens: NSObject { @@ -431,77 +434,77 @@ extension AliasTokens { private static func defaultShadows(_ token: ShadowTokens) -> ShadowInfo { switch token { case .clear: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue.clear), + return ShadowInfo(keyColor: .clear, keyBlur: 0.0, xKey: 0.0, yKey: 0.0, - ambientColor: DynamicColor(light: ColorValue.clear), + ambientColor: .clear, ambientBlur: 0.0, xAmbient: 0.0, yAmbient: 0.0) case .shadow02: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.14), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.28)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.14), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.28)), keyBlur: 2, xKey: 0, yKey: 1, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.12), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.12), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20)), ambientBlur: 2, xAmbient: 0, yAmbient: 0) case .shadow04: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.14), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.28)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.14), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.28)), keyBlur: 4, xKey: 0, yKey: 2, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.12), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.12), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20)), ambientBlur: 2, xAmbient: 0, yAmbient: 0) case .shadow08: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.14), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.28)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.14), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.28)), keyBlur: 8, xKey: 0, yKey: 4, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.12), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.12), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20)), ambientBlur: 2, xAmbient: 0, yAmbient: 0) case .shadow16: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.14), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.28)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.14), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.28)), keyBlur: 16, xKey: 0, yKey: 8, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.12), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.12), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20)), ambientBlur: 2, xAmbient: 0, yAmbient: 0) case .shadow28: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.24), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.48)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.24), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.48)), keyBlur: 28, xKey: 0, yKey: 14, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.40)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.40)), ambientBlur: 8, xAmbient: 0, yAmbient: 0) case .shadow64: - return ShadowInfo(keyColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.24), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.48)), + return ShadowInfo(keyColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.24), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.48)), keyBlur: 64, xKey: 0, yKey: 32, - ambientColor: DynamicColor(light: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.20), - dark: ColorValue(r: 0.0, g: 0.0, b: 0.0, a: 0.40)), + ambientColor: UIColor(light: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.20), + dark: UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.40)), ambientBlur: 8, xAmbient: 0, yAmbient: 0) diff --git a/ios/FluentUI/Core/Theme/Tokens/ControlTokenSet.swift b/ios/FluentUI/Core/Theme/Tokens/ControlTokenSet.swift index 02e485e4e5..2f528cb994 100644 --- a/ios/FluentUI/Core/Theme/Tokens/ControlTokenSet.swift +++ b/ios/FluentUI/Core/Theme/Tokens/ControlTokenSet.swift @@ -178,8 +178,8 @@ public class ControlTokenSet: ObservableObject { /// Union-type enumeration of all possible token values to be stored by a `ControlTokenSet`. public enum ControlTokenValue { case float(() -> CGFloat) - case dynamicColor(() -> DynamicColor) - case fontInfo(() -> FontInfo) + case uiColor(() -> UIColor) + case uiFont(() -> UIFont) case shadowInfo(() -> ShadowInfo) public var float: CGFloat { @@ -191,21 +191,21 @@ public enum ControlTokenValue { } } - public var dynamicColor: DynamicColor { - if case .dynamicColor(let dynamicColor) = self { - return dynamicColor() + public var uiColor: UIColor { + if case .uiColor(let uiColor) = self { + return uiColor() } else { - assertionFailure("Cannot convert token to DynamicColor: \(self)") + assertionFailure("Cannot convert token to UIColor: \(self)") return fallbackColor } } - public var fontInfo: FontInfo { - if case .fontInfo(let fontInfo) = self { - return fontInfo() + public var uiFont: UIFont { + if case .uiFont(let uiFont) = self { + return uiFont() } else { assertionFailure("Cannot convert token to FontInfo: \(self)") - return FontInfo(size: 0.0) + return UIFont() } } @@ -227,12 +227,12 @@ public enum ControlTokenValue { // MARK: - Helpers - private var fallbackColor: DynamicColor { + private var fallbackColor: UIColor { #if DEBUG // Use our global "Hot Pink" in debug builds, to help identify unintentional conversions. - return DynamicColor(light: ColorValue(0xE3008C)) + return GlobalTokens.sharedColor(.hotPink, .primary) #else - return DynamicColor(light: ColorValue(0x000000)) + return GlobalTokens.neutralColor(.black) #endif } } @@ -244,10 +244,10 @@ extension ControlTokenValue: CustomStringConvertible { switch self { case .float(let float): return "ControlTokenValue.float (\(float())" - case .dynamicColor(let dynamicColor): - return "ControlTokenValue.dynamicColor (\(dynamicColor())" - case .fontInfo(let fontInfo): - return "ControlTokenValue.fontInfo (\(fontInfo())" + case .uiColor(let uiColor): + return "ControlTokenValue.uiColor (\(uiColor())" + case .uiFont(let uiFont): + return "ControlTokenValue.uiFont (\(uiFont())" case .shadowInfo(let shadowInfo): return "ControlTokenValue.shadowInfo (\(shadowInfo())" } diff --git a/ios/FluentUI/Core/Theme/Tokens/GlobalTokens.swift b/ios/FluentUI/Core/Theme/Tokens/GlobalTokens.swift index 64e827c852..f26cb0aa19 100644 --- a/ios/FluentUI/Core/Theme/Tokens/GlobalTokens.swift +++ b/ios/FluentUI/Core/Theme/Tokens/GlobalTokens.swift @@ -6,9 +6,1852 @@ import SwiftUI /// Global Tokens represent a unified set of constants to be used by Fluent UI. +/// +/// Values are derived from the Fluent UI design token system at https://github.com/microsoft/fluentui-design-tokens. @objc(MSFGlobalTokens) public class GlobalTokens: NSObject { + // MARK: - BrandColor + + @objc(MSFGlobalTokensBrandColor) + public enum BrandColorToken: Int, TokenSetKey { + case comm10 + case comm20 + case comm30 + case comm40 + case comm50 + case comm60 + case comm70 + case comm80 + case comm90 + case comm100 + case comm110 + case comm120 + case comm130 + case comm140 + case comm150 + case comm160 + } + + @objc(colorForBrandColorToken:) + public static func brandColor(_ token: BrandColorToken) -> UIColor { + switch token { + case .comm10: + return UIColor(hexValue: 0x061724) + case .comm20: + return UIColor(hexValue: 0x082338) + case .comm30: + return UIColor(hexValue: 0x0A2E4A) + case .comm40: + return UIColor(hexValue: 0x0C3B5E) + case .comm50: + return UIColor(hexValue: 0x0E4775) + case .comm60: + return UIColor(hexValue: 0x0F548C) + case .comm70: + return UIColor(hexValue: 0x115EA3) + case .comm80: + return UIColor(hexValue: 0x0F6CBD) + case .comm90: + return UIColor(hexValue: 0x2886DE) + case .comm100: + return UIColor(hexValue: 0x479EF5) + case .comm110: + return UIColor(hexValue: 0x62ABF5) + case .comm120: + return UIColor(hexValue: 0x77B7F7) + case .comm130: + return UIColor(hexValue: 0x96C6FA) + case .comm140: + return UIColor(hexValue: 0xB4D6FA) + case .comm150: + return UIColor(hexValue: 0xCFE4FA) + case .comm160: + return UIColor(hexValue: 0xEBF3FC) + } + } + + // MARK: - NeutralColor + + @objc(MSFGlobalTokensNeutralColor) + public enum NeutralColorToken: Int, TokenSetKey { + case black + case grey2 + case grey4 + case grey6 + case grey8 + case grey10 + case grey12 + case grey14 + case grey16 + case grey18 + case grey20 + case grey22 + case grey24 + case grey26 + case grey28 + case grey30 + case grey32 + case grey34 + case grey36 + case grey38 + case grey40 + case grey42 + case grey44 + case grey46 + case grey48 + case grey50 + case grey52 + case grey54 + case grey56 + case grey58 + case grey60 + case grey62 + case grey64 + case grey66 + case grey68 + case grey70 + case grey72 + case grey74 + case grey76 + case grey78 + case grey80 + case grey82 + case grey84 + case grey86 + case grey88 + case grey90 + case grey92 + case grey94 + case grey96 + case grey98 + case white + } + @objc(colorForNeutralColorToken:) + public static func neutralColor(_ token: NeutralColorToken) -> UIColor { + switch token { + case .black: + return UIColor(hexValue: 0x000000) + case .grey2: + return UIColor(hexValue: 0x050505) + case .grey4: + return UIColor(hexValue: 0x0A0A0A) + case .grey6: + return UIColor(hexValue: 0x0F0F0F) + case .grey8: + return UIColor(hexValue: 0x141414) + case .grey10: + return UIColor(hexValue: 0x1A1A1A) + case .grey12: + return UIColor(hexValue: 0x1F1F1F) + case .grey14: + return UIColor(hexValue: 0x242424) + case .grey16: + return UIColor(hexValue: 0x292929) + case .grey18: + return UIColor(hexValue: 0x2E2E2E) + case .grey20: + return UIColor(hexValue: 0x333333) + case .grey22: + return UIColor(hexValue: 0x383838) + case .grey24: + return UIColor(hexValue: 0x3D3D3D) + case .grey26: + return UIColor(hexValue: 0x424242) + case .grey28: + return UIColor(hexValue: 0x474747) + case .grey30: + return UIColor(hexValue: 0x4D4D4D) + case .grey32: + return UIColor(hexValue: 0x525252) + case .grey34: + return UIColor(hexValue: 0x575757) + case .grey36: + return UIColor(hexValue: 0x5C5C5C) + case .grey38: + return UIColor(hexValue: 0x616161) + case .grey40: + return UIColor(hexValue: 0x666666) + case .grey42: + return UIColor(hexValue: 0x6B6B6B) + case .grey44: + return UIColor(hexValue: 0x707070) + case .grey46: + return UIColor(hexValue: 0x757575) + case .grey48: + return UIColor(hexValue: 0x7A7A7A) + case .grey50: + return UIColor(hexValue: 0x808080) + case .grey52: + return UIColor(hexValue: 0x858585) + case .grey54: + return UIColor(hexValue: 0x8A8A8A) + case .grey56: + return UIColor(hexValue: 0x8F8F8F) + case .grey58: + return UIColor(hexValue: 0x949494) + case .grey60: + return UIColor(hexValue: 0x999999) + case .grey62: + return UIColor(hexValue: 0x9E9E9E) + case .grey64: + return UIColor(hexValue: 0xA3A3A3) + case .grey66: + return UIColor(hexValue: 0xA8A8A8) + case .grey68: + return UIColor(hexValue: 0xADADAD) + case .grey70: + return UIColor(hexValue: 0xB2B2B2) + case .grey72: + return UIColor(hexValue: 0xB8B8B8) + case .grey74: + return UIColor(hexValue: 0xBDBDBD) + case .grey76: + return UIColor(hexValue: 0xC2C2C2) + case .grey78: + return UIColor(hexValue: 0xC7C7C7) + case .grey80: + return UIColor(hexValue: 0xCCCCCC) + case .grey82: + return UIColor(hexValue: 0xD1D1D1) + case .grey84: + return UIColor(hexValue: 0xD6D6D6) + case .grey86: + return UIColor(hexValue: 0xDBDBDB) + case .grey88: + return UIColor(hexValue: 0xE0E0E0) + case .grey90: + return UIColor(hexValue: 0xE5E5E5) + case .grey92: + return UIColor(hexValue: 0xEBEBEB) + case .grey94: + return UIColor(hexValue: 0xF0F0F0) + case .grey96: + return UIColor(hexValue: 0xF5F5F5) + case .grey98: + return UIColor(hexValue: 0xFAFAFA) + case .white: + return UIColor(hexValue: 0xFFFFFF) + } + } + + // MARK: - SharedColor + + @objc(MSFGlobalTokensSharedColorSet) + public enum SharedColorSet: Int, TokenSetKey { + case darkRed + case burgundy + case cranberry + case red + case darkOrange + case bronze + case pumpkin + case orange + case peach + case marigold + case yellow + case gold + case brass + case brown + case darkBrown + case lime + case forest + case seafoam + case lightGreen + case green + case darkGreen + case lightTeal + case teal + case darkTeal + case cyan + case steel + case lightBlue + case blue + case royalBlue + case darkBlue + case cornflower + case navy + case lavender + case purple + case darkPurple + case orchid + case grape + case berry + case lilac + case pink + case hotPink + case magenta + case plum + case beige + case mink + case silver + case platinum + case anchor + case charcoal + } + + @objc(MSFGlobalTokensSharedColor) + public enum SharedColorToken: Int, TokenSetKey { + case shade50 + case shade40 + case shade30 + case shade20 + case shade10 + case primary + case tint10 + case tint20 + case tint30 + case tint40 + case tint50 + case tint60 + } + + @objc(colorForSharedColorSet:token:) + public static func sharedColor(_ sharedColor: SharedColorSet, _ token: SharedColorToken) -> UIColor { + switch sharedColor { + case .anchor: + switch token { + case .primary: + return UIColor(hexValue: 0x394146) + case .shade10: + return UIColor(hexValue: 0x333A3F) + case .shade20: + return UIColor(hexValue: 0x2B3135) + case .shade30: + return UIColor(hexValue: 0x202427) + case .shade40: + return UIColor(hexValue: 0x111315) + case .shade50: + return UIColor(hexValue: 0x090A0B) + case .tint10: + return UIColor(hexValue: 0x4D565C) + case .tint20: + return UIColor(hexValue: 0x626C72) + case .tint30: + return UIColor(hexValue: 0x808A90) + case .tint40: + return UIColor(hexValue: 0xBCC3C7) + case .tint50: + return UIColor(hexValue: 0xDBDFE1) + case .tint60: + return UIColor(hexValue: 0xF6F7F8) + } + case .beige: + switch token { + case .primary: + return UIColor(hexValue: 0x7A7574) + case .shade10: + return UIColor(hexValue: 0x6E6968) + case .shade20: + return UIColor(hexValue: 0x5D5958) + case .shade30: + return UIColor(hexValue: 0x444241) + case .shade40: + return UIColor(hexValue: 0x252323) + case .shade50: + return UIColor(hexValue: 0x141313) + case .tint10: + return UIColor(hexValue: 0x8A8584) + case .tint20: + return UIColor(hexValue: 0x9A9594) + case .tint30: + return UIColor(hexValue: 0xAFABAA) + case .tint40: + return UIColor(hexValue: 0xD7D4D4) + case .tint50: + return UIColor(hexValue: 0xEAE8E8) + case .tint60: + return UIColor(hexValue: 0xFAF9F9) + } + case .berry: + switch token { + case .primary: + return UIColor(hexValue: 0xC239B3) + case .shade10: + return UIColor(hexValue: 0xAF33A1) + case .shade20: + return UIColor(hexValue: 0x932B88) + case .shade30: + return UIColor(hexValue: 0x6D2064) + case .shade40: + return UIColor(hexValue: 0x3A1136) + case .shade50: + return UIColor(hexValue: 0x1F091D) + case .tint10: + return UIColor(hexValue: 0xC94CBC) + case .tint20: + return UIColor(hexValue: 0xD161C4) + case .tint30: + return UIColor(hexValue: 0xDA7ED0) + case .tint40: + return UIColor(hexValue: 0xEDBBE7) + case .tint50: + return UIColor(hexValue: 0xF5DAF2) + case .tint60: + return UIColor(hexValue: 0xFDF5FC) + } + case .blue: + switch token { + case .primary: + return UIColor(hexValue: 0x0078D4) + case .shade10: + return UIColor(hexValue: 0x006CBF) + case .shade20: + return UIColor(hexValue: 0x005BA1) + case .shade30: + return UIColor(hexValue: 0x004377) + case .shade40: + return UIColor(hexValue: 0x002440) + case .shade50: + return UIColor(hexValue: 0x001322) + case .tint10: + return UIColor(hexValue: 0x1A86D9) + case .tint20: + return UIColor(hexValue: 0x3595DE) + case .tint30: + return UIColor(hexValue: 0x5CAAE5) + case .tint40: + return UIColor(hexValue: 0xA9D3F2) + case .tint50: + return UIColor(hexValue: 0xD0E7F8) + case .tint60: + return UIColor(hexValue: 0xF3F9FD) + } + case .brass: + switch token { + case .primary: + return UIColor(hexValue: 0x986F0B) + case .shade10: + return UIColor(hexValue: 0x89640A) + case .shade20: + return UIColor(hexValue: 0x745408) + case .shade30: + return UIColor(hexValue: 0x553E06) + case .shade40: + return UIColor(hexValue: 0x2E2103) + case .shade50: + return UIColor(hexValue: 0x181202) + case .tint10: + return UIColor(hexValue: 0xA47D1E) + case .tint20: + return UIColor(hexValue: 0xB18C34) + case .tint30: + return UIColor(hexValue: 0xC1A256) + case .tint40: + return UIColor(hexValue: 0xE0CEA2) + case .tint50: + return UIColor(hexValue: 0xEFE4CB) + case .tint60: + return UIColor(hexValue: 0xFBF8F2) + } + case .bronze: + switch token { + case .primary: + return UIColor(hexValue: 0xA74109) + case .shade10: + return UIColor(hexValue: 0x963A08) + case .shade20: + return UIColor(hexValue: 0x7F3107) + case .shade30: + return UIColor(hexValue: 0x5E2405) + case .shade40: + return UIColor(hexValue: 0x321303) + case .shade50: + return UIColor(hexValue: 0x1B0A01) + case .tint10: + return UIColor(hexValue: 0xB2521E) + case .tint20: + return UIColor(hexValue: 0xBC6535) + case .tint30: + return UIColor(hexValue: 0xCA8057) + case .tint40: + return UIColor(hexValue: 0xE5BBA4) + case .tint50: + return UIColor(hexValue: 0xF1D9CC) + case .tint60: + return UIColor(hexValue: 0xFBF5F2) + } + case .brown: + switch token { + case .primary: + return UIColor(hexValue: 0x8E562E) + case .shade10: + return UIColor(hexValue: 0x804D29) + case .shade20: + return UIColor(hexValue: 0x6C4123) + case .shade30: + return UIColor(hexValue: 0x50301A) + case .shade40: + return UIColor(hexValue: 0x2B1A0E) + case .shade50: + return UIColor(hexValue: 0x170E07) + case .tint10: + return UIColor(hexValue: 0x9C663F) + case .tint20: + return UIColor(hexValue: 0xA97652) + case .tint30: + return UIColor(hexValue: 0xBB8F6F) + case .tint40: + return UIColor(hexValue: 0xDDC3B0) + case .tint50: + return UIColor(hexValue: 0xEDDED3) + case .tint60: + return UIColor(hexValue: 0xFAF7F4) + } + case .burgundy: + switch token { + case .primary: + return UIColor(hexValue: 0xA4262C) + case .shade10: + return UIColor(hexValue: 0x942228) + case .shade20: + return UIColor(hexValue: 0x7D1D21) + case .shade30: + return UIColor(hexValue: 0x5C1519) + case .shade40: + return UIColor(hexValue: 0x310B0D) + case .shade50: + return UIColor(hexValue: 0x1A0607) + case .tint10: + return UIColor(hexValue: 0xAF393E) + case .tint20: + return UIColor(hexValue: 0xBA4D52) + case .tint30: + return UIColor(hexValue: 0xC86C70) + case .tint40: + return UIColor(hexValue: 0xE4AFB2) + case .tint50: + return UIColor(hexValue: 0xF0D3D4) + case .tint60: + return UIColor(hexValue: 0xFBF4F4) + } + case .charcoal: + switch token { + case .primary: + return UIColor(hexValue: 0x393939) + case .shade10: + return UIColor(hexValue: 0x333333) + case .shade20: + return UIColor(hexValue: 0x2B2B2B) + case .shade30: + return UIColor(hexValue: 0x202020) + case .shade40: + return UIColor(hexValue: 0x111111) + case .shade50: + return UIColor(hexValue: 0x090909) + case .tint10: + return UIColor(hexValue: 0x515151) + case .tint20: + return UIColor(hexValue: 0x686868) + case .tint30: + return UIColor(hexValue: 0x888888) + case .tint40: + return UIColor(hexValue: 0xC4C4C4) + case .tint50: + return UIColor(hexValue: 0xDFDFDF) + case .tint60: + return UIColor(hexValue: 0xF7F7F7) + } + case .cornflower: + switch token { + case .primary: + return UIColor(hexValue: 0x4F6BED) + case .shade10: + return UIColor(hexValue: 0x4760D5) + case .shade20: + return UIColor(hexValue: 0x3C51B4) + case .shade30: + return UIColor(hexValue: 0x2C3C85) + case .shade40: + return UIColor(hexValue: 0x182047) + case .shade50: + return UIColor(hexValue: 0x0D1126) + case .tint10: + return UIColor(hexValue: 0x637CEF) + case .tint20: + return UIColor(hexValue: 0x778DF1) + case .tint30: + return UIColor(hexValue: 0x93A4F4) + case .tint40: + return UIColor(hexValue: 0xC8D1FA) + case .tint50: + return UIColor(hexValue: 0xE1E6FC) + case .tint60: + return UIColor(hexValue: 0xF7F9FE) + } + case .cranberry: + switch token { + case .primary: + return UIColor(hexValue: 0xC50F1F) + case .shade10: + return UIColor(hexValue: 0xB10E1C) + case .shade20: + return UIColor(hexValue: 0x960B18) + case .shade30: + return UIColor(hexValue: 0x6E0811) + case .shade40: + return UIColor(hexValue: 0x3B0509) + case .shade50: + return UIColor(hexValue: 0x200205) + case .tint10: + return UIColor(hexValue: 0xCC2635) + case .tint20: + return UIColor(hexValue: 0xD33F4C) + case .tint30: + return UIColor(hexValue: 0xDC626D) + case .tint40: + return UIColor(hexValue: 0xEEACB2) + case .tint50: + return UIColor(hexValue: 0xF6D1D5) + case .tint60: + return UIColor(hexValue: 0xFDF3F4) + } + case .cyan: + switch token { + case .primary: + return UIColor(hexValue: 0x0099BC) + case .shade10: + return UIColor(hexValue: 0x008AA9) + case .shade20: + return UIColor(hexValue: 0x00748F) + case .shade30: + return UIColor(hexValue: 0x005669) + case .shade40: + return UIColor(hexValue: 0x002E38) + case .shade50: + return UIColor(hexValue: 0x00181E) + case .tint10: + return UIColor(hexValue: 0x18A4C4) + case .tint20: + return UIColor(hexValue: 0x31AFCC) + case .tint30: + return UIColor(hexValue: 0x56BFD7) + case .tint40: + return UIColor(hexValue: 0xA4DEEB) + case .tint50: + return UIColor(hexValue: 0xCDEDF4) + case .tint60: + return UIColor(hexValue: 0xF2FAFC) + } + case .darkBlue: + switch token { + case .primary: + return UIColor(hexValue: 0x003966) + case .shade10: + return UIColor(hexValue: 0x00335C) + case .shade20: + return UIColor(hexValue: 0x002B4E) + case .shade30: + return UIColor(hexValue: 0x002039) + case .shade40: + return UIColor(hexValue: 0x00111F) + case .shade50: + return UIColor(hexValue: 0x000910) + case .tint10: + return UIColor(hexValue: 0x0E4A78) + case .tint20: + return UIColor(hexValue: 0x215C8B) + case .tint30: + return UIColor(hexValue: 0x4178A3) + case .tint40: + return UIColor(hexValue: 0x92B5D1) + case .tint50: + return UIColor(hexValue: 0xC2D6E7) + case .tint60: + return UIColor(hexValue: 0xEFF4F9) + } + case .darkBrown: + switch token { + case .primary: + return UIColor(hexValue: 0x4D291C) + case .shade10: + return UIColor(hexValue: 0x452519) + case .shade20: + return UIColor(hexValue: 0x3A1F15) + case .shade30: + return UIColor(hexValue: 0x2B1710) + case .shade40: + return UIColor(hexValue: 0x170C08) + case .shade50: + return UIColor(hexValue: 0x0C0704) + case .tint10: + return UIColor(hexValue: 0x623A2B) + case .tint20: + return UIColor(hexValue: 0x784D3E) + case .tint30: + return UIColor(hexValue: 0x946B5C) + case .tint40: + return UIColor(hexValue: 0xCAADA3) + case .tint50: + return UIColor(hexValue: 0xE3D2CB) + case .tint60: + return UIColor(hexValue: 0xF8F3F2) + } + case .darkGreen: + switch token { + case .primary: + return UIColor(hexValue: 0x0B6A0B) + case .shade10: + return UIColor(hexValue: 0x0A5F0A) + case .shade20: + return UIColor(hexValue: 0x085108) + case .shade30: + return UIColor(hexValue: 0x063B06) + case .shade40: + return UIColor(hexValue: 0x032003) + case .shade50: + return UIColor(hexValue: 0x021102) + case .tint10: + return UIColor(hexValue: 0x1A7C1A) + case .tint20: + return UIColor(hexValue: 0x2D8E2D) + case .tint30: + return UIColor(hexValue: 0x4DA64D) + case .tint40: + return UIColor(hexValue: 0x9AD29A) + case .tint50: + return UIColor(hexValue: 0xC6E7C6) + case .tint60: + return UIColor(hexValue: 0xF0F9F0) + } + case .darkOrange: + switch token { + case .primary: + return UIColor(hexValue: 0xDA3B01) + case .shade10: + return UIColor(hexValue: 0xC43501) + case .shade20: + return UIColor(hexValue: 0xA62D01) + case .shade30: + return UIColor(hexValue: 0x7A2101) + case .shade40: + return UIColor(hexValue: 0x411200) + case .shade50: + return UIColor(hexValue: 0x230900) + case .tint10: + return UIColor(hexValue: 0xDE501C) + case .tint20: + return UIColor(hexValue: 0xE36537) + case .tint30: + return UIColor(hexValue: 0xE9835E) + case .tint40: + return UIColor(hexValue: 0xF4BFAB) + case .tint50: + return UIColor(hexValue: 0xF9DCD1) + case .tint60: + return UIColor(hexValue: 0xFDF6F3) + } + case .darkPurple: + switch token { + case .primary: + return UIColor(hexValue: 0x401B6C) + case .shade10: + return UIColor(hexValue: 0x3A1861) + case .shade20: + return UIColor(hexValue: 0x311552) + case .shade30: + return UIColor(hexValue: 0x240F3C) + case .shade40: + return UIColor(hexValue: 0x130820) + case .shade50: + return UIColor(hexValue: 0x0A0411) + case .tint10: + return UIColor(hexValue: 0x512B7E) + case .tint20: + return UIColor(hexValue: 0x633E8F) + case .tint30: + return UIColor(hexValue: 0x7E5CA7) + case .tint40: + return UIColor(hexValue: 0xB9A3D3) + case .tint50: + return UIColor(hexValue: 0xD8CCE7) + case .tint60: + return UIColor(hexValue: 0xF5F2F9) + } + case .darkRed: + switch token { + case .primary: + return UIColor(hexValue: 0x750B1C) + case .shade10: + return UIColor(hexValue: 0x690A19) + case .shade20: + return UIColor(hexValue: 0x590815) + case .shade30: + return UIColor(hexValue: 0x420610) + case .shade40: + return UIColor(hexValue: 0x230308) + case .shade50: + return UIColor(hexValue: 0x130204) + case .tint10: + return UIColor(hexValue: 0x861B2C) + case .tint20: + return UIColor(hexValue: 0x962F3F) + case .tint30: + return UIColor(hexValue: 0xAC4F5E) + case .tint40: + return UIColor(hexValue: 0xD69CA5) + case .tint50: + return UIColor(hexValue: 0xE9C7CD) + case .tint60: + return UIColor(hexValue: 0xF9F0F2) + } + case .darkTeal: + switch token { + case .primary: + return UIColor(hexValue: 0x006666) + case .shade10: + return UIColor(hexValue: 0x005C5C) + case .shade20: + return UIColor(hexValue: 0x004E4E) + case .shade30: + return UIColor(hexValue: 0x003939) + case .shade40: + return UIColor(hexValue: 0x001F1F) + case .shade50: + return UIColor(hexValue: 0x001010) + case .tint10: + return UIColor(hexValue: 0x0E7878) + case .tint20: + return UIColor(hexValue: 0x218B8B) + case .tint30: + return UIColor(hexValue: 0x41A3A3) + case .tint40: + return UIColor(hexValue: 0x92D1D1) + case .tint50: + return UIColor(hexValue: 0xC2E7E7) + case .tint60: + return UIColor(hexValue: 0xEFF9F9) + } + case .forest: + switch token { + case .primary: + return UIColor(hexValue: 0x498205) + case .shade10: + return UIColor(hexValue: 0x427505) + case .shade20: + return UIColor(hexValue: 0x376304) + case .shade30: + return UIColor(hexValue: 0x294903) + case .shade40: + return UIColor(hexValue: 0x162702) + case .shade50: + return UIColor(hexValue: 0x0C1501) + case .tint10: + return UIColor(hexValue: 0x599116) + case .tint20: + return UIColor(hexValue: 0x6BA02B) + case .tint30: + return UIColor(hexValue: 0x85B44C) + case .tint40: + return UIColor(hexValue: 0xBDD99B) + case .tint50: + return UIColor(hexValue: 0xDBEBC7) + case .tint60: + return UIColor(hexValue: 0xF6FAF0) + } + case .gold: + switch token { + case .primary: + return UIColor(hexValue: 0xC19C00) + case .shade10: + return UIColor(hexValue: 0xAE8C00) + case .shade20: + return UIColor(hexValue: 0x937700) + case .shade30: + return UIColor(hexValue: 0x6C5700) + case .shade40: + return UIColor(hexValue: 0x3A2F00) + case .shade50: + return UIColor(hexValue: 0x1F1900) + case .tint10: + return UIColor(hexValue: 0xC8A718) + case .tint20: + return UIColor(hexValue: 0xD0B232) + case .tint30: + return UIColor(hexValue: 0xDAC157) + case .tint40: + return UIColor(hexValue: 0xECDFA5) + case .tint50: + return UIColor(hexValue: 0xF5EECE) + case .tint60: + return UIColor(hexValue: 0xFDFBF2) + } + case .grape: + switch token { + case .primary: + return UIColor(hexValue: 0x881798) + case .shade10: + return UIColor(hexValue: 0x7A1589) + case .shade20: + return UIColor(hexValue: 0x671174) + case .shade30: + return UIColor(hexValue: 0x4C0D55) + case .shade40: + return UIColor(hexValue: 0x29072E) + case .shade50: + return UIColor(hexValue: 0x160418) + case .tint10: + return UIColor(hexValue: 0x952AA4) + case .tint20: + return UIColor(hexValue: 0xA33FB1) + case .tint30: + return UIColor(hexValue: 0xB55FC1) + case .tint40: + return UIColor(hexValue: 0xD9A7E0) + case .tint50: + return UIColor(hexValue: 0xEACEEF) + case .tint60: + return UIColor(hexValue: 0xFAF2FB) + } + case .green: + switch token { + case .primary: + return UIColor(hexValue: 0x107C10) + case .shade10: + return UIColor(hexValue: 0x0E700E) + case .shade20: + return UIColor(hexValue: 0x0C5E0C) + case .shade30: + return UIColor(hexValue: 0x094509) + case .shade40: + return UIColor(hexValue: 0x052505) + case .shade50: + return UIColor(hexValue: 0x031403) + case .tint10: + return UIColor(hexValue: 0x218C21) + case .tint20: + return UIColor(hexValue: 0x359B35) + case .tint30: + return UIColor(hexValue: 0x54B054) + case .tint40: + return UIColor(hexValue: 0x9FD89F) + case .tint50: + return UIColor(hexValue: 0xC9EAC9) + case .tint60: + return UIColor(hexValue: 0xF1FAF1) + } + case .hotPink: + switch token { + case .primary: + return UIColor(hexValue: 0xE3008C) + case .shade10: + return UIColor(hexValue: 0xCC007E) + case .shade20: + return UIColor(hexValue: 0xAD006A) + case .shade30: + return UIColor(hexValue: 0x7F004E) + case .shade40: + return UIColor(hexValue: 0x44002A) + case .shade50: + return UIColor(hexValue: 0x240016) + case .tint10: + return UIColor(hexValue: 0xE61C99) + case .tint20: + return UIColor(hexValue: 0xEA38A6) + case .tint30: + return UIColor(hexValue: 0xEE5FB7) + case .tint40: + return UIColor(hexValue: 0xF7ADDA) + case .tint50: + return UIColor(hexValue: 0xFBD2EB) + case .tint60: + return UIColor(hexValue: 0xFEF4FA) + } + case .lavender: + switch token { + case .primary: + return UIColor(hexValue: 0x7160E8) + case .shade10: + return UIColor(hexValue: 0x6656D1) + case .shade20: + return UIColor(hexValue: 0x5649B0) + case .shade30: + return UIColor(hexValue: 0x3F3682) + case .shade40: + return UIColor(hexValue: 0x221D46) + case .shade50: + return UIColor(hexValue: 0x120F25) + case .tint10: + return UIColor(hexValue: 0x8172EB) + case .tint20: + return UIColor(hexValue: 0x9184EE) + case .tint30: + return UIColor(hexValue: 0xA79CF1) + case .tint40: + return UIColor(hexValue: 0xD2CCF8) + case .tint50: + return UIColor(hexValue: 0xE7E4FB) + case .tint60: + return UIColor(hexValue: 0xF9F8FE) + } + case .lightBlue: + switch token { + case .primary: + return UIColor(hexValue: 0x3A96DD) + case .shade10: + return UIColor(hexValue: 0x3487C7) + case .shade20: + return UIColor(hexValue: 0x2C72A8) + case .shade30: + return UIColor(hexValue: 0x20547C) + case .shade40: + return UIColor(hexValue: 0x112D42) + case .shade50: + return UIColor(hexValue: 0x091823) + case .tint10: + return UIColor(hexValue: 0x4FA1E1) + case .tint20: + return UIColor(hexValue: 0x65ADE5) + case .tint30: + return UIColor(hexValue: 0x83BDEB) + case .tint40: + return UIColor(hexValue: 0xBFDDF5) + case .tint50: + return UIColor(hexValue: 0xDCEDFA) + case .tint60: + return UIColor(hexValue: 0xF6FAFE) + } + case .lightGreen: + switch token { + case .primary: + return UIColor(hexValue: 0x13A10E) + case .shade10: + return UIColor(hexValue: 0x11910D) + case .shade20: + return UIColor(hexValue: 0x0E7A0B) + case .shade30: + return UIColor(hexValue: 0x0B5A08) + case .shade40: + return UIColor(hexValue: 0x063004) + case .shade50: + return UIColor(hexValue: 0x031A02) + case .tint10: + return UIColor(hexValue: 0x27AC22) + case .tint20: + return UIColor(hexValue: 0x3DB838) + case .tint30: + return UIColor(hexValue: 0x5EC75A) + case .tint40: + return UIColor(hexValue: 0xA7E3A5) + case .tint50: + return UIColor(hexValue: 0xCEF0CD) + case .tint60: + return UIColor(hexValue: 0xF2FBF2) + } + case .lightTeal: + switch token { + case .primary: + return UIColor(hexValue: 0x00B7C3) + case .shade10: + return UIColor(hexValue: 0x00A5AF) + case .shade20: + return UIColor(hexValue: 0x008B94) + case .shade30: + return UIColor(hexValue: 0x00666D) + case .shade40: + return UIColor(hexValue: 0x00373A) + case .shade50: + return UIColor(hexValue: 0x001D1F) + case .tint10: + return UIColor(hexValue: 0x18BFCA) + case .tint20: + return UIColor(hexValue: 0x32C8D1) + case .tint30: + return UIColor(hexValue: 0x58D3DB) + case .tint40: + return UIColor(hexValue: 0xA6E9ED) + case .tint50: + return UIColor(hexValue: 0xCEF3F5) + case .tint60: + return UIColor(hexValue: 0xF2FCFD) + } + case .lilac: + switch token { + case .primary: + return UIColor(hexValue: 0xB146C2) + case .shade10: + return UIColor(hexValue: 0x9F3FAF) + case .shade20: + return UIColor(hexValue: 0x863593) + case .shade30: + return UIColor(hexValue: 0x63276D) + case .shade40: + return UIColor(hexValue: 0x35153A) + case .shade50: + return UIColor(hexValue: 0x1C0B1F) + case .tint10: + return UIColor(hexValue: 0xBA58C9) + case .tint20: + return UIColor(hexValue: 0xC36BD1) + case .tint30: + return UIColor(hexValue: 0xCF87DA) + case .tint40: + return UIColor(hexValue: 0xE6BFED) + case .tint50: + return UIColor(hexValue: 0xF2DCF5) + case .tint60: + return UIColor(hexValue: 0xFCF6FD) + } + case .lime: + switch token { + case .primary: + return UIColor(hexValue: 0x73AA24) + case .shade10: + return UIColor(hexValue: 0x689920) + case .shade20: + return UIColor(hexValue: 0x57811B) + case .shade30: + return UIColor(hexValue: 0x405F14) + case .shade40: + return UIColor(hexValue: 0x23330B) + case .shade50: + return UIColor(hexValue: 0x121B06) + case .tint10: + return UIColor(hexValue: 0x81B437) + case .tint20: + return UIColor(hexValue: 0x90BE4C) + case .tint30: + return UIColor(hexValue: 0xA4CC6C) + case .tint40: + return UIColor(hexValue: 0xCFE5AF) + case .tint50: + return UIColor(hexValue: 0xE5F1D3) + case .tint60: + return UIColor(hexValue: 0xF8FCF4) + } + case .magenta: + switch token { + case .primary: + return UIColor(hexValue: 0xBF0077) + case .shade10: + return UIColor(hexValue: 0xAC006B) + case .shade20: + return UIColor(hexValue: 0x91005A) + case .shade30: + return UIColor(hexValue: 0x6B0043) + case .shade40: + return UIColor(hexValue: 0x390024) + case .shade50: + return UIColor(hexValue: 0x1F0013) + case .tint10: + return UIColor(hexValue: 0xC71885) + case .tint20: + return UIColor(hexValue: 0xCE3293) + case .tint30: + return UIColor(hexValue: 0xD957A8) + case .tint40: + return UIColor(hexValue: 0xECA5D1) + case .tint50: + return UIColor(hexValue: 0xF5CEE6) + case .tint60: + return UIColor(hexValue: 0xFCF2F9) + } + case .marigold: + switch token { + case .primary: + return UIColor(hexValue: 0xEAA300) + case .shade10: + return UIColor(hexValue: 0xD39300) + case .shade20: + return UIColor(hexValue: 0xB27C00) + case .shade30: + return UIColor(hexValue: 0x835B00) + case .shade40: + return UIColor(hexValue: 0x463100) + case .shade50: + return UIColor(hexValue: 0x251A00) + case .tint10: + return UIColor(hexValue: 0xEDAD1C) + case .tint20: + return UIColor(hexValue: 0xEFB839) + case .tint30: + return UIColor(hexValue: 0xF2C661) + case .tint40: + return UIColor(hexValue: 0xF9E2AE) + case .tint50: + return UIColor(hexValue: 0xFCEFD3) + case .tint60: + return UIColor(hexValue: 0xFEFBF4) + } + case .mink: + switch token { + case .primary: + return UIColor(hexValue: 0x5D5A58) + case .shade10: + return UIColor(hexValue: 0x54514F) + case .shade20: + return UIColor(hexValue: 0x474443) + case .shade30: + return UIColor(hexValue: 0x343231) + case .shade40: + return UIColor(hexValue: 0x1C1B1A) + case .shade50: + return UIColor(hexValue: 0x0F0E0E) + case .tint10: + return UIColor(hexValue: 0x706D6B) + case .tint20: + return UIColor(hexValue: 0x84817E) + case .tint30: + return UIColor(hexValue: 0x9E9B99) + case .tint40: + return UIColor(hexValue: 0xCECCCB) + case .tint50: + return UIColor(hexValue: 0xE5E4E3) + case .tint60: + return UIColor(hexValue: 0xF8F8F8) + } + case .navy: + switch token { + case .primary: + return UIColor(hexValue: 0x0027B4) + case .shade10: + return UIColor(hexValue: 0x0023A2) + case .shade20: + return UIColor(hexValue: 0x001E89) + case .shade30: + return UIColor(hexValue: 0x001665) + case .shade40: + return UIColor(hexValue: 0x000C36) + case .shade50: + return UIColor(hexValue: 0x00061D) + case .tint10: + return UIColor(hexValue: 0x173BBD) + case .tint20: + return UIColor(hexValue: 0x3050C6) + case .tint30: + return UIColor(hexValue: 0x546FD2) + case .tint40: + return UIColor(hexValue: 0xA3B2E8) + case .tint50: + return UIColor(hexValue: 0xCCD5F3) + case .tint60: + return UIColor(hexValue: 0xF2F4FC) + } + case .orange: + switch token { + case .primary: + return UIColor(hexValue: 0xF7630C) + case .shade10: + return UIColor(hexValue: 0xDE590B) + case .shade20: + return UIColor(hexValue: 0xBC4B09) + case .shade30: + return UIColor(hexValue: 0x8A3707) + case .shade40: + return UIColor(hexValue: 0x4A1E04) + case .shade50: + return UIColor(hexValue: 0x271002) + case .tint10: + return UIColor(hexValue: 0xF87528) + case .tint20: + return UIColor(hexValue: 0xF98845) + case .tint30: + return UIColor(hexValue: 0xFAA06B) + case .tint40: + return UIColor(hexValue: 0xFDCFB4) + case .tint50: + return UIColor(hexValue: 0xFEE5D7) + case .tint60: + return UIColor(hexValue: 0xFFF9F5) + } + case .orchid: + switch token { + case .primary: + return UIColor(hexValue: 0x8764B8) + case .shade10: + return UIColor(hexValue: 0x795AA6) + case .shade20: + return UIColor(hexValue: 0x674C8C) + case .shade30: + return UIColor(hexValue: 0x4C3867) + case .shade40: + return UIColor(hexValue: 0x281E37) + case .shade50: + return UIColor(hexValue: 0x16101D) + case .tint10: + return UIColor(hexValue: 0x9373C0) + case .tint20: + return UIColor(hexValue: 0xA083C9) + case .tint30: + return UIColor(hexValue: 0xB29AD4) + case .tint40: + return UIColor(hexValue: 0xD7CAEA) + case .tint50: + return UIColor(hexValue: 0xE9E2F4) + case .tint60: + return UIColor(hexValue: 0xF9F8FC) + } + case .peach: + switch token { + case .primary: + return UIColor(hexValue: 0xFF8C00) + case .shade10: + return UIColor(hexValue: 0xE67E00) + case .shade20: + return UIColor(hexValue: 0xC26A00) + case .shade30: + return UIColor(hexValue: 0x8F4E00) + case .shade40: + return UIColor(hexValue: 0x4D2A00) + case .shade50: + return UIColor(hexValue: 0x291600) + case .tint10: + return UIColor(hexValue: 0xFF9A1F) + case .tint20: + return UIColor(hexValue: 0xFFA83D) + case .tint30: + return UIColor(hexValue: 0xFFBA66) + case .tint40: + return UIColor(hexValue: 0xFFDDB3) + case .tint50: + return UIColor(hexValue: 0xFFEDD6) + case .tint60: + return UIColor(hexValue: 0xFFFAF5) + } + case .pink: + switch token { + case .primary: + return UIColor(hexValue: 0xE43BA6) + case .shade10: + return UIColor(hexValue: 0xCD3595) + case .shade20: + return UIColor(hexValue: 0xAD2D7E) + case .shade30: + return UIColor(hexValue: 0x80215D) + case .shade40: + return UIColor(hexValue: 0x441232) + case .shade50: + return UIColor(hexValue: 0x24091B) + case .tint10: + return UIColor(hexValue: 0xE750B0) + case .tint20: + return UIColor(hexValue: 0xEA66BA) + case .tint30: + return UIColor(hexValue: 0xEF85C8) + case .tint40: + return UIColor(hexValue: 0xF7C0E3) + case .tint50: + return UIColor(hexValue: 0xFBDDF0) + case .tint60: + return UIColor(hexValue: 0xFEF6FB) + } + case .platinum: + switch token { + case .primary: + return UIColor(hexValue: 0x69797E) + case .shade10: + return UIColor(hexValue: 0x5F6D71) + case .shade20: + return UIColor(hexValue: 0x505C60) + case .shade30: + return UIColor(hexValue: 0x3B4447) + case .shade40: + return UIColor(hexValue: 0x1F2426) + case .shade50: + return UIColor(hexValue: 0x111314) + case .tint10: + return UIColor(hexValue: 0x79898D) + case .tint20: + return UIColor(hexValue: 0x89989D) + case .tint30: + return UIColor(hexValue: 0xA0ADB2) + case .tint40: + return UIColor(hexValue: 0xCDD6D8) + case .tint50: + return UIColor(hexValue: 0xE4E9EA) + case .tint60: + return UIColor(hexValue: 0xF8F9FA) + } + case .plum: + switch token { + case .primary: + return UIColor(hexValue: 0x77004D) + case .shade10: + return UIColor(hexValue: 0x6B0045) + case .shade20: + return UIColor(hexValue: 0x5A003B) + case .shade30: + return UIColor(hexValue: 0x43002B) + case .shade40: + return UIColor(hexValue: 0x240017) + case .shade50: + return UIColor(hexValue: 0x13000C) + case .tint10: + return UIColor(hexValue: 0x87105D) + case .tint20: + return UIColor(hexValue: 0x98246F) + case .tint30: + return UIColor(hexValue: 0xAD4589) + case .tint40: + return UIColor(hexValue: 0xD696C0) + case .tint50: + return UIColor(hexValue: 0xE9C4DC) + case .tint60: + return UIColor(hexValue: 0xFAF0F6) + } + case .pumpkin: + switch token { + case .primary: + return UIColor(hexValue: 0xCA5010) + case .shade10: + return UIColor(hexValue: 0xB6480E) + case .shade20: + return UIColor(hexValue: 0x9A3D0C) + case .shade30: + return UIColor(hexValue: 0x712D09) + case .shade40: + return UIColor(hexValue: 0x3D1805) + case .shade50: + return UIColor(hexValue: 0x200D03) + case .tint10: + return UIColor(hexValue: 0xD06228) + case .tint20: + return UIColor(hexValue: 0xD77440) + case .tint30: + return UIColor(hexValue: 0xDF8E64) + case .tint40: + return UIColor(hexValue: 0xEFC4AD) + case .tint50: + return UIColor(hexValue: 0xF7DFD2) + case .tint60: + return UIColor(hexValue: 0xFDF7F4) + } + case .purple: + switch token { + case .primary: + return UIColor(hexValue: 0x5C2E91) + case .shade10: + return UIColor(hexValue: 0x532982) + case .shade20: + return UIColor(hexValue: 0x46236E) + case .shade30: + return UIColor(hexValue: 0x341A51) + case .shade40: + return UIColor(hexValue: 0x1C0E2B) + case .shade50: + return UIColor(hexValue: 0x0F0717) + case .tint10: + return UIColor(hexValue: 0x6B3F9E) + case .tint20: + return UIColor(hexValue: 0x7C52AB) + case .tint30: + return UIColor(hexValue: 0x9470BD) + case .tint40: + return UIColor(hexValue: 0xC6B1DE) + case .tint50: + return UIColor(hexValue: 0xE0D3ED) + case .tint60: + return UIColor(hexValue: 0xF7F4FB) + } + case .red: + switch token { + case .primary: + return UIColor(hexValue: 0xD13438) + case .shade10: + return UIColor(hexValue: 0xBC2F32) + case .shade20: + return UIColor(hexValue: 0x9F282B) + case .shade30: + return UIColor(hexValue: 0x751D1F) + case .shade40: + return UIColor(hexValue: 0x3F1011) + case .shade50: + return UIColor(hexValue: 0x210809) + case .tint10: + return UIColor(hexValue: 0xD7494C) + case .tint20: + return UIColor(hexValue: 0xDC5E62) + case .tint30: + return UIColor(hexValue: 0xE37D80) + case .tint40: + return UIColor(hexValue: 0xF1BBBC) + case .tint50: + return UIColor(hexValue: 0xF8DADB) + case .tint60: + return UIColor(hexValue: 0xFDF6F6) + } + case .royalBlue: + switch token { + case .primary: + return UIColor(hexValue: 0x004E8C) + case .shade10: + return UIColor(hexValue: 0x00467E) + case .shade20: + return UIColor(hexValue: 0x003B6A) + case .shade30: + return UIColor(hexValue: 0x002C4E) + case .shade40: + return UIColor(hexValue: 0x00172A) + case .shade50: + return UIColor(hexValue: 0x000C16) + case .tint10: + return UIColor(hexValue: 0x125E9A) + case .tint20: + return UIColor(hexValue: 0x286FA8) + case .tint30: + return UIColor(hexValue: 0x4A89BA) + case .tint40: + return UIColor(hexValue: 0x9ABFDC) + case .tint50: + return UIColor(hexValue: 0xC7DCED) + case .tint60: + return UIColor(hexValue: 0xF0F6FA) + } + case .seafoam: + switch token { + case .primary: + return UIColor(hexValue: 0x00CC6A) + case .shade10: + return UIColor(hexValue: 0x00B85F) + case .shade20: + return UIColor(hexValue: 0x009B51) + case .shade30: + return UIColor(hexValue: 0x00723B) + case .shade40: + return UIColor(hexValue: 0x003D20) + case .shade50: + return UIColor(hexValue: 0x002111) + case .tint10: + return UIColor(hexValue: 0x19D279) + case .tint20: + return UIColor(hexValue: 0x34D889) + case .tint30: + return UIColor(hexValue: 0x5AE0A0) + case .tint40: + return UIColor(hexValue: 0xA8F0CD) + case .tint50: + return UIColor(hexValue: 0xCFF7E4) + case .tint60: + return UIColor(hexValue: 0xF3FDF8) + } + case .silver: + switch token { + case .primary: + return UIColor(hexValue: 0x859599) + case .shade10: + return UIColor(hexValue: 0x78868A) + case .shade20: + return UIColor(hexValue: 0x657174) + case .shade30: + return UIColor(hexValue: 0x4A5356) + case .shade40: + return UIColor(hexValue: 0x282D2E) + case .shade50: + return UIColor(hexValue: 0x151818) + case .tint10: + return UIColor(hexValue: 0x92A1A5) + case .tint20: + return UIColor(hexValue: 0xA0AEB1) + case .tint30: + return UIColor(hexValue: 0xB3BFC2) + case .tint40: + return UIColor(hexValue: 0xD8DFE0) + case .tint50: + return UIColor(hexValue: 0xEAEEEF) + case .tint60: + return UIColor(hexValue: 0xFAFBFB) + } + case .steel: + switch token { + case .primary: + return UIColor(hexValue: 0x005B70) + case .shade10: + return UIColor(hexValue: 0x005265) + case .shade20: + return UIColor(hexValue: 0x004555) + case .shade30: + return UIColor(hexValue: 0x00333F) + case .shade40: + return UIColor(hexValue: 0x001B22) + case .shade50: + return UIColor(hexValue: 0x000F12) + case .tint10: + return UIColor(hexValue: 0x0F6C81) + case .tint20: + return UIColor(hexValue: 0x237D92) + case .tint30: + return UIColor(hexValue: 0x4496A9) + case .tint40: + return UIColor(hexValue: 0x94C8D4) + case .tint50: + return UIColor(hexValue: 0xC3E1E8) + case .tint60: + return UIColor(hexValue: 0xEFF7F9) + } + case .teal: + switch token { + case .primary: + return UIColor(hexValue: 0x038387) + case .shade10: + return UIColor(hexValue: 0x037679) + case .shade20: + return UIColor(hexValue: 0x026467) + case .shade30: + return UIColor(hexValue: 0x02494C) + case .shade40: + return UIColor(hexValue: 0x012728) + case .shade50: + return UIColor(hexValue: 0x001516) + case .tint10: + return UIColor(hexValue: 0x159195) + case .tint20: + return UIColor(hexValue: 0x2AA0A4) + case .tint30: + return UIColor(hexValue: 0x4CB4B7) + case .tint40: + return UIColor(hexValue: 0x9BD9DB) + case .tint50: + return UIColor(hexValue: 0xC7EBEC) + case .tint60: + return UIColor(hexValue: 0xF0FAFA) + } + case .yellow: + switch token { + case .primary: + return UIColor(hexValue: 0xFDE300) + case .shade10: + return UIColor(hexValue: 0xE4CC00) + case .shade20: + return UIColor(hexValue: 0xC0AD00) + case .shade30: + return UIColor(hexValue: 0x817400) + case .shade40: + return UIColor(hexValue: 0x4C4400) + case .shade50: + return UIColor(hexValue: 0x282400) + case .tint10: + return UIColor(hexValue: 0xFDE61E) + case .tint20: + return UIColor(hexValue: 0xFDEA3D) + case .tint30: + return UIColor(hexValue: 0xFEEE66) + case .tint40: + return UIColor(hexValue: 0xFEF7B2) + case .tint50: + return UIColor(hexValue: 0xFFFAD6) + case .tint60: + return UIColor(hexValue: 0xFFFEF5) + } + } + } + + // MARK: - FontSize + + public enum FontSizeToken: TokenSetKey { + case size100 + case size200 + case size300 + case size400 + case size500 + case size600 + case size700 + case size800 + case size900 + } + public static func fontSize(_ token: FontSizeToken) -> CGFloat { + switch token { + case .size100: + return 12.0 + case .size200: + return 13.0 + case .size300: + return 15.0 + case .size400: + return 17.0 + case .size500: + return 20.0 + case .size600: + return 22.0 + case .size700: + return 28.0 + case .size800: + return 34.0 + case .size900: + return 60.0 + } + } + + // MARK: - FontWeight + + public enum FontWeightToken: TokenSetKey { + case regular + case medium + case semibold + case bold + } + public static func fontWeight(_ token: FontWeightToken) -> Font.Weight { + switch token { + case .regular: + return .regular + case .medium: + return .medium + case .semibold: + return .semibold + case .bold: + return .bold + } + } + + // MARK: - IconSize + + public enum IconSizeToken: TokenSetKey { + case size100 + case size120 + case size160 + case size200 + case size240 + case size280 + case size360 + case size400 + case size480 + } + public static func icon(_ token: IconSizeToken) -> CGFloat { + switch token { + case .size100: + return 10 + case .size120: + return 12 + case .size160: + return 16 + case .size200: + return 20 + case .size240: + return 24 + case .size280: + return 28 + case .size360: + return 36 + case .size400: + return 40 + case .size480: + return 48 + } + } + + // MARK: - Spacing + + public enum SpacingToken: TokenSetKey { + case sizeNone + case size20 + case size40 + case size60 + case size80 + case size100 + case size120 + case size160 + case size200 + case size240 + case size280 + case size320 + case size360 + case size400 + case size480 + case size520 + case size560 + } + public static func spacing(_ token: SpacingToken) -> CGFloat { + switch token { + case .sizeNone: + return 0 + case .size20: + return 2 + case .size40: + return 4 + case .size60: + return 6 + case .size80: + return 8 + case .size100: + return 10 + case .size120: + return 12 + case .size160: + return 16 + case .size200: + return 20 + case .size240: + return 24 + case .size280: + return 28 + case .size320: + return 32 + case .size360: + return 36 + case .size400: + return 40 + case .size480: + return 48 + case .size520: + return 52 + case .size560: + return 56 + } + } + + // MARK: - BorderRadius + + public enum CornerRadiusToken: TokenSetKey { + case radiusNone + case radius20 + case radius40 + case radius60 + case radius80 + case radius120 + case radiusCircular + } + public static func corner(_ token: CornerRadiusToken) -> CGFloat { + switch token { + case .radiusNone: + return 0 + case .radius20: + return 2 + case .radius40: + return 4 + case .radius60: + return 6 + case .radius80: + return 8 + case .radius120: + return 12 + case .radiusCircular: + return 9999 + } + } + + // MARK: - BorderSize + + public enum StrokeWidthToken: TokenSetKey { + case widthNone + case width05 + case width10 + case width15 + case width20 + case width30 + case width40 + case width60 + } + public static func stroke(_ token: StrokeWidthToken) -> CGFloat { + switch token { + case .widthNone: + return 0 + case .width05: + return 0.5 + case .width10: + return 1 + case .width15: + return 1.5 + case .width20: + return 2 + case .width30: + return 3 + case .width40: + return 4 + case .width60: + return 6 + } + } + // MARK: - Deprecated + // MARK: - BrandColors @objc(MSFBrandColorsGlobalTokens) @@ -1633,222 +3476,6 @@ public class GlobalTokens: NSObject { } } - // MARK: - FontSize - - public enum FontSizeToken: TokenSetKey { - case size100 - case size200 - case size300 - case size400 - case size500 - case size600 - case size700 - case size800 - case size900 - } - public static func fontSize(_ token: FontSizeToken) -> CGFloat { - switch token { - case .size100: - return 12.0 - case .size200: - return 13.0 - case .size300: - return 15.0 - case .size400: - return 17.0 - case .size500: - return 20.0 - case .size600: - return 22.0 - case .size700: - return 28.0 - case .size800: - return 34.0 - case .size900: - return 60.0 - } - } - - // MARK: - FontWeight - - public enum FontWeightToken: TokenSetKey { - case regular - case medium - case semibold - case bold - } - public static func fontWeight(_ token: FontWeightToken) -> Font.Weight { - switch token { - case .regular: - return .regular - case .medium: - return .medium - case .semibold: - return .semibold - case .bold: - return .bold - } - } - - // MARK: - IconSize - - public enum IconSizeToken: TokenSetKey { - case size100 - case size120 - case size160 - case size200 - case size240 - case size280 - case size360 - case size400 - case size480 - } - public static func icon(_ token: IconSizeToken) -> CGFloat { - switch token { - case .size100: - return 10 - case .size120: - return 12 - case .size160: - return 16 - case .size200: - return 20 - case .size240: - return 24 - case .size280: - return 28 - case .size360: - return 36 - case .size400: - return 40 - case .size480: - return 48 - } - } - - // MARK: - Spacing - - public enum SpacingToken: TokenSetKey { - case sizeNone - case size20 - case size40 - case size60 - case size80 - case size100 - case size120 - case size160 - case size200 - case size240 - case size280 - case size320 - case size360 - case size400 - case size480 - case size520 - case size560 - } - public static func spacing(_ token: SpacingToken) -> CGFloat { - switch token { - case .sizeNone: - return 0 - case .size20: - return 2 - case .size40: - return 4 - case .size60: - return 6 - case .size80: - return 8 - case .size100: - return 10 - case .size120: - return 12 - case .size160: - return 16 - case .size200: - return 20 - case .size240: - return 24 - case .size280: - return 28 - case .size320: - return 32 - case .size360: - return 36 - case .size400: - return 40 - case .size480: - return 48 - case .size520: - return 52 - case .size560: - return 56 - } - } - - // MARK: - BorderRadius - - public enum CornerRadiusToken: TokenSetKey { - case radiusNone - case radius20 - case radius40 - case radius60 - case radius80 - case radius120 - case radiusCircular - } - public static func corner(_ token: CornerRadiusToken) -> CGFloat { - switch token { - case .radiusNone: - return 0 - case .radius20: - return 2 - case .radius40: - return 4 - case .radius60: - return 6 - case .radius80: - return 8 - case .radius120: - return 12 - case .radiusCircular: - return 9999 - } - } - - // MARK: - BorderSize - - public enum StrokeWidthToken: TokenSetKey { - case widthNone - case width05 - case width10 - case width15 - case width20 - case width30 - case width40 - case width60 - } - public static func stroke(_ token: StrokeWidthToken) -> CGFloat { - switch token { - case .widthNone: - return 0 - case .width05: - return 0.5 - case .width10: - return 1 - case .width15: - return 1.5 - case .width20: - return 2 - case .width30: - return 3 - case .width40: - return 4 - case .width60: - return 6 - } - } - // MARK: Initialization @available(*, unavailable) diff --git a/ios/FluentUI/Core/Theme/Tokens/LinearGradientInfo.swift b/ios/FluentUI/Core/Theme/Tokens/LinearGradientInfo.swift index 828239bc37..decf817f17 100644 --- a/ios/FluentUI/Core/Theme/Tokens/LinearGradientInfo.swift +++ b/ios/FluentUI/Core/Theme/Tokens/LinearGradientInfo.swift @@ -16,7 +16,7 @@ import SwiftUI /// - locations: An optional array of values defining the location of each gradient stop. Must be in the range `[0, 1]`. /// - startPoint: The starting point for this gradient. Values should range from 0.0 to 1.0. /// - endPoint: The ending point for this gradient. Values should range from 0.0 to 1.0. - public init(colors: [DynamicColor], + public init(colors: [UIColor], locations: [CGFloat]? = nil, startPoint: CGPoint, endPoint: CGPoint) { @@ -27,7 +27,7 @@ import SwiftUI } /// The array of colors to apply to this linear gradient. - public let colors: [DynamicColor] + public let colors: [UIColor] /// An optional array of values defining the location of each gradient stop. /// @@ -49,14 +49,14 @@ extension LinearGradient { if let locations = gradientInfo.locations { // Map the colors and locations together. let stops: [Gradient.Stop] = zip(gradientInfo.colors, locations).map({ (color, location) in - return Gradient.Stop(color: Color(dynamicColor: color), + return Gradient.Stop(color: Color(color), location: location) }) self.init(stops: stops, startPoint: UnitPoint(x: gradientInfo.startPoint.x, y: gradientInfo.startPoint.y), endPoint: UnitPoint(x: gradientInfo.endPoint.x, y: gradientInfo.endPoint.y)) } else { - self.init(colors: gradientInfo.colors.map({ Color(dynamicColor: $0) }), + self.init(colors: gradientInfo.colors.map({ Color($0) }), startPoint: UnitPoint(x: gradientInfo.startPoint.x, y: gradientInfo.startPoint.y), endPoint: UnitPoint(x: gradientInfo.endPoint.x, y: gradientInfo.endPoint.y)) } diff --git a/ios/FluentUI/Core/Theme/Tokens/ShadowInfo.swift b/ios/FluentUI/Core/Theme/Tokens/ShadowInfo.swift index 0225000903..269d343c5e 100644 --- a/ios/FluentUI/Core/Theme/Tokens/ShadowInfo.swift +++ b/ios/FluentUI/Core/Theme/Tokens/ShadowInfo.swift @@ -21,11 +21,11 @@ public class ShadowInfo: NSObject { /// - ambientBlur: The blur of the ambient shadow. /// - xAmbient: The horizontal offset of the ambient shadow. /// - yAmbient: The vertical offset of the ambient shadow. - public init(keyColor: DynamicColor, + public init(keyColor: UIColor, keyBlur: CGFloat, xKey: CGFloat, yKey: CGFloat, - ambientColor: DynamicColor, + ambientColor: UIColor, ambientBlur: CGFloat, xAmbient: CGFloat, yAmbient: CGFloat) { @@ -40,7 +40,7 @@ public class ShadowInfo: NSObject { } /// The color of the key shadow. - @objc public let keyColor: DynamicColor + @objc public let keyColor: UIColor /// The blur of the key shadow. @objc public let keyBlur: CGFloat @@ -52,7 +52,7 @@ public class ShadowInfo: NSObject { @objc public let yKey: CGFloat /// The color of the ambient shadow. - @objc public let ambientColor: DynamicColor + @objc public let ambientColor: UIColor /// The blur of the ambient shadow. @objc public let ambientBlur: CGFloat @@ -92,7 +92,7 @@ public extension ShadowInfo { let layer = CALayer() layer.frame = view.bounds - layer.shadowColor = UIColor(dynamicColor: isAmbientShadow ? ambientColor : keyColor).cgColor + layer.shadowColor = (isAmbientShadow ? ambientColor : keyColor).cgColor layer.shadowRadius = isAmbientShadow ? ambientBlur : keyBlur // The shadowOpacity needs to be set to 1 since the alpha is already set through shadowColor diff --git a/ios/FluentUI/Date Time Pickers/Date Picker/DatePickerController.swift b/ios/FluentUI/Date Time Pickers/Date Picker/DatePickerController.swift index c4d57811c0..9713ed8ca0 100644 --- a/ios/FluentUI/Date Time Pickers/Date Picker/DatePickerController.swift +++ b/ios/FluentUI/Date Time Pickers/Date Picker/DatePickerController.swift @@ -189,7 +189,8 @@ class DatePickerController: UIViewController, GenericDateTimePicker { } private func updateBackgroundColor() { - view.backgroundColor = UIColor(dynamicColor: DynamicColor(light: view.fluentTheme.color(.background2).light, dark: view.fluentTheme.color(.background2).dark)) + view.backgroundColor = UIColor(light: view.fluentTheme.color(.background2).light, + dark: view.fluentTheme.color(.background2).dark) } override func viewWillAppear(_ animated: Bool) { @@ -219,8 +220,8 @@ class DatePickerController: UIViewController, GenericDateTimePicker { } private func updateBarButtonColors() { - navigationItem.rightBarButtonItem?.tintColor = UIColor(dynamicColor: view.fluentTheme.color(.brandForeground1)) - navigationItem.leftBarButtonItem?.tintColor = UIColor(dynamicColor: view.fluentTheme.color(.foreground2)) + navigationItem.rightBarButtonItem?.tintColor = view.fluentTheme.color(.brandForeground1) + navigationItem.leftBarButtonItem?.tintColor = view.fluentTheme.color(.foreground2) } public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/ios/FluentUI/Date Time Pickers/Date Time Picker/DateTimePickerController.swift b/ios/FluentUI/Date Time Pickers/Date Time Picker/DateTimePickerController.swift index 1ee36ac8a3..5706bc8f48 100644 --- a/ios/FluentUI/Date Time Pickers/Date Time Picker/DateTimePickerController.swift +++ b/ios/FluentUI/Date Time Pickers/Date Time Picker/DateTimePickerController.swift @@ -143,7 +143,8 @@ class DateTimePickerController: UIViewController, GenericDateTimePicker { } private func updateBackgroundColor() { - view.backgroundColor = UIColor(dynamicColor: DynamicColor(light: view.fluentTheme.color(.background2).light, dark: view.fluentTheme.color(.background2).dark)) + view.backgroundColor = UIColor(light: view.fluentTheme.color(.background2).light, + dark: view.fluentTheme.color(.background2).dark) } override func viewWillLayoutSubviews() { @@ -163,8 +164,8 @@ class DateTimePickerController: UIViewController, GenericDateTimePicker { } private func updateBarButtonColors() { - navigationItem.rightBarButtonItem?.tintColor = UIColor(dynamicColor: view.fluentTheme.color(.brandForeground1)) - navigationItem.leftBarButtonItem?.tintColor = UIColor(dynamicColor: view.fluentTheme.color(.foreground2)) + navigationItem.rightBarButtonItem?.tintColor = view.fluentTheme.color(.brandForeground1) + navigationItem.leftBarButtonItem?.tintColor = view.fluentTheme.color(.foreground2) } override func accessibilityPerformEscape() -> Bool { diff --git a/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerView.swift b/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerView.swift index 41a22ac6b2..643af682eb 100644 --- a/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerView.swift +++ b/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerView.swift @@ -59,7 +59,7 @@ class DateTimePickerView: UIControl { } private func updateGradientLayerColors(gradientLayer: CAGradientLayer) { - let backgroundColor = UIColor(dynamicColor: fluentTheme.color(.background2)) + let backgroundColor = fluentTheme.color(.background2) let transparentColor = backgroundColor.withAlphaComponent(0) gradientLayer.colors = [backgroundColor.cgColor, transparentColor.cgColor, transparentColor.cgColor, backgroundColor.cgColor] } @@ -97,7 +97,8 @@ class DateTimePickerView: UIControl { } private func updateBackgroundColor() { - backgroundColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, dark: fluentTheme.color(.background2).dark)) + backgroundColor = UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } public required init?(coder aDecoder: NSCoder) { diff --git a/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerViewComponentCell.swift b/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerViewComponentCell.swift index 52960f3a1b..f4f030b750 100644 --- a/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerViewComponentCell.swift +++ b/ios/FluentUI/Date Time Pickers/Date Time Picker/Views/DateTimePickerViewComponentCell.swift @@ -17,7 +17,7 @@ class DateTimePickerViewComponentCell: UITableViewCell, TokenizedControlInternal static let identifier: String = "DateTimePickerViewComponentCell" class var idealHeight: CGFloat { - let font = UIFont.fluent(FluentTheme.shared.typography(.body1)) + let font = FluentTheme.shared.typography(.body1) return max(Constants.verticalPadding * 2 + font.lineHeight, Constants.baseHeight) } @@ -39,7 +39,7 @@ class DateTimePickerViewComponentCell: UITableViewCell, TokenizedControlInternal textLabel?.textAlignment = .center textLabel?.showsLargeContentViewer = true - textLabel?.font = UIFont.fluent(fluentTheme.typography(.body1)) + textLabel?.font = fluentTheme.typography(.body1) tokenSet.registerOnUpdate(for: self) { [weak self] in self?.updateTextLabelColor() @@ -78,6 +78,6 @@ class DateTimePickerViewComponentCell: UITableViewCell, TokenizedControlInternal } private func updateTextLabelColor() { - textLabel?.textColor = emphasized ? UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) : UIColor(dynamicColor: fluentTheme.color(.foreground2)) + textLabel?.textColor = emphasized ? fluentTheme.color(.brandForeground1) : fluentTheme.color(.foreground2) } } diff --git a/ios/FluentUI/Divider/Divider.swift b/ios/FluentUI/Divider/Divider.swift index 27b657d9a1..2acfdec822 100644 --- a/ios/FluentUI/Divider/Divider.swift +++ b/ios/FluentUI/Divider/Divider.swift @@ -42,7 +42,7 @@ public struct FluentDivider: View, TokenizedControlView { public var body: some View { let isHorizontal = state.orientation == .horizontal - let color = Color(dynamicColor: tokenSet[.color].dynamicColor) + let color = Color(tokenSet[.color].color) let padding = tokenSet[.padding].float return Rectangle() diff --git a/ios/FluentUI/Divider/DividerTokenSet.swift b/ios/FluentUI/Divider/DividerTokenSet.swift index d4bafe08ee..d9e71267e5 100644 --- a/ios/FluentUI/Divider/DividerTokenSet.swift +++ b/ios/FluentUI/Divider/DividerTokenSet.swift @@ -37,7 +37,7 @@ public class DividerTokenSet: ControlTokenSet { } case .color: - return .dynamicColor { theme.color(.stroke2) } + return .color { theme.color(.stroke2) } } } } diff --git a/ios/FluentUI/Drawer/DrawerController.swift b/ios/FluentUI/Drawer/DrawerController.swift index 36d5f39c80..dff2efa85d 100644 --- a/ios/FluentUI/Drawer/DrawerController.swift +++ b/ios/FluentUI/Drawer/DrawerController.swift @@ -99,13 +99,13 @@ public protocol DrawerControllerDelegate: AnyObject { @objc(MSFDrawerController) open class DrawerController: UIViewController { @objc public static func drawerBackground(fluentTheme: FluentTheme) -> UIColor { - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, - dark: fluentTheme.color(.background2).dark)) + return UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } @objc public static func popoverBackground(fluentTheme: FluentTheme) -> UIColor { - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background4).light, - dark: fluentTheme.color(.background4).dark)) + return UIColor(light: fluentTheme.color(.background4).light, + dark: fluentTheme.color(.background4).dark) } private struct Constants { @@ -130,13 +130,13 @@ open class DrawerController: UIViewController { } private func drawerBackgroundColor(fluentTheme: FluentTheme) -> UIColor { - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, - dark: fluentTheme.color(.background2).dark)) + return UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) } private func popoverBackgroundColor(fluentTheme: FluentTheme) -> UIColor { - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background4).light, - dark: fluentTheme.color(.background4).dark)) + return UIColor(light: fluentTheme.color(.background4).light, + dark: fluentTheme.color(.background4).dark) } /** @@ -536,7 +536,7 @@ open class DrawerController: UIViewController { if presentationController is UIPopoverPresentationController { backgroundColor = popoverBackgroundColor(fluentTheme: view.fluentTheme) } else if useNavigationBarBackgroundColor { - backgroundColor = UIColor(dynamicColor: view.fluentTheme.color(.background3)) + backgroundColor = view.fluentTheme.color(.background3) } else { backgroundColor = drawerBackgroundColor(fluentTheme: view.fluentTheme) } diff --git a/ios/FluentUI/Extensions/UIColor+Extensions.swift b/ios/FluentUI/Extensions/UIColor+Extensions.swift index e05aa2d890..f2ddef89ed 100644 --- a/ios/FluentUI/Extensions/UIColor+Extensions.swift +++ b/ios/FluentUI/Extensions/UIColor+Extensions.swift @@ -59,6 +59,27 @@ extension UIColor { } } + /// Creates a dynamic color object that returns the appropriate light or dark color value based on the current + /// rendering context. + /// + /// Convenience wrapper for + ///`init(light:lightHighContrast:lightElevated:lightElevatedHighContrast:dark:darkHighContrast:darkElevated:darkElevatedHighContrast:)` + /// to simplify Objective-C consumption. + /// + /// - Parameter light: The default color for a light context. Required. + /// - Parameter dark: The override color for a dark context. Required. + @objc public convenience init(light: UIColor, + dark: UIColor) { + self.init(light: light, + lightHighContrast: nil, + lightElevated: nil, + lightElevatedHighContrast: nil, + dark: dark, + darkHighContrast: nil, + darkElevated: nil, + darkElevatedHighContrast: nil) + } + /// `DynamicColor` representation of the `UIColor` object. /// Requires the `UIColor` to be able to resolve its color values for at least the `.light` user interface style. public var dynamicColor: DynamicColor? { @@ -98,6 +119,24 @@ extension UIColor { alpha: colorValue.a) } + /// Creates a `UIColor` instance with the specified three-channel, 8-bit-per-channel color value, usually in hex. + /// + /// For example: `0xFF0000` represents red, `0x00FF00` green, and `0x0000FF` blue. There is no way to specify an + /// alpha channel via this initializer. For that, use `init(red:green:blue:alpha)` instead. + /// + /// - Parameter hexValue: The color value to store, in 24-bit (three-channel, 8-bit) RGB. + /// + /// - Returns: A color object that stores the provided color information. + @objc public convenience init(hexValue: UInt32) { + let red: CGFloat = CGFloat((hexValue & 0x00FF0000) >> 16) / 255.0 + let green: CGFloat = CGFloat((hexValue & 0x0000FF00) >> 8) / 255.0 + let blue: CGFloat = CGFloat(hexValue & 0x000000FF) / 255.0 + self.init(red: red, + green: green, + blue: blue, + alpha: 1.0) + } + /// Creates a dynamic color object that returns the appropriate color value based on the current /// rendering context. /// @@ -111,6 +150,70 @@ extension UIColor { } } + @objc public var light: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .light) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var lightHighContrast: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .light, + accessibilityContrast: .high) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var lightElevated: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .light, + userInterfaceLevel: .elevated) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var lightElevatedHighContrast: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .light, + accessibilityContrast: .high, + userInterfaceLevel: .elevated) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var dark: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .dark) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var darkHighContrast: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .dark, + accessibilityContrast: .high) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var darkElevated: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .dark, + userInterfaceLevel: .elevated) else { + return self + } + return UIColor(colorValue: color) + } + + @objc public var darkElevatedHighContrast: UIColor { + guard let color = resolvedColorValue(userInterfaceStyle: .dark, + accessibilityContrast: .high, + userInterfaceLevel: .elevated) else { + return self + } + return UIColor(colorValue: color) + } + private var colorValue: ColorValue? { var redValue: CGFloat = 1.0 var greenValue: CGFloat = 1.0 diff --git a/ios/FluentUI/HUD/HeadsUpDisplay.swift b/ios/FluentUI/HUD/HeadsUpDisplay.swift index cf94101050..2ce341b810 100644 --- a/ios/FluentUI/HUD/HeadsUpDisplay.swift +++ b/ios/FluentUI/HUD/HeadsUpDisplay.swift @@ -55,7 +55,7 @@ public struct HeadsUpDisplay: View, TokenizedControlView { case .activity: ActivityIndicator(size: .xLarge) .isAnimating(true) - .color(UIColor(dynamicColor: tokenSet[.activityIndicatorColor].dynamicColor)) + .color(tokenSet[.activityIndicatorColor].uiColor) case .custom, .failure, .success: let image: UIImage = { switch type { @@ -71,14 +71,14 @@ public struct HeadsUpDisplay: View, TokenizedControlView { }() Image(uiImage: image) - .foregroundColor(Color(dynamicColor: tokenSet[.activityIndicatorColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.activityIndicatorColor].uiColor)) } if !label.isEmpty { Spacer() .frame(height: verticalPadding) Text(label) - .foregroundColor(Color(dynamicColor: tokenSet[.labelColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.labelColor].uiColor)) .lineLimit(2) .multilineTextAlignment(.center) .fixedSize(horizontal: false, vertical: true) @@ -92,7 +92,7 @@ public struct HeadsUpDisplay: View, TokenizedControlView { .squareShaped(minSize: HeadsUpDisplayTokenSet.minSize, maxSize: HeadsUpDisplayTokenSet.maxSize) .background(Rectangle() - .fill(Color(dynamicColor: tokenSet[.backgroundColor].dynamicColor)) + .fill(Color(tokenSet[.backgroundColor].uiColor)) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) diff --git a/ios/FluentUI/HUD/HeadsUpDisplayTokenSet.swift b/ios/FluentUI/HUD/HeadsUpDisplayTokenSet.swift index b8326af195..15fa1249d9 100644 --- a/ios/FluentUI/HUD/HeadsUpDisplayTokenSet.swift +++ b/ios/FluentUI/HUD/HeadsUpDisplayTokenSet.swift @@ -26,7 +26,7 @@ public class HeadsUpDisplayTokenSet: ControlTokenSet 0 && labelFont.pointSize > maxFontSize { super.font = labelFont.withSize(maxFontSize) } else { @@ -142,7 +142,7 @@ open class Label: UILabel, TokenizedControlInternal { guard !isUsingCustomAttributedText else { return } - super.textColor = labelTextColor ?? UIColor(dynamicColor: tokenSet[.textColor].dynamicColor) + super.textColor = labelTextColor ?? tokenSet[.textColor].uiColor } @objc private func handleContentSizeCategoryDidChange() { diff --git a/ios/FluentUI/Label/LabelTokenSet.swift b/ios/FluentUI/Label/LabelTokenSet.swift index d9da78361d..1315411bec 100644 --- a/ios/FluentUI/Label/LabelTokenSet.swift +++ b/ios/FluentUI/Label/LabelTokenSet.swift @@ -29,18 +29,18 @@ public class LabelTokenSet: ControlTokenSet { super.init { [colorStyle] token, theme in switch token { case .font: - return .fontInfo { + return .uiFont { return theme.typography(textStyle()) } case .textColor: - return .dynamicColor { + return .uiColor { switch colorStyle() { case .regular: return theme.color(.foreground1) case .secondary: return theme.color(.foreground2) case .white: - return DynamicColor(light: GlobalTokens.neutralColors(.white)) + return theme.color(.foregroundLightStatic) case .primary: return theme.color(.brandForeground1) case .error: diff --git a/ios/FluentUI/Navigation/NavigationBar.swift b/ios/FluentUI/Navigation/NavigationBar.swift index 245318b951..162c5369da 100644 --- a/ios/FluentUI/Navigation/NavigationBar.swift +++ b/ios/FluentUI/Navigation/NavigationBar.swift @@ -65,28 +65,31 @@ open class NavigationBar: UINavigationBar, TokenizedControlInternal { func tintColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .primary, .default, .custom: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground2).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground2).dark) case .system: - return UIColor(dynamicColor: fluentTheme.color(.foreground2)) + return fluentTheme.color(.foreground2) } } func titleColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .primary, .default, .custom: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground1).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) case .system: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) } } public func backgroundColor(fluentTheme: FluentTheme, customColor: UIColor? = nil) -> UIColor { - let defaultColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandBackground1).light, dark: fluentTheme.color(.background3).dark)) + let defaultColor = UIColor(light: fluentTheme.color(.brandBackground1).light, + dark: fluentTheme.color(.background3).dark) switch self { case .primary, .default: return defaultColor case .system: - return UIColor(dynamicColor: fluentTheme.color(.background3)) + return fluentTheme.color(.background3) case .custom: return customColor ?? defaultColor } diff --git a/ios/FluentUI/Navigation/SearchBar.swift b/ios/FluentUI/Navigation/SearchBar.swift index 5a15db11c5..ff8cb9bf37 100644 --- a/ios/FluentUI/Navigation/SearchBar.swift +++ b/ios/FluentUI/Navigation/SearchBar.swift @@ -30,46 +30,52 @@ open class SearchBar: UIView, TokenizedControlInternal { func backgroundColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.background5)) + return fluentTheme.color(.background5) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandBackground2).light, dark: fluentTheme.color(.background5).dark)) + return UIColor(light: fluentTheme.color(.brandBackground2).light, + dark: fluentTheme.color(.background5).dark) } } func cancelButtonColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground1).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) } } func clearIconColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground2)) + return fluentTheme.color(.foreground2) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground2).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground2).dark) } } func placeholderColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground3)) + return fluentTheme.color(.foreground3) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground3).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground3).dark) } } func searchIconColor(fluentTheme: FluentTheme, isSearching: Bool = false) -> UIColor { - let searchBrandColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground1).dark)) - let idleBrandColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground3).dark)) + let searchBrandColor = UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) + let idleBrandColor = UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground3).dark) switch self { case .darkContent: - return isSearching ? UIColor(dynamicColor: fluentTheme.color(.foreground1)) : UIColor(dynamicColor: fluentTheme.color(.foreground3)) + return isSearching ? fluentTheme.color(.foreground1) : fluentTheme.color(.foreground3) case .lightContent: return isSearching ? searchBrandColor : idleBrandColor } @@ -78,27 +84,30 @@ open class SearchBar: UIView, TokenizedControlInternal { func textColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground1).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) } } func tintColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground3)) + return fluentTheme.color(.foreground3) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground3).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground3).dark) } } func progressSpinnerColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .darkContent: - return UIColor(dynamicColor: fluentTheme.color(.foreground3)) + return fluentTheme.color(.foreground3) case .lightContent: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, dark: fluentTheme.color(.foreground3).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground3).dark) } } } @@ -187,7 +196,7 @@ open class SearchBar: UIView, TokenizedControlInternal { // user interaction point private lazy var searchTextField: SearchBarTextField = { let textField = SearchBarTextField() - textField.font = UIFont.fluent(tokenSet.fluentTheme.typography(.body1)).withSize(Constants.fontSize) + textField.font = tokenSet.fluentTheme.typography(.body1).withSize(Constants.fontSize) textField.delegate = self textField.returnKeyType = .search textField.enablesReturnKeyAutomatically = true @@ -231,7 +240,7 @@ open class SearchBar: UIView, TokenizedControlInternal { // hidden when the textfield is not active private lazy var cancelButton: UIButton = { let button = UIButton(type: .system) - button.titleLabel?.font = UIFont.fluent(tokenSet.fluentTheme.typography(.body1)) + button.titleLabel?.font = tokenSet.fluentTheme.typography(.body1) button.setTitle("Common.Cancel".localized, for: .normal) button.addTarget(self, action: #selector(SearchBar.cancelButtonTapped(sender:)), for: .touchUpInside) button.alpha = 0.0 diff --git a/ios/FluentUI/Navigation/Views/LargeTitleView.swift b/ios/FluentUI/Navigation/Views/LargeTitleView.swift index 1384d256ad..6b4f62b341 100644 --- a/ios/FluentUI/Navigation/Views/LargeTitleView.swift +++ b/ios/FluentUI/Navigation/Views/LargeTitleView.swift @@ -92,7 +92,7 @@ class LargeTitleView: UIView { case .contracted: titleButton.titleLabel?.font = Constants.compactTitleFont case .expanded: - titleButton.titleLabel?.font = UIFont.fluent(fluentTheme.typography(.title1)) + titleButton.titleLabel?.font = fluentTheme.typography(.title1) } } } @@ -115,10 +115,10 @@ class LargeTitleView: UIView { private var colorForStyle: UIColor { switch style { case .primary: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground1).dark)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) case .system: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) } } @@ -212,7 +212,7 @@ class LargeTitleView: UIView { // title button setup contentStackView.addArrangedSubview(titleButton) titleButton.setTitle(nil, for: .normal) - titleButton.titleLabel?.font = UIFont.fluent(fluentTheme.typography(.title1)) + titleButton.titleLabel?.font = fluentTheme.typography(.title1) titleButton.setTitleColor(colorForStyle, for: .normal) titleButton.titleLabel?.textAlignment = .left titleButton.contentHorizontalAlignment = .left @@ -232,7 +232,7 @@ class LargeTitleView: UIView { private func expansionAnimation() { if titleSize == .automatic { - titleButton.titleLabel?.font = UIFont.fluent(fluentTheme.typography(.title1)) + titleButton.titleLabel?.font = fluentTheme.typography(.title1) } if avatarSize == .automatic { diff --git a/ios/FluentUI/Notification/FluentNotification.swift b/ios/FluentUI/Notification/FluentNotification.swift index ded375639c..36cc2c1986 100644 --- a/ios/FluentUI/Notification/FluentNotification.swift +++ b/ios/FluentUI/Notification/FluentNotification.swift @@ -136,7 +136,7 @@ public struct FluentNotification: View, TokenizedControlView { .frame(width: imageSize.width, height: imageSize.height, alignment: .center) - .foregroundColor(Color(dynamicColor: tokenSet[.imageColor].dynamicColor)) + .foregroundColor(Color(tokenSet[.imageColor].uiColor)) } } } @@ -153,8 +153,8 @@ public struct FluentNotification: View, TokenizedControlView { .accessibilityLabel(attributedTitle.string) } else if let title = state.title { Text(title) - .font(.fluent(tokenSet[.boldTextFont].fontInfo)) - .foregroundColor(Color(dynamicColor: tokenSet[.foregroundColor].dynamicColor)) + .font(.init(tokenSet[.boldTextFont].uiFont)) + .foregroundColor(Color(tokenSet[.foregroundColor].uiColor)) } } } @@ -170,8 +170,8 @@ public struct FluentNotification: View, TokenizedControlView { .accessibilityLabel(attributedMessage.string) } else if let message = state.message { Text(message) - .font(.fluent(tokenSet[.regularTextFont].fontInfo)) - .foregroundColor(Color(dynamicColor: tokenSet[.foregroundColor].dynamicColor)) + .font(.init(tokenSet[.regularTextFont].uiFont)) + .foregroundColor(Color(tokenSet[.foregroundColor].uiColor)) } } @@ -190,15 +190,15 @@ public struct FluentNotification: View, TokenizedControlView { var button: some View { let shouldHaveDefaultAction = state.showDefaultDismissActionButton && shouldSelfPresent if let buttonAction = state.actionButtonAction ?? (shouldHaveDefaultAction ? dismissAnimated : nil) { - let foregroundColor = tokenSet[.foregroundColor].dynamicColor + let foregroundColor = tokenSet[.foregroundColor].uiColor if let actionTitle = state.actionButtonTitle, !actionTitle.isEmpty { SwiftUI.Button(actionTitle) { isPresented = false buttonAction() } .lineLimit(1) - .foregroundColor(Color(dynamicColor: foregroundColor)) - .font(.fluent(tokenSet[.boldTextFont].fontInfo)) + .foregroundColor(Color(foregroundColor)) + .font(.init(tokenSet[.boldTextFont].uiFont)) .hoverEffect() } else { SwiftUI.Button(action: { @@ -213,7 +213,7 @@ public struct FluentNotification: View, TokenizedControlView { .accessibilityLabel("Accessibility.Dismiss.Label".localized) } }) - .foregroundColor(Color(dynamicColor: foregroundColor)) + .foregroundColor(Color(foregroundColor)) .hoverEffect() } } @@ -267,7 +267,7 @@ public struct FluentNotification: View, TokenizedControlView { .scaleEffect(x: 1.0, y: g.size.height / g.size.width, anchor: .top) } } else { - Color(dynamicColor: tokenSet[.backgroundColor].dynamicColor) + Color(tokenSet[.backgroundColor].uiColor) } } @@ -279,7 +279,7 @@ public struct FluentNotification: View, TokenizedControlView { RoundedRectangle(cornerRadius: tokenSet[.cornerRadius].float) .border(width: tokenSet[.outlineWidth].float, edges: state.showFromBottom ? [.top] : [.bottom], - color: Color(dynamicColor: tokenSet[.outlineColor].dynamicColor)).foregroundColor(.clear) + color: Color(tokenSet[.outlineColor].uiColor)).foregroundColor(.clear) .background( backgroundFill .clipShape(RoundedRectangle(cornerRadius: tokenSet[.cornerRadius].float)) diff --git a/ios/FluentUI/Notification/NotificationTokenSet.swift b/ios/FluentUI/Notification/NotificationTokenSet.swift index 380a910e77..bdeace0f6b 100644 --- a/ios/FluentUI/Notification/NotificationTokenSet.swift +++ b/ios/FluentUI/Notification/NotificationTokenSet.swift @@ -108,7 +108,7 @@ public class NotificationTokenSet: ControlTokenSet super.init { [style] token, theme in switch token { case .backgroundColor: - return .dynamicColor { + return .uiColor { switch style() { case .primaryToast, .primaryBar: @@ -127,7 +127,7 @@ public class NotificationTokenSet: ControlTokenSet } case .foregroundColor: - return .dynamicColor { + return .uiColor { switch style() { case .primaryToast, .primaryBar: @@ -145,7 +145,7 @@ public class NotificationTokenSet: ControlTokenSet } case .imageColor: - return .dynamicColor { + return .uiColor { switch style() { case .primaryToast, .primaryBar: @@ -192,10 +192,10 @@ public class NotificationTokenSet: ControlTokenSet return .float { 52.0 } case .outlineColor: - return .dynamicColor { + return .uiColor { switch style() { case .primaryToast, .neutralToast, .primaryBar, .neutralBar, .dangerToast, .warningToast: - return DynamicColor(light: ColorValue.clear) + return .clear case .primaryOutlineBar: return theme.color(.stroke2) } @@ -214,10 +214,10 @@ public class NotificationTokenSet: ControlTokenSet } case .boldTextFont: - return .fontInfo { theme.typography(.body2Strong) } + return .uiFont { theme.typography(.body2Strong) } case .regularTextFont: - return .fontInfo { theme.typography(.body2) } + return .uiFont { theme.typography(.body2) } } } } diff --git a/ios/FluentUI/Other Cells/ActionsCell.swift b/ios/FluentUI/Other Cells/ActionsCell.swift index f745bdb00d..8b1f96982a 100644 --- a/ios/FluentUI/Other Cells/ActionsCell.swift +++ b/ios/FluentUI/Other Cells/ActionsCell.swift @@ -25,22 +25,22 @@ open class ActionsCell: UITableViewCell, TokenizedControlInternal { func highlightedTextColor(tokenSet: TableViewCellTokenSet) -> UIColor { switch self { case .regular: - return UIColor(dynamicColor: tokenSet[.brandTextColor].dynamicColor).withAlphaComponent(0.4) + return tokenSet[.brandTextColor].uiColor.withAlphaComponent(0.4) case .destructive: - return UIColor(dynamicColor: tokenSet[.dangerTextColor].dynamicColor).withAlphaComponent(0.4) + return tokenSet[.dangerTextColor].uiColor.withAlphaComponent(0.4) case .communication: - return UIColor(dynamicColor: tokenSet[.communicationTextColor].dynamicColor).withAlphaComponent(0.4) + return tokenSet[.communicationTextColor].uiColor.withAlphaComponent(0.4) } } func textColor(tokenSet: TableViewCellTokenSet) -> UIColor { switch self { case .regular: - return UIColor(dynamicColor: tokenSet[.brandTextColor].dynamicColor) + return tokenSet[.brandTextColor].uiColor case .destructive: - return UIColor(dynamicColor: tokenSet[.dangerTextColor].dynamicColor) + return tokenSet[.dangerTextColor].uiColor case .communication: - return UIColor(dynamicColor: tokenSet[.communicationTextColor].dynamicColor) + return tokenSet[.communicationTextColor].uiColor } } } @@ -59,7 +59,7 @@ open class ActionsCell: UITableViewCell, TokenizedControlInternal { let actionCount: CGFloat = action2Title == "" ? 1 : 2 let width = ceil(containerWidth / actionCount) - let actionTitleFont = UIFont.fluent(tokenSet[.titleFont].fontInfo) + let actionTitleFont = tokenSet[.titleFont].uiFont let action1TitleHeight = action1Title.preferredSize(for: actionTitleFont, width: width).height let action2TitleHeight = action2Title.preferredSize(for: actionTitleFont, width: width).height @@ -68,7 +68,7 @@ open class ActionsCell: UITableViewCell, TokenizedControlInternal { } public class func preferredWidth(action1Title: String, action2Title: String = "", tokenSet: TableViewCellTokenSet) -> CGFloat { - let actionTitleFont = UIFont.fluent(tokenSet[.titleFont].fontInfo) + let actionTitleFont = tokenSet[.titleFont].uiFont let action1TitleWidth = action1Title.preferredSize(for: actionTitleFont).width let action2TitleWidth = action2Title.preferredSize(for: actionTitleFont).width @@ -231,7 +231,7 @@ open class ActionsCell: UITableViewCell, TokenizedControlInternal { open override func setSelected(_ selected: Bool, animated: Bool) { } private func setupAction(_ button: UIButton) { - button.titleLabel?.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) + button.titleLabel?.font = tokenSet[.titleFont].uiFont button.titleLabel?.numberOfLines = 0 button.titleLabel?.textAlignment = .center } diff --git a/ios/FluentUI/Other Cells/BooleanCell.swift b/ios/FluentUI/Other Cells/BooleanCell.swift index f548a16394..b084799f53 100644 --- a/ios/FluentUI/Other Cells/BooleanCell.swift +++ b/ios/FluentUI/Other Cells/BooleanCell.swift @@ -89,7 +89,7 @@ open class BooleanCell: TableViewCell { override func updateAppearance() { super.updateAppearance() - `switch`.onTintColor = UIColor(dynamicColor: tokenSet[.booleanCellBrandColor].dynamicColor) + `switch`.onTintColor = tokenSet[.booleanCellBrandColor].uiColor } private func updateAccessibility() { diff --git a/ios/FluentUI/Other Cells/CenteredLabelCell.swift b/ios/FluentUI/Other Cells/CenteredLabelCell.swift index 3be48a1c1a..1ae7cf6ce4 100644 --- a/ios/FluentUI/Other Cells/CenteredLabelCell.swift +++ b/ios/FluentUI/Other Cells/CenteredLabelCell.swift @@ -16,8 +16,8 @@ open class CenteredLabelCell: UITableViewCell, TokenizedControlInternal { private func updateAppearance() { setupBackgroundColors() - label.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) - label.textColor = UIColor(dynamicColor: tokenSet[.brandTextColor].dynamicColor) + label.font = tokenSet[.titleFont].uiFont + label.textColor = tokenSet[.brandTextColor].uiColor } // Public to be able to change style without wrapping every property @@ -58,8 +58,8 @@ open class CenteredLabelCell: UITableViewCell, TokenizedControlInternal { /// - Parameter text: The text to be displayed @objc open func setup(text: String) { label.text = text - label.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) - label.textColor = UIColor(dynamicColor: tokenSet[.brandTextColor].dynamicColor) + label.font = tokenSet[.titleFont].uiFont + label.textColor = tokenSet[.brandTextColor].uiColor setNeedsLayout() } diff --git a/ios/FluentUI/Other Cells/TableViewCellFileAccessoryView.swift b/ios/FluentUI/Other Cells/TableViewCellFileAccessoryView.swift index 583c0f9f7f..feb9ad5acd 100644 --- a/ios/FluentUI/Other Cells/TableViewCellFileAccessoryView.swift +++ b/ios/FluentUI/Other Cells/TableViewCellFileAccessoryView.swift @@ -239,7 +239,7 @@ open class TableViewCellFileAccessoryView: UIView { private func updateSharedStatus() { let imageName = isShared ? "ic_fluent_people_24_regular" : "ic_fluent_person_24_regular" - let imageColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + let imageColor = fluentTheme.color(.foreground2) sharedStatusImageView.image = UIImage.staticImageNamed(imageName)?.withTintColor(imageColor, renderingMode: .alwaysOriginal) sharedStatusLabel.text = isShared ? "Common.Shared".localized : "Common.OnlyMe".localized } @@ -535,11 +535,11 @@ private class FileAccessoryViewActionView: UIButton { private func updateActionColor() { if action.useAppPrimaryColor { - tintColor = UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + tintColor = fluentTheme.color(.brandForeground1) } else if action.isEnabled { - tintColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + tintColor = fluentTheme.color(.foreground2) } else { - tintColor = UIColor(dynamicColor: fluentTheme.color(.foregroundDisabled1)) + tintColor = fluentTheme.color(.foregroundDisabled1) } } diff --git a/ios/FluentUI/People Picker/PeoplePicker.swift b/ios/FluentUI/People Picker/PeoplePicker.swift index b59a7c41cf..a505f2aa44 100644 --- a/ios/FluentUI/People Picker/PeoplePicker.swift +++ b/ios/FluentUI/People Picker/PeoplePicker.swift @@ -164,8 +164,8 @@ open class PeoplePicker: BadgeField { self.pickPersona(persona: persona) } personaListView.searchDirectoryDelegate = self - personaListView.backgroundColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background2).light, - dark: fluentTheme.color(.background2).dark)) + personaListView.backgroundColor = UIColor(light: fluentTheme.color(.background2).light, + dark: fluentTheme.color(.background2).dark) NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil) diff --git a/ios/FluentUI/People Picker/PersonaListView.swift b/ios/FluentUI/People Picker/PersonaListView.swift index 4bb82496d0..87dbcaf02a 100644 --- a/ios/FluentUI/People Picker/PersonaListView.swift +++ b/ios/FluentUI/People Picker/PersonaListView.swift @@ -107,7 +107,7 @@ open class PersonaListView: UITableView { } private func updateBackgroundColor() { - backgroundColor = UIColor(dynamicColor: fluentTheme.color(.background1)) + backgroundColor = fluentTheme.color(.background1) } @objc public required init(coder aDecoder: NSCoder) { diff --git a/ios/FluentUI/PersonaButton/PersonaButton.swift b/ios/FluentUI/PersonaButton/PersonaButton.swift index f0e302914e..377c06f9b0 100644 --- a/ios/FluentUI/PersonaButton/PersonaButton.swift +++ b/ios/FluentUI/PersonaButton/PersonaButton.swift @@ -77,7 +77,7 @@ public struct PersonaButton: View, TokenizedControlView { } } .frame(minWidth: adjustedWidth, maxWidth: adjustedWidth, minHeight: 0, maxHeight: .infinity) - .background(Color(dynamicColor: tokenSet[.backgroundColor].dynamicColor)) + .background(Color(tokenSet[.backgroundColor].uiColor)) .fluentTokens(tokenSet, fluentTheme) } @@ -97,14 +97,14 @@ public struct PersonaButton: View, TokenizedControlView { Text(state.primaryText ?? "") .lineLimit(1) .frame(alignment: .center) - .font(.fluent(tokenSet[.labelFont].fontInfo)) - .foregroundColor(Color(dynamicColor: tokenSet[.labelColor].dynamicColor)) + .font(.init(tokenSet[.labelFont].uiFont)) + .foregroundColor(Color(tokenSet[.labelColor].uiColor)) if state.buttonSize.shouldShowSubtitle { Text(state.secondaryText ?? "") .lineLimit(1) .frame(alignment: .center) - .font(.fluent(tokenSet[.sublabelFont].fontInfo)) - .foregroundColor(Color(dynamicColor: tokenSet[.sublabelColor].dynamicColor)) + .font(.init(tokenSet[.sublabelFont].uiFont)) + .foregroundColor(Color(tokenSet[.sublabelColor].uiColor)) } } .padding(.horizontal, PersonaButtonTokenSet.horizontalTextPadding) diff --git a/ios/FluentUI/PersonaButton/PersonaButtonTokenSet.swift b/ios/FluentUI/PersonaButton/PersonaButtonTokenSet.swift index 3c2e40e5a1..853b3387e5 100644 --- a/ios/FluentUI/PersonaButton/PersonaButtonTokenSet.swift +++ b/ios/FluentUI/PersonaButton/PersonaButtonTokenSet.swift @@ -53,13 +53,13 @@ public class PersonaButtonTokenSet: ControlTokenSet UIColor { switch style { case .primary: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background5).light, - dark: fluentTheme.color(.background3).dark, - darkElevated: fluentTheme.color(.background5).darkElevated)) + return UIColor(light: fluentTheme.color(.background5).light, + dark: fluentTheme.color(.background3).dark, + darkElevated: fluentTheme.color(.background5).darkElevated) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandBackground2).light, - dark: fluentTheme.color(.background3).dark, - darkElevated: fluentTheme.color(.background5).darkElevated)) + return UIColor(light: fluentTheme.color(.brandBackground2).light, + dark: fluentTheme.color(.background3).dark, + darkElevated: fluentTheme.color(.background5).darkElevated) } } static func titleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foreground2)) + return fluentTheme.color(.foreground2) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground2).dark, - darkElevated: fluentTheme.color(.foreground2).darkElevated)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground2).dark, + darkElevated: fluentTheme.color(.foreground2).darkElevated) } } - static func titleFont(for fluentTheme: FluentTheme) -> FontInfo { - return fluentTheme.typography(.body2) + static func titleFont(for fluentTheme: FluentTheme) -> UIFont { + return fluentTheme.typography(.body2, adjustsForContentSizeCategory: false) } // MARK: selected state @@ -57,23 +57,23 @@ public extension PillButton { static func selectedBackgroundColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.brandBackground1)) + return fluentTheme.color(.brandBackground1) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background1).light, - dark: fluentTheme.color(.background3Selected).dark, - darkElevated: fluentTheme.color(.background5Selected).darkElevated)) + return UIColor(light: fluentTheme.color(.background1).light, + dark: fluentTheme.color(.background3Selected).dark, + darkElevated: fluentTheme.color(.background5Selected).darkElevated) } } static func selectedTitleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foregroundOnColor)) + return fluentTheme.color(.foregroundOnColor) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandForeground1).light, - dark: fluentTheme.color(.foreground1).dark, - darkElevated: fluentTheme.color(.foreground1).darkElevated)) + return UIColor(light: fluentTheme.color(.brandForeground1).light, + dark: fluentTheme.color(.foreground1).dark, + darkElevated: fluentTheme.color(.foreground1).darkElevated) } } @@ -86,11 +86,11 @@ public extension PillButton { static func disabledTitleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foregroundDisabled1)) + return fluentTheme.color(.foregroundDisabled1) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandForegroundDisabled1).light, - dark: fluentTheme.color(.foregroundDisabled1).dark, - darkElevated: fluentTheme.color(.foregroundDisabled1).darkElevated)) + return UIColor(light: fluentTheme.color(.brandForegroundDisabled1).light, + dark: fluentTheme.color(.foregroundDisabled1).dark, + darkElevated: fluentTheme.color(.foregroundDisabled1).darkElevated) } } @@ -98,23 +98,23 @@ public extension PillButton { static func selectedDisabledBackgroundColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.brandBackground1)) + return fluentTheme.color(.brandBackground1) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background1).light, - dark: fluentTheme.color(.background3Selected).dark, - darkElevated: fluentTheme.color(.background5Selected).darkElevated)) + return UIColor(light: fluentTheme.color(.background1).light, + dark: fluentTheme.color(.background3Selected).dark, + darkElevated: fluentTheme.color(.background5Selected).darkElevated) } } static func selectedDisabledTitleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.brandForegroundDisabled1)) + return fluentTheme.color(.brandForegroundDisabled1) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandForegroundDisabled2).light, - dark: fluentTheme.color(.foregroundDisabled2).dark, - darkElevated: fluentTheme.color(.foregroundDisabled2).darkElevated)) + return UIColor(light: fluentTheme.color(.brandForegroundDisabled2).light, + dark: fluentTheme.color(.foregroundDisabled2).dark, + darkElevated: fluentTheme.color(.foregroundDisabled2).darkElevated) } } @@ -123,24 +123,24 @@ public extension PillButton { static func highlightedBackgroundColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background5Pressed).light, - dark: fluentTheme.color(.background3Pressed).dark, - darkElevated: fluentTheme.color(.background5Pressed).darkElevated)) + return UIColor(light: fluentTheme.color(.background5Pressed).light, + dark: fluentTheme.color(.background3Pressed).dark, + darkElevated: fluentTheme.color(.background5Pressed).darkElevated) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandBackground2Pressed).light, - dark: fluentTheme.color(.background3Pressed).dark, - darkElevated: fluentTheme.color(.background5Pressed).darkElevated)) + return UIColor(light: fluentTheme.color(.brandBackground2Pressed).light, + dark: fluentTheme.color(.background3Pressed).dark, + darkElevated: fluentTheme.color(.background5Pressed).darkElevated) } } static func highlightedTitleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground1).dark, - darkElevated: fluentTheme.color(.foreground1).darkElevated)) + return UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark, + darkElevated: fluentTheme.color(.foreground1).darkElevated) } } @@ -149,22 +149,22 @@ public extension PillButton { static func selectedHighlightedBackgroundColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.brandBackground1Pressed)) + return fluentTheme.color(.brandBackground1Pressed) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.background1).light, - dark: fluentTheme.color(.background3Pressed).dark, - darkElevated: fluentTheme.color(.background3Pressed).darkElevated)) + return UIColor(light: fluentTheme.color(.background1).light, + dark: fluentTheme.color(.background3Pressed).dark, + darkElevated: fluentTheme.color(.background3Pressed).darkElevated) } } static func selectedHighlightedTitleColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foregroundOnColor)) + return fluentTheme.color(.foregroundOnColor) case .onBrand: - return UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.brandForeground1Pressed).light, - dark: fluentTheme.color(.foreground1).dark, - darkElevated: fluentTheme.color(.foreground1).darkElevated)) + return UIColor(light: fluentTheme.color(.brandForeground1Pressed).light, + dark: fluentTheme.color(.foreground1).dark, + darkElevated: fluentTheme.color(.foreground1).darkElevated) } } @@ -173,21 +173,21 @@ public extension PillButton { static func enabledUnreadDotColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(light: UIColor(dynamicColor: fluentTheme.color(.brandForeground1)), - dark: UIColor(dynamicColor: fluentTheme.color(.foreground2))) + return UIColor(light: fluentTheme.color(.brandForeground1), + dark: fluentTheme.color(.foreground2)) case .onBrand: - return UIColor(light: UIColor(dynamicColor: fluentTheme.color(.foregroundOnColor)), - dark: UIColor(dynamicColor: fluentTheme.color(.foreground1))) + return UIColor(light: fluentTheme.color(.foregroundOnColor), + dark: fluentTheme.color(.foreground1)) } } static func disabledUnreadDotColor(for fluentTheme: FluentTheme, for style: PillButtonStyle) -> UIColor { switch style { case .primary: - return UIColor(dynamicColor: fluentTheme.color(.foregroundDisabled1)) + return fluentTheme.color(.foregroundDisabled1) case .onBrand: - return UIColor(light: UIColor(dynamicColor: fluentTheme.color(.brandForegroundDisabled1)), - dark: UIColor(dynamicColor: fluentTheme.color(.foregroundDisabled1))) + return UIColor(light: fluentTheme.color(.brandForegroundDisabled1), + dark: fluentTheme.color(.foregroundDisabled1)) } } } diff --git a/ios/FluentUI/Popup Menu/PopupMenuController.swift b/ios/FluentUI/Popup Menu/PopupMenuController.swift index 82e385e15d..a81d6ccab5 100644 --- a/ios/FluentUI/Popup Menu/PopupMenuController.swift +++ b/ios/FluentUI/Popup Menu/PopupMenuController.swift @@ -117,7 +117,7 @@ open class PopupMenuController: DrawerController { } /// set `separatorColor` to customize separator colors of PopupMenuItem cells and the drawer - @objc open var separatorColor: UIColor = { return UIColor(dynamicColor: FluentTheme.shared.color(.stroke2)) }() { + @objc open var separatorColor: UIColor = { return FluentTheme.shared.color(.stroke2) }() { didSet { guard let separator = separator else { return @@ -224,7 +224,7 @@ open class PopupMenuController: DrawerController { } private func updateDescriptionLabelColor() { - descriptionLabel.textColor = UIColor(dynamicColor: tableView.fluentTheme.color(.foreground2)) + descriptionLabel.textColor = tableView.fluentTheme.color(.foreground2) } @objc override func themeDidChange(_ notification: Notification) { diff --git a/ios/FluentUI/Popup Menu/PopupMenuItem.swift b/ios/FluentUI/Popup Menu/PopupMenuItem.swift index ab5abbb5e8..421c86544c 100644 --- a/ios/FluentUI/Popup Menu/PopupMenuItem.swift +++ b/ios/FluentUI/Popup Menu/PopupMenuItem.swift @@ -28,19 +28,19 @@ open class PopupMenuItem: NSObject, PopupMenuTemplateItem, FluentThemeable { /// `title` color @objc public var titleColor: UIColor { - get { return customTitleColor ?? UIColor(dynamicColor: fluentTheme.color(.foreground1)) } + get { return customTitleColor ?? fluentTheme.color(.foreground1) } set { customTitleColor = newValue } } var customTitleColor: UIColor? /// `subtitle` color @objc public var subtitleColor: UIColor { - get { return customSubtitleColor ?? UIColor(dynamicColor: fluentTheme.color(.foreground2)) } + get { return customSubtitleColor ?? fluentTheme.color(.foreground2) } set { customSubtitleColor = newValue } } var customSubtitleColor: UIColor? /// `image` tint color if it is rendered as template @objc public var imageColor: UIColor { - get { return customImageColor ?? UIColor(dynamicColor: fluentTheme.color(.foreground2)) } + get { return customImageColor ?? fluentTheme.color(.foreground2) } set { customImageColor = newValue } } var customImageColor: UIColor? diff --git a/ios/FluentUI/Popup Menu/PopupMenuItemCell.swift b/ios/FluentUI/Popup Menu/PopupMenuItemCell.swift index 4ee0cd3c5b..6cff44500d 100644 --- a/ios/FluentUI/Popup Menu/PopupMenuItemCell.swift +++ b/ios/FluentUI/Popup Menu/PopupMenuItemCell.swift @@ -193,24 +193,24 @@ class PopupMenuItemCell: TableViewCell, PopupMenuItemTemplateCell { } private func updateColors() { - accessoryImageView.tintColor = UIColor(dynamicColor: fluentTheme.color(.foreground3)) + accessoryImageView.tintColor = fluentTheme.color(.foreground3) if let item = item { _imageView.tintColor = isSelected - ? item.imageSelectedColor ?? UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + ? item.imageSelectedColor ?? fluentTheme.color(.brandForeground1) : item.imageColor titleLabel.textColor = isSelected - ? item.titleSelectedColor ?? UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + ? item.titleSelectedColor ?? fluentTheme.color(.brandForeground1) : item.titleColor subtitleLabel.textColor = isSelected - ? item.subtitleSelectedColor ?? UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + ? item.subtitleSelectedColor ?? fluentTheme.color(.brandForeground1) : item.subtitleColor backgroundColor = item.backgroundColor } if isSelected && item?.isAccessoryCheckmarkVisible == true { _accessoryType = .checkmark - accessoryTypeView?.customTintColor = item?.accessoryCheckmarkColor ?? UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + accessoryTypeView?.customTintColor = item?.accessoryCheckmarkColor ?? fluentTheme.color(.brandForeground1) } else { _accessoryType = .none } diff --git a/ios/FluentUI/ResizingHandleView/ResizingHandleView.swift b/ios/FluentUI/ResizingHandleView/ResizingHandleView.swift index 7209d9d350..d4a10ae626 100644 --- a/ios/FluentUI/ResizingHandleView/ResizingHandleView.swift +++ b/ios/FluentUI/ResizingHandleView/ResizingHandleView.swift @@ -48,7 +48,7 @@ open class ResizingHandleView: UIView { } private func updateMarkLayerBackgroundColor() { - markLayer.backgroundColor = UIColor(dynamicColor: fluentTheme.color(.strokeAccessible)).cgColor + markLayer.backgroundColor = fluentTheme.color(.strokeAccessible).cgColor } public required init?(coder aDecoder: NSCoder) { diff --git a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift index 298116dab1..6b740fb593 100644 --- a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift +++ b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift @@ -31,7 +31,7 @@ class SegmentPillButton: UIButton { let tokenSet: SegmentedControlTokenSet func updateTokenizedValues() { - titleLabel?.font = UIFont.fluent(tokenSet[.font].fontInfo, shouldScale: false) + titleLabel?.font = tokenSet[.font].uiFont let verticalInset = tokenSet[.verticalInset].float let horizontalInset = tokenSet[.horizontalInset].float if #available(iOS 15.0, *) { @@ -41,10 +41,10 @@ class SegmentPillButton: UIButton { bottom: verticalInset, trailing: horizontalInset) configuration.background.backgroundColor = .clear - configuration.baseForegroundColor = UIColor(dynamicColor: tokenSet[.restLabelColor].dynamicColor) + configuration.baseForegroundColor = tokenSet[.restLabelColor].uiColor let titleTransformer = UIConfigurationTextAttributesTransformer { incoming in var outgoing = incoming - outgoing.font = UIFont.fluent(self.tokenSet[.font].fontInfo, shouldScale: false) + outgoing.font = self.tokenSet[.font].uiFont return outgoing } configuration.titleTextAttributesTransformer = titleTransformer @@ -131,8 +131,8 @@ class SegmentPillButton: UIButton { xPos = anchor.minX - tokenSet[.unreadDotOffsetX].float - tokenSet[.unreadDotSize].float } unreadDotLayer.frame.origin = CGPoint(x: xPos, y: anchor.minY + tokenSet[.unreadDotOffsetY].float) - let unreadDotColor = isEnabled ? tokenSet[.enabledUnreadDotColor].dynamicColor : tokenSet[.disabledUnreadDotColor].dynamicColor - unreadDotLayer.backgroundColor = UIColor(dynamicColor: unreadDotColor).cgColor + let unreadDotColor = isEnabled ? tokenSet[.enabledUnreadDotColor].uiColor : tokenSet[.disabledUnreadDotColor].uiColor + unreadDotLayer.backgroundColor = unreadDotColor.cgColor } } } diff --git a/ios/FluentUI/SegmentedControl/SegmentedControl.swift b/ios/FluentUI/SegmentedControl/SegmentedControl.swift index daf9cead3a..aabf0d93c2 100644 --- a/ios/FluentUI/SegmentedControl/SegmentedControl.swift +++ b/ios/FluentUI/SegmentedControl/SegmentedControl.swift @@ -222,20 +222,20 @@ open class SegmentedControl: UIView, TokenizedControlInternal { } public func updateColors() { - let tabColor: DynamicColor - let selectedTabColor: DynamicColor + let tabColor: UIColor + let selectedTabColor: UIColor let selectedContentColor: UIColor if isEnabled { - tabColor = tokenSet[.restTabColor].dynamicColor - selectedTabColor = tokenSet[.selectedTabColor].dynamicColor - selectedContentColor = UIColor(dynamicColor: tokenSet[.selectedLabelColor].dynamicColor) + tabColor = tokenSet[.restTabColor].uiColor + selectedTabColor = tokenSet[.selectedTabColor].uiColor + selectedContentColor = tokenSet[.selectedLabelColor].uiColor } else { - tabColor = tokenSet[.disabledTabColor].dynamicColor - selectedTabColor = tokenSet[.disabledSelectedTabColor].dynamicColor - selectedContentColor = UIColor(dynamicColor: tokenSet[.disabledSelectedLabelColor].dynamicColor) + tabColor = tokenSet[.disabledTabColor].uiColor + selectedTabColor = tokenSet[.disabledSelectedTabColor].uiColor + selectedContentColor = tokenSet[.disabledSelectedLabelColor].uiColor } - stackView.backgroundColor = UIColor(dynamicColor: tabColor) - pillMaskedContentContainerView.backgroundColor = UIColor(dynamicColor: selectedTabColor) + stackView.backgroundColor = tabColor + pillMaskedContentContainerView.backgroundColor = selectedTabColor for maskedLabel in pillMaskedLabels { guard let maskedLabel = maskedLabel else { continue @@ -442,7 +442,7 @@ open class SegmentedControl: UIView, TokenizedControlInternal { private let selectionChangeAnimationDuration: TimeInterval = 0.2 private func updateButtons() { - let contentColor = isEnabled ? UIColor(dynamicColor: tokenSet[.restLabelColor].dynamicColor) : UIColor(dynamicColor: tokenSet[.disabledLabelColor].dynamicColor) + let contentColor = isEnabled ? tokenSet[.restLabelColor].uiColor : tokenSet[.disabledLabelColor].uiColor for (index, button) in buttons.enumerated() { button.updateTokenizedValues() button.setTitleColor(contentColor, for: .normal) diff --git a/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift b/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift index 7e5b06341f..63a186c6a3 100644 --- a/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift +++ b/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift @@ -62,104 +62,104 @@ public class SegmentedControlTokenSet: ControlTokenSet UIColor { - return UIColor(dynamicColor: fluentTheme.color(.stroke2)) + return fluentTheme.color(.stroke2) } private func initialize(orientation: SeparatorOrientation) { diff --git a/ios/FluentUI/Shimmer/ShimmerLinesView.swift b/ios/FluentUI/Shimmer/ShimmerLinesView.swift index fd8740bfad..6fbc845931 100644 --- a/ios/FluentUI/Shimmer/ShimmerLinesView.swift +++ b/ios/FluentUI/Shimmer/ShimmerLinesView.swift @@ -76,7 +76,7 @@ open class ShimmerLinesView: ShimmerView { for i in 0..= 0 ? tokenSet[.labelCornerRadius].float : tokenSet[.cornerRadius].float - lineLayer.backgroundColor = UIColor(dynamicColor: tokenSet[.tintColor].dynamicColor).cgColor + lineLayer.backgroundColor = tokenSet[.tintColor].uiColor.cgColor // Add layer newLineLayers.append(lineLayer) diff --git a/ios/FluentUI/Shimmer/ShimmerTokenSet.swift b/ios/FluentUI/Shimmer/ShimmerTokenSet.swift index f31dc871d7..50dec732d2 100644 --- a/ios/FluentUI/Shimmer/ShimmerTokenSet.swift +++ b/ios/FluentUI/Shimmer/ShimmerTokenSet.swift @@ -69,7 +69,7 @@ public class ShimmerTokenSet: ControlTokenSet { } case .tintColor: - return .dynamicColor { + return .uiColor { switch style() { case .concealing: return theme.color(.stencil2) @@ -79,9 +79,7 @@ public class ShimmerTokenSet: ControlTokenSet { } case .darkGradient: - return .dynamicColor { - return DynamicColor(light: GlobalTokens.neutralColors(.black)) - } + return .uiColor { theme.color(.foregroundDarkStatic) } case .shimmerWidth: return .float { 180.0 } diff --git a/ios/FluentUI/Shimmer/ShimmerView.swift b/ios/FluentUI/Shimmer/ShimmerView.swift index daad3f6896..307f0da51e 100644 --- a/ios/FluentUI/Shimmer/ShimmerView.swift +++ b/ios/FluentUI/Shimmer/ShimmerView.swift @@ -102,7 +102,7 @@ open class ShimmerView: UIView, TokenizedControlInternal { let shouldApplyLabelCornerRadius = subview is UILabel && tokenSet[.labelCornerRadius].float >= 0 coverLayer.cornerRadius = shouldApplyLabelCornerRadius ? tokenSet[.labelCornerRadius].float : tokenSet[.cornerRadius].float - coverLayer.backgroundColor = UIColor(dynamicColor: tokenSet[.tintColor].dynamicColor).cgColor + coverLayer.backgroundColor = tokenSet[.tintColor].uiColor.cgColor var coverFrame = viewToCover.convert(subview.bounds, from: subview) if let label = subview as? UILabel { @@ -131,7 +131,7 @@ open class ShimmerView: UIView, TokenizedControlInternal { /// Update the gradient layer that animates to provide the shimmer effect (also updates the animation). func updateShimmeringLayer() { let light = UIColor.white.withAlphaComponent(tokenSet[.shimmerAlpha].float).cgColor - let dark = UIColor(dynamicColor: tokenSet[.darkGradient].dynamicColor).cgColor + let dark = tokenSet[.darkGradient].uiColor.cgColor shimmeringLayer.colors = self.style == .concealing ? [light, dark, light] : [dark, light, dark] let isRTL = effectiveUserInterfaceLayoutDirection == .rightToLeft diff --git a/ios/FluentUI/Tab Bar/TabBarItemView.swift b/ios/FluentUI/Tab Bar/TabBarItemView.swift index 8c8dc75470..14fed7727e 100644 --- a/ios/FluentUI/Tab Bar/TabBarItemView.swift +++ b/ios/FluentUI/Tab Bar/TabBarItemView.swift @@ -272,10 +272,10 @@ class TabBarItemView: UIControl, TokenizedControlInternal { } private func updateColors() { - let selectedColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.brandForeground1)) - let unselectedImageColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground3)) - let unselectedTextColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foreground2)) - let disabledColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.foregroundDisabled1)) + let selectedColor = tokenSet.fluentTheme.color(.brandForeground1) + let unselectedImageColor = tokenSet.fluentTheme.color(.foreground3) + let unselectedTextColor = tokenSet.fluentTheme.color(.foreground2) + let disabledColor = tokenSet.fluentTheme.color(.foregroundDisabled1) titleLabel.textColor = isEnabled ? (isSelected ? selectedColor : unselectedTextColor) : disabledColor imageView.tintColor = isEnabled ? (isSelected ? selectedColor : unselectedImageColor) : disabledColor diff --git a/ios/FluentUI/Table View/TableViewCell.swift b/ios/FluentUI/Table View/TableViewCell.swift index 83dd27e8fc..af29c8c261 100644 --- a/ios/FluentUI/Table View/TableViewCell.swift +++ b/ios/FluentUI/Table View/TableViewCell.swift @@ -39,11 +39,11 @@ public enum TableViewCellAccessoryType: Int { case .none: return nil case .disclosureIndicator: - return UIColor(dynamicColor: tokenSet[.accessoryDisclosureIndicatorColor].dynamicColor) + return tokenSet[.accessoryDisclosureIndicatorColor].uiColor case .detailButton: - return UIColor(dynamicColor: tokenSet[.accessoryDetailButtonColor].dynamicColor) + return tokenSet[.accessoryDetailButtonColor].uiColor case .checkmark: - return UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + return fluentTheme.color(.brandForeground1) } } @@ -73,9 +73,9 @@ public enum TableViewCellBackgroundStyleType: Int { func defaultColor(tokenSet: TableViewCellTokenSet) -> UIColor? { switch self { case .plain: - return UIColor(dynamicColor: tokenSet[.cellBackgroundColor].dynamicColor) + return tokenSet[.cellBackgroundColor].uiColor case .grouped: - return UIColor(dynamicColor: tokenSet[.cellBackgroundGroupedColor].dynamicColor) + return tokenSet[.cellBackgroundGroupedColor].uiColor case .clear: return .clear case .custom: @@ -132,22 +132,22 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { /// TableViewCell colors with obj-c support @objc public static var tableBackgroundColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.backgroundColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.backgroundColor].uiColor } @objc public static var tableBackgroundGroupedColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.backgroundGroupedColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.backgroundGroupedColor].uiColor } @objc public static var tableCellBackgroundColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundColor].uiColor } @objc public static var tableCellBackgroundGroupedColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundGroupedColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundGroupedColor].uiColor } @objc public static var tableCellBackgroundSelectedColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundSelectedColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.cellBackgroundSelectedColor].uiColor } @objc public static var tableCellImageColor: UIColor { - UIColor(dynamicColor: TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.imageColor].dynamicColor) + TableViewCellTokenSet(customViewSize: { MSFTableViewCellCustomViewSize.zero })[.imageColor].uiColor } /// Identifier string for TableViewCell @@ -332,7 +332,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { titleHeight: labelSize(text: title, attributedText: attributedTitle, isAttributedTextSet: isAttributedTitleSet, - font: titleFont ?? UIFont.fluent(tokenSet[.titleFont].fontInfo), + font: titleFont ?? tokenSet[.titleFont].uiFont, numberOfLines: titleNumberOfLines, textAreaWidth: textAreaWidth, leadingAccessoryView: titleLeadingAccessoryView, @@ -342,7 +342,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { subtitleHeight: labelSize(text: subtitle, attributedText: attributedSubtitle, isAttributedTextSet: isAttributedSubtitleSet, - font: subtitleFont ?? UIFont.fluent(layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].fontInfo : tokenSet[.subtitleThreeLinesFont].fontInfo), + font: subtitleFont ?? (layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].uiFont : tokenSet[.subtitleThreeLinesFont].uiFont), numberOfLines: subtitleNumberOfLines, textAreaWidth: textAreaWidth, leadingAccessoryView: subtitleLeadingAccessoryView, @@ -352,7 +352,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { footerHeight: labelSize(text: footer, attributedText: attributedFooter, isAttributedTextSet: isAttributedFooterSet, - font: footerFont ?? UIFont.fluent(tokenSet[.subtitleThreeLinesFont].fontInfo), + font: footerFont ?? tokenSet[.subtitleThreeLinesFont].uiFont, numberOfLines: footerNumberOfLines, textAreaWidth: textAreaWidth, leadingAccessoryView: footerLeadingAccessoryView, @@ -496,7 +496,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { var textAreaWidth = Self.labelPreferredWidth(text: title, attributedText: attributedTitle, isAttributedTextSet: isAttributedTitleSet, - font: titleFont ?? UIFont.fluent(tokenSet[.titleFont].fontInfo), + font: titleFont ?? tokenSet[.titleFont].uiFont, leadingAccessoryView: titleLeadingAccessoryView, trailingAccessoryView: titleTrailingAccessoryView, labelAccessoryViewMarginTrailing: labelAccessoryViewMarginTrailing, @@ -505,7 +505,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { let subtitleWidth = Self.labelPreferredWidth(text: subtitle, attributedText: attributedSubtitle, isAttributedTextSet: isAttributedSubtitleSet, - font: subtitleFont ?? UIFont.fluent(layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].fontInfo : tokenSet[.subtitleThreeLinesFont].fontInfo), + font: subtitleFont ?? (layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].uiFont : tokenSet[.subtitleThreeLinesFont].uiFont), leadingAccessoryView: subtitleLeadingAccessoryView, trailingAccessoryView: subtitleTrailingAccessoryView, labelAccessoryViewMarginTrailing: labelAccessoryViewMarginTrailing, @@ -515,7 +515,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { let footerWidth = Self.labelPreferredWidth(text: footer, attributedText: attributedFooter, isAttributedTextSet: isAttributedFooterSet, - font: footerFont ?? UIFont.fluent(tokenSet[.footerFont].fontInfo), + font: footerFont ?? tokenSet[.footerFont].uiFont, leadingAccessoryView: footerLeadingAccessoryView, trailingAccessoryView: footerTrailingAccessoryView, labelAccessoryViewMarginTrailing: labelAccessoryViewMarginTrailing, @@ -865,7 +865,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { let unreadDotSize = TableViewCellTokenSet.unreadDotDimensions unreadDotLayer.bounds.size = CGSize(width: unreadDotSize, height: unreadDotSize) unreadDotLayer.cornerRadius = unreadDotSize / 2 - unreadDotLayer.backgroundColor = UIColor(dynamicColor: tokenSet[.booleanCellBrandColor].dynamicColor).cgColor + unreadDotLayer.backgroundColor = tokenSet[.booleanCellBrandColor].uiColor.cgColor return unreadDotLayer }() @@ -1209,13 +1209,13 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { private func updateFonts() { if !isAttributedTitleSet { - titleLabel.font = UIFont.fluent(tokenSet[.titleFont].fontInfo) + titleLabel.font = tokenSet[.titleFont].uiFont } if !isAttributedSubtitleSet { - subtitleLabel.font = UIFont.fluent(layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].fontInfo : tokenSet[.subtitleThreeLinesFont].fontInfo) + subtitleLabel.font = (layoutType == .twoLines ? tokenSet[.subtitleTwoLinesFont].uiFont : tokenSet[.subtitleThreeLinesFont].uiFont) } if !isAttributedFooterSet { - footerLabel.font = UIFont.fluent(tokenSet[.footerFont].fontInfo) + footerLabel.font = tokenSet[.footerFont].uiFont } } @@ -1446,13 +1446,13 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { public func updateTextColors() { if !isUsingCustomTextColors { if !isAttributedTitleSet { - titleLabel.textColor = UIColor(dynamicColor: tokenSet[.titleColor].dynamicColor) + titleLabel.textColor = tokenSet[.titleColor].uiColor } if !isAttributedSubtitleSet { - subtitleLabel.textColor = UIColor(dynamicColor: tokenSet[.subtitleColor].dynamicColor) + subtitleLabel.textColor = tokenSet[.subtitleColor].uiColor } if !isAttributedFooterSet { - footerLabel.textColor = UIColor(dynamicColor: tokenSet[.footerColor].dynamicColor) + footerLabel.textColor = tokenSet[.footerColor].uiColor } } } @@ -1875,7 +1875,7 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { if backgroundStyleType != .custom { // Customize the background color to use the tint color when the cell is highlighted or selected. if state.isHighlighted || state.isSelected || state.isFocused { - backgroundConfiguration?.backgroundColor = UIColor(dynamicColor: tokenSet[.cellBackgroundSelectedColor].dynamicColor) + backgroundConfiguration?.backgroundColor = tokenSet[.cellBackgroundSelectedColor].uiColor } else { backgroundConfiguration?.backgroundColor = backgroundStyleType.defaultColor(tokenSet: tokenSet) } @@ -1962,8 +1962,8 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { } private func updateSelectionImageColor() { - selectionImageView.tintColor = UIColor(dynamicColor: isSelected ? tokenSet[.brandTextColor].dynamicColor : tokenSet[.selectionIndicatorOffColor].dynamicColor) - unreadDotLayer.backgroundColor = UIColor(dynamicColor: tokenSet[.brandTextColor].dynamicColor).cgColor + selectionImageView.tintColor = isSelected ? tokenSet[.brandTextColor].uiColor : tokenSet[.selectionIndicatorOffColor].uiColor + unreadDotLayer.backgroundColor = tokenSet[.brandTextColor].uiColor.cgColor } private func updateSeparator(_ separator: Separator, with type: SeparatorType) { diff --git a/ios/FluentUI/Table View/TableViewCellTokenSet.swift b/ios/FluentUI/Table View/TableViewCellTokenSet.swift index 790e1cc497..f1c3a8d681 100644 --- a/ios/FluentUI/Table View/TableViewCellTokenSet.swift +++ b/ios/FluentUI/Table View/TableViewCellTokenSet.swift @@ -78,22 +78,22 @@ public class TableViewCellTokenSet: ControlTokenSet UIColor { switch self { case .regular: - return UIColor(dynamicColor: fluentTheme.color(.foreground2)) + return fluentTheme.color(.foreground2) case .primary: - return UIColor(dynamicColor: fluentTheme.color(.brandForeground1)) + return fluentTheme.color(.brandForeground1) } } } @@ -47,18 +47,18 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont func textColor(fluentTheme: FluentTheme) -> UIColor { switch self { case .header, .footer: - return UIColor(dynamicColor: fluentTheme.color(.foreground2)) + return fluentTheme.color(.foreground2) case .headerPrimary: - return UIColor(dynamicColor: fluentTheme.color(.foreground1)) + return fluentTheme.color(.foreground1) } } func textFont() -> UIFont { switch self { case .headerPrimary: - return UIFont.fluent(FluentTheme.shared.typography(.body1Strong)) + return FluentTheme.shared.typography(.body1Strong) case .header, .footer: - return UIFont.fluent(FluentTheme.shared.typography(.caption1)) + return FluentTheme.shared.typography(.caption1) } } } @@ -482,9 +482,9 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont titleView.textColor = style.textColor(fluentTheme: tokenSet.fluentTheme) if tableViewCellStyle == .grouped { - backgroundView?.backgroundColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.backgroundCanvas)) + backgroundView?.backgroundColor = tokenSet.fluentTheme.color(.backgroundCanvas) } else if tableViewCellStyle == .plain { - backgroundView?.backgroundColor = UIColor(dynamicColor: tokenSet.fluentTheme.color(.background1)) + backgroundView?.backgroundColor = tokenSet.fluentTheme.color(.background1) } else { backgroundView?.backgroundColor = .clear } @@ -498,7 +498,7 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont } private func updateAccessoryButtonTitleStyle() { - accessoryButton?.titleLabel?.font = UIFont.fluent(tokenSet.fluentTheme.typography(.caption1Strong)) + accessoryButton?.titleLabel?.font = tokenSet.fluentTheme.typography(.caption1Strong) updateAccessoryButtonTitleColor() } @@ -549,7 +549,7 @@ private class TableViewHeaderFooterTitleView: UITextView { } func updateLinkTextColor(_ fluentTheme: FluentTheme) { - linkTextAttributes = [.foregroundColor: UIColor(dynamicColor: fluentTheme.color(.brandForeground1))] + linkTextAttributes = [.foregroundColor: fluentTheme.color(.brandForeground1)] } required init?(coder: NSCoder) { diff --git a/ios/FluentUI/TextField/FluentTextField.swift b/ios/FluentUI/TextField/FluentTextField.swift index 1bd63a73c6..2db4a876fc 100644 --- a/ios/FluentUI/TextField/FluentTextField.swift +++ b/ios/FluentUI/TextField/FluentTextField.swift @@ -188,7 +188,7 @@ public final class FluentTextField: UIView, UITextFieldDelegate, TokenizedContro guard let placeholder else { return nil } - return NSAttributedString(string: placeholder, attributes: [.foregroundColor: UIColor(dynamicColor: tokenSet[.placeholderColor].dynamicColor)]) + return NSAttributedString(string: placeholder, attributes: [.foregroundColor: tokenSet[.placeholderColor].uiColor]) } // The leadingImageView needs a container to be vertically centered on the @@ -242,20 +242,20 @@ public final class FluentTextField: UIView, UITextFieldDelegate, TokenizedContro } private func updateTokenizedValues() { - backgroundColor = UIColor(dynamicColor: tokenSet[.backgroundColor].dynamicColor) + backgroundColor = tokenSet[.backgroundColor].uiColor - leadingImageView.tintColor = UIColor(dynamicColor: tokenSet[.leadingIconColor].dynamicColor) + leadingImageView.tintColor = tokenSet[.leadingIconColor].uiColor - titleLabel.font = UIFont.fluent(tokenSet[.titleLabelFont].fontInfo) - titleLabel.textColor = UIColor(dynamicColor: tokenSet[.titleLabelColor].dynamicColor) - assistiveTextLabel.font = UIFont.fluent(tokenSet[.assistiveTextFont].fontInfo) - assistiveTextLabel.textColor = UIColor(dynamicColor: tokenSet[.assistiveTextColor].dynamicColor) + titleLabel.font = tokenSet[.titleLabelFont].uiFont + titleLabel.textColor = tokenSet[.titleLabelColor].uiColor + assistiveTextLabel.font = tokenSet[.assistiveTextFont].uiFont + assistiveTextLabel.textColor = tokenSet[.assistiveTextColor].uiColor - separator.backgroundColor = UIColor(dynamicColor: tokenSet[.strokeColor].dynamicColor) + separator.backgroundColor = tokenSet[.strokeColor].uiColor - textfield.font = UIFont.fluent(tokenSet[.inputTextFont].fontInfo) - textfield.tintColor = UIColor(dynamicColor: tokenSet[.cursorColor].dynamicColor) - textfield.textColor = UIColor(dynamicColor: tokenSet[.inputTextColor].dynamicColor) + textfield.font = tokenSet[.inputTextFont].uiFont + textfield.tintColor = tokenSet[.cursorColor].uiColor + textfield.textColor = tokenSet[.inputTextColor].uiColor textfield.attributedPlaceholder = attributedPlaceholder textfield.clearButton.tokenSet[.foregroundColor] = tokenSet[.trailingIconColor] } diff --git a/ios/FluentUI/TextField/TextFieldTokenSet.swift b/ios/FluentUI/TextField/TextFieldTokenSet.swift index 64d76beb71..c2446e0455 100644 --- a/ios/FluentUI/TextField/TextFieldTokenSet.swift +++ b/ios/FluentUI/TextField/TextFieldTokenSet.swift @@ -57,7 +57,7 @@ public class TextFieldTokenSet: ControlTokenSet { super.init { [state] token, theme in switch token { case .assistiveTextColor: - return .dynamicColor { + return .uiColor { switch state() { case .unfocused, .focused: return theme.color(.foreground2) @@ -66,17 +66,17 @@ public class TextFieldTokenSet: ControlTokenSet { } } case .assistiveTextFont: - return .fontInfo { theme.typography(.caption2) } + return .uiFont { theme.typography(.caption2) } case .backgroundColor: - return .dynamicColor { theme.color(.background1) } + return .uiColor { theme.color(.background1) } case .cursorColor: - return .dynamicColor { theme.color(.foreground3) } + return .uiColor { theme.color(.foreground3) } case .inputTextColor: - return .dynamicColor { theme.color(.foreground1) } + return .uiColor { theme.color(.foreground1) } case .inputTextFont: - return .fontInfo { theme.typography(.body1) } + return .uiFont { theme.typography(.body1) } case .leadingIconColor: - return .dynamicColor { + return .uiColor { switch state() { case .unfocused, .error: return theme.color(.foreground2) @@ -85,9 +85,9 @@ public class TextFieldTokenSet: ControlTokenSet { } } case .placeholderColor: - return .dynamicColor { theme.color(.foreground2) } + return .uiColor { theme.color(.foreground2) } case .strokeColor: - return .dynamicColor { + return .uiColor { switch state() { case .unfocused: return theme.color(.stroke1) @@ -98,7 +98,7 @@ public class TextFieldTokenSet: ControlTokenSet { } } case .titleLabelColor: - return .dynamicColor { + return .uiColor { switch state() { case .unfocused: return theme.color(.foreground2) @@ -109,9 +109,9 @@ public class TextFieldTokenSet: ControlTokenSet { } } case .titleLabelFont: - return .fontInfo { theme.typography(.caption2) } + return .uiFont { theme.typography(.caption2) } case .trailingIconColor: - return .dynamicColor { + return .uiColor { return theme.color(.foreground2) } } diff --git a/ios/FluentUI/Tooltip/TooltipTokenSet.swift b/ios/FluentUI/Tooltip/TooltipTokenSet.swift index 83d62e36f9..b4bf304814 100644 --- a/ios/FluentUI/Tooltip/TooltipTokenSet.swift +++ b/ios/FluentUI/Tooltip/TooltipTokenSet.swift @@ -40,10 +40,10 @@ public class TooltipTokenSet: ControlTokenSet { super.init { token, theme in switch token { case .tooltipColor: - return .dynamicColor { theme.color(.backgroundDarkStatic) } + return .uiColor { theme.color(.backgroundDarkStatic) } case .textColor: - return .dynamicColor { theme.color(.foregroundLightStatic) } + return .uiColor { theme.color(.foregroundLightStatic) } case .shadowInfo: return .shadowInfo { theme.shadow(.shadow16) } @@ -52,10 +52,10 @@ public class TooltipTokenSet: ControlTokenSet { return .float { GlobalTokens.corner(.radius80) } case .messageLabelTextStyle: - return .fontInfo { theme.typography(.body2) } + return .uiFont { theme.typography(.body2) } case .titleLabelTextStyle: - return .fontInfo { theme.typography(.body1Strong) } + return .uiFont { theme.typography(.body1Strong) } case .maximumWidth: return .float { 250.0 } diff --git a/ios/FluentUI/Tooltip/TooltipView.swift b/ios/FluentUI/Tooltip/TooltipView.swift index 9b04859366..ffc6011690 100644 --- a/ios/FluentUI/Tooltip/TooltipView.swift +++ b/ios/FluentUI/Tooltip/TooltipView.swift @@ -28,7 +28,7 @@ class TooltipView: UIView, Shadowable { let arrowImageViewBaseImage = UIImage.staticImageNamed("tooltip-arrow") arrowImageView = UIImageView(image: arrowImageViewBaseImage) - arrowImageView.image = arrowImageViewBaseImage?.withTintColor(UIColor(dynamicColor: tokenSet[.tooltipColor].dynamicColor), renderingMode: .alwaysOriginal) + arrowImageView.image = arrowImageViewBaseImage?.withTintColor(tokenSet[.tooltipColor].uiColor, renderingMode: .alwaysOriginal) super.init(frame: .zero) @@ -89,9 +89,9 @@ class TooltipView: UIView, Shadowable { } func updateFonts() { - messageLabel.font = UIFont.fluent(tokenSet[.messageLabelTextStyle].fontInfo) + messageLabel.font = tokenSet[.messageLabelTextStyle].uiFont if let titleLabel = titleLabel { - titleLabel.font = UIFont.fluent(tokenSet[.titleLabelTextStyle].fontInfo) + titleLabel.font = tokenSet[.titleLabelTextStyle].uiFont } } @@ -232,9 +232,9 @@ class TooltipView: UIView, Shadowable { } private func updateColors() { - let textColor = UIColor(dynamicColor: tokenSet[.textColor].dynamicColor) - backgroundView.backgroundColor = UIColor(dynamicColor: tokenSet[.tooltipColor].dynamicColor) - arrowImageView.image = arrowImageView.image?.withTintColor(UIColor(dynamicColor: tokenSet[.tooltipColor].dynamicColor), renderingMode: .alwaysOriginal) + let textColor = tokenSet[.textColor].uiColor + backgroundView.backgroundColor = tokenSet[.tooltipColor].uiColor + arrowImageView.image = arrowImageView.image?.withTintColor(tokenSet[.tooltipColor].uiColor, renderingMode: .alwaysOriginal) messageLabel.textColor = textColor titleLabel?.textColor = textColor } @@ -305,7 +305,7 @@ class TooltipView: UIView, Shadowable { tokenSet: TooltipTokenSet, isMessage: Bool) -> CGSize { let boundingWidth = isAccessibilityContentSize ? size.width : min(tokenSet[.maximumWidth].float - (2 * TooltipTokenSet.paddingHorizontal), size.width) - return text.preferredSize(for: UIFont.fluent(tokenSet[isMessage ? .messageLabelTextStyle : .titleLabelTextStyle].fontInfo), width: boundingWidth) + return text.preferredSize(for: tokenSet[isMessage ? .messageLabelTextStyle : .titleLabelTextStyle].uiFont, width: boundingWidth) } private var arrowPosition: CGFloat { @@ -414,7 +414,7 @@ class TooltipView: UIView, Shadowable { let view = UIView() view.layer.cornerRadius = tokenSet[.backgroundCornerRadius].float view.layer.cornerCurve = .continuous - view.backgroundColor = UIColor(dynamicColor: tokenSet[.tooltipColor].dynamicColor) + view.backgroundColor = tokenSet[.tooltipColor].uiColor return view }() @@ -432,8 +432,8 @@ class TooltipView: UIView, Shadowable { private lazy var messageLabel: UILabel = { let label = Label() - label.font = UIFont.fluent(tokenSet[.messageLabelTextStyle].fontInfo) - label.textColor = UIColor(dynamicColor: tokenSet[.textColor].dynamicColor) + label.font = tokenSet[.messageLabelTextStyle].uiFont + label.textColor = tokenSet[.textColor].uiColor label.numberOfLines = 0 label.lineBreakStrategy = [] label.isAccessibilityElement = false @@ -443,8 +443,8 @@ class TooltipView: UIView, Shadowable { private lazy var titleLabel: UILabel? = { if let title = titleMessage { let label = Label() - label.font = UIFont.fluent(tokenSet[.titleLabelTextStyle].fontInfo) - label.textColor = UIColor(dynamicColor: tokenSet[.textColor].dynamicColor) + label.font = tokenSet[.titleLabelTextStyle].uiFont + label.textColor = tokenSet[.textColor].uiColor label.numberOfLines = 0 label.lineBreakStrategy = [] label.isAccessibilityElement = false diff --git a/ios/FluentUI/TwoLineTitleView/TwoLineTitleView.swift b/ios/FluentUI/TwoLineTitleView/TwoLineTitleView.swift index 66e9abac20..a2948b4363 100644 --- a/ios/FluentUI/TwoLineTitleView/TwoLineTitleView.swift +++ b/ios/FluentUI/TwoLineTitleView/TwoLineTitleView.swift @@ -216,16 +216,16 @@ open class TwoLineTitleView: UIView { private func applyStyle() { switch currentStyle { case .system: - titleButtonLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground1)) - subtitleButtonLabel.textColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) - titleButtonImageView.tintColor = UIColor(dynamicColor: fluentTheme.color(.foreground2)) + titleButtonLabel.textColor = fluentTheme.color(.foreground1) + subtitleButtonLabel.textColor = fluentTheme.color(.foreground2) + titleButtonImageView.tintColor = fluentTheme.color(.foreground2) case .primary: - titleButtonLabel.textColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground1).dark)) - subtitleButtonLabel.textColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground2).dark)) - titleButtonImageView.tintColor = UIColor(dynamicColor: DynamicColor(light: fluentTheme.color(.foregroundOnColor).light, - dark: fluentTheme.color(.foreground2).dark)) + titleButtonLabel.textColor = UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground1).dark) + subtitleButtonLabel.textColor = UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground2).dark) + titleButtonImageView.tintColor = UIColor(light: fluentTheme.color(.foregroundOnColor).light, + dark: fluentTheme.color(.foreground2).dark) } // unlike title accessory image view, subtitle accessory image view should be the same color as subtitle label @@ -282,8 +282,8 @@ open class TwoLineTitleView: UIView { } private func updateFonts() { - titleButtonLabel.font = UIFont.fluent(fluentTheme.typography(.body1Strong)) - subtitleButtonLabel.font = UIFont.fluent(fluentTheme.typography(.caption1)) + titleButtonLabel.font = fluentTheme.typography(.body1Strong) + subtitleButtonLabel.font = fluentTheme.typography(.caption1) } open override func layoutSubviews() {