Skip to content

Add SystemImage protocol #47

Closed
Closed
@mpospese

Description

@mpospese

We have ImageAsset protocol to allow users to load images from asset catalogs, unit test them, and have a fallback image (so that we can return a non-optional UIImage. We should do the same thing for system images, e.g. for UIImage(systemName:) optional initializer.

We could declare a new protocol SystemImage and either derive it from ImageAsset or just copy the needed functionality. While we would need:

    static var fallbackImage: UIImage { get }
    var image: UIImage { get }
    func loadImage() -> UIImage?

we do not need (not applicable):

    static var bundle: Bundle { get }
    static var namespace: String? { get }

loadImage would have default implementation:

func loadImage() -> UIImage? { UIImage(systemName: rawValue) }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions