Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

hectr/FluentBuilder

Repository files navigation

FluentBuilder

Platform SwiftPM CocoaPods License

Examples

This is how you use Builder to customize any object:

Builder(subject: UIView())
    .frame(CGRect(x: 0, y: 0, width: 100, height: 100))
    .backgroundColor(.blue)
    .build()    

And these is how you can use it to create new instances of objects that conform to Initiable protocol:

extension UIView: Initiable {}

UIButton()
    .builder
    .frame(CGRect(x: 0, y: 0, width: 100, height: 100))
    .isSelected(true)
    .build()

UIView
    .builder
    .backgroundColor(.white)
    .alpha(0.5)
    .build()

Builder(UITextField.self)
    .placeholder("Type here")
    .build()

let _: UILabel = Builder()
    .text("text")
    .build()

let _: UIImageView = Builder
    .tintColor(.black)
    .contentMode(.scaleAspectFit)
    .build()

Alternatives

License

FluentBuilder is released under the MIT license. See LICENSE file for details.

About

Generic fluent interface builder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published