ruby_motion_query 1.5.0 → 1.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36206f4aa5851fc94846f652c572a70611c553e3
4
- data.tar.gz: 3094ad46a32906503f7a131b9721bdd413ffe5d8
3
+ metadata.gz: 2470da3bf0ecba5d45eaca32dbfa623c1f8b6d69
4
+ data.tar.gz: bf6cfd75685027a85c41718fc6b2c1b845c3dc24
5
5
  SHA512:
6
- metadata.gz: a7fd7969a95296f5d3c21c3a556812c71378b03ec657e8059443841b660249f15de0397788727cdd42166ca1e26eeae1db8fbec1d0c6c997575d64703ac0b3c1
7
- data.tar.gz: c9e7d776bedfab71771c1df803950dd91edbbae2e3a24b7020967c7fb588b3ff5da932f9ba3138b1ac0910951ee51dad8ec48e11b2b935212b0b1ea79a6c5b6f
6
+ metadata.gz: 383304052b21e730b67132d4f17e9d5f2829897cc1c06851a5410a27456a7dcdd7c3b96a6f0c83a2581abc6ee5b5aaf8a550737f983a71d6f6fc5fb7585697a9
7
+ data.tar.gz: fc9e2f23eed27d67fe809525fe6f809dd76bfcf0c314a13bab0e543f7a402aa14adfbcd2d718b3055a24bfd7e2fffee7368524f078f84cb6e186c76976d194cc
@@ -0,0 +1,20 @@
1
+ module RubyMotionQuery
2
+ class RMQ
3
+
4
+ # @return [Accessibility]
5
+ def self.accessibility
6
+ Accessibility
7
+ end
8
+
9
+ # @return [Accessibility]
10
+ def accessibility
11
+ Accessibility
12
+ end
13
+ end
14
+
15
+ class Accessibility
16
+ def self.voiceover_running?
17
+ UIAccessibilityIsVoiceOverRunning()
18
+ end
19
+ end
20
+ end
@@ -44,13 +44,17 @@ module RubyMotionQuery
44
44
  nil
45
45
  end
46
46
 
47
- UIView.animateWithDuration(
48
- opts[:duration] || 0.3,
49
- delay: opts[:delay] || 0.0,
50
- options: opts[:options] || UIViewAnimationOptionCurveEaseInOut,
51
- animations: animations_lambda,
52
- completion: after_lambda
53
- )
47
+ if accessibility.voiceover_running?
48
+ after_lambda.call(true)
49
+ else
50
+ UIView.animateWithDuration(
51
+ opts[:duration] || 0.3,
52
+ delay: opts[:delay] || 0.0,
53
+ options: opts[:options] || UIViewAnimationOptionCurveEaseInOut,
54
+ animations: animations_lambda,
55
+ completion: after_lambda
56
+ )
57
+ end
54
58
  end
55
59
 
56
60
  self
@@ -156,9 +156,9 @@ module RubyMotionQuery
156
156
  # Which means it only has 1 selected view, and that view
157
157
  # is the view you called rmq in. Which is a tad confusing, but if you call *just* rmq inside a
158
158
  # view, then only that view will be *selected* and this rmq will be *root*. If you call rmq
159
- # inside a controller, only controller.view will be selected and the rma instance will be a root.
159
+ # inside a controller, only controller.view will be selected and the rmq instance will be a root.
160
160
  def root?
161
- (selected.length == 1) && (selected.first == @context)
161
+ (selected.length == 1) && (selected.first == context_or_context_view)
162
162
  end
163
163
 
164
164
  # The context is where rmq was created (not the selectors).
@@ -9,30 +9,33 @@ module RubyMotionQuery
9
9
  return ValidationEvent.new(block)
10
10
  elsif @sdk_event_or_recognizer = VIEW_GESTURES[event]
11
11
  @gesture = true
12
- elsif sender.is_a?(UIControl)
12
+ @custom_event = false
13
+ elsif sender.is_a?(UIControl) && (@sdk_event_or_recognizer = CONTROL_EVENTS[event])
13
14
  @gesture = false
14
- @sdk_event_or_recognizer = CONTROL_EVENTS[event]
15
+ @custom_event = false
16
+ else
17
+ @gesture = false
18
+ @sdk_event_or_recognizer = nil
19
+ @custom_event = true
15
20
  end
16
21
 
17
- if @sdk_event_or_recognizer
18
- @sender = sender
19
- @event = event
20
- @block = block
22
+ @sender = sender
23
+ @event = event
24
+ @block = block
21
25
 
26
+ if @sdk_event_or_recognizer
22
27
  if @gesture
23
28
  @recognizer = @sdk_event_or_recognizer.alloc.initWithTarget(self, action: "handle_gesture_or_event:")
24
29
  @sender.addGestureRecognizer(@recognizer)
25
30
  else
26
31
  @sender.addTarget(self, action: "handle_gesture_or_event:", forControlEvents: @sdk_event_or_recognizer)
27
32
  end
28
- else
29
- raise "[RMQ Error] Invalid event or gesture or invalid sender (#{event}). Example of use: button.on(:touch) { my_code }"
30
33
  end
31
34
  end
32
35
 
33
36
  def handle_gesture_or_event(gesture)
34
37
  # Don't fire :long_press events twice.
35
- return if @sdk_event_or_recognizer == VIEW_GESTURES[:long_press] && gesture.state == UIGestureRecognizerStateEnded
38
+ return if gesture.class == VIEW_GESTURES[:long_press] && gesture.state != UIGestureRecognizerStateBegan
36
39
 
37
40
  # Handle debounce logic
38
41
  if @debounce_length
@@ -78,7 +81,6 @@ module RubyMotionQuery
78
81
  when :swipe_right then o.direction = UISwipeGestureRecognizerDirectionRight
79
82
  end
80
83
 
81
-
82
84
  if opts.include?(:init)
83
85
  opts[:init].call(@recognizer)
84
86
  end
@@ -90,6 +92,14 @@ module RubyMotionQuery
90
92
  @gesture
91
93
  end
92
94
 
95
+ def sdk_event?
96
+ !@custom_event && !@gesture
97
+ end
98
+
99
+ def custom_event?
100
+ @custom_event
101
+ end
102
+
93
103
  def location
94
104
  if gesture?
95
105
  @recognizer.locationInView(@sender)
@@ -106,6 +106,14 @@ module RubyMotionQuery
106
106
  self
107
107
  end
108
108
 
109
+ def trigger(event)
110
+ selected.each do |view|
111
+ events(view)[event].block.call(view.rmq) if events(view)[event]
112
+ end
113
+
114
+ self
115
+ end
116
+
109
117
  protected
110
118
 
111
119
  def events(view)
@@ -134,7 +142,9 @@ module RubyMotionQuery
134
142
  raise "[RMQ Error] Event already exists on this object: #{event}. Remove first, using .off" if @event_set[event]
135
143
 
136
144
  if rmqe = event_instance(view, event, block)
137
- view.userInteractionEnabled = true
145
+ if rmqe.is_a?(RubyMotionQuery::Event) && !rmqe.custom_event?
146
+ view.userInteractionEnabled = true
147
+ end
138
148
 
139
149
  rmqe.set_options(args) if rmqe.respond_to? :set_options
140
150
 
@@ -262,14 +262,27 @@ module RubyMotionQuery
262
262
  def iphone?
263
263
  device.iphone?
264
264
  end
265
+
265
266
  def ipad?
266
267
  device.ipad?
267
268
  end
268
269
 
270
+ def three_point_five_inch?
271
+ device.three_point_five_inch?
272
+ end
273
+
269
274
  def four_inch?
270
275
  device.four_inch?
271
276
  end
272
277
 
278
+ def four_point_seven_inch?
279
+ device.four_point_seven_inch?
280
+ end
281
+
282
+ def five_point_five_inch?
283
+ device.five_point_five_inch?
284
+ end
285
+
273
286
  def retina?
274
287
  device.retina?
275
288
  end
@@ -35,8 +35,13 @@ module RubyMotionQuery
35
35
  #
36
36
  # @example
37
37
  # rmq.all.log
38
+ # rmq(:container).all
38
39
  def all
39
- self.weak_view_controller.rmq.find
40
+ if self.root?
41
+ self.weak_view_controller.rmq.find
42
+ else
43
+ self.find
44
+ end
40
45
  end
41
46
 
42
47
  # @return [RMQ] A new rmq instance reducing selected views to those that match selectors provided
@@ -1,5 +1,5 @@
1
1
  module RubyMotionQuery
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
 
4
4
  class RMQ
5
5
  def version
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: 1.5.0
4
+ version: 1.6.0
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: 2015-05-26 00:00:00.000000000 Z
12
+ date: 2015-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -52,6 +52,7 @@ files:
52
52
  - bin/rmq
53
53
  - lib/ruby_motion_query.rb
54
54
  - motion/ext.rb
55
+ - motion/ruby_motion_query/accessibility.rb
55
56
  - motion/ruby_motion_query/actions.rb
56
57
  - motion/ruby_motion_query/animations.rb
57
58
  - motion/ruby_motion_query/app.rb