motion-prime 0.8.4 → 0.8.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.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/ROADMAP.md +4 -4
- data/files/Gemfile +1 -1
- data/motion-prime/elements/table_header.rb +7 -0
- data/motion-prime/sections/base_section.rb +1 -1
- data/motion-prime/sections/form.rb +1 -1
- data/motion-prime/sections/form/{base_header_section.rb → form_header_section.rb} +2 -8
- data/motion-prime/sections/header.rb +11 -0
- data/motion-prime/sections/table.rb +51 -16
- data/motion-prime/support/mp_cell_with_section.rb +0 -1
- data/motion-prime/support/mp_table_header_with_section.rb +23 -0
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/_frame_calculator_mixin.rb +2 -0
- data/motion-prime/views/view_builder.rb +10 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzczMDQyODkxMTkxZTg5MTY4MjhlYTlkN2NkNmMzNjBiZTI4MTM2Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2IxMjIyNGI0MGM3Y2M4MWM3NWMzMjMxYTY3NjE1OWUwOTM0MzA0NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZjNmZiZjNiM2IyYTYxZGJjOWNlZTYzM2JiZGJiZWE2YTIxYmRhODE1NDli
|
10
|
+
ZmFiNTMxNmYzZWE3ZGM2YWQyMTg2ZWEwNTFhYmE4N2VkZTRjZTNjMjUzZmJi
|
11
|
+
NGEzZjQ5OTY0YjE4Y2JjOWJjOGM4NzMxYzc0MTNjMTNlYTUwNjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWQ4ZmVmMzM0ZDc5YWQxYzM1YWM2ODM5MDRlMDcwZDE0MjhiNDViZmIzYjI1
|
14
|
+
MjYzNTc2ZTIzMWIwMTNkMjJiNDIzODM2MTJlYjM1ZWVlNGFkNGE2MGYyYzg4
|
15
|
+
ZDU0YWNhNzMyZmYzNjRjY2U4NDBkNGJhZjU4MmVhYWYxM2FjZTE=
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/ROADMAP.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
=== 0.
|
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.
|
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.
|
18
|
+
=== 1.1.0
|
19
19
|
* add sections/screens/models generator
|
20
20
|
|
21
|
-
=== 1.
|
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
@@ -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?(
|
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
|
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
|
@@ -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 =
|
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 <<
|
106
|
-
delete_from_data(
|
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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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(
|
229
|
-
return unless options = self.group_header_options.try(:[],
|
230
|
-
self.group_header_sections[
|
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(
|
257
|
+
def header_section_for_group(group)
|
234
258
|
self.group_header_sections ||= []
|
235
|
-
self.group_header_sections[
|
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(:
|
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
|
@@ -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
|
data/motion-prime/version.rb
CHANGED
@@ -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
|
+
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-
|
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
|