motion-prime 0.8.1 → 0.8.2
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/ROADMAP.md +3 -0
- data/files/Gemfile +1 -1
- data/motion-prime/api_client.rb +5 -2
- data/motion-prime/core_ext/kernel.rb +36 -0
- data/motion-prime/elements/_content_text_mixin.rb +32 -11
- data/motion-prime/elements/base_element.rb +33 -16
- data/motion-prime/elements/draw.rb +10 -4
- data/motion-prime/elements/draw/image.rb +26 -15
- data/motion-prime/elements/map.rb +5 -0
- data/motion-prime/models/_association_mixin.rb +0 -3
- data/motion-prime/models/_base_mixin.rb +24 -3
- data/motion-prime/models/_filter_mixin.rb +28 -0
- data/motion-prime/models/_sync_mixin.rb +13 -10
- data/motion-prime/models/association_collection.rb +41 -16
- data/motion-prime/models/errors.rb +46 -24
- data/motion-prime/models/model.rb +8 -0
- data/motion-prime/screens/_sections_mixin.rb +1 -1
- data/motion-prime/screens/extensions/_indicators_mixin.rb +4 -2
- data/motion-prime/screens/extensions/_navigation_bar_mixin.rb +1 -1
- data/motion-prime/screens/screen.rb +4 -0
- data/motion-prime/sections/_async_form_mixin.rb +12 -0
- data/motion-prime/sections/_async_table_mixin.rb +193 -0
- data/motion-prime/sections/_cell_section_mixin.rb +6 -6
- data/motion-prime/sections/_draw_section_mixin.rb +13 -5
- data/motion-prime/sections/base_section.rb +62 -36
- data/motion-prime/sections/form.rb +19 -35
- data/motion-prime/sections/form/base_field_section.rb +42 -34
- data/motion-prime/sections/form/static_field_section.rb +9 -0
- data/motion-prime/sections/table.rb +143 -201
- data/motion-prime/sections/table/table_delegate.rb +15 -15
- data/motion-prime/services/table_data_indexes.rb +12 -2
- data/motion-prime/styles/base.rb +1 -1
- data/motion-prime/styles/form.rb +6 -6
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/layout.rb +5 -2
- data/motion-prime/views/view_styler.rb +2 -0
- data/spec/models/association_collection_spec.rb +28 -6
- metadata +6 -2
@@ -20,25 +20,25 @@ module MotionPrime
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def numberOfSectionsInTableView(table)
|
23
|
-
table_section.
|
23
|
+
table_section.number_of_groups(table)
|
24
24
|
end
|
25
25
|
|
26
26
|
def tableView(table, cellForRowAtIndexPath: index)
|
27
|
-
|
28
|
-
|
29
|
-
if @
|
30
|
-
|
31
|
-
|
32
|
-
@deceleration_speed =
|
27
|
+
cur_call_time = Time.now.to_f
|
28
|
+
cur_call_offset = table.contentOffset.y
|
29
|
+
if @prev_call_time
|
30
|
+
time_delta = cur_call_time - @prev_call_time
|
31
|
+
offset_delta = cur_call_offset - @prev_call_offset
|
32
|
+
@deceleration_speed = offset_delta/time_delta
|
33
33
|
end
|
34
|
-
@
|
35
|
-
@
|
34
|
+
@prev_call_time = cur_call_time
|
35
|
+
@prev_call_offset = cur_call_offset
|
36
36
|
|
37
37
|
table_section.cell_for_index(table, index)
|
38
38
|
end
|
39
39
|
|
40
|
-
def tableView(table, numberOfRowsInSection:
|
41
|
-
table_section.
|
40
|
+
def tableView(table, numberOfRowsInSection: group)
|
41
|
+
table_section.cell_sections_for_group(group).try(:count).to_i
|
42
42
|
end
|
43
43
|
|
44
44
|
def tableView(table, heightForRowAtIndexPath: index)
|
@@ -49,12 +49,12 @@ module MotionPrime
|
|
49
49
|
table_section.on_click(table, index)
|
50
50
|
end
|
51
51
|
|
52
|
-
def tableView(table, viewForHeaderInSection:
|
53
|
-
table_section.
|
52
|
+
def tableView(table, viewForHeaderInSection: group)
|
53
|
+
table_section.header_cell_in_group(table, group)
|
54
54
|
end
|
55
55
|
|
56
|
-
def tableView(table, heightForHeaderInSection:
|
57
|
-
table_section.
|
56
|
+
def tableView(table, heightForHeaderInSection: group)
|
57
|
+
table_section.height_for_header_in_group(table, group)
|
58
58
|
end
|
59
59
|
|
60
60
|
def scrollViewDidScroll(scroll)
|
@@ -14,6 +14,14 @@ class TableDataIndexes
|
|
14
14
|
a.section > b.section || a.row > b.row ? 1 : -1
|
15
15
|
end
|
16
16
|
|
17
|
+
def greater_than(a, b)
|
18
|
+
compare_indexes(a, b) > 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def less_than(a, b)
|
22
|
+
compare_indexes(a, b) < 0
|
23
|
+
end
|
24
|
+
|
17
25
|
def sum_index(a, rows, crop_to_edges = true)
|
18
26
|
row = a.row + rows
|
19
27
|
section = a.section
|
@@ -25,8 +33,10 @@ class TableDataIndexes
|
|
25
33
|
section = a.section + direction
|
26
34
|
edge_row = [[0, row].max, max_row].min
|
27
35
|
|
28
|
-
|
29
|
-
|
36
|
+
max_section = sections_count - 1
|
37
|
+
if section < 0 || section > max_section
|
38
|
+
edge_section = [[section, 0].max, max_section].min
|
39
|
+
return crop_to_edges ? NSIndexPath.indexPathForRow(edge_row, inSection: edge_section) : false
|
30
40
|
end
|
31
41
|
|
32
42
|
start_row = edge_row.zero? ? count_in_section(section) - 1 : 0
|
data/motion-prime/styles/base.rb
CHANGED
data/motion-prime/styles/form.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
motion_require '../views/styles.rb'
|
2
2
|
MotionPrime::Styles.define :base_form do
|
3
3
|
style :header, container: {height: 25}
|
4
|
-
style :header_label,
|
4
|
+
style :header_label, mixins: [:multiline],
|
5
5
|
left: 0,
|
6
6
|
bottom: 5,
|
7
7
|
top: nil,
|
@@ -13,7 +13,7 @@ MotionPrime::Styles.define :base_form do
|
|
13
13
|
top: nil,
|
14
14
|
width: 320
|
15
15
|
|
16
|
-
style :field,
|
16
|
+
style :field, :cell,
|
17
17
|
selection_style: :none,
|
18
18
|
background_color: :clear
|
19
19
|
|
@@ -95,10 +95,10 @@ MotionPrime::Styles.define :base_form do
|
|
95
95
|
style :with_sections_field_switch,
|
96
96
|
right: 20
|
97
97
|
|
98
|
-
style :with_sections_field_text_field,
|
99
|
-
:with_sections_field_text_view,
|
100
|
-
:with_sections_field_password_field,
|
101
|
-
:with_sections_field_label,
|
98
|
+
style :with_sections_field_text_field,
|
99
|
+
:with_sections_field_text_view,
|
100
|
+
:with_sections_field_password_field,
|
101
|
+
:with_sections_field_label,
|
102
102
|
:with_sections_field_button,
|
103
103
|
left: 20,
|
104
104
|
right: 20
|
data/motion-prime/version.rb
CHANGED
@@ -5,8 +5,11 @@ module MotionPrime
|
|
5
5
|
module Layout
|
6
6
|
def add_view(klass, options = {}, &block)
|
7
7
|
options = options.clone
|
8
|
+
render_target = options.delete(:render_target)
|
9
|
+
parent_view = options.delete(:parent_view) || render_target
|
10
|
+
|
8
11
|
bounds = if view_stack.empty?
|
9
|
-
|
12
|
+
parent_view.try(:bounds) || CGRectZero
|
10
13
|
else
|
11
14
|
view_stack.last.bounds
|
12
15
|
end
|
@@ -15,7 +18,7 @@ module MotionPrime
|
|
15
18
|
view = builder.view
|
16
19
|
insert_index = options.delete(:at_index)
|
17
20
|
|
18
|
-
if render_target
|
21
|
+
if render_target
|
19
22
|
options[:bounds] = render_target.bounds
|
20
23
|
insert_index ? render_target.insertSubview(view, atIndex: insert_index) : render_target.addSubview(view)
|
21
24
|
elsif view_stack.any?
|
@@ -140,6 +140,8 @@ module MotionPrime
|
|
140
140
|
view.layer.insertSublayer(gradient, atIndex: 0)
|
141
141
|
elsif key == 'selection_style' && view.is_a?(UITableViewCell) && value.is_a?(Symbol)
|
142
142
|
view.setSelectionStyle value.uitablecellselectionstyle
|
143
|
+
elsif key == 'estimated_cell_height' && view.is_a?(UITableView)
|
144
|
+
view.setEstimatedRowHeight value
|
143
145
|
elsif key == 'separator_inset' && (view.is_a?(UITableViewCell) || view.is_a?(UITableView))
|
144
146
|
if value.to_s == 'none'
|
145
147
|
view.separatorInset = UIEdgeInsetsMake(0, 320, 0, 0)
|
@@ -37,21 +37,43 @@ describe "Prime::AssociationCollection" do
|
|
37
37
|
describe "#all" do
|
38
38
|
before do
|
39
39
|
@organization = Organization.new
|
40
|
-
puts "count 1: #{@organization.projects.count}"
|
41
40
|
project = Project.new(title: 'test 1')
|
42
41
|
@organization.projects.add(project)
|
43
|
-
puts "count 2: #{@organization.projects.count}"
|
44
42
|
project = Project.new(title: 'test 2')
|
45
43
|
@organization.projects.add(project)
|
46
|
-
puts "count 3: #{@organization.projects.count}"
|
47
44
|
end
|
48
45
|
|
49
|
-
it "should return all records
|
46
|
+
it "should return all records" do
|
50
47
|
@organization.projects.all.count.should == 2
|
51
48
|
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#find" do
|
52
|
+
before do
|
53
|
+
@organization = Organization.new
|
54
|
+
project = Project.create(title: 'test 1')
|
55
|
+
@organization.projects.add(project)
|
56
|
+
project = Project.create(title: 'test 2')
|
57
|
+
@organization.projects.add(project)
|
58
|
+
@organization.save
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return saved records by first hash" do
|
62
|
+
@organization.projects.find(title: 'test 1').count.should == 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#filter" do
|
67
|
+
before do
|
68
|
+
@organization = Organization.new
|
69
|
+
project = Project.new(title: 'test 1')
|
70
|
+
@organization.projects.add(project)
|
71
|
+
project = Project.new(title: 'test 2')
|
72
|
+
@organization.projects.add(project)
|
73
|
+
end
|
52
74
|
|
53
|
-
it "should return
|
54
|
-
@organization.projects.
|
75
|
+
it "should return saved records by first hash" do
|
76
|
+
@organization.projects.filter(title: 'test 1').count.should == 1
|
55
77
|
end
|
56
78
|
end
|
57
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-prime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Haziev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -281,6 +281,7 @@ files:
|
|
281
281
|
- motion-prime/models/_association_mixin.rb
|
282
282
|
- motion-prime/models/_base_mixin.rb
|
283
283
|
- motion-prime/models/_dirty_mixin.rb
|
284
|
+
- motion-prime/models/_filter_mixin.rb
|
284
285
|
- motion-prime/models/_finder_mixin.rb
|
285
286
|
- motion-prime/models/_nano_bag_mixin.rb
|
286
287
|
- motion-prime/models/_sync_mixin.rb
|
@@ -301,6 +302,8 @@ files:
|
|
301
302
|
- motion-prime/screens/extensions/_navigation_bar_mixin.rb
|
302
303
|
- motion-prime/screens/screen.rb
|
303
304
|
- motion-prime/sections/__section_with_container_mixin.rb
|
305
|
+
- motion-prime/sections/_async_form_mixin.rb
|
306
|
+
- motion-prime/sections/_async_table_mixin.rb
|
304
307
|
- motion-prime/sections/_cell_section_mixin.rb
|
305
308
|
- motion-prime/sections/_delegate_mixin.rb
|
306
309
|
- motion-prime/sections/_draw_section_mixin.rb
|
@@ -312,6 +315,7 @@ files:
|
|
312
315
|
- motion-prime/sections/form/form_delegate.rb
|
313
316
|
- motion-prime/sections/form/password_field_section.rb
|
314
317
|
- motion-prime/sections/form/select_field_section.rb
|
318
|
+
- motion-prime/sections/form/static_field_section.rb
|
315
319
|
- motion-prime/sections/form/string_field_section.rb
|
316
320
|
- motion-prime/sections/form/submit_field_section.rb
|
317
321
|
- motion-prime/sections/form/switch_field_section.rb
|