Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce light mode iOS tokens on visionOS #2008

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions ios/FluentUI/Core/Theme/FluentTheme+visionOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,52 @@ import UIKit
#if os(visionOS)
extension FluentTheme {
static func defaultColor_visionOS(_ token: FluentTheme.ColorToken) -> UIColor {
let visionColor: UIColor

// Apply overrides as needed. Note that visionOS only supports one mode, so there's no
// need to provide multiple values (e.g. light + dark, elevated, etc).
switch token {
case .foreground1:
return .white
visionColor = .white
case .foreground2:
return .white
visionColor = .white
case .foreground3:
return .white
visionColor = .white
case .foregroundDisabled1:
return .white.withAlphaComponent(0.8)
visionColor = .white.withAlphaComponent(0.8)
case .foregroundOnColor:
return .white
visionColor = .white
case .background1:
return .clear
visionColor = .clear
case .background1Pressed:
return .white.withAlphaComponent(0.1)
visionColor = .white.withAlphaComponent(0.1)
case .background2:
return .black.withAlphaComponent(0.1)
visionColor = .black.withAlphaComponent(0.1)
case .background2Pressed:
return .clear
visionColor = .clear
case .background3:
return .black.withAlphaComponent(0.1)
visionColor = .black.withAlphaComponent(0.1)
case .background4:
return .clear
visionColor = .clear
case .background5:
return .black.withAlphaComponent(0.2)
visionColor = .black.withAlphaComponent(0.2)
case .background5Pressed:
return .black.withAlphaComponent(0.1)
visionColor = .black.withAlphaComponent(0.1)
case .backgroundCanvas:
return .clear
visionColor = .clear
case .stroke1:
return .white.withAlphaComponent(0.4)
visionColor = .white.withAlphaComponent(0.4)
case .stroke2:
return .white.withAlphaComponent(0.5)
visionColor = .white.withAlphaComponent(0.5)
case .dangerForeground2:
return GlobalTokens.sharedColor(.red, .primary)
visionColor = GlobalTokens.sharedColor(.red, .primary)

default:
// Return the standard iOS color by default.
return defaultColor(token)
visionColor = defaultColor(token)
}

return UIColor(light: defaultColor(token).light, dark: visionColor.dark)
}
}
#endif
Loading