formotion 1.4.0 → 1.5.0
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.
- checksums.yaml +8 -8
- data/README.md +5 -5
- data/examples/Persistence/app/controller.rb +1 -1
- data/lib/formotion/form/form.rb +9 -2
- data/lib/formotion/row/row.rb +14 -0
- data/lib/formotion/row/row_cell_builder.rb +6 -0
- data/lib/formotion/row_type/image_row.rb +1 -0
- data/lib/formotion/row_type/map_row.rb +24 -7
- data/lib/formotion/row_type/object_row.rb +50 -10
- data/lib/formotion/row_type/paged_image_row.rb +1 -0
- data/lib/formotion/row_type/tags_row.rb +1 -0
- data/lib/formotion/row_type/template_row.rb +10 -0
- data/lib/formotion/row_type/web_view_row.rb +41 -2
- data/lib/formotion/version.rb +1 -1
- data/spec/functional/map_row_spec.rb +45 -0
- data/spec/functional/template_row_ext_spec.rb +131 -0
- data/spec/functional/web_view_row_spec.rb +55 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjFjOTExNWIyMWJiZGNkZWY0MDY2MWI1OWUwM2MxZTljMGU4ZTZlOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDk5YmIzNmNjNDUyYTEzZjJmNWNlYjkxZmI3YTI5Njg3NGQwYjIzYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTk2ZTI5YmY3ZDRiNjAzOTdmZDAyMWRiOTM5MDA2NjdkMzY3NDlkMzZhNzI2
|
10
|
+
OGVkY2QxOGU2YWRmYWJmZTQwNTAxZWU1YzZhOTQyZjA2ZWY2ZGY5ZTgzYWRh
|
11
|
+
YjBkNjE3Mjk3OWI2OTdjMWYzNTViYjlkNTdiM2IyNzZiMzNjZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWNhYjQ1NzgwMTY0MjhhNDY2ZWNmZTY1NDU0NDBkMjYxNWJiMjBhODViZGIx
|
14
|
+
MzgxZWYwMjllMzQzOTk1YzlmNzhlMDA2ZDI5ZDVkMGY3OGMxNGQ1YmZjMTI0
|
15
|
+
NjI4NjRhNTI4OTUxYjI5MzNkMzJhYjAxNGE2Mzc2MDEwZDI5Zjc=
|
data/README.md
CHANGED
@@ -112,7 +112,7 @@ self.navigationController.pushViewController(@controller, animated: true)
|
|
112
112
|
|
113
113
|
### Data Types
|
114
114
|
|
115
|
-
See [the visual list of support row types](https://github.com/clayallsopp/formotion/
|
115
|
+
See [the visual list of support row types](https://github.com/clayallsopp/formotion/blob/master/LIST_OF_ROW_TYPES.md).
|
116
116
|
|
117
117
|
To add your own, check [the guide to adding new row types](https://github.com/clayallsopp/formotion/blob/master/NEW_ROW_TYPES.md).
|
118
118
|
|
@@ -181,20 +181,20 @@ end
|
|
181
181
|
|
182
182
|
### Persistence
|
183
183
|
|
184
|
-
You can easily synchronize a `Form`'s state to disk using the `persist_as` key in
|
184
|
+
You can easily synchronize a `Form`'s state to disk using the `persist_as` key in form properties. When your user edits the form, any changes will be immediately saved. For example:
|
185
185
|
|
186
186
|
```ruby
|
187
|
-
@form = Formotion::Form.
|
187
|
+
@form = Formotion::Form.new({
|
188
188
|
persist_as: :settings,
|
189
189
|
sections: ...
|
190
190
|
})
|
191
191
|
```
|
192
192
|
|
193
|
-
This will load the form if it exists, or create it if necessary. If you use `
|
193
|
+
This will load the form if it exists, or create it if necessary. If you use remove the `persist_as` key, then the form will not be loaded and any changes you make will override existing saved forms.
|
194
194
|
|
195
195
|
Your form values and state are automatically persisted across application loads, no save buttons needed.
|
196
196
|
|
197
|
-
To reset the form,
|
197
|
+
To reset the form, call `reset`, which restores it to the original state.
|
198
198
|
|
199
199
|
View the [Persistence Example](./examples/Persistence) to see it in action.
|
200
200
|
|
data/lib/formotion/form/form.rb
CHANGED
@@ -24,8 +24,6 @@ module Formotion
|
|
24
24
|
|
25
25
|
def self.persist(params = {})
|
26
26
|
form = new(params)
|
27
|
-
form.open
|
28
|
-
form.init_observer_for_save
|
29
27
|
form
|
30
28
|
end
|
31
29
|
|
@@ -37,6 +35,15 @@ module Formotion
|
|
37
35
|
sections && sections.each_with_index {|section_hash, index|
|
38
36
|
section = create_section(section_hash.merge({index: index}))
|
39
37
|
}
|
38
|
+
|
39
|
+
initialize_persist unless self.persist_as.nil?
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize_persist
|
44
|
+
self.open
|
45
|
+
self.init_observer_for_save
|
46
|
+
self
|
40
47
|
end
|
41
48
|
|
42
49
|
# Use this as a DSL for building forms
|
data/lib/formotion/row/row.rb
CHANGED
@@ -37,6 +37,8 @@ module Formotion
|
|
37
37
|
:text_alignment,
|
38
38
|
# placeholder text
|
39
39
|
:placeholder,
|
40
|
+
# accessibility label
|
41
|
+
:accessibility,
|
40
42
|
# whether or not the entry field is secure (like a password)
|
41
43
|
:secure,
|
42
44
|
# given by a UIReturnKey___ integer, string, or symbol
|
@@ -306,10 +308,22 @@ module Formotion
|
|
306
308
|
# Used in :button type rows
|
307
309
|
def on_tap(&block)
|
308
310
|
self.on_tap_callback = block
|
311
|
+
# set on_tap for all template children
|
312
|
+
if self.type == :template
|
313
|
+
for templ in self.template_children do
|
314
|
+
templ.on_tap_callback = block
|
315
|
+
end
|
316
|
+
end
|
309
317
|
end
|
310
318
|
|
311
319
|
def on_delete(&block)
|
312
320
|
self.on_delete_callback = block
|
321
|
+
# set on_tap for all template children
|
322
|
+
if self.type == :template
|
323
|
+
for templ in self.template_children do
|
324
|
+
templ.on_delete_callback = block
|
325
|
+
end
|
326
|
+
end
|
313
327
|
end
|
314
328
|
|
315
329
|
#########################
|
@@ -20,6 +20,12 @@ module Formotion
|
|
20
20
|
cell.detailTextLabel.text = row.subtitle
|
21
21
|
|
22
22
|
edit_field = row.object.build_cell(cell)
|
23
|
+
|
24
|
+
if edit_field and edit_field.respond_to?("accessibilityLabel=")
|
25
|
+
label = row.accessibility
|
26
|
+
label = row.title unless label
|
27
|
+
edit_field.accessibilityLabel = label if label
|
28
|
+
end
|
23
29
|
|
24
30
|
[cell, edit_field]
|
25
31
|
end
|
@@ -104,6 +104,7 @@ module Formotion
|
|
104
104
|
def add_plus_accessory(cell)
|
105
105
|
@add_button ||= begin
|
106
106
|
button = UIButton.buttonWithType(UIButtonTypeContactAdd)
|
107
|
+
button.accessibilityLabel = BW.localized_string("add image", nil)
|
107
108
|
button.when(UIControlEventTouchUpInside) do
|
108
109
|
self._on_select(nil, nil)
|
109
110
|
end
|
@@ -29,23 +29,40 @@ module Formotion
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class MapRow < Base
|
32
|
+
include BW::KVO
|
32
33
|
|
33
34
|
MAP_VIEW_TAG=1100
|
34
35
|
|
36
|
+
def set_pin
|
37
|
+
return unless row.value
|
38
|
+
coord = (row.value.is_a?(Array) and row.value.size==2) ? CLLocationCoordinate2D.new(row.value[0], row.value[1]) : row.value
|
39
|
+
if coord.is_a?(CLLocationCoordinate2D)
|
40
|
+
@map_view.removeAnnotation(@map_row_data) if @map_row_data
|
41
|
+
region = MKCoordinateRegionMakeWithDistance(coord, 400.0, 480.0)
|
42
|
+
@map_row_data = MapRowData.new(nil, nil, coord)
|
43
|
+
@map_view.setRegion(region, animated:true)
|
44
|
+
@map_view.addAnnotation(@map_row_data)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def annotations
|
49
|
+
@map_view.annotations
|
50
|
+
end
|
51
|
+
|
35
52
|
def build_cell(cell)
|
36
53
|
cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue
|
37
54
|
|
38
55
|
@map_view = MKMapView.alloc.init
|
39
56
|
@map_view.delegate = self
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@map_view.addAnnotation(m)
|
57
|
+
|
58
|
+
set_pin
|
59
|
+
|
60
|
+
observe(self.row, "value") do |old_value, new_value|
|
61
|
+
break_with_semaphore do
|
62
|
+
set_pin
|
47
63
|
end
|
48
64
|
end
|
65
|
+
|
49
66
|
@map_view.tag = MAP_VIEW_TAG
|
50
67
|
@map_view.contentMode = UIViewContentModeScaleAspectFit
|
51
68
|
@map_view.backgroundColor = UIColor.clearColor
|
@@ -5,19 +5,59 @@ module Formotion
|
|
5
5
|
class ObjectRow < StringRow
|
6
6
|
|
7
7
|
def build_cell(cell)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
field.instance_eval unswizzle
|
8
|
+
cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue
|
9
|
+
field = UITextField.alloc.initWithFrame(CGRectZero)
|
10
|
+
field.tag = TEXT_FIELD_TAG
|
11
|
+
|
12
|
+
observe(self.row, "value") do |old_value, new_value|
|
13
|
+
break_with_semaphore do
|
14
|
+
update_text_field(new_value)
|
18
15
|
end
|
16
|
+
end
|
17
|
+
|
18
|
+
field.clearButtonMode = UITextFieldViewModeWhileEditing
|
19
|
+
field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter
|
20
|
+
field.textAlignment = row.text_alignment || UITextAlignmentRight
|
21
|
+
|
22
|
+
field.keyboardType = keyboardType
|
23
|
+
|
24
|
+
field.secureTextEntry = true if row.secure?
|
25
|
+
field.returnKeyType = row.return_key || UIReturnKeyNext
|
26
|
+
field.autocapitalizationType = row.auto_capitalization if row.auto_capitalization
|
27
|
+
field.autocorrectionType = row.auto_correction if row.auto_correction
|
28
|
+
field.clearButtonMode = row.clear_button || UITextFieldViewModeWhileEditing
|
29
|
+
field.enabled = row.editable?
|
30
|
+
field.inputAccessoryView = input_accessory_view(row.input_accessory) if row.input_accessory
|
31
|
+
|
32
|
+
add_callbacks(field)
|
19
33
|
|
34
|
+
cell.swizzle(:layoutSubviews) do
|
35
|
+
def layoutSubviews
|
36
|
+
old_layoutSubviews
|
37
|
+
|
38
|
+
# viewWithTag is terrible, but I think it's ok to use here...
|
39
|
+
formotion_field = self.viewWithTag(TEXT_FIELD_TAG)
|
40
|
+
formotion_field.sizeToFit
|
41
|
+
|
42
|
+
field_frame = formotion_field.frame
|
43
|
+
field_frame.origin.x = self.textLabel.frame.origin.x + self.textLabel.frame.size.width + Formotion::RowType::Base.field_buffer
|
44
|
+
field_frame.origin.y = ((self.frame.size.height - field_frame.size.height) / 2.0).round
|
45
|
+
field_frame.size.width = self.frame.size.width - field_frame.origin.x - Formotion::RowType::Base.field_buffer
|
46
|
+
formotion_field.frame = field_frame
|
47
|
+
end
|
20
48
|
end
|
49
|
+
|
50
|
+
field.font = BW::Font.new(row.font) if row.font
|
51
|
+
field.placeholder = row.placeholder
|
52
|
+
field.text = row_value.to_s
|
53
|
+
cell.addSubview(field)
|
54
|
+
field
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
# Used when row.value changes
|
59
|
+
def update_text_field(new_value)
|
60
|
+
self.row.text_field.text = row_value.to_s
|
21
61
|
end
|
22
62
|
|
23
63
|
# overriden in subclasses
|
@@ -130,6 +130,7 @@ module Formotion
|
|
130
130
|
def add_plus_accessory(cell)
|
131
131
|
@add_button ||= begin
|
132
132
|
button = UIButton.buttonWithType(UIButtonTypeContactAdd)
|
133
|
+
button.accessibilityLabel = BW.localized_string("add image", nil)
|
133
134
|
button.when(UIControlEventTouchUpInside) do
|
134
135
|
@page_view.becomeFirstResponder
|
135
136
|
take_photo
|
@@ -82,6 +82,7 @@ module Formotion
|
|
82
82
|
def add_plus_accessory(cell)
|
83
83
|
@add_button ||= begin
|
84
84
|
button = UIButton.buttonWithType(UIButtonTypeContactAdd)
|
85
|
+
button.accessibilityLabel = BW.localized_string("add tag", nil)
|
85
86
|
button.when(UIControlEventTouchUpInside) do
|
86
87
|
if row.on_tap_callback
|
87
88
|
row.on_tap_callback.call(self.row)
|
@@ -60,6 +60,16 @@ module Formotion
|
|
60
60
|
row.template_parent.template_children.delete_at(row.index)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
# inherit some infos to template child
|
65
|
+
if row.on_tap_callback
|
66
|
+
new_row.on_tap_callback = row.on_tap_callback
|
67
|
+
end
|
68
|
+
if row.on_delete_callback
|
69
|
+
new_row.on_delete_callback = row.on_delete_callback
|
70
|
+
end
|
71
|
+
new_row.key = "#{row.key}_template".to_sym
|
72
|
+
|
63
73
|
new_row.remove_on_delete = true
|
64
74
|
new_row.template_parent = row
|
65
75
|
row.template_children ||= []
|
@@ -3,14 +3,43 @@ motion_require 'base'
|
|
3
3
|
module Formotion
|
4
4
|
module RowType
|
5
5
|
class WebViewRow < Base
|
6
|
+
include BW::KVO
|
6
7
|
|
7
8
|
WEB_VIEW_TAG=1100
|
8
9
|
|
10
|
+
def set_page
|
11
|
+
if row.value =~/^https?:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\+&%\$#\=~])*$/
|
12
|
+
@loading = true
|
13
|
+
req = NSURLRequest.requestWithURL(NSURL.URLWithString(row.value))
|
14
|
+
@web_view.loadRequest(req)
|
15
|
+
else
|
16
|
+
@web_view.loadHTMLString(row.value, baseURL:nil) if row.value
|
17
|
+
@loading = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def stringByEvaluatingJavaScriptFromString(script)
|
22
|
+
@web_view.stringByEvaluatingJavaScriptFromString(script)
|
23
|
+
end
|
24
|
+
|
25
|
+
def loading
|
26
|
+
@loading
|
27
|
+
end
|
28
|
+
|
9
29
|
def build_cell(cell)
|
10
30
|
cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue
|
11
|
-
|
31
|
+
|
32
|
+
@loading = true
|
12
33
|
@web_view = UIWebView.alloc.init
|
13
|
-
@web_view.
|
34
|
+
@web_view.delegate = self
|
35
|
+
set_page
|
36
|
+
|
37
|
+
observe(self.row, "value") do |old_value, new_value|
|
38
|
+
break_with_semaphore do
|
39
|
+
set_page
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
14
43
|
@web_view.tag = WEB_VIEW_TAG
|
15
44
|
@web_view.contentMode = UIViewContentModeScaleAspectFit
|
16
45
|
@web_view.backgroundColor = UIColor.clearColor
|
@@ -38,7 +67,17 @@ module Formotion
|
|
38
67
|
return
|
39
68
|
end
|
40
69
|
end
|
70
|
+
|
71
|
+
#def webView(web_view, didFailLoadWithError:error)
|
72
|
+
#end
|
41
73
|
|
74
|
+
#def webViewDidStartLoad(web_view)
|
75
|
+
#end
|
76
|
+
|
77
|
+
def webViewDidFinishLoad(web_view)
|
78
|
+
@loading = false
|
79
|
+
end
|
80
|
+
|
42
81
|
end
|
43
82
|
end
|
44
83
|
end
|
data/lib/formotion/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
describe "FormController/MapRow" do
|
2
|
+
tests Formotion::FormController
|
3
|
+
|
4
|
+
# By default, `tests` uses @controller.init
|
5
|
+
# this isn't ideal for our case, so override.
|
6
|
+
def controller
|
7
|
+
row_settings = {
|
8
|
+
title: "Map",
|
9
|
+
key: :map,
|
10
|
+
type: :map,
|
11
|
+
value: [47.5, 8.5]
|
12
|
+
}
|
13
|
+
@form ||= Formotion::Form.new(
|
14
|
+
sections: [{
|
15
|
+
rows:[row_settings]
|
16
|
+
}])
|
17
|
+
|
18
|
+
@controller ||= Formotion::FormController.alloc.initWithForm(@form)
|
19
|
+
end
|
20
|
+
|
21
|
+
def map_row
|
22
|
+
@form.row(:map)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should only one pin" do
|
26
|
+
map_row.object.annotations.size.should == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be a pin at the predefined position" do
|
30
|
+
coord = map_row.object.annotations[0].coordinate
|
31
|
+
coord.latitude.should == 47.5
|
32
|
+
coord.longitude.should == 8.5
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should set a new pin with new position" do
|
36
|
+
map_row.value = CLLocationCoordinate2D.new(48.5, 9.5)
|
37
|
+
wait 1 do
|
38
|
+
map_row.object.annotations.size.should == 1
|
39
|
+
coord = map_row.object.annotations[0].coordinate
|
40
|
+
coord.latitude.should == 48.5
|
41
|
+
coord.longitude.should == 9.5
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
describe "FormController/TemplateRowExt" do
|
2
|
+
tests Formotion::FormController
|
3
|
+
|
4
|
+
class Item
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name=name
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
@name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# By default, `tests` uses @controller.init
|
17
|
+
# this isn't ideal for our case, so override.
|
18
|
+
def controller
|
19
|
+
@item1 = Item.new("Value 1")
|
20
|
+
row_settings = {
|
21
|
+
title: "Add element",
|
22
|
+
key: :template,
|
23
|
+
type: :template,
|
24
|
+
value: [@item1],
|
25
|
+
template: {
|
26
|
+
title: 'Element',
|
27
|
+
type: :object,
|
28
|
+
indented: true,
|
29
|
+
deletable: true
|
30
|
+
}
|
31
|
+
}
|
32
|
+
@form ||= Formotion::Form.new(
|
33
|
+
sections: [{
|
34
|
+
rows:[row_settings]
|
35
|
+
}])
|
36
|
+
|
37
|
+
@controller ||= Formotion::FormController.alloc.initWithForm(@form)
|
38
|
+
end
|
39
|
+
|
40
|
+
def new_row
|
41
|
+
@form.sections.first.rows[-2]
|
42
|
+
end
|
43
|
+
|
44
|
+
after do
|
45
|
+
@form = nil
|
46
|
+
@controller = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should work with DSL" do
|
50
|
+
@form = Formotion::Form.new
|
51
|
+
|
52
|
+
item2 = Item.new("Value 2")
|
53
|
+
@form.build_section do |section|
|
54
|
+
section.build_row do |row|
|
55
|
+
row.title = "Add element"
|
56
|
+
row.type = :template
|
57
|
+
row.key = :template
|
58
|
+
row.value = [@item1, item2]
|
59
|
+
row.template = {
|
60
|
+
title: 'Element',
|
61
|
+
type: :object,
|
62
|
+
indented: true,
|
63
|
+
deletable: true
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
@controller ||= Formotion::FormController.alloc.initWithForm(@form)
|
69
|
+
@form.render[:template].should == [@item1, item2]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should insert row" do
|
73
|
+
tap("Add element")
|
74
|
+
@form.sections.first.rows.size.should == 3
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should remove row" do
|
78
|
+
tap("Add element")
|
79
|
+
new_row.object.on_delete(nil, nil)
|
80
|
+
@form.sections.first.rows.size.should == 2
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should render values as array" do
|
84
|
+
tap("Add element")
|
85
|
+
item2 = Item.new("Value 2")
|
86
|
+
new_row.value = item2
|
87
|
+
|
88
|
+
tap("Add element")
|
89
|
+
item3 = Item.new("Value 3")
|
90
|
+
new_row.value = item3
|
91
|
+
|
92
|
+
@form.render[:template].should == [@item1, item2, item3]
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should call on_tap on the specific element" do
|
96
|
+
@tapped_item = nil
|
97
|
+
row = @form.row(:template)
|
98
|
+
row.on_tap do |row|
|
99
|
+
@tapped_item = row.value
|
100
|
+
end
|
101
|
+
|
102
|
+
tap("Element")
|
103
|
+
wait 1 do
|
104
|
+
@tapped_item.class.should == Item
|
105
|
+
@tapped_item.to_s.should == "Value 1"
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should call on_tap on a newly added element" do
|
111
|
+
@tapped_item = nil
|
112
|
+
row = @form.row(:template)
|
113
|
+
row.on_tap do |row|
|
114
|
+
@tapped_item = row.value
|
115
|
+
end
|
116
|
+
|
117
|
+
# patch template to get an new title for the element
|
118
|
+
row.template[:title] = "Value 2"
|
119
|
+
tap("Add element")
|
120
|
+
item2 = Item.new("Value 2")
|
121
|
+
new_row.value = item2
|
122
|
+
|
123
|
+
tap("Value 2")
|
124
|
+
wait 1 do
|
125
|
+
@tapped_item.class.should == Item
|
126
|
+
@tapped_item.to_s.should == "Value 2"
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe "FormController/WebViewRow" do
|
2
|
+
tests Formotion::FormController
|
3
|
+
|
4
|
+
# By default, `tests` uses @controller.init
|
5
|
+
# this isn't ideal for our case, so override.
|
6
|
+
def controller
|
7
|
+
row_settings = {
|
8
|
+
title: "WebView",
|
9
|
+
key: :web_view,
|
10
|
+
type: :web_view,
|
11
|
+
value: "<html><body><b class=\"test\">This is a Test</b></body></html>"
|
12
|
+
}
|
13
|
+
@form ||= Formotion::Form.new(
|
14
|
+
sections: [{
|
15
|
+
rows:[row_settings]
|
16
|
+
}])
|
17
|
+
|
18
|
+
@controller ||= Formotion::FormController.alloc.initWithForm(@form)
|
19
|
+
end
|
20
|
+
|
21
|
+
def webview_row
|
22
|
+
@form.row(:web_view)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should display the html content" do
|
26
|
+
content = ""
|
27
|
+
wait 1 do
|
28
|
+
0.upto(6) do |i|
|
29
|
+
content = webview_row.object.stringByEvaluatingJavaScriptFromString("document.getElementsByClassName('test')[0].innerHTML;")
|
30
|
+
break if content != ""
|
31
|
+
sleep 1
|
32
|
+
end
|
33
|
+
content.should == "This is a Test"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should load the google home page" do
|
38
|
+
webview_row.value = "https://www.google.com"
|
39
|
+
wait 1 do
|
40
|
+
while webview_row.object.loading
|
41
|
+
sleep 1
|
42
|
+
end
|
43
|
+
content = ""
|
44
|
+
0.upto(6) do |i|
|
45
|
+
content = webview_row.object.stringByEvaluatingJavaScriptFromString("document.body.innerHTML")
|
46
|
+
break if content != ""
|
47
|
+
sleep 1
|
48
|
+
end
|
49
|
+
content.index("google").should > 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clay Allsopp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bubble-wrap
|
@@ -178,14 +178,17 @@ files:
|
|
178
178
|
- spec/functional/date_row_spec.rb
|
179
179
|
- spec/functional/formable_controller_spec.rb
|
180
180
|
- spec/functional/image_row_spec.rb
|
181
|
+
- spec/functional/map_row_spec.rb
|
181
182
|
- spec/functional/options_row_spec.rb
|
182
183
|
- spec/functional/picker_row_spec.rb
|
183
184
|
- spec/functional/slider_row_spec.rb
|
184
185
|
- spec/functional/subform_row.rb
|
185
186
|
- spec/functional/submit_row_spec.rb
|
186
187
|
- spec/functional/switch_row_spec.rb
|
188
|
+
- spec/functional/template_row_ext_spec.rb
|
187
189
|
- spec/functional/template_row_spec.rb
|
188
190
|
- spec/functional/text_row_spec.rb
|
191
|
+
- spec/functional/web_view_row_spec.rb
|
189
192
|
- spec/helpers/row_test_helpers.rb
|
190
193
|
- spec/row_spec.rb
|
191
194
|
- spec/row_type/back_spec.rb
|
@@ -228,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
231
|
version: '0'
|
229
232
|
requirements: []
|
230
233
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.0.
|
234
|
+
rubygems_version: 2.0.7
|
232
235
|
signing_key:
|
233
236
|
specification_version: 4
|
234
237
|
summary: Making iOS Forms insanely great with RubyMotion
|
@@ -243,14 +246,17 @@ test_files:
|
|
243
246
|
- spec/functional/date_row_spec.rb
|
244
247
|
- spec/functional/formable_controller_spec.rb
|
245
248
|
- spec/functional/image_row_spec.rb
|
249
|
+
- spec/functional/map_row_spec.rb
|
246
250
|
- spec/functional/options_row_spec.rb
|
247
251
|
- spec/functional/picker_row_spec.rb
|
248
252
|
- spec/functional/slider_row_spec.rb
|
249
253
|
- spec/functional/subform_row.rb
|
250
254
|
- spec/functional/submit_row_spec.rb
|
251
255
|
- spec/functional/switch_row_spec.rb
|
256
|
+
- spec/functional/template_row_ext_spec.rb
|
252
257
|
- spec/functional/template_row_spec.rb
|
253
258
|
- spec/functional/text_row_spec.rb
|
259
|
+
- spec/functional/web_view_row_spec.rb
|
254
260
|
- spec/helpers/row_test_helpers.rb
|
255
261
|
- spec/row_spec.rb
|
256
262
|
- spec/row_type/back_spec.rb
|