Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling in API requests #2144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Backpack-SwiftUI/Icons/Classes/BPKIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
* 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 ?? BPKCommonBundle.iconsBundle
self.bundle = bundle
}

public enum Size {
Expand Down
5 changes: 3 additions & 2 deletions Backpack-SwiftUI/Icons/Classes/BPKIconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ 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: icon.bundle)
self.init(iconName, bundle: bundle)
} else {
self.init(decorative: iconName, bundle: icon.bundle)
self.init(decorative: iconName, bundle: bundle)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions Backpack-SwiftUI/Icons/Classes/Generated/BPKIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +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
10 changes: 5 additions & 5 deletions templates/swiftui/BPKIcons.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +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
Loading