flex-ui
是一个小型工具,帮助链式 UI 配置。
import FlexUI
let label = UILabel()
label
.flex
.text("Label Text")
.textColor(.black)
.font(.systemFont(ofSize: 17.0))
新的配置方法可以通过扩展 Flex 组件的接口来添加,例如
import FlexUI
import UIKit
public enum Fonts {
public enum Headings {
/// The largest heading style.
case h1
/// A slightly smaller heading style.
case h2
/// A medium-sized heading style.
case h3
var font: UIFont {
/// Implementation to return a specific UIFont based on the heading style.
}
}
}
public extension FlexUI where Component: UIButton {
@discardableResult
@MainActor
func font(_ heading: Fonts.Headings) -> Self {
component.titleLabel?.font = heading.font
return self
}
}
let button = UIButton()
button
.flex
.font(.h3)
Swift 包管理器是一个用于自动化 Swift 代码分发的工具,并且集成到了 swift
编译器中。它还处于早期开发阶段,但是 flex-ui
确实支持在受支持的平台上使用它。
一旦你设置好你的 Swift 包,添加 flex-ui
作为依赖项就如同将其添加到你的 Package.swift
的 dependencies
值中一样简单。
dependencies: [
.package(url: "https://github.com/space-code/flex-ui.git", .upToNextMajor(from: "1.0.0"))
]
启动开发环境
make bootstrap
请随时帮助改进这个项目!如果你看到任何可以改进的地方或者想要新功能,请提交 issue 或发送 Pull Request!
Nikita Vasilev, nv3212@gmail.com
flex-ui 在 MIT 许可证下可用。查看 LICENSE 文件获取更多信息。