Skip to content

Commit 60ebfb3

Browse files
committed
Added example of persistence
1 parent 67e0ec0 commit 60ebfb3

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

examples/Persistence/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.repl_history
2+
build
3+
resources/*.nib
4+
resources/*.momd
5+
resources/*.storyboardc

examples/Persistence/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Persistence example in Formotion
2+
3+
![Persistence](http://i.imgur.com/fdCfV.png)

examples/Persistence/Rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
$:.unshift("/Library/RubyMotion/lib")
3+
require 'motion/project'
4+
require '../../lib/formotion'
5+
6+
Motion::Project::App.setup do |app|
7+
# Use `rake config' to see complete project settings.
8+
app.name = 'KitchenSink'
9+
end
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
class AppDelegate
2+
def application(application, didFinishLaunchingWithOptions:launchOptions)
3+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4+
5+
@form = Formotion::Form.new({
6+
title: "Persist Example",
7+
persist: true,
8+
sections: [{
9+
title: "Section Title",
10+
footer: "This is the footer for the section. It's good for displaying detailed data about the section.",
11+
rows: [{
12+
title: "Static",
13+
type: :static,
14+
}, {
15+
title: "Email",
16+
key: :email,
17+
placeholder: "[email protected]",
18+
type: :email,
19+
auto_correction: :no,
20+
auto_capitalization: :none
21+
}, {
22+
title: "Gender",
23+
key: :gender,
24+
type: :options,
25+
items: ['Female', 'Male']
26+
}, {
27+
title: "Password",
28+
key: :password,
29+
placeholder: "required",
30+
type: :string,
31+
secure: true
32+
}, {
33+
title: "Phone",
34+
key: :phone,
35+
placeholder: "555-555-5555",
36+
type: :phone,
37+
auto_correction: :no,
38+
auto_capitalization: :none
39+
}, {
40+
title: "Number",
41+
key: :number,
42+
placeholder: "12345",
43+
type: :number,
44+
auto_correction: :no,
45+
auto_capitalization: :none
46+
}, {
47+
title: "Subtitle",
48+
subtitle: "Confirmation",
49+
key: :confirm,
50+
placeholder: "required",
51+
type: :string,
52+
secure: true
53+
}, {
54+
title: "Row Height",
55+
key: :row_height,
56+
placeholder: "60px",
57+
type: :string,
58+
row_height: 60
59+
}, {
60+
title: "Text",
61+
key: :text,
62+
type: :text,
63+
placeholder: "Enter your text here",
64+
row_height: 100
65+
}, {
66+
title: "Check",
67+
key: :check,
68+
type: :check,
69+
value: true
70+
}, {
71+
title: "Remember?",
72+
key: :remember,
73+
type: :switch,
74+
}, {
75+
title: "Date Full",
76+
subtitle: "w/ :value",
77+
value: 326937600,
78+
key: :date_long,
79+
type: :date,
80+
format: :full
81+
}, {
82+
title: "Date Medium",
83+
subtitle: "w/ :value",
84+
value: 1341273600,
85+
key: :date_medium,
86+
type: :date,
87+
format: :medium
88+
}, {
89+
title: "Date Short",
90+
subtitle: "w/ :placeholder",
91+
placeholder: "DOB",
92+
key: :date_short,
93+
type: :date,
94+
format: :short
95+
}, {
96+
title: "Slider",
97+
key: :slider,
98+
type: :slider,
99+
range: (1..100),
100+
value: 25
101+
}]
102+
}]
103+
})
104+
105+
@view_controller = Formotion::FormController.alloc.initWithForm(@form)
106+
@view_controller.form.on_submit do |form|
107+
form.active_row && form.active_row.text_field.resignFirstResponder
108+
alert = UIAlertView.alloc.init
109+
alert.title = "@form.render"
110+
alert.message = @form.render.to_s
111+
alert.addButtonWithTitle("OK")
112+
alert.show
113+
end
114+
115+
@navigation_controller = UINavigationController.alloc.initWithRootViewController(@view_controller)
116+
117+
@window.rootViewController = @navigation_controller
118+
@window.makeKeyAndVisible
119+
120+
true
121+
end
122+
123+
def submit
124+
@form.submit
125+
end
126+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
describe "Application 'KitchenSink'" do
2+
before do
3+
@app = UIApplication.sharedApplication
4+
end
5+
6+
it "has one window" do
7+
@app.windows.size.should == 1
8+
end
9+
end

0 commit comments

Comments
 (0)