Skip to content

Commit

Permalink
create separate method for custom icons (#2134)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-skyscanner authored Jan 13, 2025
1 parent def0b5f commit 6d77026
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,12 @@ public extension BPKIcon {
}

public extension BPKIcon {
// swiftlint:disable function_body_length cyclomatic_complexity
static func named(_ iconName: String, bundle: Bundle? = nil) -> BPKIcon? {

if let bundle {
return BPKIcon(name: iconName, bundle: bundle)
}
static func named(_ iconName: String, bundle: Bundle) -> BPKIcon {
BPKIcon(name: iconName, bundle: bundle)
}

// swiftlint:disable function_body_length cyclomatic_complexity
static func named(_ iconName: String) -> BPKIcon? {
switch iconName {
case "accessibility": return .accessibility
case "account--add": return .accountAdd
Expand Down
11 changes: 5 additions & 6 deletions templates/swiftui/BPKIcons.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ public extension BPKIcon {
}

public extension BPKIcon {
// swiftlint:disable function_body_length cyclomatic_complexity
static func named(_ iconName: String, bundle: Bundle? = nil) -> BPKIcon? {

if let bundle {
return BPKIcon(name: iconName, bundle: bundle)
}
static func named(_ iconName: String, bundle: Bundle) -> BPKIcon {
BPKIcon(name: iconName, bundle: bundle)
}

// swiftlint:disable function_body_length cyclomatic_complexity
static func named(_ iconName: String) -> BPKIcon? {
switch iconName {
{% for icon in icons -%}
case "{{icon.file}}": return .{{icon.name}}
Expand Down

0 comments on commit 6d77026

Please sign in to comment.