项目作者: sebj

项目描述 :
A SwiftGen SwiftUI template for Xcode asset catalog colors and images
高级语言:
项目地址: git://github.com/sebj/SwiftGen-SwiftUI-xcassets.git
创建时间: 2020-01-15T17:09:17Z
项目社区:https://github.com/sebj/SwiftGen-SwiftUI-xcassets

开源协议:

下载


A SwiftGen SwiftUI template for Asset Catalogs

This template is a fork of SwiftGen’s bundled xcassets/swift4.stencil template, to generate SwiftUI supporting type-safe code for colors and images in an Xcode asset catalog (*.xcassets).

It supports most of the same options, and produces mostly the same output.

♻️ Changed:

  • name property for assets is fileprivate, instead of using accessModifier option value (internal by default)

🔥 Removed:

  • Compiler checks for platform, as SwiftUI supports all Apple platforms
  • Generation for data assets (including the dataType option parameter), as this template focuses on SwiftUI support
  • Option parameters colorAliasName, and imageAliasName, as SwiftUI uses Color and Image types on all platforms

Usage Example

  1. // You can create new images with the convenience constructor like this:
  2. let bananaImage = Image(Asset.Exotic.banana)
  3. let privateImage = Image(Asset.private)
  4. // Or as an alternative, you can refer to an enum instance and call .image on it:
  5. let sameBananaImage = Asset.Exotic.banana.image
  6. let samePrivateImage = Asset.private.image
  7. // You can create colors by referring to the enum instance and calling `.color` on it:
  8. let primaryColor = Asset.Theme.primary.color
  9. let backgroundColor = Asset.Theme.background.color
  10. // Or as an alternative, you can use the convenience constructor like this:
  11. let samePrimaryColor = Color(asset: Asset.Theme.primary)
  12. let sameBackgroundColor = Color(asset: Asset.Theme.background)

Further documentation

See SwiftGen’s documentation for full usage and insallation information for the tool itself.

See SwiftGen’s documentation for the xcassets/swift4.stencil template for information on the options and generated code available.