Dona

1.0.0-beta.14

Declarative UIKit
timnazar/Dona

What's New

v1.0.0

2024-05-14T19:18:03Z

Doná

Doná (means seed in Tajik language) is a library based on Apple's UIKit which helps you to create your own declarative UI.

Usage Example

For more information use Wiki.

UImageView Example

private let imageView = UIImageView()
    .decorated(with: .namedImage("ExampleLogo"))
    .decorated(with: .contentMode(.scaleAspectFit))
    .decorated(with: .disabledAutoresizingMask())

UILabel Example

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())

How to make your own custom ViewDecorator?

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)

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 17 2024 17:58:49 GMT-0900 (Hawaii-Aleutian Daylight Time)