motion-prime 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +7 -3
  3. data/Gemfile.lock +1 -1
  4. data/README.md +1 -1
  5. data/ROADMAP.md +12 -0
  6. data/motion-prime/api_client.rb +1 -0
  7. data/motion-prime/app_delegate.rb +1 -1
  8. data/motion-prime/elements/_content_padding_mixin.rb +49 -0
  9. data/motion-prime/elements/_field_dimensions_mixin.rb +37 -21
  10. data/motion-prime/elements/_text_dimensions_mixin.rb +0 -4
  11. data/motion-prime/elements/base.rb +20 -7
  12. data/motion-prime/elements/button.rb +2 -1
  13. data/motion-prime/elements/draw/label.rb +19 -8
  14. data/motion-prime/elements/error_message.rb +2 -1
  15. data/motion-prime/elements/image.rb +1 -0
  16. data/motion-prime/elements/label.rb +10 -10
  17. data/motion-prime/elements/text_field.rb +2 -0
  18. data/motion-prime/models/bag.rb +8 -3
  19. data/motion-prime/models/model.rb +1 -1
  20. data/motion-prime/models/sync.rb +17 -8
  21. data/motion-prime/screens/_aliases_mixin.rb +2 -0
  22. data/motion-prime/screens/_base_mixin.rb +19 -52
  23. data/motion-prime/screens/_navigation_mixin.rb +31 -29
  24. data/motion-prime/screens/base_screen.rb +8 -0
  25. data/motion-prime/screens/extensions/_indicators_mixin.rb +26 -0
  26. data/motion-prime/screens/{_navigation_bar_mixin.rb → extensions/_navigation_bar_mixin.rb} +0 -0
  27. data/motion-prime/screens/sidebar_container_screen.rb +1 -1
  28. data/motion-prime/sections/base.rb +1 -1
  29. data/motion-prime/sections/form.rb +5 -2
  30. data/motion-prime/sections/form/base_field_section.rb +2 -2
  31. data/motion-prime/support/_key_value_store.rb +1 -1
  32. data/motion-prime/support/_padding_attribute.rb +60 -0
  33. data/motion-prime/support/dm_button.rb +20 -20
  34. data/motion-prime/support/dm_text_field.rb +12 -17
  35. data/motion-prime/support/dm_text_view.rb +1 -1
  36. data/motion-prime/support/mp_label.rb +9 -0
  37. data/motion-prime/version.rb +1 -1
  38. data/motion-prime/views/layout.rb +1 -0
  39. data/motion-prime/views/styles.rb +1 -1
  40. data/motion-prime/views/view_styler.rb +5 -1
  41. data/spec/helpers/models.rb +8 -1
  42. data/travis.sh +1 -3
  43. metadata +8 -3
@@ -1,7 +1,7 @@
1
1
  class DMButton < UIButton
2
- include MotionPrime::KeyValueStore
3
- DEFAULT_PADDING_LEFT = 5
4
- attr_accessor :paddingLeft, :paddingRight, :paddingTop, :padding, :sizeToFit
2
+ include MotionPrime::SupportKeyValueStore
3
+ include MotionPrime::SupportPaddingAttribute
4
+ attr_accessor :sizeToFit
5
5
 
6
6
  def setTitle(value)
7
7
  setTitle value, forState: UIControlStateNormal
@@ -16,35 +16,35 @@ class DMButton < UIButton
16
16
  super
17
17
  end
18
18
 
19
- def padding_left
20
- self.paddingLeft || self.padding || DEFAULT_PADDING_LEFT
19
+ def self.default_padding_left
20
+ 5
21
21
  end
22
22
 
23
- def padding_right
24
- self.paddingRight || padding_left || DEFAULT_PADDING_LEFT
23
+ def self.default_padding_right
24
+ 5
25
25
  end
26
26
 
27
- def padding_top
28
- self.paddingTop || self.padding || default_padding_top
27
+ def padding_top # to center title label
28
+ self.paddingTop || self.padding || begin
29
+ single_line_height = self.font.pointSize
30
+ (self.bounds.size.height - single_line_height)/2 + 1
31
+ end
29
32
  end
30
33
 
31
- def default_padding_top # to center title label
32
- single_line_height = self.font.pointSize
33
- (self.bounds.size.height - single_line_height)/2 + 1
34
+ def padding_bottom
35
+ self.bounds.size.height - (self.font.pointSize + padding_top)
34
36
  end
35
37
 
36
- def drawPadding(rect)
37
- return if @custom_title_inset_drawn || [padding_top, padding_left, padding_right].all?(&:zero?)
38
+ def apply_padding!(rect)
39
+ self.setTitleEdgeInsets(padding_insets)
40
+ end
38
41
 
39
- height_diff = self.bounds.size.height - (self.font.pointSize + padding_top*2)
40
- self.setTitleEdgeInsets UIEdgeInsetsMake(
41
- padding_top, padding_left,
42
- padding_top + height_diff, padding_right
43
- )
42
+ def apply_padding?
43
+ super && !@custom_title_inset_drawn
44
44
  end
45
45
 
46
46
  def drawRect(rect)
47
- drawPadding(rect)
47
+ apply_padding(rect)
48
48
  super
49
49
  end
50
50
  end
@@ -2,11 +2,9 @@
2
2
  # * support padding, padding_left, padding_right options
3
3
  # * support placeholder_color, placeholder_font options
4
4
  class DMTextField < UITextField
5
- DEFAULT_PADDING_LEFT = 5
6
- include MotionPrime::KeyValueStore
7
-
8
- attr_accessor :paddingLeft, :paddingRight, :paddingTop, :padding,
9
- :placeholderColor, :placeholderFont
5
+ include MotionPrime::SupportKeyValueStore
6
+ include MotionPrime::SupportPaddingAttribute
7
+ attr_accessor :placeholderColor, :placeholderFont
10
8
 
11
9
  # placeholder position
12
10
  def textRectForBounds(bounds)
@@ -25,21 +23,19 @@ class DMTextField < UITextField
25
23
  self.placeholder.drawInRect(rect, withFont: font)
26
24
  end
27
25
 
28
- def padding_left
29
- self.paddingLeft || self.padding || DEFAULT_PADDING_LEFT
30
- end
31
-
32
- def padding_right
33
- self.paddingRight || self.padding_left
26
+ def padding_top # to center title label
27
+ self.paddingTop || self.padding || begin
28
+ single_line_height = self.font.pointSize
29
+ (self.bounds.size.height - single_line_height)/2 + 2
30
+ end
34
31
  end
35
32
 
36
- def padding_top
37
- self.paddingTop || self.padding || default_padding_top
33
+ def self.default_padding_left
34
+ 5
38
35
  end
39
36
 
40
- def default_padding_top # to center title label
41
- single_line_height = self.font.pointSize
42
- (self.bounds.size.height - single_line_height)/2 + 2
37
+ def self.default_padding_right
38
+ 5
43
39
  end
44
40
 
45
41
  private
@@ -50,5 +46,4 @@ class DMTextField < UITextField
50
46
  bounds.origin.x + padding_left, bounds.origin.y + padding_top,
51
47
  bounds.size.width - (padding_left + padding_right), bounds.size.height - padding_top*2)
52
48
  end
53
-
54
49
  end
@@ -2,7 +2,7 @@
2
2
  # * support padding, padding_left, padding_right options
3
3
  # * support placeholder, placeholder_color, placeholder_font options
4
4
  class DMTextView < UITextView
5
- include MotionPrime::KeyValueStore
5
+ include MotionPrime::SupportKeyValueStore
6
6
  DEFAULT_PADDING_LEFT = 7
7
7
 
8
8
  attr_accessor :paddingLeft, :paddingTop, :padding,
@@ -0,0 +1,9 @@
1
+ class MPLabel < UILabel
2
+ include MotionPrime::SupportKeyValueStore
3
+ include MotionPrime::SupportPaddingAttribute
4
+
5
+ def drawTextInRect(rect)
6
+ rect = UIEdgeInsetsInsetRect(rect, padding_insets)
7
+ super(rect)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -11,6 +11,7 @@ module MotionPrime
11
11
  options = builder.options.merge(calculate_frame: true, bounds: bounds)
12
12
  view = builder.view
13
13
  if render_target = options.delete(:render_target)
14
+ options[:bounds] = render_target.bounds
14
15
  render_target.addSubview(view)
15
16
  elsif view_stack.any?
16
17
  view_stack.last.addSubview(view)
@@ -14,7 +14,7 @@ module MotionPrime
14
14
  if block_given?
15
15
  raise "Only style names are available for nested styles, received: `#{args.inspect}`. Namespace: `#{@namespace}`" if options.present?
16
16
  names.each do |name|
17
- puts namespace = [@namespace, name].compact.join('_')
17
+ namespace = [@namespace, name].compact.join('_')
18
18
  self.class.new(namespace).instance_eval(&block)
19
19
  end
20
20
  else
@@ -36,6 +36,7 @@ module MotionPrime
36
36
  options[:frame] = bounds
37
37
  else
38
38
  frame = CGRectZero
39
+
39
40
  max_width = bounds.size.width
40
41
  max_height = bounds.size.height
41
42
  width = 0.0 if width.nil?
@@ -107,7 +108,10 @@ module MotionPrime
107
108
  # ignore options
108
109
  return if key == 'size_to_fit' && view.is_a?(UILabel)
109
110
  return if (key == 'url' || key == 'default') && view.is_a?(UIImageView)
110
- return if %w[max_width min_width height_to_fit container].include? key.to_s
111
+ return if %w[
112
+ max_width max_outer_width min_width min_outer_width
113
+ max_height max_outer_height min_height min_outer_width
114
+ height_to_fit container].include? key.to_s
111
115
 
112
116
  # apply options
113
117
  if key.end_with?('title_color')
@@ -3,38 +3,45 @@ class User < MotionPrime::BaseModel
3
3
  end
4
4
 
5
5
  class Plane < MotionPrime::BaseModel
6
- attributes :name, :age
6
+ attributes :id, :name, :age
7
7
  end
8
8
 
9
9
  class Listing < MotionPrime::BaseModel
10
+ attribute :id
10
11
  attribute :name
11
12
  end
12
13
 
13
14
  class Todo < MotionPrime::BaseModel
15
+ attribute :id
14
16
  attribute :title
15
17
  bag :items
16
18
  end
17
19
 
18
20
  class TodoItem < MotionPrime::BaseModel
21
+ attribute :id
19
22
  attribute :completed
20
23
  attribute :text
21
24
  end
22
25
 
23
26
  class Page < MotionPrime::BaseModel
27
+ attribute :id
24
28
  attribute :text
25
29
  attribute :index
26
30
  end
27
31
 
28
32
  class Animal < MotionPrime::BaseModel
33
+ attribute :id
29
34
  attribute :name
30
35
  end
31
36
 
32
37
  class Autobot < MotionPrime::BaseModel
38
+ attribute :id
33
39
  attribute :name
34
40
  end
35
41
 
36
42
  module CustomModule; end
37
43
  class CustomModule::Car < MotionPrime::BaseModel
44
+ attribute :id
38
45
  attribute :name
39
46
  attribute :created_at
40
47
  end
data/travis.sh CHANGED
@@ -5,6 +5,4 @@ sudo bundle install
5
5
  sudo pod setup
6
6
  sudo bundle exec rake pod:install
7
7
  sudo bundle exec rake clean &&
8
- sudo bundle exec rake spec &&
9
- sudo bundle exec rake clean &&
10
- sudo bundle exec rake spec osx=true
8
+ sudo bundle exec rake spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-prime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
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-11-27 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -178,6 +178,7 @@ files:
178
178
  - Gemfile
179
179
  - Gemfile.lock
180
180
  - README.md
181
+ - ROADMAP.md
181
182
  - Rakefile
182
183
  - app/app_delegate.rb
183
184
  - bin/prime
@@ -209,6 +210,7 @@ files:
209
210
  - motion-prime/config/base.rb
210
211
  - motion-prime/config/config.rb
211
212
  - motion-prime/core_ext/kernel.rb
213
+ - motion-prime/elements/_content_padding_mixin.rb
212
214
  - motion-prime/elements/_field_dimensions_mixin.rb
213
215
  - motion-prime/elements/_text_dimensions_mixin.rb
214
216
  - motion-prime/elements/base.rb
@@ -243,10 +245,11 @@ files:
243
245
  - motion-prime/mp.rb
244
246
  - motion-prime/screens/_aliases_mixin.rb
245
247
  - motion-prime/screens/_base_mixin.rb
246
- - motion-prime/screens/_navigation_bar_mixin.rb
247
248
  - motion-prime/screens/_navigation_mixin.rb
248
249
  - motion-prime/screens/_orientations_mixin.rb
249
250
  - motion-prime/screens/base_screen.rb
251
+ - motion-prime/screens/extensions/_indicators_mixin.rb
252
+ - motion-prime/screens/extensions/_navigation_bar_mixin.rb
250
253
  - motion-prime/screens/sidebar_container_screen.rb
251
254
  - motion-prime/sections/base.rb
252
255
  - motion-prime/sections/draw.rb
@@ -268,12 +271,14 @@ files:
268
271
  - motion-prime/styles/base.rb
269
272
  - motion-prime/styles/form.rb
270
273
  - motion-prime/support/_key_value_store.rb
274
+ - motion-prime/support/_padding_attribute.rb
271
275
  - motion-prime/support/dm_button.rb
272
276
  - motion-prime/support/dm_cell_with_section.rb
273
277
  - motion-prime/support/dm_text_field.rb
274
278
  - motion-prime/support/dm_text_view.rb
275
279
  - motion-prime/support/dm_view_controller.rb
276
280
  - motion-prime/support/dm_view_with_section.rb
281
+ - motion-prime/support/mp_label.rb
277
282
  - motion-prime/support/navigation_controller.rb
278
283
  - motion-prime/support/ui_search_bar_custom.rb
279
284
  - motion-prime/support/ui_view.rb