Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Sources/MarkdownUI/Extensibility/AssetImageProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public struct AssetImageProvider: ImageProvider {
}

private func image(url: URL) -> PlatformImage? {
#if canImport(AppKit)
#if canImport(UIKit)
return UIImage(named: self.name(url), in: self.bundle, with: nil)
#elseif canImport(AppKit)
if let bundle, bundle != .main {
return bundle.image(forResource: self.name(url))
} else {
return NSImage(named: self.name(url))
}
#elseif canImport(UIKit)
return UIImage(named: self.name(url), in: self.bundle, with: nil)
#endif
}
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/MarkdownUI/Utility/Color+RGBA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ extension Color {
/// - light: The light appearance color value.
/// - dark: The dark appearance color value.
public init(light: @escaping @autoclosure () -> Color, dark: @escaping @autoclosure () -> Color) {
#if canImport(AppKit)
self.init(
nsColor: .init(name: nil) { appearance in
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
return NSColor(light())
} else {
return NSColor(dark())
}
}
)
#elseif os(watchOS)
#if os(watchOS)
self = dark()
#elseif canImport(UIKit)
self.init(
Expand All @@ -42,6 +32,16 @@ extension Color {
}
}
)
#elseif canImport(AppKit)
self.init(
nsColor: .init(name: nil) { appearance in
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua {
return NSColor(light())
} else {
return NSColor(dark())
}
}
)
#endif
}
}