-
Notifications
You must be signed in to change notification settings - Fork 172
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
Move FluentTheme
code to new FluentUI_common
module
#2139
base: main
Are you sure you want to change the base?
Changes from all commits
320e374
e6b2370
069ec24
1e07c89
f96f468
3155a2a
3d110a1
ec1d094
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Constants | ||
common_root = 'Sources/FluentUI_common' | ||
ios_root = 'Sources/FluentUI_iOS' | ||
macos_root = 'Sources/FluentUI_macOS' | ||
|
||
|
@@ -13,14 +14,22 @@ Pod::Spec.new do |s| | |
s.homepage = "https://www.microsoft.com/design/fluent/#/" | ||
s.license = { :type => 'MIT', :file => 'LICENSE' } | ||
s.author = { "Microsoft" => "[email protected]"} | ||
s.source = { :git => "https://github.com/microsoft/fluentui-apple.git", :tag => "#{s.version}" } | ||
s.swift_version = "5.9" | ||
s.module_name = 'FluentUI' | ||
s.source = { :git => "https://github.com/microsoft/fluentui-apple.git", :tag => "#{s.version}" } | ||
s.swift_version = "5.9" | ||
s.module_name = 'FluentUI' | ||
|
||
s.ios.deployment_target = "16.0" | ||
s.osx.deployment_target = "12.0" | ||
|
||
# iOS | ||
|
||
s.ios.deployment_target = "16.0" | ||
# Common | ||
|
||
s.subspec 'Core_common' do |core_common| | ||
core_common.source_files = ["#{common_root}/#{core_dir}/**/*.{swift,h}"] | ||
end | ||
|
||
|
||
# iOS | ||
|
||
s.subspec 'Avatar_ios' do |avatar_ios| | ||
avatar_ios.platform = :ios | ||
|
@@ -111,6 +120,7 @@ Pod::Spec.new do |s| | |
|
||
s.subspec 'Core_ios' do |core_ios| | ||
core_ios.platform = :ios | ||
core_ios.dependency "#{s.name}/Core_common" | ||
core_ios.resource_bundle = { 'FluentUIResources-ios' => ["#{ios_root}/#{resources_dir}/**/*.{storyboard,xib,xcassets,strings,stringsdict}"] } | ||
core_ios.script_phase = { :name => 'Optimize resource bundle', | ||
:script => 'REMOVE_UNUSED_RESOURCES_SCRIPT_PATH=${PODS_TARGET_SRCROOT}/scripts/removeUnusedResourcesFromAssets.swift | ||
|
@@ -354,24 +364,15 @@ fi', :execution_position => :before_compile } | |
|
||
# Mac | ||
|
||
s.osx.deployment_target = "12" | ||
|
||
s.subspec 'Appearance_mac' do |appearance_mac| | ||
appearance_mac.platform = :osx | ||
appearance_mac.source_files = ["#{macos_root}/#{components_dir}/Appearance/**/*.{swift,h}"] | ||
end | ||
|
||
s.subspec 'AvatarView_mac' do |avatarview_mac| | ||
avatarview_mac.platform = :osx | ||
avatarview_mac.dependency "#{s.name}/Core_mac" | ||
avatarview_mac.dependency "#{s.name}/DynamicColor_mac" | ||
avatarview_mac.source_files = ["#{macos_root}/#{components_dir}/AvatarView/**/*.{swift,h}"] | ||
end | ||
|
||
s.subspec 'BadgeView_mac' do |badgeview_mac| | ||
badgeview_mac.platform = :osx | ||
badgeview_mac.dependency "#{s.name}/Core_mac" | ||
badgeview_mac.dependency "#{s.name}/DynamicColor_mac" | ||
badgeview_mac.source_files = ["#{macos_root}/#{components_dir}/Badge/**/*.{swift,h}"] | ||
end | ||
|
||
|
@@ -383,23 +384,17 @@ fi', :execution_position => :before_compile } | |
|
||
s.subspec 'Core_mac' do |core_mac| | ||
core_mac.platform = :osx | ||
core_mac.dependency "#{s.name}/Core_common" | ||
core_mac.resource_bundle = { 'FluentUIResources-macos' => ["#{macos_root}/#{resources_dir}/**/*.{storyboard,xib,xcassets,strings,stringsdict}"] } | ||
core_mac.source_files = ["#{macos_root}/#{core_dir}/**/*.{swift,h}"] | ||
end | ||
|
||
s.subspec 'DatePicker_mac' do |datepicker_mac| | ||
datepicker_mac.platform = :osx | ||
datepicker_mac.dependency "#{s.name}/Core_mac" | ||
datepicker_mac.dependency "#{s.name}/Appearance_mac" | ||
datepicker_mac.source_files = ["#{macos_root}/#{components_dir}/DatePicker/**/*.{swift,h}"] | ||
end | ||
|
||
s.subspec 'DynamicColor_mac' do |dynamiccolor_mac| | ||
dynamiccolor_mac.platform = :osx | ||
dynamiccolor_mac.dependency "#{s.name}/Appearance_mac" | ||
dynamiccolor_mac.source_files = ["#{macos_root}/#{components_dir}/DynamicColor/**/*.{swift,h}"] | ||
end | ||
|
||
s.subspec 'Link_mac' do |link_mac| | ||
link_mac.platform = :osx | ||
link_mac.dependency "#{s.name}/Core_mac" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,19 @@ extension Color { | |
/// | ||
/// - Parameter dynamicColor: A dynmic color structure that describes the `Color` to be created. | ||
init(dynamicColor: DynamicColor) { | ||
if #available(iOS 17, *) { | ||
if #available(iOS 17, macOS 14, *) { | ||
self.init(dynamicColor) | ||
} else { | ||
#if os(macOS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a good excuse to rename |
||
self.init(nsColor: NSColor(dynamicColor: dynamicColor)) | ||
#else | ||
self.init(uiColor: UIColor(dynamicColor: dynamicColor)) | ||
#endif // os(macOS) | ||
} | ||
} | ||
|
||
var dynamicColor: DynamicColor { | ||
if #available(iOS 17, *) { | ||
if #available(iOS 17, macOS 14, *) { | ||
var lightEnvironment = EnvironmentValues.init() | ||
lightEnvironment.colorScheme = .light | ||
|
||
|
@@ -58,9 +62,15 @@ extension Color { | |
return DynamicColor(light: Color(self.resolve(in: lightEnvironment)), | ||
dark: Color(self.resolve(in: darkEnvironment))) | ||
} else { | ||
#if os(macOS) | ||
let nsColor = NSColor(self) | ||
return DynamicColor(light: Color(nsColor.light), | ||
dark: Color(nsColor.dark)) | ||
#else | ||
let uiColor = UIColor(self) | ||
return DynamicColor(light: Color(uiColor.light), | ||
dark: Color(uiColor.dark)) | ||
#endif // os(macOS) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
|
||
#if canImport(AppKit) | ||
import AppKit | ||
import SwiftUI | ||
|
||
extension NSColor { | ||
|
||
|
@@ -51,6 +50,14 @@ extension NSColor { | |
return resolvedColorValue(appearance: NSAppearance(named: .darkAqua)) | ||
} | ||
|
||
convenience init(dynamicColor: DynamicColor) { | ||
// Simple closure to return a nil NSColor if the passed-in Color is | ||
// also nil, since the argument to `NSColor.init(_:)` is not optional. | ||
let colorResolver = { $0 != nil ? NSColor($0!) : nil } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
|
||
self.init(light: NSColor(dynamicColor.light), | ||
dark: colorResolver(dynamicColor.dark)) | ||
} | ||
|
||
/// Returns the version of the current color that results from the specified traits as an `NSColor`. | ||
/// | ||
/// - Parameter appearance: The user interface appearance to use when resolving the color information. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Not related to this PR, but there's a typo here.
dynmic
->dynamic