motion-prime 0.9.4 → 0.9.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 +6 -0
- data/Gemfile.lock +3 -3
- data/ROADMAP.md +1 -0
- data/files/Gemfile +1 -1
- data/generators/scaffold_generator.rb +2 -2
- data/generators/templates/scaffold/styles.rb +1 -1
- data/motion-prime.gemspec +4 -4
- data/motion-prime/config/base.rb +2 -1
- data/motion-prime/delegate/_base_mixin.rb +9 -2
- data/motion-prime/elements/draw.rb +20 -28
- data/motion-prime/elements/draw/label.rb +5 -5
- data/motion-prime/models/_finder_mixin.rb +4 -22
- data/motion-prime/prime.rb +1 -1
- data/motion-prime/screens/_base_mixin.rb +4 -2
- data/motion-prime/screens/_navigation_mixin.rb +1 -1
- data/motion-prime/screens/_sections_mixin.rb +31 -3
- data/motion-prime/screens/controllers/navigation_controller.rb +12 -0
- data/motion-prime/{support → screens/controllers}/tab_bar_controller.rb +0 -0
- data/motion-prime/screens/extensions/_navigation_bar_mixin.rb +1 -1
- data/motion-prime/sections/_cell_section_mixin.rb +7 -0
- data/motion-prime/sections/base_section.rb +21 -14
- data/motion-prime/sections/table.rb +6 -6
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/_frame_calculator_mixin.rb +1 -1
- data/motion-prime/views/view_styler.rb +139 -79
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGU1Njc4YzVkNGIyNmZjNDg0MWIwZGYzYmMwMDliNWZhMDVkNWI5Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGNiYjkyMThmM2QwZWU5YzQzM2E0YWI0ZDgxZjlkMzAzZDQ3NDU1MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODg2YmIyZTc5Y2ZhMGQxZTMzNDlhM2RmNDdlM2FmN2RiOTVjZGJhMjE4ODBl
|
10
|
+
NjU3NTY2MDNjYjk3ZWMzNmM1MWJjMTI4OGY5NjUzMWRhOWRlNzI2ZmIzNTdl
|
11
|
+
MjdhYzdjMTk0OGUwODZlYTIzNWQ1ZmZkNTQ3YzBlZWY0YzFhNmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzdiYTliMTNmNWVhMzI2NDZjNzRlZGVmYzllODI1YTg2ZjAyYmRiMGIyYmU3
|
14
|
+
N2EzODQ2YWM2OGE2M2U4ZGRjM2NmN2RkODA2NTM3ZTJmNzhkYmEyYmJjYmIw
|
15
|
+
MWU5ZTkzNzdiY2JjNjhiYTUyZjY0MmE2ZjhiZDk3MmMwYmFhMzk=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.9.5
|
2
|
+
* Ability to set wrapper for sections in screen.
|
3
|
+
* Screen refresh reloads all sections in screen.
|
4
|
+
* Fix overriding title color of button in nav bar.
|
5
|
+
* Better support for edge inset attributes.
|
6
|
+
|
1
7
|
=== 0.9.4
|
2
8
|
* Ability to render multiple sections inside screen action.
|
3
9
|
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
motion-prime (0.9.
|
4
|
+
motion-prime (0.9.5)
|
5
5
|
activesupport
|
6
|
-
afmotion (~> 2.
|
6
|
+
afmotion (~> 2.1.0)
|
7
7
|
bubble-wrap (~> 1.5.0)
|
8
8
|
cocoapods
|
9
9
|
methadone
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
activesupport (3.2.17)
|
21
21
|
i18n (~> 0.6, >= 0.6.4)
|
22
22
|
multi_json (~> 1.0)
|
23
|
-
afmotion (2.
|
23
|
+
afmotion (2.1.0)
|
24
24
|
motion-cocoapods (~> 1.4.0)
|
25
25
|
motion-require (~> 0.0.7)
|
26
26
|
bubble-wrap (1.5.0)
|
data/ROADMAP.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
=== 1.0.0
|
2
|
+
* bug: size_to_fit makes draw label multiline by default.
|
2
3
|
* bug: content_vertical_alignment conflicts with padding.
|
3
4
|
* bug: content_vertical_alignment has not ideal centering.
|
4
5
|
* bug: if mp label do not have text and was set as hidden, it should unhide after setting text.
|
data/files/Gemfile
CHANGED
@@ -8,8 +8,8 @@ class MotionPrime::ScaffoldGenerator < MotionPrime::Generator
|
|
8
8
|
@p_class_name = @p_name.camelize
|
9
9
|
template 'scaffold/screen.rb', "app/screens/#{@p_name}.rb"
|
10
10
|
template 'scaffold/model.rb', "app/models/#{@s_name}.rb"
|
11
|
-
template 'scaffold/table.rb', "app/sections/#{@p_name}/
|
12
|
-
template 'scaffold/cell.rb', "app/sections/#{@p_name}/
|
11
|
+
template 'scaffold/table.rb', "app/sections/#{@p_name}/index_table.rb"
|
12
|
+
template 'scaffold/cell.rb', "app/sections/#{@p_name}/index_cell.rb"
|
13
13
|
template 'scaffold/form.rb', "app/sections/#{@p_name}/form.rb"
|
14
14
|
template 'scaffold/show.rb', "app/sections/#{@p_name}/show.rb"
|
15
15
|
template 'scaffold/styles.rb', "app/styles/#{@p_name}.rb"
|
data/motion-prime.gemspec
CHANGED
@@ -26,9 +26,9 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency "motion-support", '~> 0.2.6'
|
27
27
|
spec.add_dependency 'bubble-wrap', '~> 1.5.0'
|
28
28
|
spec.add_dependency 'sugarcube', '~> 1.5.2'
|
29
|
-
spec.add_dependency 'afmotion', '~> 2.
|
29
|
+
spec.add_dependency 'afmotion', '~> 2.1.0'
|
30
30
|
spec.add_dependency "methadone"
|
31
|
-
spec.add_dependency "rm-digest"
|
32
|
-
spec.add_dependency "thor"
|
33
|
-
spec.add_dependency "activesupport"
|
31
|
+
spec.add_dependency "rm-digest"
|
32
|
+
spec.add_dependency "thor"
|
33
|
+
spec.add_dependency "activesupport"
|
34
34
|
end
|
data/motion-prime/config/base.rb
CHANGED
@@ -6,12 +6,13 @@ MotionPrime::Config.configure do |config|
|
|
6
6
|
config.model.store_type = :file
|
7
7
|
end
|
8
8
|
config.model.auto_generate_id = true
|
9
|
-
|
9
|
+
|
10
10
|
config.fonts do |fonts|
|
11
11
|
fonts.base = :system
|
12
12
|
end
|
13
13
|
|
14
14
|
config.colors do |colors|
|
15
|
+
colors.navigation_base = 0x1b75bc
|
15
16
|
colors.base = 0x1b75bc
|
16
17
|
colors.dark = 0x333333
|
17
18
|
colors.error = 0xef471f
|
@@ -18,6 +18,7 @@ module MotionPrime
|
|
18
18
|
def application(application, didRegisterForRemoteNotificationsWithDeviceToken: token)
|
19
19
|
on_apn_register_success(application, token)
|
20
20
|
end
|
21
|
+
|
21
22
|
def application(application, didFailToRegisterForRemoteNotificationsWithError: error)
|
22
23
|
on_apn_register_fail(application, error)
|
23
24
|
end
|
@@ -25,8 +26,14 @@ module MotionPrime
|
|
25
26
|
def on_load(application, launch_options)
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
# Return the main controller.
|
30
|
+
def main_controller
|
31
|
+
window.rootViewController
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return content controller (without sidebar)
|
35
|
+
def content_controller
|
36
|
+
main_controller.content_controller
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -11,7 +11,7 @@ module MotionPrime
|
|
11
11
|
options = computed_options
|
12
12
|
background_color = options[:background_color].try(:uicolor)
|
13
13
|
{
|
14
|
-
rect: CGRectMake(
|
14
|
+
rect: CGRectMake(frame_left, frame_top, frame_outer_width, frame_outer_height),
|
15
15
|
background_color: background_color,
|
16
16
|
masks_to_bounds: options[:layer].try(:[], :masks_to_bounds) || options[:clips_to_bounds],
|
17
17
|
corner_radius: options[:layer].try(:[], :corner_radius).to_f,
|
@@ -27,39 +27,13 @@ module MotionPrime
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def computed_frame
|
30
|
-
@computed_frame ||=
|
30
|
+
@computed_frame ||= calculate_frame_for(view.try(:bounds) || section.container_bounds, computed_options)
|
31
31
|
end
|
32
32
|
|
33
33
|
def default_padding_for(side)
|
34
34
|
0
|
35
35
|
end
|
36
36
|
|
37
|
-
def computed_max_width
|
38
|
-
view.bounds.size.width
|
39
|
-
end
|
40
|
-
|
41
|
-
def computed_max_height
|
42
|
-
view.bounds.size.height
|
43
|
-
end
|
44
|
-
|
45
|
-
def computed_outer_width; computed_frame.size.width end
|
46
|
-
def computed_width; computed_outer_width - content_padding_width end
|
47
|
-
|
48
|
-
def computed_outer_height; computed_frame.size.height end
|
49
|
-
def computed_height; computed_outer_height - content_padding_height end
|
50
|
-
|
51
|
-
def computed_top; computed_frame.origin.y end
|
52
|
-
def computed_inner_top; computed_top + content_padding_top end
|
53
|
-
|
54
|
-
def computed_left; computed_frame.origin.x end
|
55
|
-
def computed_inner_left; computed_left + content_padding_left end
|
56
|
-
|
57
|
-
def computed_bottom; computed_top + computed_outer_height end
|
58
|
-
def computed_inner_bottom; computed_bottom - content_padding_bottom end
|
59
|
-
|
60
|
-
def computed_right; computed_left + computed_width end
|
61
|
-
def computed_inner_right; computed_right - content_padding_right end
|
62
|
-
|
63
37
|
def bind_gesture(action, receiver = nil, target = nil)
|
64
38
|
target ||= section
|
65
39
|
target.bind_gesture_on_container_for(self, action, receiver)
|
@@ -92,6 +66,24 @@ module MotionPrime
|
|
92
66
|
end
|
93
67
|
|
94
68
|
private
|
69
|
+
def frame_outer_width; computed_frame.size.width end
|
70
|
+
def frame_width; frame_outer_width - content_padding_width end
|
71
|
+
|
72
|
+
def frame_outer_height; computed_frame.size.height end
|
73
|
+
def frame_height; frame_outer_height - content_padding_height end
|
74
|
+
|
75
|
+
def frame_top; computed_frame.origin.y end
|
76
|
+
def frame_inner_top; frame_top + content_padding_top end
|
77
|
+
|
78
|
+
def frame_left; computed_frame.origin.x end
|
79
|
+
def frame_inner_left; frame_left + content_padding_left end
|
80
|
+
|
81
|
+
def frame_bottom; frame_top + frame_outer_height end
|
82
|
+
def frame_inner_bottom; frame_bottom - content_padding_bottom end
|
83
|
+
|
84
|
+
def frame_right; frame_left + frame_outer_width end
|
85
|
+
def frame_inner_right; frame_right - content_padding_right end
|
86
|
+
|
95
87
|
def reset_computed_values
|
96
88
|
@content_height = nil
|
97
89
|
@content_width = nil
|
@@ -16,9 +16,9 @@ module MotionPrime
|
|
16
16
|
line_break_mode_name = options.fetch(:line_break_mode, :tail_truncation)
|
17
17
|
line_break_mode = line_break_mode_name.uilinebreakmode
|
18
18
|
|
19
|
-
top_left_corner = CGPointMake(
|
19
|
+
top_left_corner = CGPointMake(frame_inner_left, frame_inner_top)
|
20
20
|
if options[:number_of_lines].to_i.zero?
|
21
|
-
inner_rect = CGRectMake(*top_left_corner.to_a,
|
21
|
+
inner_rect = CGRectMake(*top_left_corner.to_a, frame_width, frame_height)
|
22
22
|
end
|
23
23
|
super.merge({
|
24
24
|
text: text,
|
@@ -97,10 +97,10 @@ module MotionPrime
|
|
97
97
|
|
98
98
|
def set_text_position
|
99
99
|
if computed_options.slice(:padding_top, :padding_bottom, :padding).values.none?
|
100
|
-
computed_options[:width] ||=
|
100
|
+
computed_options[:width] ||= frame_width
|
101
101
|
content_height = cached_content_height
|
102
|
-
content_height =
|
103
|
-
@padding_top = (
|
102
|
+
content_height = frame_outer_height if content_height > frame_outer_height
|
103
|
+
@padding_top = (frame_outer_height - content_height)/2
|
104
104
|
# @padding_top += 1 unless @padding_top.zero?
|
105
105
|
end
|
106
106
|
end
|
@@ -64,12 +64,8 @@ module MotionPrime
|
|
64
64
|
raise "Unexpected parameters: #{arg}."
|
65
65
|
end
|
66
66
|
search = NSFNanoSearch.searchWithStore(self.store)
|
67
|
-
|
68
|
-
|
69
|
-
search.expressions = expressions
|
70
|
-
|
71
|
-
sort_descriptors = sort_descriptor_with_options(sort_options)
|
72
|
-
search.sort = sort_descriptors
|
67
|
+
search.expressions = expressions_with_options(options)
|
68
|
+
search.sort = sort_descriptor_with_options(sort_options)
|
73
69
|
search.filterClass = self.bare_class_name
|
74
70
|
|
75
71
|
error_ptr = Pointer.new(:id)
|
@@ -86,28 +82,18 @@ module MotionPrime
|
|
86
82
|
# Find model keys by criteria
|
87
83
|
#
|
88
84
|
# @example:
|
89
|
-
# User.find_keys(:name, NSFEqualTo, "Bob") # => ["1"]
|
90
85
|
# User.find_keys(:name => "Bob") # => ["1"]
|
91
86
|
# User.find_keys(:name => {NSFEqualTo => "Bob"}) # => ["1"]
|
92
87
|
#
|
93
88
|
# @return keys [Array] array of models
|
94
89
|
def find_keys(*arg)
|
95
90
|
if arg[0].is_a?(Hash)
|
96
|
-
# hash style
|
97
91
|
options = arg[0]
|
98
92
|
if arg[1] && arg[1].is_a?(Hash)
|
99
93
|
sort_options = arg[1][:sort] || {}
|
100
94
|
else
|
101
95
|
sort_options = {}
|
102
96
|
end
|
103
|
-
elsif arg[0] && arg[1] && arg[2]
|
104
|
-
# standard way to find
|
105
|
-
options = {arg[0] => {arg[1] => arg[2]}}
|
106
|
-
if arg[4] && arg[4].is_a?(Hash)
|
107
|
-
sort_options = arg[4][:sort] || {}
|
108
|
-
else
|
109
|
-
sort_options = {}
|
110
|
-
end
|
111
97
|
elsif arg.empty?
|
112
98
|
options = {}
|
113
99
|
sort_options = {}
|
@@ -116,12 +102,8 @@ module MotionPrime
|
|
116
102
|
end
|
117
103
|
|
118
104
|
search = NSFNanoSearch.searchWithStore(self.store)
|
119
|
-
|
120
|
-
|
121
|
-
search.expressions = expressions
|
122
|
-
|
123
|
-
sort_descriptors = sort_descriptor_with_options(sort_options)
|
124
|
-
search.sort = sort_descriptors
|
105
|
+
search.expressions = expressions_with_options(options)
|
106
|
+
search.sort = sort_descriptor_with_options(sort_options)
|
125
107
|
search.filterClass = self.bare_class_name
|
126
108
|
|
127
109
|
error_ptr = Pointer.new(:id)
|
data/motion-prime/prime.rb
CHANGED
@@ -59,12 +59,14 @@ module MotionPrime
|
|
59
59
|
end
|
60
60
|
alias_method :set_title, :title=
|
61
61
|
|
62
|
+
# Return the main controller.
|
62
63
|
def main_controller
|
63
64
|
has_navigation? ? navigation_controller : self
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
# Return content controller (without sidebar)
|
68
|
+
def content_controller
|
69
|
+
self
|
68
70
|
end
|
69
71
|
|
70
72
|
# Class methods
|
@@ -118,7 +118,7 @@ module MotionPrime
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def wrap_in_navigation!
|
121
|
-
self.navigation_controller =
|
121
|
+
self.navigation_controller = NavigationController.alloc.initWithRootViewController(self)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -19,12 +19,24 @@ module MotionPrime
|
|
19
19
|
Array.wrap(@sections.try(:values))
|
20
20
|
end
|
21
21
|
|
22
|
+
def all_sections_with_main
|
23
|
+
(all_sections + [main_section]).compact.uniq
|
24
|
+
end
|
25
|
+
|
22
26
|
def set_section(name, options = {})
|
23
27
|
self._action_section_options ||= {}
|
24
28
|
self._action_section_options[name.to_sym] = options
|
25
29
|
end
|
26
30
|
alias_method :section, :set_section
|
27
31
|
|
32
|
+
def set_sections_wrapper(value)
|
33
|
+
self.class.set_sections_wrapper(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def refresh
|
37
|
+
all_sections_with_main.each { |s| s.try(:reload) }
|
38
|
+
end
|
39
|
+
|
28
40
|
protected
|
29
41
|
def add_sections
|
30
42
|
@main_section ||= nil
|
@@ -52,17 +64,33 @@ module MotionPrime
|
|
52
64
|
_action_section_options || {}
|
53
65
|
end
|
54
66
|
|
67
|
+
def sections_wrapper
|
68
|
+
self.class.sections_wrapper
|
69
|
+
end
|
70
|
+
|
55
71
|
def render_sections
|
56
72
|
return unless @sections.present?
|
57
|
-
|
58
|
-
|
73
|
+
table_wrap = sections_wrapper.nil? ? all_sections.count > 1 : sections_wrapper
|
74
|
+
if table_wrap
|
75
|
+
table_class = table_wrap.is_a?(TrueClass) ? MotionPrime::TableSection : table_class
|
76
|
+
@main_section = table_class.new(model: all_sections, screen: self)
|
59
77
|
@main_section.render
|
60
78
|
else
|
61
|
-
all_sections.
|
79
|
+
all_sections.each do |section|
|
80
|
+
section.render
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
64
84
|
|
65
85
|
module ClassMethods
|
86
|
+
def sections_wrapper
|
87
|
+
@sections_wrapper
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_sections_wrapper(value)
|
91
|
+
@sections_wrapper = value
|
92
|
+
end
|
93
|
+
|
66
94
|
def section_options
|
67
95
|
_section_options || {}
|
68
96
|
end
|
File without changes
|
@@ -69,7 +69,7 @@ module MotionPrime
|
|
69
69
|
face = UIButton.buttonWithType UIButtonTypeCustom
|
70
70
|
face.setImage(image, forState: UIControlStateNormal) if args[:icon]
|
71
71
|
face.setTitle(title, forState: UIControlStateNormal)
|
72
|
-
face.setTitleColor((:
|
72
|
+
face.setTitleColor((args[:title_color] || :app_navigation_base).uicolor, forState: UIControlStateNormal)
|
73
73
|
face.setContentHorizontalAlignment UIControlContentHorizontalAlignmentLeft
|
74
74
|
face.sizeToFit
|
75
75
|
face.on :touch do
|
@@ -61,6 +61,13 @@ module MotionPrime
|
|
61
61
|
container_view.setNeedsDisplay
|
62
62
|
end
|
63
63
|
|
64
|
+
def cell
|
65
|
+
container_view || begin
|
66
|
+
first_element = elements.values.first
|
67
|
+
first_element.view.superview.superview
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
64
71
|
def dealloc
|
65
72
|
# TODO: remove this when solve this problem: dealloc TableCells on TableView.reloadData (in case when reuseIdentifier has been used)
|
66
73
|
container_view.section = nil if container_view.respond_to?(:setSection)
|
@@ -190,13 +190,6 @@ module MotionPrime
|
|
190
190
|
true
|
191
191
|
end
|
192
192
|
|
193
|
-
def cell
|
194
|
-
container_view || begin
|
195
|
-
first_element = elements.values.first
|
196
|
-
first_element.view.superview.superview
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
193
|
def render(container_options = {})
|
201
194
|
create_elements
|
202
195
|
self.container_options.merge!(container_options)
|
@@ -233,19 +226,35 @@ module MotionPrime
|
|
233
226
|
element(name).view
|
234
227
|
end
|
235
228
|
|
229
|
+
# Hide all elements of section.
|
230
|
+
# It will hide all base elements and container of draw elements.
|
231
|
+
# FIXME: container_view manipulation should be in draw mixin.
|
236
232
|
def hide
|
237
233
|
if container_view
|
238
234
|
container_view.hidden = true
|
239
|
-
else
|
240
|
-
elements.values.each(&:hide)
|
241
235
|
end
|
236
|
+
elements_to_render.values.each(&:hide)
|
242
237
|
end
|
243
238
|
|
239
|
+
# Show all elements of section.
|
240
|
+
# It will show all base elements and container of draw elements.
|
241
|
+
# FIXME: container_view manipulation should be in draw mixin.
|
244
242
|
def show
|
245
243
|
if container_view
|
246
244
|
container_view.hidden = false
|
247
|
-
|
248
|
-
|
245
|
+
end
|
246
|
+
elements_to_render.values.each(&:show)
|
247
|
+
end
|
248
|
+
|
249
|
+
# Bring all views of section to front.
|
250
|
+
# It will bring to front all base elements and container of draw elements.
|
251
|
+
# FIXME: container_view manipulation should be in draw mixin.
|
252
|
+
def bring_to_front
|
253
|
+
if container_view
|
254
|
+
container_view.superview.bringSubviewToFront container_view
|
255
|
+
end
|
256
|
+
elements_to_render.values.each do |element|
|
257
|
+
element.view.superview.bringSubviewToFront element.view
|
249
258
|
end
|
250
259
|
end
|
251
260
|
|
@@ -331,9 +340,7 @@ module MotionPrime
|
|
331
340
|
end
|
332
341
|
|
333
342
|
def has_drawn_content?
|
334
|
-
|
335
|
-
element.is_a?(DrawElement)
|
336
|
-
end
|
343
|
+
elements_to_draw.any?
|
337
344
|
end
|
338
345
|
|
339
346
|
# Force load section
|
@@ -121,7 +121,7 @@ module MotionPrime
|
|
121
121
|
end
|
122
122
|
|
123
123
|
# Delete section from data at index
|
124
|
-
#
|
124
|
+
#
|
125
125
|
# @param index [NSIndexPath] index of cell which will be removed from table data.
|
126
126
|
def delete_from_data(index)
|
127
127
|
if flat_data?
|
@@ -230,7 +230,7 @@ module MotionPrime
|
|
230
230
|
end
|
231
231
|
|
232
232
|
def table_view
|
233
|
-
table_element.view
|
233
|
+
table_element.try(:view)
|
234
234
|
end
|
235
235
|
|
236
236
|
def hide
|
@@ -321,10 +321,10 @@ module MotionPrime
|
|
321
321
|
return cached if cached.present?
|
322
322
|
|
323
323
|
styles = cell_section_styles(header).values.flatten
|
324
|
-
wrapper = MotionPrime::BaseElement.factory(:table_header,
|
325
|
-
screen: screen,
|
326
|
-
styles: styles,
|
327
|
-
parent_view: table_view,
|
324
|
+
wrapper = MotionPrime::BaseElement.factory(:table_header,
|
325
|
+
screen: screen,
|
326
|
+
styles: styles,
|
327
|
+
parent_view: table_view,
|
328
328
|
reuse_identifier: reuse_identifier,
|
329
329
|
section: header
|
330
330
|
)
|
data/motion-prime/version.rb
CHANGED
@@ -30,7 +30,7 @@ module MotionPrime
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def prepare_frame_for(bounds)
|
33
|
-
options[:frame] =
|
33
|
+
options[:frame] = calculate_frame_for(bounds, options.merge(test: view.is_a?(UITextView)))
|
34
34
|
if options.slice(:width, :height, :right, :bottom, :height_to_fit).values.any?
|
35
35
|
mask = UIViewAutoresizingNone
|
36
36
|
mask |= UIViewAutoresizingFlexibleTopMargin if options[:top].nil?
|
@@ -84,91 +84,151 @@ module MotionPrime
|
|
84
84
|
def set_option(key, value)
|
85
85
|
# return if value.nil?
|
86
86
|
# ignore options
|
87
|
-
return if
|
88
|
-
return if key == 'size_to_fit' && view.is_a?(UILabel)
|
89
|
-
return if %w[url default draw_in_rect].include?(key.to_s) && view.is_a?(UIImageView)
|
90
|
-
return if %w[
|
91
|
-
styles has_drawn_content
|
92
|
-
width height top right bottom left value_type
|
93
|
-
max_width max_outer_width min_width min_outer_width
|
94
|
-
max_height max_outer_height min_height min_outer_width
|
95
|
-
height_to_fit container parent_frame].include? key.to_s
|
87
|
+
return if ignore_option?(key)
|
96
88
|
|
97
89
|
# apply options
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
view.
|
115
|
-
|
116
|
-
|
90
|
+
result ||= set_color_options(key, value)
|
91
|
+
result ||= set_image_options(key, value)
|
92
|
+
result ||= set_text_options(key, value)
|
93
|
+
result ||= set_inset_options(key, value)
|
94
|
+
result ||= set_layer_options(key, value)
|
95
|
+
result ||= set_other_options(key, value)
|
96
|
+
result ||= set_hash_options(key, value)
|
97
|
+
|
98
|
+
unless result
|
99
|
+
view.setValue value, forKey: low_camelize_factory(key)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
protected
|
104
|
+
def set_color_options(key, value)
|
105
|
+
if key.end_with?('color') && view.is_a?(UIControl)
|
106
|
+
view.send :"set#{camelize_factory(key)}:forState", value.uicolor, UIControlStateNormal
|
107
|
+
true
|
108
|
+
elsif key.end_with?('color')
|
109
|
+
color = value.try(:uicolor)
|
110
|
+
color = color.cgcolor if view.is_a?(CALayer)
|
111
|
+
view.send :"#{low_camelize_factory(key)}=", color
|
112
|
+
true
|
113
|
+
elsif key == 'gradient'
|
114
|
+
gradient = prepare_gradient(value)
|
115
|
+
view.layer.insertSublayer(gradient, atIndex: 0)
|
116
|
+
true
|
117
117
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
view.
|
123
|
-
|
124
|
-
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_image_options(key, value)
|
121
|
+
if key.end_with?('background_image')
|
122
|
+
if view.is_a?(UIControl) || view.is_a?(UISearchBar)
|
123
|
+
view.send :"set#{camelize_factory(key)}:forState", value.uiimage, UIControlStateNormal
|
124
|
+
else
|
125
|
+
view.setBackgroundColor value.uiimage.uicolor
|
126
|
+
end
|
127
|
+
true
|
128
|
+
elsif key.end_with?('background_view')
|
129
|
+
if view.is_a?(UITableView)
|
130
|
+
bg_view = UIView.alloc.initWithFrame(view.bounds)
|
131
|
+
bg_view.backgroundColor = value[:color].uicolor
|
132
|
+
view.backgroundView = bg_view
|
133
|
+
else
|
134
|
+
view.setValue value, forKey: low_camelize_factory(key)
|
135
|
+
end
|
136
|
+
true
|
137
|
+
elsif key.end_with?('image')
|
138
|
+
view.setValue value.uiimage, forKey: camelize_factory(key)
|
139
|
+
true
|
125
140
|
end
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
mask_layer.path = mask_path.CGPath
|
146
|
-
view.mask = mask_layer
|
147
|
-
elsif key == 'attributed_text'
|
148
|
-
if view.is_a?(UIButton)
|
149
|
-
view.setAttributedTitle value, forState: UIControlStateNormal
|
150
|
-
else
|
151
|
-
view.attributedText = value
|
141
|
+
end
|
142
|
+
|
143
|
+
def set_text_options(key, value)
|
144
|
+
if key.end_with?('alignment') && value.is_a?(Symbol)
|
145
|
+
view.setValue value.uitextalignment, forKey: camelize_factory(key)
|
146
|
+
true
|
147
|
+
elsif key.end_with?('line_break_mode') && value.is_a?(Symbol)
|
148
|
+
view.setValue value.uilinebreakmode, forKey: camelize_factory(key)
|
149
|
+
true
|
150
|
+
elsif key == 'autocapitalization'
|
151
|
+
view.autocapitalizationType = UITextAutocapitalizationTypeNone if value === false
|
152
|
+
true
|
153
|
+
elsif key == 'attributed_text'
|
154
|
+
if view.is_a?(UIButton)
|
155
|
+
view.setAttributedTitle value, forState: UIControlStateNormal
|
156
|
+
else
|
157
|
+
view.attributedText = value
|
158
|
+
end
|
159
|
+
true
|
152
160
|
end
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
161
|
+
end
|
162
|
+
|
163
|
+
def set_inset_options(key, value)
|
164
|
+
if key.end_with?('_content_inset')
|
165
|
+
current_inset = view.contentInset
|
166
|
+
current_inset.send("#{key.partition('_').first}=", value)
|
167
|
+
view.contentInset = current_inset
|
168
|
+
true
|
169
|
+
elsif key.end_with?('inset')
|
170
|
+
inset = if value.to_s == 'none'
|
171
|
+
UIEdgeInsetsMake(0, 320, 0, 0)
|
172
|
+
elsif value.is_a?(Array) && value.count == 2
|
173
|
+
UIEdgeInsetsMake(0, value.first, 0, value.last)
|
174
|
+
elsif value.is_a?(Array) && value.count == 4
|
175
|
+
UIEdgeInsetsMake(value[0], value[1], value[2], value[3])
|
176
|
+
end
|
177
|
+
view.send(:"#{low_camelize_factory(key)}=", inset) if inset
|
178
|
+
true
|
165
179
|
end
|
166
|
-
elsif value.is_a?(Hash)
|
167
|
-
self.class.new(view.send(low_camelize_factory(key).to_sym), nil, value.merge(parent_frame: options[:frame] || options[:parent_frame])).apply
|
168
|
-
else
|
169
|
-
view.setValue value, forKey: low_camelize_factory(key)
|
170
180
|
end
|
171
|
-
|
181
|
+
|
182
|
+
def set_layer_options(key, value)
|
183
|
+
if key == 'rounded_corners'
|
184
|
+
radius = value[:radius].to_f
|
185
|
+
corner_consts = {top_left: UIRectCornerTopLeft, bottom_left: UIRectCornerBottomLeft, bottom_right: UIRectCornerBottomRight, top_right: UIRectCornerTopRight}
|
186
|
+
corners = value[:corners].inject(0) { |result, corner| result|corner_consts[corner] }
|
187
|
+
size = options[:parent_frame].size
|
188
|
+
bounds = CGRectMake(0, 0, size.width, size.height)
|
189
|
+
mask_path = UIBezierPath.bezierPathWithRoundedRect(bounds, byRoundingCorners: corners, cornerRadii: CGSizeMake(radius, radius))
|
190
|
+
mask_layer = CAShapeLayer.layer
|
191
|
+
mask_layer.frame = bounds
|
192
|
+
mask_layer.path = mask_path.CGPath
|
193
|
+
view.mask = mask_layer
|
194
|
+
true
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def set_hash_options(key, value)
|
199
|
+
if value.is_a?(Hash)
|
200
|
+
self.class.new(
|
201
|
+
view.send(low_camelize_factory(key).to_sym), nil,
|
202
|
+
value.merge(parent_frame: options[:frame] || options[:parent_frame])
|
203
|
+
).apply
|
204
|
+
true
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def set_other_options(key, value)
|
209
|
+
if key == 'keyboard_type'
|
210
|
+
view.setKeyboardType value.uikeyboardtype
|
211
|
+
true
|
212
|
+
elsif key == 'selection_style' && view.is_a?(UITableViewCell) && value.is_a?(Symbol)
|
213
|
+
view.setSelectionStyle value.uitablecellselectionstyle
|
214
|
+
true
|
215
|
+
elsif key == 'estimated_cell_height' && view.is_a?(UITableView)
|
216
|
+
view.setEstimatedRowHeight value
|
217
|
+
true
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def ignore_option?(key)
|
222
|
+
(key == 'section' && !view.respond_to?(:section=)) ||
|
223
|
+
(key == 'size_to_fit' && view.is_a?(UILabel)) ||
|
224
|
+
(%w[url default draw_in_rect].include?(key.to_s) && view.is_a?(UIImageView)) ||
|
225
|
+
%w[
|
226
|
+
styles has_drawn_content value_type height_to_fit container parent_frame
|
227
|
+
width height top right bottom left
|
228
|
+
max_width max_outer_width min_width min_outer_width
|
229
|
+
max_height max_outer_height min_height min_outer_width
|
230
|
+
].include?(key.to_s)
|
231
|
+
end
|
172
232
|
|
173
233
|
STRUCTS_MAP = {
|
174
234
|
CGAffineTransform => Proc.new {|v| NSValue.valueWithCGAffineTransform(v) },
|
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.9.
|
4
|
+
version: 0.9.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-03-
|
12
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -143,14 +143,14 @@ dependencies:
|
|
143
143
|
requirements:
|
144
144
|
- - ~>
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 2.
|
146
|
+
version: 2.1.0
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
151
|
- - ~>
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: 2.
|
153
|
+
version: 2.1.0
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: methadone
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -346,6 +346,8 @@ files:
|
|
346
346
|
- motion-prime/screens/_navigation_mixin.rb
|
347
347
|
- motion-prime/screens/_orientations_mixin.rb
|
348
348
|
- motion-prime/screens/_sections_mixin.rb
|
349
|
+
- motion-prime/screens/controllers/navigation_controller.rb
|
350
|
+
- motion-prime/screens/controllers/tab_bar_controller.rb
|
349
351
|
- motion-prime/screens/extensions/_indicators_mixin.rb
|
350
352
|
- motion-prime/screens/extensions/_navigation_bar_mixin.rb
|
351
353
|
- motion-prime/screens/screen.rb
|
@@ -392,7 +394,6 @@ files:
|
|
392
394
|
- motion-prime/support/mp_text_view.rb
|
393
395
|
- motion-prime/support/mp_view_controller.rb
|
394
396
|
- motion-prime/support/mp_view_with_section.rb
|
395
|
-
- motion-prime/support/tab_bar_controller.rb
|
396
397
|
- motion-prime/support/temp_fixes.rb
|
397
398
|
- motion-prime/support/ui_view.rb
|
398
399
|
- motion-prime/version.rb
|