From 6d7702610a70f1fed7fa6af56b160a85458f0d21 Mon Sep 17 00:00:00 2001 From: pablo-skyscanner Date: Mon, 13 Jan 2025 15:52:07 +0100 Subject: [PATCH] create separate method for custom icons (#2134) --- .../Icons/Classes/Generated/BPKIcons.swift | 11 +++++------ templates/swiftui/BPKIcons.njk | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift b/Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift index 9521a32a3..8e35b62b4 100644 --- a/Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift +++ b/Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift @@ -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 diff --git a/templates/swiftui/BPKIcons.njk b/templates/swiftui/BPKIcons.njk index 1a40e8412..024938da2 100644 --- a/templates/swiftui/BPKIcons.njk +++ b/templates/swiftui/BPKIcons.njk @@ -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}}