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
2 changes: 1 addition & 1 deletion Sources/HandySwiftUI/Extensions/ImageExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension Image {
/// let imageView = Image(convertible: symbol)
/// ```
public init(convertible: CustomSymbolConvertible, variableValue: Double? = nil) {
self.init(systemName: convertible.symbolName, variableValue: variableValue)
self.init(systemName: convertible.symbolSystemName, variableValue: variableValue)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/HandySwiftUI/Extensions/LabelExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ extension Label<Text, Image> {
/// // Creates a Label with "Settings" text and a gear icon
/// ```
public init(convertible: CustomLabelConvertible) {
self.init(convertible.description, systemImage: convertible.symbolName)
self.init(convertible.description, systemImage: convertible.symbolSystemName)
}
}
25 changes: 25 additions & 0 deletions Tests/HandySwiftUITests/ConvertibleTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import SwiftUI
import Testing

@testable import HandySwiftUI

@MainActor
struct ConvertibleTests {
struct RotatedStar: CustomLabelConvertible {
var description: String { "Rotated Star" }
var symbolName: String { "star:45*2" }
}

@Test
func imageUsesTheSymbolNameWithoutMetadata() {
#expect(Image(convertible: RotatedStar()) == Image(systemName: "star"))
}

@Test
func labelUsesTheSymbolNameWithoutMetadata() throws {
let label = Label(convertible: RotatedStar())
let icon = try #require(Mirror(reflecting: label).children.first { $0.label == "icon" }?.value as? Image)

#expect(icon == Image(systemName: "star"))
}
}
Loading