formotion 0.0.3 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +6 -0
- data/LIST_OF_ROW_TYPES.md +163 -0
- data/NEW_ROW_TYPES.md +73 -0
- data/README.md +11 -14
- data/Rakefile +6 -0
- data/app/app_delegate.rb +22 -0
- data/examples/KitchenSink/Rakefile +1 -1
- data/examples/KitchenSink/app/app_delegate.rb +50 -2
- data/examples/Login/.gitignore +5 -0
- data/examples/Login/Rakefile +9 -0
- data/examples/Login/app/app_delegate.rb +16 -0
- data/examples/Login/app/login_controller.rb +47 -0
- data/examples/Login/app/user_controller.rb +38 -0
- data/examples/Login/spec/main_spec.rb +9 -0
- data/lib/formotion.rb +7 -1
- data/lib/formotion/{form.rb → form/form.rb} +0 -0
- data/lib/formotion/{form_delegate.rb → form/form_delegate.rb} +10 -15
- data/lib/formotion/patch/object.rb +9 -0
- data/lib/formotion/patch/ui_action_sheet.rb +27 -0
- data/lib/formotion/patch/ui_text_view.rb +122 -0
- data/lib/formotion/patch/ui_text_view_placeholder.rb +65 -0
- data/lib/formotion/{row.rb → row/row.rb} +37 -27
- data/lib/formotion/row/row_cell_builder.rb +28 -0
- data/lib/formotion/row_type/base.rb +41 -0
- data/lib/formotion/row_type/check_row.rb +30 -0
- data/lib/formotion/row_type/date_row.rb +61 -0
- data/lib/formotion/row_type/email_row.rb +11 -0
- data/lib/formotion/row_type/image_row.rb +99 -0
- data/lib/formotion/row_type/number_row.rb +11 -0
- data/lib/formotion/row_type/options_row.rb +24 -0
- data/lib/formotion/row_type/phone_row.rb +11 -0
- data/lib/formotion/row_type/row_type.rb +21 -0
- data/lib/formotion/row_type/slider_row.rb +43 -0
- data/lib/formotion/row_type/static_row.rb +6 -0
- data/lib/formotion/row_type/string_row.rb +112 -0
- data/lib/formotion/row_type/submit_row.rb +34 -0
- data/lib/formotion/row_type/switch_row.rb +19 -0
- data/lib/formotion/row_type/text_row.rb +76 -0
- data/lib/formotion/{section.rb → section/section.rb} +3 -0
- data/lib/formotion/version.rb +1 -1
- data/spec/form_spec.rb +5 -4
- data/spec/functional/character_spec.rb +70 -0
- data/spec/functional/check_row_spec.rb +42 -0
- data/spec/functional/date_row_spec.rb +63 -0
- data/spec/functional/image_row_spec.rb +82 -0
- data/spec/functional/options_row_spec.rb +27 -0
- data/spec/functional/slider_row_spec.rb +27 -0
- data/spec/functional/submit_row_spec.rb +30 -0
- data/spec/functional/switch_row_spec.rb +28 -0
- data/spec/functional/text_row_spec.rb +60 -0
- data/spec/row_type/check_spec.rb +27 -0
- data/spec/row_type/date_spec.rb +69 -0
- data/spec/row_type/email_spec.rb +22 -0
- data/spec/row_type/image_spec.rb +43 -0
- data/spec/row_type/number_spec.rb +22 -0
- data/spec/row_type/options_spec.rb +37 -0
- data/spec/row_type/phone_spec.rb +22 -0
- data/spec/row_type/slider_spec.rb +47 -0
- data/spec/row_type/static_spec.rb +15 -0
- data/spec/row_type/string_spec.rb +52 -0
- data/spec/row_type/submit_spec.rb +28 -0
- data/spec/row_type/switch_spec.rb +27 -0
- data/spec/row_type/text_spec.rb +41 -0
- data/spec/support/ui_control_wrap_extension.rb +7 -0
- metadata +88 -9
- data/lib/formotion/row_cell_builder.rb +0 -168
- data/lib/formotion/row_type.rb +0 -33
@@ -0,0 +1,15 @@
|
|
1
|
+
describe "Static Row" do
|
2
|
+
before do
|
3
|
+
row_settings = {
|
4
|
+
title: "Static",
|
5
|
+
key: :static,
|
6
|
+
type: :static,
|
7
|
+
}
|
8
|
+
@row = Formotion::Row.new(row_settings)
|
9
|
+
@row.reuse_identifier = 'test'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize with correct settings" do
|
13
|
+
@row.object.class.should == Formotion::RowType::StaticRow
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Tests character row behavior on a string type
|
2
|
+
describe "String Row Type" do
|
3
|
+
before do
|
4
|
+
row_settings = {
|
5
|
+
title: "String",
|
6
|
+
key: :string,
|
7
|
+
type: :string,
|
8
|
+
}
|
9
|
+
@row = Formotion::Row.new(row_settings)
|
10
|
+
@row.reuse_identifier = 'test'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should initialize with correct settings" do
|
14
|
+
@row.object.class.should == Formotion::RowType::StringRow
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should build cell with textfield" do
|
18
|
+
cell = @row.make_cell
|
19
|
+
@row.text_field.class.should == UITextField
|
20
|
+
end
|
21
|
+
|
22
|
+
# Value
|
23
|
+
it "should have no value by default" do
|
24
|
+
cell = @row.make_cell
|
25
|
+
@row.text_field.text.should == ''
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should use custom value" do
|
29
|
+
@row.value = 'init value'
|
30
|
+
cell = @row.make_cell
|
31
|
+
|
32
|
+
@row.text_field.text.should == 'init value'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Placeholder
|
36
|
+
it "should have no placeholder by default" do
|
37
|
+
cell = @row.make_cell
|
38
|
+
@row.text_field.placeholder.should == nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should use custom placeholder" do
|
42
|
+
@row.placeholder = 'placeholder'
|
43
|
+
cell = @row.make_cell
|
44
|
+
@row.text_field.placeholder.should == 'placeholder'
|
45
|
+
end
|
46
|
+
|
47
|
+
# Keyboard
|
48
|
+
it "should use default keyboard" do
|
49
|
+
cell = @row.make_cell
|
50
|
+
@row.text_field.keyboardType.should == UIKeyboardTypeDefault
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
describe "Submit Row" do
|
2
|
+
before do
|
3
|
+
row_settings = {
|
4
|
+
title: "Submit",
|
5
|
+
key: :submit,
|
6
|
+
type: :submit,
|
7
|
+
}
|
8
|
+
@row = Formotion::Row.new(row_settings)
|
9
|
+
@row.reuse_identifier = 'test'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize with correct settings" do
|
13
|
+
@row.object.class.should == Formotion::RowType::SubmitRow
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should submit on select" do
|
17
|
+
fake_delegate = FakeDelegateClass.new
|
18
|
+
@row.object.on_select(nil, fake_delegate)
|
19
|
+
fake_delegate.submit_called.should == true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class FakeDelegateClass
|
24
|
+
attr_accessor :submit_called
|
25
|
+
def submit
|
26
|
+
self.submit_called = true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe "Switch Row" do
|
2
|
+
before do
|
3
|
+
row_settings = {
|
4
|
+
title: "Switch",
|
5
|
+
key: :switch,
|
6
|
+
type: :switch,
|
7
|
+
}
|
8
|
+
@row = Formotion::Row.new(row_settings)
|
9
|
+
@row.reuse_identifier = 'test'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize with correct settings" do
|
13
|
+
@row.object.class.should == Formotion::RowType::SwitchRow
|
14
|
+
end
|
15
|
+
|
16
|
+
# Value
|
17
|
+
it "should be off by default" do
|
18
|
+
cell = @row.make_cell
|
19
|
+
cell.accessoryView.on?.should == false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be on when true" do
|
23
|
+
@row.value = true
|
24
|
+
cell = @row.make_cell
|
25
|
+
cell.accessoryView.on?.should == true
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
describe "Text Row" do
|
2
|
+
before do
|
3
|
+
row_settings = {
|
4
|
+
title: "Text",
|
5
|
+
key: :text,
|
6
|
+
type: :text,
|
7
|
+
}
|
8
|
+
@row = Formotion::Row.new(row_settings)
|
9
|
+
@row.reuse_identifier = 'test'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize with correct settings" do
|
13
|
+
@row.object.class.should == Formotion::RowType::TextRow
|
14
|
+
end
|
15
|
+
|
16
|
+
# Value
|
17
|
+
it "should have no value by default" do
|
18
|
+
cell = @row.make_cell
|
19
|
+
@row.text_field.text.should == ''
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should use custom value" do
|
23
|
+
@row.value = 'init value'
|
24
|
+
cell = @row.make_cell
|
25
|
+
|
26
|
+
@row.text_field.text.should == 'init value'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Placeholder
|
30
|
+
it "should have no placeholder by default" do
|
31
|
+
cell = @row.make_cell
|
32
|
+
@row.text_field.placeholder.should == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should use custom placeholder" do
|
36
|
+
@row.placeholder = 'placeholder'
|
37
|
+
cell = @row.make_cell
|
38
|
+
@row.text_field.placeholder.should == 'placeholder'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bubble-wrap
|
@@ -51,8 +51,12 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- CHANGELOG.md
|
54
55
|
- Formotion.gemspec
|
56
|
+
- Gemfile
|
55
57
|
- LICENSE
|
58
|
+
- LIST_OF_ROW_TYPES.md
|
59
|
+
- NEW_ROW_TYPES.md
|
56
60
|
- README.md
|
57
61
|
- Rakefile
|
58
62
|
- app/app_delegate.rb
|
@@ -61,21 +65,68 @@ files:
|
|
61
65
|
- examples/KitchenSink/Rakefile
|
62
66
|
- examples/KitchenSink/app/app_delegate.rb
|
63
67
|
- examples/KitchenSink/spec/main_spec.rb
|
68
|
+
- examples/Login/.gitignore
|
69
|
+
- examples/Login/Rakefile
|
70
|
+
- examples/Login/app/app_delegate.rb
|
71
|
+
- examples/Login/app/login_controller.rb
|
72
|
+
- examples/Login/app/user_controller.rb
|
73
|
+
- examples/Login/spec/main_spec.rb
|
64
74
|
- lib/formotion.rb
|
65
75
|
- lib/formotion/base.rb
|
66
76
|
- lib/formotion/exceptions.rb
|
67
|
-
- lib/formotion/form.rb
|
77
|
+
- lib/formotion/form/form.rb
|
78
|
+
- lib/formotion/form/form_delegate.rb
|
68
79
|
- lib/formotion/form_controller.rb
|
69
|
-
- lib/formotion/
|
80
|
+
- lib/formotion/patch/object.rb
|
81
|
+
- lib/formotion/patch/ui_action_sheet.rb
|
70
82
|
- lib/formotion/patch/ui_text_field.rb
|
71
|
-
- lib/formotion/
|
72
|
-
- lib/formotion/
|
73
|
-
- lib/formotion/
|
74
|
-
- lib/formotion/
|
83
|
+
- lib/formotion/patch/ui_text_view.rb
|
84
|
+
- lib/formotion/patch/ui_text_view_placeholder.rb
|
85
|
+
- lib/formotion/row/row.rb
|
86
|
+
- lib/formotion/row/row_cell_builder.rb
|
87
|
+
- lib/formotion/row_type/base.rb
|
88
|
+
- lib/formotion/row_type/check_row.rb
|
89
|
+
- lib/formotion/row_type/date_row.rb
|
90
|
+
- lib/formotion/row_type/email_row.rb
|
91
|
+
- lib/formotion/row_type/image_row.rb
|
92
|
+
- lib/formotion/row_type/number_row.rb
|
93
|
+
- lib/formotion/row_type/options_row.rb
|
94
|
+
- lib/formotion/row_type/phone_row.rb
|
95
|
+
- lib/formotion/row_type/row_type.rb
|
96
|
+
- lib/formotion/row_type/slider_row.rb
|
97
|
+
- lib/formotion/row_type/static_row.rb
|
98
|
+
- lib/formotion/row_type/string_row.rb
|
99
|
+
- lib/formotion/row_type/submit_row.rb
|
100
|
+
- lib/formotion/row_type/switch_row.rb
|
101
|
+
- lib/formotion/row_type/text_row.rb
|
102
|
+
- lib/formotion/section/section.rb
|
75
103
|
- lib/formotion/version.rb
|
76
104
|
- spec/form_spec.rb
|
105
|
+
- spec/functional/character_spec.rb
|
106
|
+
- spec/functional/check_row_spec.rb
|
107
|
+
- spec/functional/date_row_spec.rb
|
108
|
+
- spec/functional/image_row_spec.rb
|
109
|
+
- spec/functional/options_row_spec.rb
|
110
|
+
- spec/functional/slider_row_spec.rb
|
111
|
+
- spec/functional/submit_row_spec.rb
|
112
|
+
- spec/functional/switch_row_spec.rb
|
113
|
+
- spec/functional/text_row_spec.rb
|
77
114
|
- spec/row_spec.rb
|
115
|
+
- spec/row_type/check_spec.rb
|
116
|
+
- spec/row_type/date_spec.rb
|
117
|
+
- spec/row_type/email_spec.rb
|
118
|
+
- spec/row_type/image_spec.rb
|
119
|
+
- spec/row_type/number_spec.rb
|
120
|
+
- spec/row_type/options_spec.rb
|
121
|
+
- spec/row_type/phone_spec.rb
|
122
|
+
- spec/row_type/slider_spec.rb
|
123
|
+
- spec/row_type/static_spec.rb
|
124
|
+
- spec/row_type/string_spec.rb
|
125
|
+
- spec/row_type/submit_spec.rb
|
126
|
+
- spec/row_type/switch_spec.rb
|
127
|
+
- spec/row_type/text_spec.rb
|
78
128
|
- spec/section_spec.rb
|
129
|
+
- spec/support/ui_control_wrap_extension.rb
|
79
130
|
homepage: https://github.com/clayallsopp/Formotion
|
80
131
|
licenses: []
|
81
132
|
post_install_message:
|
@@ -88,12 +139,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
139
|
- - ! '>='
|
89
140
|
- !ruby/object:Gem::Version
|
90
141
|
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: -3547767700420537743
|
91
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
146
|
none: false
|
93
147
|
requirements:
|
94
148
|
- - ! '>='
|
95
149
|
- !ruby/object:Gem::Version
|
96
150
|
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: -3547767700420537743
|
97
154
|
requirements: []
|
98
155
|
rubyforge_project:
|
99
156
|
rubygems_version: 1.8.24
|
@@ -102,6 +159,28 @@ specification_version: 3
|
|
102
159
|
summary: Making iOS Forms insanely great with RubyMotion
|
103
160
|
test_files:
|
104
161
|
- spec/form_spec.rb
|
162
|
+
- spec/functional/character_spec.rb
|
163
|
+
- spec/functional/check_row_spec.rb
|
164
|
+
- spec/functional/date_row_spec.rb
|
165
|
+
- spec/functional/image_row_spec.rb
|
166
|
+
- spec/functional/options_row_spec.rb
|
167
|
+
- spec/functional/slider_row_spec.rb
|
168
|
+
- spec/functional/submit_row_spec.rb
|
169
|
+
- spec/functional/switch_row_spec.rb
|
170
|
+
- spec/functional/text_row_spec.rb
|
105
171
|
- spec/row_spec.rb
|
172
|
+
- spec/row_type/check_spec.rb
|
173
|
+
- spec/row_type/date_spec.rb
|
174
|
+
- spec/row_type/email_spec.rb
|
175
|
+
- spec/row_type/image_spec.rb
|
176
|
+
- spec/row_type/number_spec.rb
|
177
|
+
- spec/row_type/options_spec.rb
|
178
|
+
- spec/row_type/phone_spec.rb
|
179
|
+
- spec/row_type/slider_spec.rb
|
180
|
+
- spec/row_type/static_spec.rb
|
181
|
+
- spec/row_type/string_spec.rb
|
182
|
+
- spec/row_type/submit_spec.rb
|
183
|
+
- spec/row_type/switch_spec.rb
|
184
|
+
- spec/row_type/text_spec.rb
|
106
185
|
- spec/section_spec.rb
|
107
|
-
|
186
|
+
- spec/support/ui_control_wrap_extension.rb
|
@@ -1,168 +0,0 @@
|
|
1
|
-
#################
|
2
|
-
#
|
3
|
-
# Formotion::RowCellBuilder
|
4
|
-
# RowCellBuilder handles taking Formotion::Rows
|
5
|
-
# and configuring UITableViewCells based on their properties.
|
6
|
-
#
|
7
|
-
#################
|
8
|
-
module Formotion
|
9
|
-
class RowCellBuilder
|
10
|
-
# The new UITextField in a UITableViewCell
|
11
|
-
# will be assigned this tag, if applicable.
|
12
|
-
TEXT_FIELD_TAG=1000
|
13
|
-
|
14
|
-
# PARAMS row.is_a? Formotion::Row
|
15
|
-
# RETURNS [cell configured to that row, a UITextField for that row if applicable or nil]
|
16
|
-
def self.make_cell(row)
|
17
|
-
cell, text_field = nil
|
18
|
-
|
19
|
-
cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier:row.reuse_identifier)
|
20
|
-
|
21
|
-
cell.accessoryType = UITableViewCellAccessoryNone
|
22
|
-
cell.textLabel.text = row.title
|
23
|
-
cell.detailTextLabel.text = row.subtitle
|
24
|
-
|
25
|
-
if row.submit_button?
|
26
|
-
make_submit_cell(row, cell)
|
27
|
-
elsif row.switchable?
|
28
|
-
make_switch_cell(row, cell)
|
29
|
-
elsif row.checkable?
|
30
|
-
make_check_cell(row, cell)
|
31
|
-
elsif row.editable?
|
32
|
-
text_field = make_text_field(row, cell)
|
33
|
-
end
|
34
|
-
[cell, text_field]
|
35
|
-
end
|
36
|
-
|
37
|
-
# This is actually called whenever again cell is checked/unchecked
|
38
|
-
# in the UITableViewDelegate callbacks. So (for now) don't
|
39
|
-
# instantiate long-lived objects in them.
|
40
|
-
# Maybe that logic should be moved elsewhere?
|
41
|
-
def self.make_check_cell(row, cell)
|
42
|
-
cell.accessoryType = row.value ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.make_switch_cell(row, cell)
|
46
|
-
cell.selectionStyle = UITableViewCellSelectionStyleNone
|
47
|
-
switchView = UISwitch.alloc.initWithFrame(CGRectZero)
|
48
|
-
cell.accessoryView = switchView
|
49
|
-
switchView.setOn(row.value || false, animated:false)
|
50
|
-
switchView.when(UIControlEventValueChanged) do
|
51
|
-
row.value = switchView.isOn
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Does a clever little trick to override #layoutSubviews
|
56
|
-
# for just this one UITableViewCell object, in order to
|
57
|
-
# center it's labels horizontally.
|
58
|
-
def self.make_submit_cell(row, cell)
|
59
|
-
cell.class.send(:alias_method, :old_layoutSubviews, :layoutSubviews)
|
60
|
-
cell.instance_eval do
|
61
|
-
def layoutSubviews
|
62
|
-
old_layoutSubviews
|
63
|
-
|
64
|
-
center = lambda {|frame, dimen|
|
65
|
-
((self.frame.size.send(dimen) - frame.size.send(dimen)) / 2.0)
|
66
|
-
}
|
67
|
-
|
68
|
-
self.textLabel.center = CGPointMake(self.frame.size.width / 2 - 10, self.textLabel.center.y)
|
69
|
-
self.detailTextLabel.center = CGPointMake(self.frame.size.width / 2 - 10, self.detailTextLabel.center.y)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Configures the cell to have a new UITextField
|
75
|
-
# which is used to enter data. Consists of
|
76
|
-
# 1) setting up that field with the appropriate properties
|
77
|
-
# specified by `row` 2) configures the callbacks on the field
|
78
|
-
# to call any callbacks `row` listens for.
|
79
|
-
# Also does the layoutSubviews swizzle trick
|
80
|
-
# to size the UITextField so it won't bump into the titleLabel.
|
81
|
-
def self.make_text_field(row, cell)
|
82
|
-
field = UITextField.alloc.initWithFrame(CGRectZero)
|
83
|
-
field.tag = TEXT_FIELD_TAG
|
84
|
-
|
85
|
-
field.placeholder = row.placeholder
|
86
|
-
field.text = row.value
|
87
|
-
|
88
|
-
field.clearButtonMode = UITextFieldViewModeWhileEditing
|
89
|
-
field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter
|
90
|
-
field.textAlignment = UITextAlignmentRight
|
91
|
-
|
92
|
-
case row.type
|
93
|
-
when RowType::EMAIL
|
94
|
-
field.keyboardType = UIKeyboardTypeEmailAddress
|
95
|
-
when RowType::PHONE
|
96
|
-
field.keyboardType = UIKeyboardTypePhonePad
|
97
|
-
when RowType::NUMBER
|
98
|
-
field.keyboardType = UIKeyboardTypeDecimalPad
|
99
|
-
else
|
100
|
-
field.keyboardType = UIKeyboardTypeDefault
|
101
|
-
end
|
102
|
-
|
103
|
-
field.secureTextEntry = true if row.secure?
|
104
|
-
field.returnKeyType = row.return_key || UIReturnKeyNext
|
105
|
-
field.autocapitalizationType = row.auto_capitalization if row.auto_capitalization
|
106
|
-
field.autocorrectionType = row.auto_correction if row.auto_correction
|
107
|
-
field.clearButtonMode = row.clear_button || UITextFieldViewModeWhileEditing
|
108
|
-
|
109
|
-
if row.on_enter_callback
|
110
|
-
field.should_return? do |text_field|
|
111
|
-
if row.on_enter_callback.arity == 0
|
112
|
-
row.on_enter_callback.call
|
113
|
-
elsif row.on_enter_callback.arity == 1
|
114
|
-
row.on_enter_callback.call(row)
|
115
|
-
end
|
116
|
-
false
|
117
|
-
end
|
118
|
-
elsif field.returnKeyType == UIReturnKeyDone
|
119
|
-
field.should_return? do |text_field|
|
120
|
-
text_field.resignFirstResponder
|
121
|
-
false
|
122
|
-
end
|
123
|
-
else
|
124
|
-
field.should_return? do |text_field|
|
125
|
-
if row.next_row && row.next_row.text_field
|
126
|
-
row.next_row.text_field.becomeFirstResponder
|
127
|
-
else
|
128
|
-
text_field.resignFirstResponder
|
129
|
-
end
|
130
|
-
true
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
field.on_begin do |text_field|
|
135
|
-
row.on_begin_callback && row.on_begin_callback.call
|
136
|
-
end
|
137
|
-
|
138
|
-
field.should_begin? do |text_field|
|
139
|
-
row.section.form.active_row = row
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
field.on_change do |text_field|
|
144
|
-
row.value = text_field.text
|
145
|
-
end
|
146
|
-
|
147
|
-
cell.class.send(:alias_method, :old_layoutSubviews, :layoutSubviews)
|
148
|
-
cell.instance_eval do
|
149
|
-
def layoutSubviews
|
150
|
-
old_layoutSubviews
|
151
|
-
|
152
|
-
# viewWithTag is terrible, but I think it's ok to use here...
|
153
|
-
formotion_field = self.viewWithTag(Formotion::RowCellBuilder::TEXT_FIELD_TAG)
|
154
|
-
formotion_field.sizeToFit
|
155
|
-
|
156
|
-
field_frame = formotion_field.frame
|
157
|
-
field_frame.origin.x = self.textLabel.frame.origin.x + self.textLabel.frame.size.width + 20
|
158
|
-
field_frame.origin.y = ((self.frame.size.height - field_frame.size.height) / 2.0).round
|
159
|
-
field_frame.size.width = self.frame.size.width - field_frame.origin.x - 20
|
160
|
-
formotion_field.frame = field_frame
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
cell.addSubview(field)
|
165
|
-
field
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|