Skip to content

Commit

Permalink
Merge pull request #46 from RakuyoKit/feature/color-for-sf-symbols
Browse files Browse the repository at this point in the history
feat: Add `color` for `FastImageContentProviding.sfSymbols` method
  • Loading branch information
rakuyoMo authored Jun 17, 2024
2 parents 714b1df + 653311c commit ab2931d
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 ab2931d

Please sign in to comment.