Swiftpack.co - Hsieh-1989/Atelier as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Hsieh-1989.
Hsieh-1989/Atelier 0.1.0
A library that makes defines your style sheet like a breeze.
⭐️ 1
🕓 2 years ago
iOS
.package(url: "https://github.com/Hsieh-1989/Atelier.git", from: "0.1.0")

Atelier

A library that makes defines your style sheet like a breeze.

Requirements

  • iOS 13.0+
  • Xcode 12.0+
  • Swift 5.3+

Installation

You can add Atelier to an Xcode project by adding it as a package dependency.

https://github.com/Hsieh-1989/Atelier.git

If you want to use HSLayout in a SwiftPM project, it's as simple as adding a dependencies clause to your Package.swift:

dependencies: [
    .package(url: "https://github.com/Hsieh-1989/Atelier.git", from: "0.1.0")
]

Examples

Colors

Define your color palette:

// define your color brush
enum Colors: String, HexColorBrush {
    case red = "#FF0000FF"
    case orange = "#FF8000FF"
    case yellow = "#FFFF00FF"
    case green = "#00FF00FF"
    case cyan = "#00FFFFFF"
    case blue = "#0000FFFF"
    case purple = "#800080FF"
    case brown = "#996633FF"
}

// wrapped it to the palette
extension UIColor {
    @Palette(Colors.self)
    static var palette: ColorPalette
}

// usage
view.backgroundColor = .palette(.red)

Image

Define your image palette:

// define your image brush
enum Shape: String, SystemImageBrush {
    case seal
    case circle
    case capsule
    case oval
}

// wrapped it to the palette
extension UIImage {
    @Palette(Shape.self)
    static var shape: ImagePalette
}

// usage
imageView.image = .shape(.seal)

Categorize your assets!

One of the benefits of defining your own type to represent your assets is your can categorize them!

enum Bird: String, CaseIterable, NamedImageBrush {
    case budgie
    case dove
    ...
}

enum Dog: String, CaseIterable, NamedImageBrush {
    case corgi
    case poodle
    ...
}

enum Inset: String, CaseIterable, DynamicNamedImageBrush {
    case bee
    case bug
    ...
}

extension UIImage {
    @Palette(Bird.self)
    static var bird: ImagePalette
    
    @Palette(Dog.self)
    static var dog: ImagePalette
    
    @Palette(Inset.self)
    static var inset: ImagePalette
}
// usage
birdImageView.image = .bird(.budgie)
dogImageView.image = .dob(.corgi)
insetImageView.image = .inset(.bee)

More Advanced Usage

You can check the Example App to see more examples!

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics