motion-prime 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +1 -1
  4. data/ROADMAP.md +9 -4
  5. data/doc/code/getting_started.rb +1 -2
  6. data/doc/code/screens.rb +54 -0
  7. data/doc/docs/getting_started.html +27 -6
  8. data/doc/docs/screens.html +166 -0
  9. data/files/Gemfile +1 -1
  10. data/files/Gemfile.lock +64 -0
  11. data/files/app/environment.rb +10 -0
  12. data/files/app/styles/sidebar.rb +3 -10
  13. data/files/resources/images/menu_button.png +0 -0
  14. data/files/resources/images/menu_button@2x.png +0 -0
  15. data/motion-prime/app_delegate.rb +19 -0
  16. data/motion-prime/core_ext/kernel.rb +4 -0
  17. data/motion-prime/elements/_content_text_mixin.rb +23 -11
  18. data/motion-prime/elements/_text_mixin.rb +54 -0
  19. data/motion-prime/elements/base_element.rb +19 -14
  20. data/motion-prime/elements/draw.rb +22 -1
  21. data/motion-prime/elements/draw/_draw_background_mixin.rb +28 -28
  22. data/motion-prime/elements/draw/image.rb +67 -48
  23. data/motion-prime/elements/draw/label.rb +59 -49
  24. data/motion-prime/elements/draw/view.rb +5 -3
  25. data/motion-prime/helpers/has_style_chain_builder.rb +1 -3
  26. data/motion-prime/models/association_collection.rb +8 -0
  27. data/motion-prime/models/finder.rb +8 -0
  28. data/motion-prime/mp.rb +4 -0
  29. data/motion-prime/screens/_navigation_mixin.rb +4 -0
  30. data/motion-prime/screens/base_screen.rb +7 -0
  31. data/motion-prime/screens/sidebar_container_screen.rb +2 -2
  32. data/motion-prime/sections/_cell_section_mixin.rb +44 -5
  33. data/motion-prime/sections/_draw_section_mixin.rb +120 -0
  34. data/motion-prime/sections/base_section.rb +29 -24
  35. data/motion-prime/sections/form.rb +48 -65
  36. data/motion-prime/sections/form/base_field_section.rb +2 -2
  37. data/motion-prime/sections/table.rb +143 -82
  38. data/motion-prime/sections/table/table_delegate.rb +48 -0
  39. data/motion-prime/styles/form.rb +1 -1
  40. data/motion-prime/support/mp_cell_with_section.rb +6 -2
  41. data/motion-prime/support/mp_view_with_section.rb +1 -1
  42. data/motion-prime/version.rb +1 -1
  43. data/motion-prime/views/_frame_calculator_mixin.rb +4 -8
  44. data/motion-prime/views/layout.rb +1 -0
  45. data/motion-prime/views/view_styler.rb +3 -12
  46. metadata +34 -26
  47. data/motion-prime/sections/_draw_mixin.rb +0 -66
@@ -0,0 +1,48 @@
1
+ module MotionPrime
2
+ class TableDelegate
3
+ attr_accessor :table_section
4
+ def initialize(options)
5
+ self.table_section = options[:section].try(:weak_ref)
6
+ end
7
+
8
+ def numberOfSectionsInTableView(table)
9
+ table_section.number_of_sections(table)
10
+ end
11
+
12
+ def tableView(table, cellForRowAtIndexPath: index)
13
+ table_section.cell_for_index(table, index)
14
+ end
15
+
16
+ def tableView(table, numberOfRowsInSection: section)
17
+ table_section.rows_for_section(section).try(:count).to_i
18
+ end
19
+
20
+ def tableView(table, heightForRowAtIndexPath: index)
21
+ table_section.height_for_index(table, index)
22
+ end
23
+
24
+ def tableView(table, didSelectRowAtIndexPath:index)
25
+ table_section.on_click(table, index)
26
+ end
27
+
28
+ def tableView(table, viewForHeaderInSection: section)
29
+ table_section.view_for_header_in_section(table, section)
30
+ end
31
+
32
+ def tableView(table, heightForHeaderInSection: section)
33
+ table_section.height_for_header_in_section(table, section)
34
+ end
35
+
36
+ def scrollViewWillBeginDragging(scroll)
37
+ table_section.scroll_view_will_begin_dragging(scroll)
38
+ end
39
+
40
+ def scrollViewDidEndDecelerating(scroll)
41
+ table_section.scroll_view_did_end_decelerating(scroll)
42
+ end
43
+
44
+ def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate)
45
+ table_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate)
46
+ end
47
+ end
48
+ end
@@ -14,7 +14,7 @@ MotionPrime::Styles.define :base_form do
14
14
  width: 320
15
15
 
16
16
  style :field,
17
- selection_style: UITableViewCellSelectionStyleNone,
17
+ selection_style: :none,
18
18
  background_color: :clear
19
19
 
20
20
  style :with_sections,
@@ -2,11 +2,15 @@ class MPCellWithSection < UITableViewCell
2
2
  attr_accessor :section
3
3
 
4
4
  def setSection(section)
5
- @section = section
5
+ @section = section.try(:weak_ref)
6
6
  end
7
7
 
8
8
  def drawRect(rect)
9
9
  super
10
- section.draw_in(rect) if section.respond_to?(:draw_in)
10
+ draw_in(rect)
11
+ end
12
+
13
+ def draw_in(rect)
14
+ section and section.draw_in(rect) if section.respond_to?(:draw_in)
11
15
  end
12
16
  end
@@ -2,7 +2,7 @@ class MPViewWithSection < UIView
2
2
  attr_accessor :section
3
3
 
4
4
  def setSection(section)
5
- @section = section
5
+ @section = section.try(:weak_ref)
6
6
  end
7
7
 
8
8
  def drawRect(rect)
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -43,31 +43,27 @@ module MotionPrime
43
43
 
44
44
  if !left.nil? && !right.nil?
45
45
  frame.origin.x = left
46
- frame.size.width = max_width - left - right
46
+ width = max_width - left - right
47
47
  elsif !right.nil?
48
48
  frame.origin.x = max_width - width - right
49
- frame.size.width = width
50
49
  elsif !left.nil?
51
50
  frame.origin.x = left
52
- frame.size.width = width
53
51
  else
54
52
  frame.origin.x = max_width / 2 - width / 2
55
- frame.size.width = width
56
53
  end
54
+ frame.size.width = width
57
55
 
58
56
  if !top.nil? && !bottom.nil?
59
57
  frame.origin.y = top
60
- frame.size.height = max_height - top - bottom
58
+ height = max_height - top - bottom if options[:height_to_fit].nil?
61
59
  elsif !bottom.nil?
62
60
  frame.origin.y = max_height - height - bottom
63
- frame.size.height = height
64
61
  elsif !top.nil?
65
62
  frame.origin.y = top
66
- frame.size.height = height
67
63
  else
68
64
  frame.origin.y = max_height / 2 - height / 2
69
- frame.size.height = height
70
65
  end
66
+ frame.size.height = height
71
67
 
72
68
  frame
73
69
  end
@@ -17,6 +17,7 @@ module MotionPrime
17
17
  elsif view_stack.any?
18
18
  view_stack.last.addSubview(view)
19
19
  end
20
+
20
21
  setup(view, options, &block)
21
22
  view.on_added if view.respond_to?(:on_added)
22
23
 
@@ -28,8 +28,7 @@ module MotionPrime
28
28
  end
29
29
 
30
30
  def prepare_frame_for(bounds)
31
- options[:frame] = calculate_frome_for(bounds, options)
32
-
31
+ options[:frame] = calculate_frome_for(bounds, options.merge(test: view.is_a?(UITextView)))
33
32
  if options.slice(:width, :height, :right, :bottom, :height_to_fit).values.any?
34
33
  mask = UIViewAutoresizingNone
35
34
  mask |= UIViewAutoresizingFlexibleTopMargin if options[:top].nil?
@@ -37,7 +36,7 @@ module MotionPrime
37
36
  mask |= UIViewAutoresizingFlexibleBottomMargin if options[:bottom].nil?
38
37
  mask |= UIViewAutoresizingFlexibleRightMargin if options[:right].nil?
39
38
  mask |= UIViewAutoresizingFlexibleWidth if !options[:left].nil? && !options[:right].nil?
40
- mask |= UIViewAutoresizingFlexibleHeight if !options[:top].nil? && !options[:bottom].nil?
39
+ mask |= UIViewAutoresizingFlexibleHeight if options[:height_to_fit].nil? && (!options[:top].nil? && !options[:bottom].nil?)
41
40
  options[:autoresizingMask] = mask
42
41
  end
43
42
  end
@@ -47,7 +46,7 @@ module MotionPrime
47
46
  # ignore options
48
47
  return if key == 'section' && !view.respond_to?(:section=)
49
48
  return if key == 'size_to_fit' && view.is_a?(UILabel)
50
- return if (key == 'url' || key == 'default') && view.is_a?(UIImageView)
49
+ return if %w[url default draw_in_rect].include?(key.to_s) && view.is_a?(UIImageView)
51
50
  return if %w[
52
51
  styles has_drawn_content
53
52
  width height top right bottom left value_type
@@ -105,14 +104,6 @@ module MotionPrime
105
104
  mask_layer.frame = bounds
106
105
  mask_layer.path = mask_path.CGPath
107
106
  view.mask = mask_layer
108
- elsif key == 'mask'
109
- radius = value[:radius]
110
- bounds = CGRectMake(0, 0, value[:width], value[:height])
111
- mask_path = UIBezierPath.bezierPathWithRoundedRect(bounds, byRoundingCorners: UIRectCornerAllCorners, cornerRadii: CGSizeMake(radius, radius))
112
- mask_layer = CAShapeLayer.layer
113
- mask_layer.frame = bounds
114
- mask_layer.path = mask_path.CGPath
115
- view.layer.mask = mask_layer
116
107
  elsif key == 'attributed_text_options'
117
108
  attributes = {}
118
109
  if line_spacing = value[:line_spacing]
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-prime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: motion-stump
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: motion-redgreen
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cocoapods
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: motion-cocoapods
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: motion-require
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: motion-support
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bubble-wrap
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: sugarcube
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: methadone
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  description: RubyMotion apps development framework
@@ -172,6 +172,7 @@ files:
172
172
  - doc/SECTION.md
173
173
  - doc/STYLE.md
174
174
  - doc/code/getting_started.rb
175
+ - doc/code/screens.rb
175
176
  - doc/docs/docco.css
176
177
  - doc/docs/getting_started.html
177
178
  - doc/docs/public/fonts/aller-bold.eot
@@ -184,10 +185,13 @@ files:
184
185
  - doc/docs/public/fonts/novecento-bold.ttf
185
186
  - doc/docs/public/fonts/novecento-bold.woff
186
187
  - doc/docs/public/stylesheets/normalize.css
188
+ - doc/docs/screens.html
187
189
  - files/Gemfile
190
+ - files/Gemfile.lock
188
191
  - files/Rakefile
189
192
  - files/app/app_delegate.rb
190
193
  - files/app/config/base.rb
194
+ - files/app/environment.rb
191
195
  - files/app/models/.gitkeep
192
196
  - files/app/screens/application_screen.rb
193
197
  - files/app/screens/help_screen.rb
@@ -202,6 +206,8 @@ files:
202
206
  - files/resources/Icon.png
203
207
  - files/resources/fonts/ubuntu.ttf
204
208
  - files/resources/images/arrow.png
209
+ - files/resources/images/menu_button.png
210
+ - files/resources/images/menu_button@2x.png
205
211
  - lib/motion-prime.rb
206
212
  - motion-prime.gemspec
207
213
  - motion-prime/api_client.rb
@@ -211,6 +217,7 @@ files:
211
217
  - motion-prime/core_ext/kernel.rb
212
218
  - motion-prime/elements/_content_padding_mixin.rb
213
219
  - motion-prime/elements/_content_text_mixin.rb
220
+ - motion-prime/elements/_text_mixin.rb
214
221
  - motion-prime/elements/base_element.rb
215
222
  - motion-prime/elements/button.rb
216
223
  - motion-prime/elements/draw.rb
@@ -255,7 +262,7 @@ files:
255
262
  - motion-prime/screens/extensions/_navigation_bar_mixin.rb
256
263
  - motion-prime/screens/sidebar_container_screen.rb
257
264
  - motion-prime/sections/_cell_section_mixin.rb
258
- - motion-prime/sections/_draw_mixin.rb
265
+ - motion-prime/sections/_draw_section_mixin.rb
259
266
  - motion-prime/sections/base_section.rb
260
267
  - motion-prime/sections/form.rb
261
268
  - motion-prime/sections/form/base_field_section.rb
@@ -270,6 +277,7 @@ files:
270
277
  - motion-prime/sections/tabbed.rb
271
278
  - motion-prime/sections/table.rb
272
279
  - motion-prime/sections/table/refresh_mixin.rb
280
+ - motion-prime/sections/table/table_delegate.rb
273
281
  - motion-prime/services/table_data_indexes.rb
274
282
  - motion-prime/styles/_mixins.rb
275
283
  - motion-prime/styles/base.rb
@@ -318,17 +326,17 @@ require_paths:
318
326
  - lib
319
327
  required_ruby_version: !ruby/object:Gem::Requirement
320
328
  requirements:
321
- - - ! '>='
329
+ - - '>='
322
330
  - !ruby/object:Gem::Version
323
331
  version: '0'
324
332
  required_rubygems_version: !ruby/object:Gem::Requirement
325
333
  requirements:
326
- - - ! '>='
334
+ - - '>='
327
335
  - !ruby/object:Gem::Version
328
336
  version: '0'
329
337
  requirements: []
330
338
  rubyforge_project:
331
- rubygems_version: 2.0.5
339
+ rubygems_version: 2.0.6
332
340
  signing_key:
333
341
  specification_version: 4
334
342
  summary: RubyMotion apps development framework
@@ -1,66 +0,0 @@
1
- module MotionPrime
2
- module DrawMixin
3
- include HasStyles
4
- attr_accessor :container_element, :container_gesture_recognizers
5
-
6
- def container_view
7
- container_element.try(:view)
8
- end
9
-
10
- def draw_in(rect)
11
- draw_background(rect)
12
- draw_elements(rect)
13
- end
14
-
15
- def bind_gesture_on_container_for(element, action, receiver = nil)
16
- self.container_gesture_recognizers ||= begin
17
- set_container_gesture_recognizer
18
- []
19
- end
20
- self.container_gesture_recognizers << {element: element, action: action, receiver: receiver}
21
- end
22
-
23
- private
24
- def set_container_gesture_recognizer
25
- single_tap = UITapGestureRecognizer.alloc.initWithTarget(self, action: 'on_container_tap_gesture:')
26
- single_tap.cancelsTouchesInView = false
27
- container_view.addGestureRecognizer single_tap
28
- container_view.setUserInteractionEnabled true
29
- end
30
-
31
- def on_container_tap_gesture(recognizer)
32
- target = Array.wrap(container_gesture_recognizers).detect do |gesture_data|
33
- CGRectContainsPoint(gesture_data[:element].computed_frame, recognizer.locationInView(container_view))
34
- end
35
- (target[:receiver] || self).send(target[:action], recognizer, target[:element]) if target
36
- end
37
-
38
- def draw_elements(rect)
39
- elements_to_draw.each do |key, element|
40
- element.draw_in(rect)
41
- end
42
- end
43
-
44
- def draw_background(rect)
45
- options = container_element.computed_options
46
-
47
- if gradient_options = options[:gradient]
48
- start_point = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect))
49
- end_point = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect))
50
-
51
- context = UIGraphicsGetCurrentContext()
52
- # CGContextSaveGState(context)
53
- CGContextAddRect(context, rect)
54
- CGContextClip(context)
55
- gradient = prepare_gradient(gradient_options)
56
- CGContextDrawLinearGradient(context, gradient, start_point, end_point, 0)
57
- # CGContextRestoreGState(context)
58
- elsif background_color = options[:background_color]
59
- unless background_color.uicolor == :clear.uicolor
60
- background_color.uicolor.setFill
61
- UIRectFill(rect)
62
- end
63
- end
64
- end
65
- end
66
- end