Giter Club home page Giter Club logo

formulary's Introduction

Formulary

Formulary is a new library for creating dynamic, declarative, table view forms for iOS.

There's no lack of declarative TableView form libraries for iOS.

Formulary is inspired by XLForm, written in Swift, and designed for developer flexibility. It is intended to stay small and possibly as a foundation for ther libraries.

Development-oriented features include:

  • Form components are Swift protocols
  • Lots of points of control to override default behavior
  • Easy to integrate with existing model classes

Other cool features:

  • "Floating Labels" for form fields.
  • Composable validation functions
self.form = Formulary.ConcreteForm(sections: [
    Formulary.ConcreteFormSection(rows: [
        Formulary.ConcreteFormRow(name:"Name", tag: "name", type: .Text, validation: RequiredString("Name")),
        Formulary.ConcreteFormRow(name:"Email", tag: "email", type: .Text),
        Formulary.ConcreteFormRow(name:"Age", tag: "age", type: .Number, validation: MinimumNumber("Age", 13))],
        name:"Profile"),
    Formulary.ConcreteFormSection(rows: [
        Formulary.ConcreteFormRow(name:"Favorite Number", tag: "favoriteNumber", value: nil, type: .Decimal, validation: MinimumNumber("Your favorite number", 47) && MaximumNumber("Your favorite number", 47)),
        Formulary.ConcreteFormRow(name:"Ice Cream?", tag: "wantsIceCream", value: false, type: .Switch),
        Formulary.ConcreteFormRow(name:"Beer?", tag: "wantsBeer", value: true, type: .Switch),
        Formulary.ConcreteFormRow(name:"Other Thoughts?", tag: "thoughts", type: .Text),],
        name:"Preferences",
        footerName: "Fin"),
    Formulary.ConcreteFormSection(rows: [
        Formulary.ConcreteFormRow(name:"Show Values", tag: "show", type: .Button, action: { _ in
            
            let data = NSJSONSerialization.dataWithJSONObject(values(self.form) as NSDictionary, options: nil, error: nil)!
            let s = NSString(data: data, encoding: NSUTF8StringEncoding)
            
            let alert = UIAlertController(title: "Form Values", message: s, preferredStyle: .Alert)
            alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
            self.presentViewController(alert, animated: true, completion: nil)
        })
        ])
    ]
)

Screen-Capture of Example Form

Author

Fabian Canas (@fcanas)

License

Formulary is available under the MIT license.

formulary's People

Contributors

fcanas avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.