Skip to content

Commit

Permalink
Remove MarkdownStyle.Color (onevcat#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezreal committed Feb 26, 2022
1 parent 81c6651 commit 3c6b679
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 216 deletions.
18 changes: 15 additions & 3 deletions Sources/MarkdownUI/Rendering/AttributedStringRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
struct AttributedStringRenderer {
struct State {
var font: MarkdownStyle.Font
var foregroundColor: MarkdownStyle.Color
var foregroundColor: SwiftUI.Color
var paragraphSpacing: CGFloat
var headIndent: CGFloat = 0
var tailIndent: CGFloat = 0
Expand Down Expand Up @@ -343,7 +343,7 @@ extension AttributedStringRenderer {
attributes: [
.font: state.font.resolve(),
.strikethroughStyle: NSUnderlineStyle.single.rawValue,
.strikethroughColor: MarkdownStyle.Color.separator.platformColor!,
.strikethroughColor: PlatformColor.separator,
]
)
)
Expand Down Expand Up @@ -425,7 +425,7 @@ extension AttributedStringRenderer {
string: text,
attributes: [
.font: state.font.resolve(),
.foregroundColor: state.foregroundColor.platformColor!,
.foregroundColor: PlatformColor(state.foregroundColor),
]
)
}
Expand Down Expand Up @@ -549,3 +549,15 @@ extension NSTextAlignment {
}
}
}

// MARK: - PlatformColor

#if os(macOS)
private typealias PlatformColor = NSColor

extension NSColor {
fileprivate static var separator: NSColor { .separatorColor }
}
#elseif os(iOS) || os(tvOS)
private typealias PlatformColor = UIColor
#endif
145 changes: 0 additions & 145 deletions Sources/MarkdownUI/Style/Color.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/MarkdownUI/Style/MarkdownStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public struct MarkdownStyle: Hashable {
public var font: MarkdownStyle.Font

/// The text color.
public var foregroundColor: MarkdownStyle.Color
public var foregroundColor: SwiftUI.Color

/// The measurements of the Markdown elements.
public var measurements: Measurements
Expand All @@ -18,7 +18,7 @@ public struct MarkdownStyle: Hashable {
/// - measurements: The measurements of the Markdown elements.
public init(
font: MarkdownStyle.Font = .body,
foregroundColor: MarkdownStyle.Color = .primary,
foregroundColor: SwiftUI.Color = .primary,
measurements: MarkdownStyle.Measurements = .init()
) {
self.font = font
Expand Down
66 changes: 0 additions & 66 deletions Tests/MarkdownUITests/ColorTests.swift

This file was deleted.

0 comments on commit 3c6b679

Please sign in to comment.