forked from clayallsopp/formotion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3eb60
commit da8d808
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.repl_history | ||
build | ||
resources/*.nib | ||
resources/*.momd | ||
resources/*.storyboardc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |