formotion 0.0.3 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,16 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
4
|
+
|
5
|
+
@navigation_controller = UINavigationController.alloc.initWithRootViewController(UserController.controller)
|
6
|
+
@window.rootViewController = @navigation_controller
|
7
|
+
@window.makeKeyAndVisible
|
8
|
+
|
9
|
+
@login = LoginController.alloc.init
|
10
|
+
@login_navigation = UINavigationController.alloc.initWithRootViewController(@login)
|
11
|
+
|
12
|
+
UserController.controller.presentModalViewController(@login_navigation, animated:false)
|
13
|
+
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class LoginController < Formotion::FormController
|
2
|
+
def init
|
3
|
+
form = Formotion::Form.new({
|
4
|
+
title: "Login",
|
5
|
+
sections: [{
|
6
|
+
rows: [{
|
7
|
+
title: "User Name",
|
8
|
+
type: :string,
|
9
|
+
placeholder: "name",
|
10
|
+
key: :user
|
11
|
+
}, {
|
12
|
+
title: "Password",
|
13
|
+
type: :string,
|
14
|
+
placeholder: "password",
|
15
|
+
key: :password,
|
16
|
+
secure: true
|
17
|
+
}, {
|
18
|
+
title: "Remember?",
|
19
|
+
type: :switch,
|
20
|
+
key: :remember,
|
21
|
+
value: true
|
22
|
+
}]
|
23
|
+
}, {
|
24
|
+
rows: [{
|
25
|
+
title: "Login",
|
26
|
+
type: :submit,
|
27
|
+
}]
|
28
|
+
}]
|
29
|
+
})
|
30
|
+
form.on_submit do
|
31
|
+
self.login
|
32
|
+
end
|
33
|
+
super.initWithForm(form)
|
34
|
+
end
|
35
|
+
|
36
|
+
def viewDidLoad
|
37
|
+
super
|
38
|
+
self.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithTitle("Login", style: UIBarButtonItemStyleDone, target:self, action:'login')
|
39
|
+
end
|
40
|
+
|
41
|
+
def login
|
42
|
+
[:user, :password, :remember].each { |prop|
|
43
|
+
UserController.controller.send(prop.to_s + "=", form.render[prop])
|
44
|
+
}
|
45
|
+
self.navigationController.dismissModalViewControllerAnimated(true)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class UserController < UIViewController
|
2
|
+
def self.controller
|
3
|
+
@controller ||= UserController.alloc.initWithNibName(nil, bundle: nil)
|
4
|
+
end
|
5
|
+
|
6
|
+
def viewDidLoad
|
7
|
+
super
|
8
|
+
|
9
|
+
self.view.backgroundColor = UIColor.whiteColor
|
10
|
+
|
11
|
+
@user_label = UILabel.alloc.initWithFrame(CGRectZero)
|
12
|
+
self.view.addSubview(@user_label)
|
13
|
+
|
14
|
+
@password_label = UILabel.alloc.initWithFrame(CGRectZero)
|
15
|
+
self.view.addSubview(@password_label)
|
16
|
+
|
17
|
+
@remember_label = UILabel.alloc.initWithFrame(CGRectZero)
|
18
|
+
self.view.addSubview(@remember_label)
|
19
|
+
end
|
20
|
+
|
21
|
+
def user=(user)
|
22
|
+
@user_label.text = "User: #{user}"
|
23
|
+
@user_label.sizeToFit
|
24
|
+
@user_label.center = [self.view.frame.size.width/2, self.view.frame.size.height/2 - 40]
|
25
|
+
end
|
26
|
+
|
27
|
+
def password=(password)
|
28
|
+
@password_label.text = "Password: #{password}"
|
29
|
+
@password_label.sizeToFit
|
30
|
+
@password_label.center = [@user_label.center.x, @user_label.center.y + @password_label.bounds.size.height]
|
31
|
+
end
|
32
|
+
|
33
|
+
def remember=(remember)
|
34
|
+
@remember_label.text = "Remember? #{remember}"
|
35
|
+
@remember_label.sizeToFit
|
36
|
+
@remember_label.center = [@password_label.center.x, @password_label.center.y + @remember_label.bounds.size.height]
|
37
|
+
end
|
38
|
+
end
|
data/lib/formotion.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
require "formotion/version"
|
2
2
|
require 'bubble-wrap/core'
|
3
|
+
require 'bubble-wrap/camera'
|
3
4
|
|
4
5
|
BW.require File.expand_path('../formotion/**/*.rb', __FILE__) do
|
5
|
-
|
6
|
+
file("lib/formotion/row_type/string_row.rb").depends_on 'lib/formotion/row_type/base.rb'
|
7
|
+
['date_row', 'email_row', 'number_row', 'phone_row'].each {|file|
|
8
|
+
file("lib/formotion/row_type/#{file}.rb").depends_on 'lib/formotion/row_type/string_row.rb'
|
9
|
+
}
|
10
|
+
|
11
|
+
['form/form.rb', 'row/row.rb', 'section/section.rb'].each {|file|
|
6
12
|
file("lib/formotion/#{file}").depends_on 'lib/formotion/base.rb'
|
7
13
|
}
|
8
14
|
file("lib/formotion/form_controller.rb").depends_on 'lib/formotion/patch/ui_text_field.rb'
|
File without changes
|
@@ -52,6 +52,10 @@ module Formotion
|
|
52
52
|
section = self.sections[section].title
|
53
53
|
end
|
54
54
|
|
55
|
+
def tableView(tableView, titleForFooterInSection:section)
|
56
|
+
self.sections[section].footer
|
57
|
+
end
|
58
|
+
|
55
59
|
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
56
60
|
row = row_for_index_path(indexPath)
|
57
61
|
reuseIdentifier = row.reuse_identifier
|
@@ -63,25 +67,16 @@ module Formotion
|
|
63
67
|
cell
|
64
68
|
end
|
65
69
|
|
70
|
+
def tableView(tableView, heightForRowAtIndexPath: indexPath)
|
71
|
+
row = row_for_index_path(indexPath)
|
72
|
+
row.rowHeight || tableView.rowHeight
|
73
|
+
end
|
74
|
+
|
66
75
|
# UITableViewDelegate Methods
|
67
76
|
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
|
68
77
|
tableView.deselectRowAtIndexPath(indexPath, animated:true)
|
69
78
|
row = row_for_index_path(indexPath)
|
70
|
-
|
71
|
-
self.submit
|
72
|
-
elsif row.checkable?
|
73
|
-
if row.section.select_one and !row.value
|
74
|
-
row.section.rows.each {|other_row|
|
75
|
-
other_row.value = (other_row == row)
|
76
|
-
Formotion::RowCellBuilder.make_check_cell(other_row, tableView.cellForRowAtIndexPath(other_row.index_path))
|
77
|
-
}
|
78
|
-
elsif !row.section.select_one
|
79
|
-
row.value = !row.value
|
80
|
-
Formotion::RowCellBuilder.make_check_cell(row, tableView.cellForRowAtIndexPath(row.index_path))
|
81
|
-
end
|
82
|
-
elsif row.editable?
|
83
|
-
row.text_field.becomeFirstResponder
|
84
|
-
end
|
79
|
+
row.object.on_select(tableView, self)
|
85
80
|
end
|
86
81
|
end
|
87
82
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# To make accessibility labels work in UIActionSheets
|
2
|
+
# adapted from https://gist.github.com/953326
|
3
|
+
|
4
|
+
class UIActionSheet
|
5
|
+
|
6
|
+
alias_method :old_addButtonWithTitle, :addButtonWithTitle
|
7
|
+
|
8
|
+
def addButtonWithTitle(title)
|
9
|
+
button_index = old_addButtonWithTitle(title)
|
10
|
+
self.subviews.each { |subview|
|
11
|
+
if subview.respond_to? :title
|
12
|
+
controlTitle = subview.send(:title)
|
13
|
+
if (title == controlTitle)
|
14
|
+
copyAccessibilityMetadataFrom(title, toControl: subview)
|
15
|
+
return button_index
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}
|
19
|
+
button_index
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def copyAccessibilityMetadataFrom(title, toControl:control)
|
24
|
+
control.accessibilityLabel = title
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# Methods which use blocks for UITextViewDelegate methods.
|
2
|
+
# EX
|
3
|
+
# field.should_end? do |text_field|
|
4
|
+
# if text_field.text != "secret"
|
5
|
+
# return false
|
6
|
+
# end
|
7
|
+
# true
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# Also includes an on_change method, which calls after the text
|
11
|
+
# has changed (there is no UITextViewDelegate equivalent.)
|
12
|
+
# EX
|
13
|
+
# field.on_change do |text_field|
|
14
|
+
# p text_field.text
|
15
|
+
# end
|
16
|
+
|
17
|
+
class UITextView
|
18
|
+
attr_accessor :menu_options_enabled
|
19
|
+
|
20
|
+
def canPerformAction(action, withSender:sender)
|
21
|
+
self.menu_options_enabled
|
22
|
+
end
|
23
|
+
|
24
|
+
# block takes argument textView; should return true/false
|
25
|
+
def should_begin?(&block)
|
26
|
+
add_delegate_method do
|
27
|
+
@delegate.textViewShouldBeginEditing_callback = block
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# block takes argument textView
|
32
|
+
def on_begin(&block)
|
33
|
+
add_delegate_method do
|
34
|
+
@delegate.textViewDidBeginEditing_callback = block
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# block takes argument textView; should return true/false
|
39
|
+
def should_end?(&block)
|
40
|
+
add_delegate_method do
|
41
|
+
@delegate.textViewShouldEndEditing_callback = block
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# block takes argument textView
|
46
|
+
def on_end(&block)
|
47
|
+
add_delegate_method do
|
48
|
+
@delegate.textViewDidEndEditing_callback = block
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# block takes argument textView
|
53
|
+
def on_change(&block)
|
54
|
+
add_delegate_method do
|
55
|
+
@delegate.textViewDidChange_callback = block
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# block takes argument textView, range [NSRange], and string; should return true/false
|
60
|
+
def should_change?(&block)
|
61
|
+
add_delegate_method do
|
62
|
+
@delegate.shouldChangeCharactersInRange_callback = block
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def add_delegate_method
|
68
|
+
# create strong reference to the delegate
|
69
|
+
# (.delegate= only creates a weak reference)
|
70
|
+
@delegate ||= UITextView_Delegate.new
|
71
|
+
yield
|
72
|
+
self.delegate = @delegate
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class UITextView_Delegate
|
77
|
+
[:textViewShouldBeginEditing, :textViewDidBeginEditing,
|
78
|
+
:textViewShouldEndEditing, :textViewDidEndEditing,
|
79
|
+
:textViewDidChange, :shouldChangeCharactersInRange].each {|method|
|
80
|
+
attr_accessor (method.to_s + "_callback").to_sym
|
81
|
+
}
|
82
|
+
|
83
|
+
def textViewShouldBeginEditing(theTextView)
|
84
|
+
if self.textViewShouldBeginEditing_callback
|
85
|
+
return self.textViewShouldBeginEditing_callback.call(theTextView)
|
86
|
+
end
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def textViewDidBeginEditing(theTextView)
|
91
|
+
if self.textViewDidBeginEditing_callback
|
92
|
+
return self.textViewDidBeginEditing_callback.call(theTextView)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def textViewShouldEndEditing(theTextView)
|
97
|
+
if self.textViewShouldEndEditing_callback
|
98
|
+
return self.textViewShouldEndEditing_callback.call(theTextView)
|
99
|
+
end
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def textView(textView, shouldChangeTextInRange:range, replacementText:text)
|
104
|
+
if self.shouldChangeCharactersInRange_callback
|
105
|
+
return self.shouldChangeCharactersInRange_callback.call(textView, range, text)
|
106
|
+
end
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
110
|
+
def textViewDidEndEditing(theTextView)
|
111
|
+
if self.textViewDidEndEditing_callback
|
112
|
+
return self.textViewDidEndEditing_callback.call(theTextView)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def textViewDidChange(theTextView)
|
117
|
+
if self.textViewDidChange_callback
|
118
|
+
self.textViewDidChange_callback.call(theTextView)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class UITextView
|
2
|
+
attr_reader :placeholder
|
3
|
+
attr_accessor :placeholder_color
|
4
|
+
|
5
|
+
alias_method :old_initWithCoder, :initWithCoder
|
6
|
+
def initWithCoder(decoder)
|
7
|
+
old_initWithCoder(decoder)
|
8
|
+
setup
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method :old_initWithFrame, :initWithFrame
|
13
|
+
def initWithFrame(frame)
|
14
|
+
old_initWithFrame(frame)
|
15
|
+
setup
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@foreground_observer = NSNotificationCenter.defaultCenter.observe UITextViewTextDidChangeNotification do |notification|
|
21
|
+
updateShouldDrawPlaceholder
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :old_drawRect, :drawRect
|
26
|
+
def drawRect(rect)
|
27
|
+
old_drawRect(rect)
|
28
|
+
|
29
|
+
if (@shouldDrawPlaceholder)
|
30
|
+
self.placeholder_color.set
|
31
|
+
self.placeholder.drawInRect(placeholder_rect, withFont:self.font)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
alias_method :old_setText, :setText
|
37
|
+
def setText(text)
|
38
|
+
old_setText(text)
|
39
|
+
|
40
|
+
updateShouldDrawPlaceholder
|
41
|
+
end
|
42
|
+
|
43
|
+
def placeholder=(placeholder)
|
44
|
+
return if @placeholder == placeholder
|
45
|
+
|
46
|
+
@placeholder = placeholder
|
47
|
+
|
48
|
+
updateShouldDrawPlaceholder
|
49
|
+
end
|
50
|
+
|
51
|
+
def placeholder_rect
|
52
|
+
CGRectMake(self.contentInset.left + 10.0, self.contentInset.top, self.frame.size.width - self.contentInset.left - self.contentInset.right - 16.0, self.frame.size.height - self.contentInset.top - self.contentInset.bottom - 16.0)
|
53
|
+
end
|
54
|
+
|
55
|
+
def placeholder_color
|
56
|
+
@placeholder_color ||= UIColor.lightGrayColor
|
57
|
+
end
|
58
|
+
|
59
|
+
def updateShouldDrawPlaceholder
|
60
|
+
prev = @shouldDrawPlaceholder;
|
61
|
+
@shouldDrawPlaceholder = self.placeholder && self.text.length == 0
|
62
|
+
|
63
|
+
self.setNeedsDisplay if (prev != @shouldDrawPlaceholder)
|
64
|
+
end
|
65
|
+
end
|
@@ -6,20 +6,23 @@ module Formotion
|
|
6
6
|
# the user's (or configured) value for this row.
|
7
7
|
:value,
|
8
8
|
# set as cell.titleLabel.text
|
9
|
-
:title,
|
9
|
+
:title,
|
10
10
|
# set as cell.detailLabel.text
|
11
11
|
:subtitle,
|
12
12
|
# configures the type of input this is (string, phone, switch, etc)
|
13
13
|
# either Formotion::RowType or a string/symbol representation of one
|
14
14
|
# see row_type.rb
|
15
15
|
:type,
|
16
|
+
# Stores possible formatting information (used by date pickers, etc)
|
17
|
+
# if :type == :date, accepts values in [:short, :medium, :long, :full]
|
18
|
+
:format,
|
16
19
|
|
17
20
|
# The following apply only to text-input fields
|
18
21
|
|
19
22
|
# placeholder text
|
20
23
|
:placeholder,
|
21
24
|
# whether or not the entry field is secure (like a password)
|
22
|
-
:secure,
|
25
|
+
:secure,
|
23
26
|
# given by a UIReturnKey___ integer, string, or symbol
|
24
27
|
# EX :default, :google
|
25
28
|
:return_key,
|
@@ -32,7 +35,20 @@ module Formotion
|
|
32
35
|
# field.clearButtonMode; given by a UITextFieldViewMode__ integer, string, symbol
|
33
36
|
# EX :never, :while_editing
|
34
37
|
# DEFAULT is nil, which is used as :while_editing
|
35
|
-
:clear_button
|
38
|
+
:clear_button,
|
39
|
+
# row height as integer; used for heightForRowAtIndexPath
|
40
|
+
# EX 200
|
41
|
+
# DEFAULT is nil, which is used as the tableView.rowHeight
|
42
|
+
:rowHeight,
|
43
|
+
# range used for slider min and max value
|
44
|
+
# EX (1..100)
|
45
|
+
# DEFAULT is (1..10)
|
46
|
+
:range,
|
47
|
+
# Array used for control row items
|
48
|
+
# EX ['free', 'pro']
|
49
|
+
# DEFAULT is []
|
50
|
+
:items,
|
51
|
+
]
|
36
52
|
PROPERTIES.each {|prop|
|
37
53
|
attr_accessor prop
|
38
54
|
}
|
@@ -62,6 +78,9 @@ module Formotion
|
|
62
78
|
# starts editing #text_field.
|
63
79
|
attr_accessor :on_begin_callback
|
64
80
|
|
81
|
+
# row type object
|
82
|
+
attr_accessor :object
|
83
|
+
|
65
84
|
def initialize(params = {})
|
66
85
|
super
|
67
86
|
|
@@ -74,7 +93,7 @@ module Formotion
|
|
74
93
|
# these should be done with alias_method but there's currently a bug
|
75
94
|
# in RM which messes up attr_accessors with alias_method
|
76
95
|
# EX
|
77
|
-
# row.
|
96
|
+
# row.secure?
|
78
97
|
# => true
|
79
98
|
# row.checkable?
|
80
99
|
# => nil
|
@@ -103,7 +122,7 @@ module Formotion
|
|
103
122
|
|
104
123
|
def next_row
|
105
124
|
# if there are more rows in this section, use that.
|
106
|
-
return self.section.rows[self.index + 1] if self.index < (self.section.rows.count - 1)
|
125
|
+
return self.section.rows[self.index + 1] if self.index < (self.section.rows.count - 1)
|
107
126
|
|
108
127
|
# if there are more sections, then use the first row of that section.
|
109
128
|
return self.section.next_section.rows[0] if self.section.next_section
|
@@ -112,7 +131,7 @@ module Formotion
|
|
112
131
|
end
|
113
132
|
|
114
133
|
def previous_row
|
115
|
-
return self.section.rows[self.index - 1] if self.index > 0
|
134
|
+
return self.section.rows[self.index - 1] if self.index > 0
|
116
135
|
|
117
136
|
# if there are more sections, then use the first row of that section.
|
118
137
|
return self.section.previous_section.rows[-1] if self.section.previous_section
|
@@ -120,41 +139,30 @@ module Formotion
|
|
120
139
|
nil
|
121
140
|
end
|
122
141
|
|
123
|
-
def editable?
|
124
|
-
Formotion::RowType::TEXT_FIELD_TYPES.member? self.type
|
125
|
-
end
|
126
|
-
|
127
142
|
def submit_button?
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
def switchable?
|
132
|
-
self.type == Formotion::RowType::SWITCH
|
133
|
-
end
|
134
|
-
|
135
|
-
def checkable?
|
136
|
-
self.type == Formotion::RowType::CHECK
|
143
|
+
object.submit_button?
|
137
144
|
end
|
138
145
|
|
139
146
|
#########################
|
140
147
|
# setter overrides
|
141
148
|
def type=(type)
|
142
|
-
@
|
149
|
+
@object = Formotion::RowType.for(type).new(self)
|
150
|
+
@type = type
|
143
151
|
end
|
144
152
|
|
145
153
|
def return_key=(value)
|
146
154
|
@return_key = const_int_get("UIReturnKey", value)
|
147
155
|
end
|
148
156
|
|
149
|
-
def auto_correction=(value)
|
157
|
+
def auto_correction=(value)
|
150
158
|
@auto_correction = const_int_get("UITextAutocorrectionType", value)
|
151
159
|
end
|
152
160
|
|
153
|
-
def auto_capitalization=(value)
|
161
|
+
def auto_capitalization=(value)
|
154
162
|
@auto_capitalization = const_int_get("UITextAutocapitalizationType", value)
|
155
163
|
end
|
156
164
|
|
157
|
-
def clear_button=(value)
|
165
|
+
def clear_button=(value)
|
158
166
|
@clear_button = const_int_get("UITextFieldViewMode", value)
|
159
167
|
end
|
160
168
|
|
@@ -176,6 +184,7 @@ module Formotion
|
|
176
184
|
def make_cell
|
177
185
|
cell, text_field = Formotion::RowCellBuilder.make_cell(self)
|
178
186
|
@text_field = text_field
|
187
|
+
self.object.after_build(cell)
|
179
188
|
cell
|
180
189
|
end
|
181
190
|
|
@@ -197,14 +206,15 @@ module Formotion
|
|
197
206
|
# directly in your code, they don't get added
|
198
207
|
# to Kernel and const_int_get crashes.
|
199
208
|
def load_constants_hack
|
200
|
-
[UITextAutocapitalizationTypeNone, UITextAutocapitalizationTypeWords,
|
209
|
+
[UITextAutocapitalizationTypeNone, UITextAutocapitalizationTypeWords,
|
201
210
|
UITextAutocapitalizationTypeSentences,UITextAutocapitalizationTypeAllCharacters,
|
202
211
|
UITextAutocorrectionTypeNo, UITextAutocorrectionTypeYes, UITextAutocorrectionTypeDefault,
|
203
|
-
UIReturnKeyDefault, UIReturnKeyGo, UIReturnKeyGoogle, UIReturnKeyJoin,
|
212
|
+
UIReturnKeyDefault, UIReturnKeyGo, UIReturnKeyGoogle, UIReturnKeyJoin,
|
204
213
|
UIReturnKeyNext, UIReturnKeyRoute, UIReturnKeySearch, UIReturnKeySend,
|
205
|
-
UIReturnKeyYahoo, UIReturnKeyDone, UIReturnKeyEmergencyCall,
|
214
|
+
UIReturnKeyYahoo, UIReturnKeyDone, UIReturnKeyEmergencyCall,
|
206
215
|
UITextFieldViewModeNever, UITextFieldViewModeAlways, UITextFieldViewModeWhileEditing,
|
207
|
-
UITextFieldViewModeUnlessEditing
|
216
|
+
UITextFieldViewModeUnlessEditing, NSDateFormatterShortStyle, NSDateFormatterMediumStyle,
|
217
|
+
NSDateFormatterLongStyle, NSDateFormatterFullStyle
|
208
218
|
]
|
209
219
|
end
|
210
220
|
end
|