Skip to content

Commit

Permalink
Set default bundle for BPKIcon if not provided and update BPKIconView…
Browse files Browse the repository at this point in the history
… accordingly
  • Loading branch information
frugoman committed Jan 23, 2025
1 parent 0883cac commit 92610d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Backpack-SwiftUI/Icons/Classes/BPKIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
* limitations under the License.
*/

import Backpack_Common

public struct BPKIcon {
public let name: String
let bundle: Bundle?

init (name: String, bundle: Bundle? = nil) {
self.name = name
self.bundle = bundle
self.bundle = bundle ?? BPKCommonBundle.iconsBundle
}

public enum Size {
Expand Down
5 changes: 2 additions & 3 deletions Backpack-SwiftUI/Icons/Classes/BPKIconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ private extension BPKIcon.Size {
private extension Image {
init(icon: BPKIcon, size: BPKIcon.Size = .small, shouldEnableAccessibility: Bool) {
let iconName = "\(icon.name)-\(size.suffix)"
let bundle = icon.bundle ?? BPKCommonBundle.iconsBundle
if shouldEnableAccessibility {
self.init(iconName, bundle: bundle)
self.init(iconName, bundle: icon.bundle)
} else {
self.init(decorative: iconName, bundle: bundle)
self.init(decorative: iconName, bundle: icon.bundle)
}
}
}
Expand Down

0 comments on commit 92610d0

Please sign in to comment.