Skip to content

Commit

Permalink
feat: Add color for FastImageContentProviding.sfSymbols method
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Jun 17, 2024
1 parent 714b1df commit 653311c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ extension AnyButtonImageContent: FastImageContentProviding {
.init(UIImage(contentsOfFile: path))
}

public static func sfSymbols(name: String, configuration: UIImage.SymbolConfiguration? = nil) -> Self {
.init(UIImage(systemName: name, withConfiguration: configuration))
public static func sfSymbols(name: String, color: UIColor? = nil, configuration: UIImage.SymbolConfiguration? = nil) -> Self {
let image = UIImage(systemName: name, withConfiguration: configuration)
let finalImage = color.flatMap { image?.withTintColor($0, renderingMode: .alwaysOriginal) } ?? image
return .init(finalImage)
}
}
#endif
6 changes: 4 additions & 2 deletions Sources/Epoxy/Row/ImageRow/AnyImageContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ extension AnyImageContent: FastImageContentProviding {
.init(UIImage(contentsOfFile: path))
}

public static func sfSymbols(name: String, configuration: UIImage.SymbolConfiguration? = nil) -> Self {
.init(UIImage(systemName: name, withConfiguration: configuration))
public static func sfSymbols(name: String, color: UIColor? = nil, configuration: UIImage.SymbolConfiguration? = nil) -> Self {
let image = UIImage(systemName: name, withConfiguration: configuration)
let finalImage = color.flatMap { image?.withTintColor($0, renderingMode: .alwaysOriginal) } ?? image
return .init(finalImage)
}
}
#endif
2 changes: 1 addition & 1 deletion Sources/Epoxy/Row/ImageRow/FastImageContentProviding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public protocol FastImageContentProviding {
static func asset(name: String, bundle: Bundle, with configuration: UIImage.Configuration?) -> Self
static func data(_ data: Data) -> Self
static func file(path: String) -> Self
static func sfSymbols(name: String, configuration: UIImage.SymbolConfiguration?) -> Self
static func sfSymbols(name: String, color: UIColor?, configuration: UIImage.SymbolConfiguration?) -> Self
}

0 comments on commit 653311c

Please sign in to comment.