ruby_motion_query 0.3.5 → 0.3.6

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
- YWNlNGE2M2YwYzFkYTMyZTFmZDNkN2MwMGQ3NjM3YWFlNzc1M2VlMQ==
4
+ MGJlZGVhZTBlMjc4NGFiMzhkODI1ODQ0ODI5YWJjMjBjMWQ2MGJmNw==
5
5
  data.tar.gz: !binary |-
6
- YmUwYjFlZGU4ODlkMDIzMzUwOTc0ZTYyMjg0ODQxNmYwOTg4ZjMzMA==
6
+ MmVkZTA5ZjU1YTg0YmViMDYzMmY4NWUzOWFkZDg0MWM0NmVlZWZkOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjBhZGY2ZjMwZTI5M2M5MWI5NDc3NWY0YjdjOTkzN2Y0YmY0N2JiN2M3ZGI0
10
- NGFiNzNjZTQ0OGEzZDQ4OWQ3ZTQ5MzNmMTIxYzE0ODhjMzdkYjVmMzAyMzIx
11
- MTQ5NjAwZjI3ODZhY2NjNmUxYTcxODdkZGQwOGUxMWY1MWE4MDA=
9
+ ZjczODk0ZjM4ZmM4ZDc1YmEzMzBlNGFlNGU5YTc5MzU1ZmEzY2ZlYTE1ZDBl
10
+ MDVhYjkwYWY3Zjg0NDViNjkzM2RiNWMzYWQxOTgxMWYzYzY1NzNkN2EyODBi
11
+ MTcwNTJmOTJiZmNlYjhlMzkxZDg4MDFhNTEzOWI5NWE0OTAzZmQ=
12
12
  data.tar.gz: !binary |-
13
- MjQxYjUwNDFlYzJiNWJkNDE5OGYyZDE2ZTdiMmViYjkyN2NkZmRlOTQ3Mzcz
14
- ZGM1N2VkNDc5MTJhYzAyYjM2NjAyYTZiZDE5ZjUzODRlMTNiM2Y5NWEyOTY3
15
- YTc2MDIzODE0MGEyZGM2ZDNmMDZjYWI5N2FlMTk2YTQ5ZjI3MmU=
13
+ NGQyNWY0MDExOTNjNzdmNGQ0MzQ0YjA3YzA3NmM4OTFhYTU5Mjk4YWQ5Njc1
14
+ MjkwYzY0NGU4NmZjZDE0NGYwMDFmNTQ3ZmMzNzllYWRlM2JiNTE2ZjMwMzgx
15
+ YTIyOTY1NWZiMjY3ODI1OTNiZWQ5MTNiMTJjNTdlMTgyOWVhNDA=
data/README.md CHANGED
@@ -102,7 +102,7 @@ rmq(:a_tag, :a_style_name, UIImageView).hide
102
102
  rmq(hidden: true).show
103
103
 
104
104
  # If you use a set of selectors, they are an "or", to do an "and" use .and
105
- rmq(:UIImageView).and(hidden: true).show
105
+ rmq(UIImageView).and(hidden: true).show
106
106
  ```
107
107
 
108
108
  **rmq by itself is the rmq instance of the current UIViewController if you're inside a UIViewController**.
@@ -83,19 +83,21 @@ module RubyMotionQuery
83
83
  end
84
84
 
85
85
  # @return [RMQ]
86
- def throb
86
+ def throb(opts = {})
87
+ opts.merge!({
88
+ duration: 0.4,
89
+ animations: -> (cq) {
90
+ cq.style {|st| st.scale = 1.0}
91
+ }
92
+ })
93
+
87
94
  @rmq.animate(
88
95
  duration: 0.1,
89
96
  animations: -> (q) {
90
97
  q.style {|st| st.scale = 1.1}
91
98
  },
92
99
  completion: -> (did_finish, q) {
93
- q.animate(
94
- duration: 0.4,
95
- animations: -> (cq) {
96
- cq.style {|st| st.scale = 1.0}
97
- }
98
- )
100
+ q.animate(opts)
99
101
  }
100
102
  )
101
103
  end
@@ -64,6 +64,7 @@ module RubyMotionQuery
64
64
  def family_list
65
65
  UIFont.familyNames.sort
66
66
  end
67
+ alias :family_names :family_list
67
68
 
68
69
  # @return [Array]
69
70
  def for_family(family)
@@ -11,6 +11,18 @@ module RubyMotionQuery
11
11
  def color=(value) ; @view.textColor = value ; end
12
12
  def color ; @view.textColor ; end
13
13
 
14
+ def number_of_lines=(value)
15
+ value = 0 if value == :unlimited
16
+ @view.numberOfLines = value
17
+ end
18
+ def number_of_lines
19
+ if @view.numberOfLines == 0
20
+ :unlimited
21
+ else
22
+ @view.numberOfLines
23
+ end
24
+ end
25
+
14
26
  def text_alignment=(value)
15
27
  @view.textAlignment = TEXT_ALIGNMENTS[value] || value
16
28
  end
@@ -23,6 +35,7 @@ module RubyMotionQuery
23
35
  end
24
36
  alias :size_to_fit :resize_to_fit_text
25
37
 
38
+
26
39
  TEXT_ALIGNMENTS = {
27
40
  left: NSTextAlignmentLeft,
28
41
  center: NSTextAlignmentCenter,
@@ -24,6 +24,14 @@ module RubyMotionQuery
24
24
  end
25
25
  alias :parent :superview
26
26
 
27
+ def super_height
28
+ @view.superview.frame.size.height
29
+ end
30
+
31
+ def super_width
32
+ @view.superview.frame.size.width
33
+ end
34
+
27
35
  def tag(tags)
28
36
  rmq(@view).tag(tags)
29
37
  end
@@ -189,7 +197,9 @@ module RubyMotionQuery
189
197
  @view.backgroundColor
190
198
  end
191
199
 
192
- # TODO add background_image_tiled
200
+ def background_image=(value)
201
+ @view.backgroundColor = UIColor.colorWithPatternImage(value)
202
+ end
193
203
 
194
204
  def z_position=(index)
195
205
  @view.layer.zPosition = index
@@ -44,7 +44,7 @@ module RubyMotionQuery
44
44
  def reapply_styles
45
45
  selected.each do |selected_view|
46
46
  if style_name = selected_view.rmq_data.style_name
47
- apply_style_to_view selected_view, style_name
47
+ apply_style_to_view selected_view, style_name
48
48
  end
49
49
  end
50
50
  self
@@ -58,7 +58,7 @@ module RubyMotionQuery
58
58
  when UILabel then Stylers::UILabelStyler.new(view)
59
59
  when UIButton then Stylers::UIButtonStyler.new(view)
60
60
  when UIImageView then Stylers::UIImageViewStyler.new(view)
61
- when UIScrollView then Stylers::UIScrollViewStyler.new(view)
61
+ when UITableView then Stylers::UITableViewStyler.new(view)
62
62
  when UISwitch then Stylers::UISwitchStyler.new(view)
63
63
  when UIDatePicker then Stylers::UIDatePickerStyler.new(view)
64
64
  when UISegmentedControl then Stylers::UISegmentedControlStyler.new(view)
@@ -67,11 +67,11 @@ module RubyMotionQuery
67
67
  when UISlider then Stylers::UISliderStyler.new(view)
68
68
  when UIStepper then Stylers::UIStepperStyler.new(view)
69
69
  when UITabBar then Stylers::UITabBarStyler.new(view)
70
- when UITableView then Stylers::UITableViewStyler.new(view)
71
70
  when UITableViewCell then Stylers::UITableViewCellStyler.new(view)
72
71
  when UITextView then Stylers::UITextViewStyler.new(view)
73
72
  when UITextField then Stylers::UITextFieldStyler.new(view)
74
73
  when UINavigationBar then Stylers::UINavigationBarStyler.new(view)
74
+ when UIScrollView then Stylers::UIScrollViewStyler.new(view)
75
75
  # TODO, all the controls are done, but missing some views, add
76
76
  when UIControl then Stylers::UIControlStyler.new(view)
77
77
  else
@@ -130,10 +130,10 @@ module RubyMotionQuery
130
130
 
131
131
  # Convenience methods -------------------
132
132
  def rmq
133
- if @controller
134
- @controller.rmq
133
+ if @controller.nil?
134
+ RMQ.new
135
135
  else
136
- RMQ
136
+ @controller.rmq
137
137
  end
138
138
  end
139
139
 
@@ -20,7 +20,7 @@ module RubyMotionQuery
20
20
  new_view = view_or_constant
21
21
  else
22
22
  created = true
23
- new_view = create_view(view_or_constant)
23
+ new_view = create_view(view_or_constant, opts)
24
24
  end
25
25
 
26
26
  subviews_added << new_view
@@ -47,13 +47,16 @@ module RubyMotionQuery
47
47
  alias :insert :add_subview
48
48
 
49
49
  # @return [RMQ]
50
- def append(view_or_constant, style=nil)
51
- add_subview(view_or_constant, style: style)
50
+ def append(view_or_constant, style=nil, opts = {})
51
+ opts[:style] = style
52
+ add_subview(view_or_constant, opts)
52
53
  end
53
54
 
54
55
  # @return [RMQ]
55
- def unshift(view_or_constant, style = nil)
56
- add_subview view_or_constant, style: style, at_index: 0
56
+ def unshift(view_or_constant, style=nil, opts = {})
57
+ opts[:at_index] = 0
58
+ opts[:style] = style
59
+ add_subview view_or_constant, opts
57
60
  end
58
61
  alias :prepend :unshift
59
62
 
@@ -66,7 +69,7 @@ module RubyMotionQuery
66
69
  # @example
67
70
  # def tableView(table_view, cellForRowAtIndexPath: index_path)
68
71
  # cell = tableView.dequeueReusableCellWithIdentifier(CELL_IDENTIFIER) || begin
69
- # rmq.create(StoreCell, :store_cell)
72
+ # rmq.create(StoreCell, :store_cell, reuse_identifier: CELL_IDENTIFIER)
70
73
  # end
71
74
  # end
72
75
  #
@@ -76,19 +79,26 @@ module RubyMotionQuery
76
79
  # end
77
80
  # end
78
81
  #
79
- def create(view_or_constant, style = nil)
82
+ def create(view_or_constant, style = nil, opts = {})
80
83
  # TODO, refactor so that add_subview uses create, not backwards like it is now
81
- add_subview view_or_constant, style: style, do_not_add: true
84
+ opts[:do_not_add] = true
85
+ opts[:style] = style
86
+ add_subview view_or_constant, opts
82
87
  end
83
88
 
84
89
  protected
85
90
 
86
- def create_view(klass)
91
+ def create_view(klass, opts)
87
92
  if klass == UIButton
88
93
  klass.buttonWithType(UIButtonTypeCustom).tap do |o|
89
94
  o.hidden = false
90
95
  o.opaque = true
91
96
  end
97
+ elsif reuse_identifier = opts[:reuse_identifier]
98
+ klass.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: reuse_identifier).tap do |o|
99
+ o.hidden = false
100
+ o.opaque = true
101
+ end
92
102
  else
93
103
  klass.alloc.initWithFrame(CGRectZero).tap do |o|
94
104
  o.hidden = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_motion_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Werth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-01 00:00:00.000000000 Z
12
+ date: 2013-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.0.6
115
+ rubygems_version: 2.0.7
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: RubyMotionQuery - RMQ