Doná (means seed in Tajik language) is a library based on Apple's UIKit which helps you to create your own declarative UI.
For more information use Wiki.
private let imageView = UIImageView()
.decorated(with: .namedImage("ExampleLogo"))
.decorated(with: .contentMode(.scaleAspectFit))
.decorated(with: .disabledAutoresizingMask())
private let titleLabel = UILabel()
.decorated(with: .text("Hello, World!"))
.decorated(with: .textColor(.systemOrange))
.decorated(with: .textAlignment(.center))
.decorated(with: .font(.systemFont(ofSize: 16, weight: .medium)))
.decorated(with: .disabledAutoresizingMask())
You can extened decorators with extension
for ViewDecorator
struct for implementing your own design system (learn what is design system). In example:
import DonaCore
extension DonaViewDecorator {
static var largeTitle: DonaViewDecorator<UILabel> {
DonaViewDecorator<UILabel> {
$0.decorated(with: .disabledAutoresizingMask())
.decorated(with: .font(.systemFont(ofSize: 29, weight: .bold)))
.decorated(with: .textColor(.primary))
.decorated(with: .numberOfLines(0))
}
}
}
After combining or creating new decorators you can use it as usual:
private let titleLabel = UILabel()
.decorated(with: .text("Welcome 👋"))
.decorated(with: .largeTitle)