motion-prime 0.8.2 → 0.8.3

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
- YzY4ZDViYzJiOGMwNWM5YTdhN2UwZjNlYTNlOWQ0OTc0MDM4NDM4Yw==
4
+ MDAzNzE5ODQ3ZTNkZjlmZjA0ZGE3MmI5YzUxZDc4ZGRhMWQxOGEyMg==
5
5
  data.tar.gz: !binary |-
6
- ODRiYzRiZDAxNTMzYzdiNzVmNTg3N2FhNjY0M2E1ZGQ2NDU5YjdlZQ==
6
+ YzAyMzQxYjRhMzFmNzlkZDBkMzg4ZDcwZTBjMWIyMjBjMGE3NTFhOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDAyNTU2NzE0ODhhZWIxNzg5M2Y3ZWRlOWVlYWE0MjJmMDEzM2ZlMzE2NDI1
10
- ZmMyODZjZGEyYjBmYmJlODZhZWRmYzZmZjg3OWE5ZmMzMDkxMjBkMGE2YjY1
11
- NDNiMjMzN2I1NWRhNjVjNjJkYTc3NmZhYTI0ZmRlYTcxYjA4ZWM=
9
+ NmFmMzVmYTg5ZGIxMTQwYmUwMzJhZDhlMjU1YzUxZWVkYWRlZjFjNmFjYjIy
10
+ OGYxNTk4ZDFiODA2ODRkYjAzMWMyN2I2NWNiMWEwNmJjZWUwMTRhYjJjMzYw
11
+ MTEyYjVlM2UwNGEwYmIwYWU4MmM1MDVhZGQzY2Q5YmVhYmJhNmI=
12
12
  data.tar.gz: !binary |-
13
- MWJiZDQ3OGJlN2QzNWRlNjVhNTg2MGQyN2U2NThlNTUwNmUyMmFhMGZiN2Y1
14
- MmQ2YzY0MjFmYzA4YjU4NzVkOThkY2Q4ZmNiM2Q4YTFiMjBlMWE1OGI2MWFm
15
- NmZjOGQ2YWU5NGQ4NDJjM2Y2ZTc2MGUxN2IxMzExNGQ0YzViZTU=
13
+ MGI1OTU0NzZjZjMwY2ZkZjM0NWQzMDgyMGRiMDE5ODViMTFmMzZmMzY1NWRj
14
+ NmMxYzk0NjBlOTFiNGYxYzE4NDNmY2U1NGU2MDJhMjNhMmY4ZDM1MmM3ODNj
15
+ OWVhNTQ1YTVlODBlOThjYWNiNGI2NGNlZWNkMjFkOWRkODcwYTQ=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.8.3
2
+ * Ability to pass UIButton to set_navigation_left_button/set_navigation_right_button
3
+ * Bug fixes
4
+
1
5
  === 0.8.2
2
6
  * bug fixes.
3
7
  * added #clone method for Model.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.8.2)
4
+ motion-prime (0.8.3)
5
5
  afmotion (~> 2.0.0)
6
6
  bubble-wrap (~> 1.4.0)
7
7
  cocoapods
@@ -45,7 +45,7 @@ GEM
45
45
  i18n (0.6.9)
46
46
  json (1.8.1)
47
47
  json_pure (1.8.1)
48
- methadone (1.3.1)
48
+ methadone (1.3.2)
49
49
  bundler
50
50
  motion-cocoapods (1.4.0)
51
51
  cocoapods (>= 0.26.2)
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.2'
6
+ gem 'motion-prime', '0.8.3'
7
7
 
8
8
  # add reside menu for sidebar support
9
9
  gem 'prime_reside_menu', '~> 0.1.4'
@@ -83,7 +83,9 @@ module MotionPrime
83
83
  if is_a?(TextViewElement)
84
84
  options |= NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine
85
85
  end
86
- text.boundingRectWithSize([width, Float::MAX], options: options, context:nil)
86
+ rect = text.boundingRectWithSize([width, Float::MAX], options: options, context:nil)
87
+ rect.size.height += 1 # {font_size: 13, line_spacing: 2, number_of_lines: 2} computed height = 28, but we need 29 to fit the text
88
+ rect
87
89
  end
88
90
 
89
91
  def button_content_text
@@ -29,7 +29,12 @@ module MotionPrime
29
29
  @view_name = self.class_name_without_kvo.demodulize.underscore.gsub(/(_draw)?_element/, '')
30
30
 
31
31
  if Prime.env.development?
32
- @_element_info = "#{@name} #{view_name} #{section.try(:name)} #{screen.class}"
32
+ info = []
33
+ info << @name
34
+ info << view_name
35
+ info << section.try(:name)
36
+ info << screen.class
37
+ @_element_info = info.join(' ')
33
38
  @@_allocated_elements ||= []
34
39
  @@_allocated_elements << @_element_info
35
40
  end
@@ -101,7 +101,7 @@ module MotionPrime
101
101
 
102
102
  def update_with_options(new_options = {})
103
103
  super
104
- self.image_data = nil if new_options.has_key?(:url)
104
+ self.image_data = nil if new_options.slice(:url, :image).any?
105
105
  end
106
106
  end
107
107
  end
@@ -26,7 +26,7 @@ module MotionPrime
26
26
 
27
27
  def size_to_fit_if_needed
28
28
  if computed_options[:size_to_fit] && computed_options[:width]
29
- @computed_options[:height_to_fit] = cached_content_outer_height
29
+ @computed_options[:height_to_fit] = content_outer_height
30
30
  end
31
31
  end
32
32
 
@@ -13,6 +13,7 @@ module MotionPrime
13
13
  end
14
14
 
15
15
  def set_navigation_right_button(title, args = {})
16
+ puts title.inspect
16
17
  navigationItem.rightBarButtonItem = create_navigation_button(title, args)
17
18
  end
18
19
 
@@ -44,30 +45,44 @@ module MotionPrime
44
45
  args[:style] ||= UIBarButtonItemStylePlain
45
46
  args[:action] ||= nil
46
47
  # TODO: Find better place for this code, may be just create custom control
47
- if args[:image]
48
- image = args[:image].uiimage
49
- face = UIButton.buttonWithType UIButtonTypeCustom
50
- face.bounds = CGRectMake(0, 0, image.size.width, image.size.height)
51
- face.setImage image, forState: UIControlStateNormal
52
- face.on :touch do
48
+ if title.is_a?(UIButton)
49
+ title.on :touch do
53
50
  args[:action].to_proc.call(self)
54
- end
55
- UIBarButtonItem.alloc.initWithCustomView(face)
51
+ end if args[:action]
52
+ title.sizeToFit
53
+ UIBarButtonItem.alloc.initWithCustomView(title)
54
+ elsif args[:image]
55
+ create_navigation_button_with_icon(title, args)
56
56
  elsif args[:icon]
57
- image = args[:icon].uiimage
58
- face = UIButton.buttonWithType UIButtonTypeCustom
59
- face.setImage(image, forState: UIControlStateNormal)
60
- face.setTitle(title, forState: UIControlStateNormal)
61
- face.setContentHorizontalAlignment UIControlContentHorizontalAlignmentLeft
62
- face.sizeToFit
63
- face.on :touch do
64
- args[:action].to_proc.call(self)
65
- end
66
- UIBarButtonItem.alloc.initWithCustomView(face)
57
+ create_navigation_button_with_icon(title, args)
67
58
  else
68
59
  UIBarButtonItem.alloc.initWithTitle(title,
69
60
  style: args[:style], target: args[:target] || self, action: args[:action])
70
61
  end
71
62
  end
63
+
64
+ def create_navigation_button_with_image(title, args)
65
+ image = args[:icon].uiimage
66
+ face = UIButton.buttonWithType UIButtonTypeCustom
67
+ face.setImage(image, forState: UIControlStateNormal)
68
+ face.setTitle(title, forState: UIControlStateNormal)
69
+ face.setContentHorizontalAlignment UIControlContentHorizontalAlignmentLeft
70
+ face.sizeToFit
71
+ face.on :touch do
72
+ args[:action].to_proc.call(self)
73
+ end if args[:action]
74
+ UIBarButtonItem.alloc.initWithCustomView(face)
75
+ end
76
+
77
+ def create_navigation_button_with_icon(title, args)
78
+ image = args[:image].uiimage
79
+ face = UIButton.buttonWithType UIButtonTypeCustom
80
+ face.bounds = CGRectMake(0, 0, image.size.width, image.size.height)
81
+ face.setImage image, forState: UIControlStateNormal
82
+ face.on :touch do
83
+ args[:action].to_proc.call(self)
84
+ end if args[:action]
85
+ UIBarButtonItem.alloc.initWithCustomView(face)
86
+ end
72
87
  end
73
88
  end
@@ -33,6 +33,10 @@ module Prime
33
33
 
34
34
  def height_for_index(table, index)
35
35
  section = cell_section_by_index(index)
36
+ unless section
37
+ Prime.logger.debug "could not find section with index #{index} for #{self.to_s}"
38
+ return 0
39
+ end
36
40
  preload_section_by_index(index)
37
41
  section.container_height
38
42
  end
@@ -171,6 +175,7 @@ module Prime
171
175
 
172
176
  def preload_section_by_index(index)
173
177
  section = cell_section_by_index(index)
178
+
174
179
  if section.create_elements && !section.container_element && async_data? # perform only if just loaded
175
180
  section.load_container_with_elements(container: container_element_options_for(index))
176
181
  section
@@ -100,18 +100,24 @@ module MotionPrime
100
100
  def delete_cell_sections(sections)
101
101
  paths = []
102
102
  Array.wrap(sections).each do |section|
103
- paths << NSIndexPath.indexPathForRow(@data.index(section), inSection: 0)
103
+ index = @data.try(:index, section)
104
+ next Prime.logger.debug("Delete cell section: `#{section.name}` is not in the list") unless index
105
+ paths << NSIndexPath.indexPathForRow(index, inSection: 0)
104
106
  delete_from_data(section)
105
107
  end
106
- table_view.beginUpdates
107
- table_view.deleteRowsAtIndexPaths(paths, withRowAnimation: UITableViewRowAnimationLeft)
108
- table_view.endUpdates
108
+ if paths.any?
109
+ table_view.beginUpdates
110
+ table_view.deleteRowsAtIndexPaths(paths, withRowAnimation: UITableViewRowAnimationLeft)
111
+ table_view.endUpdates
112
+ end
109
113
  paths
110
114
  end
111
115
 
112
116
  def delete_from_data(section)
113
117
  # section will not deallocate if you'll just write @data.delete(section)
114
- index = @data.index(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
120
+ end
115
121
  @data[index] = nil
116
122
  @data.delete_at(index)
117
123
  end
@@ -12,15 +12,15 @@ module MotionPrime
12
12
  end
13
13
 
14
14
  def error(*args)
15
- pp(*args) if LOGGER_ERROR_LEVEL <= current_level
15
+ pp("PRIME_ERROR", *args) if LOGGER_ERROR_LEVEL <= current_level
16
16
  end
17
17
 
18
18
  def info(*args)
19
- pp(*args) if LOGGER_INFO_LEVEL <= current_level
19
+ pp("PRIME_INFO", *args) if LOGGER_INFO_LEVEL <= current_level
20
20
  end
21
21
 
22
22
  def debug(*args)
23
- pp(*args) if LOGGER_DEBUG_LEVEL <= current_level
23
+ pp("PRIME_DEBUG", *args) if LOGGER_DEBUG_LEVEL <= current_level
24
24
  end
25
25
 
26
26
  def dealloc_message(type, object, *args)
@@ -34,14 +34,11 @@ MotionPrime::Styles.define :base_form do
34
34
  font: proc { :app_base.uifont(12) },
35
35
  size_to_fit: true
36
36
 
37
- style :field_error_message,
37
+ style :field_error_message, mixins: [:multiline],
38
38
  top: nil,
39
39
  bottom: 0,
40
40
  width: 280,
41
41
  left: 0,
42
- line_break_mode: :word_wrap,
43
- number_of_lines: 0,
44
- size_to_fit: true,
45
42
  text_color: :app_error,
46
43
  font: proc { :app_base.uifont(12) }
47
44
 
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
@@ -51,7 +51,7 @@ module MotionPrime
51
51
 
52
52
  if !left.nil? && !right.nil?
53
53
  frame.origin.x = left
54
- width = max_width - left - right
54
+ width = max_width - left - right if options[:height_to_fit].nil?
55
55
  elsif !right.nil?
56
56
  frame.origin.x = max_width - width - right
57
57
  elsif !left.nil?
@@ -72,8 +72,10 @@ module MotionPrime
72
72
  frame.origin.y = max_height / 2 - height / 2
73
73
  end
74
74
  frame.size.height = height
75
-
76
75
  frame
76
+ rescue => e
77
+ Prime.logger.error "can't calculate frame in #{self.class.name}. #{e}"
78
+ CGRectMake(0,0,0,0)
77
79
  end
78
80
  end
79
81
  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.2
4
+ version: 0.8.3
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-24 00:00:00.000000000 Z
12
+ date: 2014-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake