motion-prime 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmViYTYyYjYzMjkwMGEzMzVkZWQ4ZGVmOGM3NjBmYzQ0YWViZTJmNA==
4
+ MzczMDQyODkxMTkxZTg5MTY4MjhlYTlkN2NkNmMzNjBiZTI4MTM2Mw==
5
5
  data.tar.gz: !binary |-
6
- MDJlN2YxOGJhMWIwZTU2MjVmNmQ1NzM4YjQ5MWY0ZDFmYzZhZWE1Nw==
6
+ Y2IxMjIyNGI0MGM3Y2M4MWM3NWMzMjMxYTY3NjE1OWUwOTM0MzA0NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjljMjBmZDg2MDI1NTYxYTliMzgxZGE4MDQyNDViMmE4OTMxYThlMjJiM2Jk
10
- YWNkYmQwODA5MzVmODk4OWE5YjVkNTUwYTEyNGJiMThhODgwYjMyNzUzZmRl
11
- NzA0MDUzNzhiZTYwOTkwYjI1NDMyNGJlNTZmMjVmZTkwNzkyZDI=
9
+ ZDZjNmZiZjNiM2IyYTYxZGJjOWNlZTYzM2JiZGJiZWE2YTIxYmRhODE1NDli
10
+ ZmFiNTMxNmYzZWE3ZGM2YWQyMTg2ZWEwNTFhYmE4N2VkZTRjZTNjMjUzZmJi
11
+ NGEzZjQ5OTY0YjE4Y2JjOWJjOGM4NzMxYzc0MTNjMTNlYTUwNjM=
12
12
  data.tar.gz: !binary |-
13
- YTEwNWUzNWZjMWNlMzQwN2JjZTdlYWViODBlZWU5MWMwNzY4ZDFhNThhODkw
14
- NjRlZGViMTJmMWIyMmE4ODA2MTg5MmFhYmY2ZjlkYmM1NGJiMjcwZjA4OWY0
15
- MGRmMjg5MjE4YTZiZDc2YzNhZjQ1MjU4ODhmYTFmNzIyOGE0ZmI=
13
+ YWQ4ZmVmMzM0ZDc5YWQxYzM1YWM2ODM5MDRlMDcwZDE0MjhiNDViZmIzYjI1
14
+ MjYzNTc2ZTIzMWIwMTNkMjJiNDIzODM2MTJlYjM1ZWVlNGFkNGE2MGYyYzg4
15
+ ZDU0YWNhNzMyZmYzNjRjY2U4NDBkNGJhZjU4MmVhYWYxM2FjZTE=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.8.5
2
+ * Table header improvements.
3
+ * Fix bug: header section draw elements doesn't work
4
+
1
5
  === 0.8.3 - 0.8.4
2
6
  * Ability to pass UIButton to set_navigation_left_button/set_navigation_right_button
3
7
  * Bug fixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.8.4)
4
+ motion-prime (0.8.5)
5
5
  afmotion (~> 2.0.0)
6
6
  bubble-wrap (~> 1.4.0)
7
7
  cocoapods
data/ROADMAP.md CHANGED
@@ -1,8 +1,8 @@
1
- === 0.8.2
1
+ === 0.9.0
2
2
  * Move api_client and model sync mixin to prime_api gem.
3
3
  * Move bind keyboard events to forms.
4
4
 
5
- === 0.9.0
5
+ === 0.1.0
6
6
  * bug: if mp label do not have text and was set as hidden, it should unhide after setting text
7
7
  * bug: size_to_fit works incorrect with relative width.
8
8
  * bug: bind_keyboard_close breaks bind_guesture
@@ -15,10 +15,10 @@
15
15
  * add different templates. some templates should be more like final app.
16
16
  * add size_to_fit support for images.
17
17
 
18
- === 1.0.0
18
+ === 1.1.0
19
19
  * add sections/screens/models generator
20
20
 
21
- === 1.1.0
21
+ === 1.2.0
22
22
  * add cell preload for reverse scrolling table.
23
23
  * add computed_options.get(), this will allow to make sure that options is computed.
24
24
  * add testing framework
data/files/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
3
3
  gem 'motion-cocoapods', '~> 1.4.0'
4
4
  gem 'motion-support', '~> 0.2.4'
5
5
 
6
- gem 'motion-prime', '0.8.4'
6
+ gem 'motion-prime', '0.8.5'
7
7
 
8
8
  # add reside menu for sidebar support
9
9
  gem 'prime_reside_menu', '~> 0.1.4'
@@ -0,0 +1,7 @@
1
+ module MotionPrime
2
+ class TableHeaderElement < BaseElement
3
+ def view_class
4
+ "MPTableHeaderWithSectionView"
5
+ end
6
+ end
7
+ end
@@ -331,7 +331,7 @@ module MotionPrime
331
331
  def build_element(options = {})
332
332
  type = options.delete(:type)
333
333
  render_as = options.delete(:as).to_s
334
- if render_as != 'draw' && (render_as == 'view' || self.is_a?(BaseFieldSection) || self.is_a?(BaseHeaderSection))
334
+ if render_as != 'draw' && (render_as == 'view' || self.is_a?(BaseFieldSection) || self.is_a?(FormHeaderSection))
335
335
  BaseElement.factory(type, options)
336
336
  else
337
337
  DrawElement.factory(type, options) || BaseElement.factory(type, options)
@@ -247,7 +247,7 @@ module MotionPrime
247
247
  end
248
248
 
249
249
  def init_form_headers
250
- options = Array.wrap(self.class.group_header_options).clone
250
+ options = Array.wrap(self.class.group_header_options).map(&:clone)
251
251
  options.compact.each { |opts| normalize_options(opts) }
252
252
  self.group_header_options = options.delete_if.each_with_index { |opts, id| grouped_data[id].nil? }
253
253
  end
@@ -1,17 +1,11 @@
1
+ motion_require '../header.rb'
1
2
  module MotionPrime
2
- class BaseHeaderSection < Section
3
- include CellSectionMixin
3
+ class FormHeaderSection < HeaderSection
4
4
  DEFAULT_HEADER_HEIGHT = 20
5
5
 
6
6
  element :title, text: proc { @options[:title] }
7
7
  element :hint, text: proc { @options[:hint] }
8
8
 
9
- before_initialize :prepare_header_options
10
-
11
- def prepare_header_options
12
- @cell_type = :header
13
- end
14
-
15
9
  def render_element?(name)
16
10
  @options[name].present?
17
11
  end
@@ -0,0 +1,11 @@
1
+ module MotionPrime
2
+ class HeaderSection < Section
3
+ include Prime::CellSectionMixin
4
+
5
+ before_initialize :prepare_header_options
6
+
7
+ def prepare_header_options
8
+ @cell_type = :header
9
+ end
10
+ end
11
+ end
@@ -100,10 +100,10 @@ module MotionPrime
100
100
  def delete_cell_sections(sections)
101
101
  paths = []
102
102
  Array.wrap(sections).each do |section|
103
- index = @data.try(:index, section)
103
+ index = index_for_cell_section(section)
104
104
  next Prime.logger.debug("Delete cell section: `#{section.name}` is not in the list") unless index
105
- paths << NSIndexPath.indexPathForRow(index, inSection: 0)
106
- delete_from_data(section)
105
+ paths << index
106
+ delete_from_data(index)
107
107
  end
108
108
  if paths.any?
109
109
  table_view.beginUpdates
@@ -113,13 +113,37 @@ module MotionPrime
113
113
  paths
114
114
  end
115
115
 
116
- def delete_from_data(section)
117
- # section will not deallocate if you'll just write @data.delete(section)
118
- unless index = @data.try(:index, section)
119
- Prime.logger.debug("Delete cell section from @data: `#{section.name}` is not in the list") and return
116
+ # Delete section from data at index
117
+ #
118
+ # @param index [NSIndexPath] index of cell which will be removed from table data.
119
+ def delete_from_data(index)
120
+ if flat_data?
121
+ delete_from_flat_data(index)
122
+ else
123
+ delete_from_groped_data(index)
124
+ end
125
+ end
126
+
127
+ def delete_from_flat_data(index)
128
+ @data[index.row] = nil
129
+ @data.delete_at(index.row)
130
+ end
131
+
132
+ def delete_from_groped_data(index)
133
+ @data[index.section][index.row] = nil
134
+ @data[index.section].delete_at(index.row)
135
+ end
136
+
137
+ def index_for_cell_section(section)
138
+ if flat_data?
139
+ row = @data.try(:index, section)
140
+ NSIndexPath.indexPathForRow(row, inSection: 0)
141
+ else
142
+ (@data || []).each_with_index do |cell_sections, group|
143
+ row = cell_sections.index(section)
144
+ return NSIndexPath.indexPathForRow(row, inSection: group) if row
145
+ end
120
146
  end
121
- @data[index] = nil
122
- @data.delete_at(index)
123
147
  end
124
148
 
125
149
  def reload_cell_section(section)
@@ -225,14 +249,14 @@ module MotionPrime
225
249
  view
226
250
  end
227
251
 
228
- def render_header(section)
229
- return unless options = self.group_header_options.try(:[], section)
230
- self.group_header_sections[section] ||= BaseHeaderSection.new(options.merge(screen: screen, table: self.weak_ref))
252
+ def render_header(group)
253
+ return unless options = self.group_header_options.try(:[], group)
254
+ self.group_header_sections[group] ||= FormHeaderSection.new(options.merge(screen: screen, table: self.weak_ref))
231
255
  end
232
256
 
233
- def header_section_for_group(section)
257
+ def header_section_for_group(group)
234
258
  self.group_header_sections ||= []
235
- self.group_header_sections[section] || render_header(section)
259
+ self.group_header_sections[group] || render_header(group)
236
260
  end
237
261
 
238
262
  def on_cell_render(cell, index); end
@@ -285,12 +309,18 @@ module MotionPrime
285
309
  def header_cell_in_group(table, group)
286
310
  return unless header = header_section_for_group(group)
287
311
 
288
- reuse_identifier = "header_#{group}"
312
+ reuse_identifier = "header_#{group}_#{@header_stamp}"
289
313
  cached = table.dequeueReusableHeaderFooterViewWithIdentifier(reuse_identifier)
290
314
  return cached if cached.present?
291
315
 
292
316
  styles = cell_section_styles(header).values.flatten
293
- wrapper = MotionPrime::BaseElement.factory(:table_view_header_footer_view, screen: screen, styles: styles, parent_view: table_view, reuse_identifier: reuse_identifier)
317
+ wrapper = MotionPrime::BaseElement.factory(:table_header,
318
+ screen: screen,
319
+ styles: styles,
320
+ parent_view: table_view,
321
+ reuse_identifier: reuse_identifier,
322
+ section: header
323
+ )
294
324
  wrapper.render do |container_view, container_element|
295
325
  header.container_element = container_element
296
326
  header.render
@@ -364,9 +394,14 @@ module MotionPrime
364
394
  end
365
395
  end
366
396
 
397
+ def set_header_stamp
398
+ @header_stamp = Time.now.to_i
399
+ end
400
+
367
401
  def reset_data_stamps
368
402
  keys = data.flatten.map(&:object_id)
369
403
  set_data_stamp(keys)
404
+ set_header_stamp
370
405
  end
371
406
 
372
407
  def create_section_elements
@@ -4,7 +4,6 @@ class MPCellWithSection < UITableViewCell
4
4
 
5
5
  def setNeedsDisplay
6
6
  content_view.try(:setNeedsDisplay)
7
-
8
7
  super
9
8
  end
10
9
 
@@ -0,0 +1,23 @@
1
+ class MPTableHeaderWithSectionView < UITableViewHeaderFooterView
2
+ attr_accessor :section, :selection_style, :content_view
3
+
4
+ def setSection(section)
5
+ @section = section.try(:weak_ref)
6
+ self.content_view.setSection(@section)
7
+ end
8
+
9
+ def setNeedsDisplay
10
+ content_view.try(:setNeedsDisplay)
11
+ super
12
+ end
13
+
14
+ def initialize_content
15
+ self.content_view = MPTableViewCellContentView.alloc.initWithFrame(self.bounds)
16
+ self.content_view.setBackgroundColor(:clear.uicolor)
17
+ self.content_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
18
+ self.content_view.top = 0
19
+ self.content_view.left = 0
20
+
21
+ self.addSubview(content_view)
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
@@ -7,6 +7,7 @@ module MotionPrime
7
7
  right = options[:right]
8
8
  bottom = options[:bottom]
9
9
  left = options[:left]
10
+
10
11
  value_type = options[:value_type].to_s # absolute/relative
11
12
 
12
13
  if options[:height_to_fit].present? && height.nil? && (top.nil? || bottom.nil?)
@@ -72,6 +73,7 @@ module MotionPrime
72
73
  frame.origin.y = max_height / 2 - height / 2
73
74
  end
74
75
  frame.size.height = height
76
+
75
77
  frame
76
78
  rescue => e
77
79
  Prime.logger.error "can't calculate frame in #{self.class.name}. #{e}"
@@ -94,7 +94,16 @@ module MotionPrime
94
94
  end
95
95
 
96
96
  obj = klass.alloc.initWithStyle style, reuseIdentifier: options.delete(:reuse_identifier)
97
- obj.initialize_content
97
+ obj.initialize_content if obj.respond_to?(:initialize_content)
98
+ obj
99
+ },
100
+ 'UITableViewHeaderFooterView' => Proc.new{|klass, options|
101
+ if options[:has_drawn_content]
102
+ options[:background_color] = :clear
103
+ options.delete(:gradient)
104
+ end
105
+ obj = klass.alloc.initWithReuseIdentifier options.delete(:reuse_identifier)
106
+ obj.initialize_content if obj.respond_to?(:initialize_content)
98
107
  obj
99
108
  },
100
109
  'MPViewWithSection' => Proc.new{|klass, options|
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
4
+ version: 0.8.5
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-25 00:00:00.000000000 Z
12
+ date: 2014-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -265,6 +265,7 @@ files:
265
265
  - motion-prime/elements/map.rb
266
266
  - motion-prime/elements/progress_hud.rb
267
267
  - motion-prime/elements/spinner.rb
268
+ - motion-prime/elements/table_header.rb
268
269
  - motion-prime/elements/table_view.rb
269
270
  - motion-prime/elements/table_view_cell.rb
270
271
  - motion-prime/elements/text_field.rb
@@ -310,9 +311,9 @@ files:
310
311
  - motion-prime/sections/base_section.rb
311
312
  - motion-prime/sections/form.rb
312
313
  - motion-prime/sections/form/base_field_section.rb
313
- - motion-prime/sections/form/base_header_section.rb
314
314
  - motion-prime/sections/form/date_field_section.rb
315
315
  - motion-prime/sections/form/form_delegate.rb
316
+ - motion-prime/sections/form/form_header_section.rb
316
317
  - motion-prime/sections/form/password_field_section.rb
317
318
  - motion-prime/sections/form/select_field_section.rb
318
319
  - motion-prime/sections/form/static_field_section.rb
@@ -320,6 +321,7 @@ files:
320
321
  - motion-prime/sections/form/submit_field_section.rb
321
322
  - motion-prime/sections/form/switch_field_section.rb
322
323
  - motion-prime/sections/form/text_field_section.rb
324
+ - motion-prime/sections/header.rb
323
325
  - motion-prime/sections/tabbed.rb
324
326
  - motion-prime/sections/table.rb
325
327
  - motion-prime/sections/table/refresh_mixin.rb
@@ -337,6 +339,7 @@ files:
337
339
  - motion-prime/support/mp_label.rb
338
340
  - motion-prime/support/mp_search_bar_custom.rb
339
341
  - motion-prime/support/mp_spinner.rb
342
+ - motion-prime/support/mp_table_header_with_section.rb
340
343
  - motion-prime/support/mp_table_view.rb
341
344
  - motion-prime/support/mp_text_field.rb
342
345
  - motion-prime/support/mp_text_view.rb