Skip to content

Commit

Permalink
Add kitchen sink example
Browse files Browse the repository at this point in the history
  • Loading branch information
clayallsopp committed Jun 25, 2012
1 parent 2b3eb60 commit da8d808
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/KitchenSink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.repl_history
build
resources/*.nib
resources/*.momd
resources/*.storyboardc
9 changes: 9 additions & 0 deletions examples/KitchenSink/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'formotion'

Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'KitchenSink'
end
101 changes: 101 additions & 0 deletions examples/KitchenSink/app/app_delegate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)

@form = Formotion::Form.new({
title: "Kitchen Sink",
sections: [{
title: "Section Title",
rows: [{
title: "Static",
type: :static,
}, {
title: "Email",
key: :email,
placeholder: "[email protected]",
type: :email,
auto_correction: :no,
auto_capitalization: :none
}, {
title: "Password",
key: :password,
placeholder: "required",
type: :string,
secure: true
}, {
title: "Phone",
key: :phone,
placeholder: "555-555-5555",
type: :phone,
auto_correction: :no,
auto_capitalization: :none
}, {
title: "Number",
key: :number,
placeholder: "12345",
type: :number,
auto_correction: :no,
auto_capitalization: :none
}, {
title: "Subtitle",
subtitle: "Confirmation",
key: :confirm,
placeholder: "required",
type: :string,
secure: true
}, {
title: "Remember?",
key: :remember,
type: :switch,
}]
}, {
title: "Select One",
key: :account_type,
select_one: true,
rows: [{
title: "A",
key: :a,
type: :check,
}, {
title: "B (value: true)",
value: true,
key: :b,
type: :check,
}, {
title: "C",
key: :c,
type: :check,
}]
}, {
rows: [{
title: "Submit",
type: :submit,
}]
}]
})

@navigation_controller = UINavigationController.alloc.init

@view_controller = Formotion::FormController.alloc.initWithForm(@form)
@view_controller.form.on_submit do |form|
alert = UIAlertView.alloc.init
alert.title = "@form.render"
alert.message = @form.render.to_s
alert.addButtonWithTitle("OK")
alert.show
end

@view_controller.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemSave, target:self, action:'submit')

@navigation_controller = UINavigationController.alloc.initWithRootViewController(@view_controller)

@window.rootViewController = @navigation_controller
@window.makeKeyAndVisible

true
end

def submit
@form.submit
end
end
9 changes: 9 additions & 0 deletions examples/KitchenSink/spec/main_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe "Application 'KitchenSink'" do
before do
@app = UIApplication.sharedApplication
end

it "has one window" do
@app.windows.size.should == 1
end
end

0 comments on commit da8d808

Please sign in to comment.