配方 0.4

配方 0.4

测试已测试
语言 SwiftSwift
许可证 MIT
发布最后发布2017 年 12 月
SwiftSwift 版本4.0
SPM支持 SPM

Fabian Canas 维护。




配方 0.4

配方

配方是一个用于创建动态、声明式 iOS 表视图单的新库。

配方处于设计和开发的早期阶段,所以如果您现在加入,您可以对库的设计、功能和实用性产生重大影响。

配方受到 XLForm 的启发,用 Swift 编写,旨在实现简洁和开发速度。

其他酷炫特性

  • 表单字段的“浮动标签”。
  • 可组合验证函数
let decimalFormatter = NSNumberFormatter()
decimalFormatter.maximumFractionDigits = 5

let integerFormatter = NSNumberFormatter()

self.form = Form(sections: [
    FormSection(rows: [
        TextEntryFormRow(name:"Name", tag: "name", validation: RequiredString("Name")),
        TextEntryFormRow(name: "Email", tag: "email", textType: TextEntryType.Email),
        TextEntryFormRow(name:"Age", tag: "age", textType: TextEntryType.Number, validation: MinimumNumber("Age", 13), formatter: integerFormatter)],
        name:"Profile"),
    FormSection(rows: [
        TextEntryFormRow(name:"Favorite Number", tag: "favoriteNumber", value: nil, textType: .Decimal, validation: MinimumNumber("Your favorite number", 47) && MaximumNumber("Your favorite number", 47), formatter: decimalFormatter),
        FormRow(name:"Do you like goats?", tag: "likesGoats", type: .Switch, value: false),
        TextEntryFormRow(name:"Other Thoughts?", tag: "thoughts", textType: .Plain),],
        name:"Preferences",
        footerName: "Fin"),
    OptionSection(rowValues:["Ice Cream", "Pizza", "Beer"], name: "Food", value: ["Pizza", "Ice Cream"]),
    FormSection(rows: [
        FormRow(name:"Show Values", tag: "show", type: .Button, value: nil, action: { _ in

            let data = NSJSONSerialization.dataWithJSONObject(values(self.form), options: nil, error: nil)!
            let s = NSString(data: data, encoding: NSUTF8StringEncoding)

            let alert = UIAlertController(title: "Form Values", message: s as? String, preferredStyle: UIAlertControllerStyle.Alert)
            alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
            self.presentViewController(alert, animated: true, completion: nil)
        })
    ])
])

Screen-Capture of Example Form

开发状态

我在生产中使用这个库,并且我使用的这种方式工作正常。YMMV。

在 1.0.0 发布之前,该项目遵循修改后的 SemVer

主版本零(0.y.z)是用于初始开发。任何东西都可能随时更改。公共 API 不应被视为稳定。

在向公共 API 引入新的向后兼容功能时,使用合理的努力使用补丁版本 Z(x.y.Z | x = 0)。当向公共 API 引入任何不兼容更改时,则为较小版本 Y(x.Y.z | x = 0)。

我打算提前发布 1.0.0,并且主要版本号将快速跳过,而不是继续 0.y.z 版本发布。如果想知道项目健康状况,请查看 Formulary 的 脉搏

作者

Fabian Canas (@fcanas)

许可证

配方可在 MIT 许可证下使用。