ruby_motion_query 0.7.1 → 0.8.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 +4 -4
- data/README.md +2 -0
- data/motion/ext.rb +4 -0
- data/motion/ruby_motion_query/actions.rb +5 -5
- data/motion/ruby_motion_query/animations.rb +1 -1
- data/motion/ruby_motion_query/app.rb +3 -1
- data/motion/ruby_motion_query/data.rb +1 -1
- data/motion/ruby_motion_query/device.rb +85 -8
- data/motion/ruby_motion_query/enumerablish.rb +4 -2
- data/motion/ruby_motion_query/events.rb +2 -0
- data/motion/ruby_motion_query/grid.rb +93 -70
- data/motion/ruby_motion_query/rect.rb +35 -35
- data/motion/ruby_motion_query/stylers/ui_button_styler.rb +7 -0
- data/motion/ruby_motion_query/stylers/ui_text_view_styler.rb +14 -3
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +14 -2
- data/motion/ruby_motion_query/stylesheet.rb +25 -14
- data/motion/ruby_motion_query/subviews.rb +10 -3
- data/motion/ruby_motion_query/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c13477305c59894c43b5b220acb157aaf32bd34
|
4
|
+
data.tar.gz: f2ff2ecd3a1baa31fa47b9499c20711f9bcb7164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f605689d32c537f42ef60f5d4c7b6cd70d354a9d2c8e6b708faa65616685dd04f21a9240dacf59c353f6eb2a39aadfc23d462205b19cc1f976c429fe83f1e8
|
7
|
+
data.tar.gz: 41b7414448a6763a076a5dc18ba98ea171c39d644d2e30e3ef5889605729303de2645da1e3e003027794f5ea51072573a3c3ba0f4023b4295845faf8d9cf2d86
|
data/README.md
CHANGED
data/motion/ext.rb
CHANGED
@@ -16,6 +16,7 @@ class UIView
|
|
16
16
|
# @deprecated No longer needed, use rmq_build
|
17
17
|
def rmq_did_create(self_in_rmq)
|
18
18
|
end
|
19
|
+
|
19
20
|
def rmq_created
|
20
21
|
end
|
21
22
|
|
@@ -26,6 +27,9 @@ class UIView
|
|
26
27
|
def rmq_appended
|
27
28
|
end
|
28
29
|
|
30
|
+
def rmq_style_applied
|
31
|
+
end
|
32
|
+
|
29
33
|
# Technically my_view.rmq is the same as rmq(my_view), so it may seem enticing to use,
|
30
34
|
# but the really nice thing about rmq is its consistent API, and doing this
|
31
35
|
# for one view: my_view.rmq and this for two views: rmq(my_view, my_other_view) sucks
|
@@ -16,8 +16,8 @@ module RubyMotionQuery
|
|
16
16
|
# For example, text for UILabel, image for UIImageView
|
17
17
|
#
|
18
18
|
# @return [RMQ]
|
19
|
-
def data(new_data =
|
20
|
-
if new_data
|
19
|
+
def data(new_data = :rmq_not_provided)
|
20
|
+
if new_data != :rmq_not_provided
|
21
21
|
selected.each do |view|
|
22
22
|
case view
|
23
23
|
when UILabel then view.setText new_data # set is faster than =
|
@@ -33,8 +33,8 @@ module RubyMotionQuery
|
|
33
33
|
#when UIStepper then
|
34
34
|
#when UITabBar then
|
35
35
|
#when UITableViewCell then
|
36
|
-
when UITextView then view.
|
37
|
-
when UITextField
|
36
|
+
when UITextView then view.text = new_data
|
37
|
+
when UITextField then view.text = new_data
|
38
38
|
#when UINavigationBar then
|
39
39
|
#when UIScrollView then
|
40
40
|
|
@@ -80,7 +80,7 @@ module RubyMotionQuery
|
|
80
80
|
# @example
|
81
81
|
# rmq(my_view).data = 'some data'
|
82
82
|
def data=(new_data)
|
83
|
-
data(new_data)
|
83
|
+
self.data(new_data)
|
84
84
|
end
|
85
85
|
|
86
86
|
# @return [RMQ]
|
@@ -46,7 +46,7 @@ module RubyMotionQuery
|
|
46
46
|
|
47
47
|
UIView.animateWithDuration(
|
48
48
|
opts[:duration] || 0.3,
|
49
|
-
delay: opts[:delay] || 0,
|
49
|
+
delay: opts[:delay] || 0.0,
|
50
50
|
options: opts[:options] || UIViewAnimationOptionCurveEaseInOut,
|
51
51
|
animations: animations_lambda,
|
52
52
|
completion: after_lambda
|
@@ -85,11 +85,13 @@ module RubyMotionQuery
|
|
85
85
|
root_view_controller.visibleViewController
|
86
86
|
when UITabBarController
|
87
87
|
current_view_controller(root_view_controller.selectedViewController)
|
88
|
-
else
|
88
|
+
else
|
89
89
|
if root_view_controller.respond_to?(:visibleViewController)
|
90
90
|
current_view_controller(root_view_controller.visibleViewController)
|
91
91
|
elsif root_view_controller.respond_to?(:topViewController)
|
92
92
|
current_view_controller(root_view_controller.topViewController)
|
93
|
+
elsif root_view_controller.respond_to?(:frontViewController)
|
94
|
+
current_view_controller(root_view_controller.frontViewController)
|
93
95
|
elsif root_view_controller.childViewControllers.count > 0
|
94
96
|
current_view_controller(root_view_controller.childViewControllers.first)
|
95
97
|
else
|
@@ -13,27 +13,64 @@ module RubyMotionQuery
|
|
13
13
|
|
14
14
|
class Device
|
15
15
|
class << self
|
16
|
+
def ios_eight?
|
17
|
+
@_ios_eight ||= screen.respond_to?(:coordinateSpace)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Find out what version of iOS you're using.
|
21
|
+
# `rmq.device.is_version? 8`
|
22
|
+
# `rmq.device.is_version? "7.1"`
|
23
|
+
#
|
24
|
+
# @return [Boolean]
|
25
|
+
def is_version? version
|
26
|
+
!!ios_version.match("^#{version}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def ios_version
|
30
|
+
UIDevice.currentDevice.systemVersion
|
31
|
+
end
|
32
|
+
|
16
33
|
# @return [UIScreen]
|
17
34
|
def screen
|
18
35
|
UIScreen.mainScreen
|
19
36
|
end
|
20
37
|
|
38
|
+
def size_a
|
39
|
+
@_size_a ||= screen.bounds.size.to_a.sort
|
40
|
+
end
|
41
|
+
|
42
|
+
# Width is the width of the device, regardless of its orientation.
|
43
|
+
# This is static. If you want the width with the correct orientation, use
|
44
|
+
# screen_width
|
45
|
+
#
|
21
46
|
# @return [Numeric]
|
22
47
|
def width
|
23
|
-
|
48
|
+
size_a[0]
|
49
|
+
end
|
50
|
+
def width_landscape
|
51
|
+
size_a[1]
|
24
52
|
end
|
25
53
|
|
54
|
+
# Height is the height of the device, regardless of its orientation.
|
55
|
+
# This is static. If you want the height with the correct orientation, use
|
56
|
+
# screen_height
|
57
|
+
#
|
26
58
|
# @return [Numeric]
|
27
59
|
def height
|
28
|
-
|
60
|
+
size_a[1]
|
61
|
+
end
|
62
|
+
def height_landscape
|
63
|
+
size_a[0]
|
29
64
|
end
|
30
65
|
|
66
|
+
# @return [Numeric]
|
31
67
|
def screen_width
|
32
|
-
portrait? ?
|
68
|
+
portrait? ? width : width_landscape
|
33
69
|
end
|
34
70
|
|
71
|
+
# @return [Numeric]
|
35
72
|
def screen_height
|
36
|
-
portrait? ?
|
73
|
+
portrait? ? height : height_landscape
|
37
74
|
end
|
38
75
|
|
39
76
|
def ipad?
|
@@ -51,11 +88,26 @@ module RubyMotionQuery
|
|
51
88
|
@_simulator
|
52
89
|
end
|
53
90
|
|
91
|
+
def three_point_five_inch?
|
92
|
+
@_three_point_five_inch = (Device.height == 480.0) if @_three_point_five_inch.nil?
|
93
|
+
@_three_point_five_inch
|
94
|
+
end
|
95
|
+
|
54
96
|
def four_inch?
|
55
97
|
@_four_inch = (Device.height == 568.0) if @_four_inch.nil?
|
56
98
|
@_four_inch
|
57
99
|
end
|
58
100
|
|
101
|
+
def four_point_seven_inch?
|
102
|
+
@_four_point_seven_inch = (Device.height == 667.0) if @_four_point_seven_inch.nil?
|
103
|
+
@_four_point_seven_inch
|
104
|
+
end
|
105
|
+
|
106
|
+
def five_point_five_inch?
|
107
|
+
@_five_point_five_inch = (Device.height == 736.0) if @_five_point_five_inch.nil?
|
108
|
+
@_five_point_five_inch
|
109
|
+
end
|
110
|
+
|
59
111
|
def retina?
|
60
112
|
if @_retina.nil?
|
61
113
|
main_screen = Device.screen
|
@@ -67,16 +119,41 @@ module RubyMotionQuery
|
|
67
119
|
|
68
120
|
# @return :unknown or from ORIENTATIONS
|
69
121
|
def orientation
|
70
|
-
|
71
|
-
|
122
|
+
if @custom_orientation
|
123
|
+
@custom_orientation
|
124
|
+
else
|
125
|
+
orientation = UIApplication.sharedApplication.statusBarOrientation
|
126
|
+
ORIENTATIONS[orientation] || :unknown
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# You can manually set the orientation, if set it RMQ won't automatically get the
|
131
|
+
# orientation from the sharedApplication. If you want the automatic orientation to work again
|
132
|
+
# set this to nil
|
133
|
+
#
|
134
|
+
# For options of what to set it to, see RubyMotionQuery::Device::ORIENTATIONS
|
135
|
+
#
|
136
|
+
# You can set this to :landscape, which isn't real option, but it will automatically
|
137
|
+
# get converted to :landscape_left
|
138
|
+
def orientation=(value)
|
139
|
+
if value
|
140
|
+
if value == :landscape
|
141
|
+
value = :landscape_left
|
142
|
+
elsif !value.is_a?(Symbol)
|
143
|
+
value = ORIENTATIONS[value] || :unknown
|
144
|
+
end
|
145
|
+
end
|
146
|
+
@custom_orientation = value
|
72
147
|
end
|
73
148
|
|
74
149
|
def landscape?
|
75
|
-
|
150
|
+
orientated = orientation
|
151
|
+
orientated == :landscape || orientated == :landscape_left || orientated == :landscape_right
|
76
152
|
end
|
77
153
|
|
78
154
|
def portrait?
|
79
|
-
|
155
|
+
orientated = orientation
|
156
|
+
orientated == :portrait || orientated == :unknown
|
80
157
|
end
|
81
158
|
|
82
159
|
def orientations
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module RubyMotionQuery
|
1
|
+
module RubyMotionQuery
|
2
2
|
class RMQ
|
3
|
-
# I'm purposly not including Enumerable,
|
3
|
+
# I'm purposly not including Enumerable,
|
4
4
|
# please use to_a if you want one
|
5
5
|
|
6
6
|
|
@@ -67,10 +67,12 @@ module RubyMotionQuery
|
|
67
67
|
|
68
68
|
# @return [RMQ]
|
69
69
|
def first
|
70
|
+
# TODO, check if it fails with nil
|
70
71
|
RMQ.create_with_array_and_selectors([selected.first], @selectors, @context)
|
71
72
|
end
|
72
73
|
# @return [RMQ]
|
73
74
|
def last
|
75
|
+
# TODO, check if it fails with nil
|
74
76
|
RMQ.create_with_array_and_selectors([selected.last], @selectors, @context)
|
75
77
|
end
|
76
78
|
|
@@ -134,6 +134,8 @@ module RubyMotionQuery
|
|
134
134
|
raise "[RMQ Error] Event already exists on this object: #{event}. Remove first, using .off" if @event_set[event]
|
135
135
|
|
136
136
|
if rmqe = event_instance(view, event, block)
|
137
|
+
view.userInteractionEnabled = true
|
138
|
+
|
137
139
|
rmqe.set_options(args) if rmqe.respond_to? :set_options
|
138
140
|
|
139
141
|
@event_set[event] = rmqe
|
@@ -116,6 +116,7 @@ module RubyMotionQuery
|
|
116
116
|
|
117
117
|
def initialize(params)
|
118
118
|
@grid_hash = {}
|
119
|
+
@grid_hash_landscape = {}
|
119
120
|
|
120
121
|
self.num_columns = params[:num_columns]
|
121
122
|
self.num_rows = params[:num_rows]
|
@@ -185,84 +186,90 @@ module RubyMotionQuery
|
|
185
186
|
#
|
186
187
|
# @return hash with any combination of l:, t:, w:, or :h. Or nil if invalid
|
187
188
|
def [](coord)
|
188
|
-
|
189
|
-
|
189
|
+
if Device.landscape?
|
190
|
+
@grid_hash_landscape[coord] ||= calc_coord(coord)
|
191
|
+
else
|
192
|
+
@grid_hash[coord] ||= calc_coord(coord)
|
193
|
+
end
|
194
|
+
end
|
190
195
|
|
191
|
-
|
192
|
-
|
193
|
-
case coord.length
|
194
|
-
when 2
|
195
|
-
RubyMotionQuery::Rect.new([l, t, column_width, row_height])
|
196
|
-
when 4
|
197
|
-
RubyMotionQuery::Rect.new([l, t, coord[2], coord[3]])
|
198
|
-
else
|
199
|
-
nil
|
200
|
-
end
|
196
|
+
private def calc_coord(coord)
|
197
|
+
if coord.is_a?(Array)
|
201
198
|
|
199
|
+
l = column_lefts[coord[0]]
|
200
|
+
t = row_tops[coord[1]]
|
201
|
+
case coord.length
|
202
|
+
when 2
|
203
|
+
RubyMotionQuery::Rect.new([l, t, column_width, row_height])
|
204
|
+
when 4
|
205
|
+
RubyMotionQuery::Rect.new([l, t, coord[2], coord[3]])
|
202
206
|
else
|
203
|
-
|
204
|
-
|
205
|
-
# TODO this needs refactoring once the full tests are done
|
206
|
-
coord.gsub!(/\s/, '')
|
207
|
-
is_end_coord = coord.start_with?(':')
|
208
|
-
parts = coord.split(':')
|
209
|
-
parts.reject!{|o| o == ''}
|
207
|
+
nil
|
208
|
+
end
|
210
209
|
|
211
|
-
|
212
|
-
|
213
|
-
nil
|
214
|
-
when 1
|
215
|
-
lefts = column_lefts
|
216
|
-
tops = row_tops
|
217
|
-
|
218
|
-
p1 = parts.first
|
219
|
-
digits = p1.gsub(/\D/, '')
|
220
|
-
if digits == ''
|
221
|
-
digits = nil
|
222
|
-
else
|
223
|
-
top_i = digits.to_i
|
224
|
-
top_i = (tops.length - 1) if top_i >= tops.length
|
225
|
-
end
|
210
|
+
else
|
211
|
+
return nil unless coord
|
226
212
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
left_i = (letter.ord - 97)
|
233
|
-
left_i = (lefts.length - 1) if left_i >= lefts.length
|
234
|
-
end
|
213
|
+
# TODO this needs refactoring once the full tests are done
|
214
|
+
coord.gsub!(/\s/, '')
|
215
|
+
is_end_coord = coord.start_with?(':')
|
216
|
+
parts = coord.split(':')
|
217
|
+
parts.reject!{|o| o == ''}
|
235
218
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
219
|
+
case parts.length
|
220
|
+
when 0
|
221
|
+
nil
|
222
|
+
when 1
|
223
|
+
lefts = column_lefts
|
224
|
+
tops = row_tops
|
225
|
+
|
226
|
+
p1 = parts.first
|
227
|
+
digits = p1.gsub(/\D/, '')
|
228
|
+
if digits == ''
|
229
|
+
digits = nil
|
230
|
+
else
|
231
|
+
top_i = digits.to_i
|
232
|
+
top_i = (tops.length - 1) if top_i >= tops.length
|
233
|
+
end
|
234
|
+
|
235
|
+
letter = p1.gsub(/\d/, '')
|
236
|
+
if letter == ''
|
237
|
+
letter = nil
|
238
|
+
else
|
239
|
+
letter.downcase!
|
240
|
+
left_i = (letter.ord - 97)
|
241
|
+
left_i = (lefts.length - 1) if left_i >= lefts.length
|
242
|
+
end
|
243
|
+
|
244
|
+
if digits && letter
|
245
|
+
if lefts.length > left_i && tops.length > top_i
|
253
246
|
if is_end_coord
|
254
|
-
{r: lefts[left_i] + column_width}
|
247
|
+
{r: lefts[left_i] + column_width, b: tops[top_i] + row_height}
|
255
248
|
else
|
256
|
-
{l: lefts[left_i]}
|
249
|
+
{l: lefts[left_i], t: tops[top_i]}
|
257
250
|
end
|
258
251
|
else
|
259
252
|
nil
|
260
253
|
end
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
254
|
+
elsif digits
|
255
|
+
if is_end_coord
|
256
|
+
{b: tops[top_i] + row_height}
|
257
|
+
else
|
258
|
+
{t: tops[top_i]}
|
259
|
+
end
|
260
|
+
elsif letter
|
261
|
+
if is_end_coord
|
262
|
+
{r: lefts[left_i] + column_width}
|
263
|
+
else
|
264
|
+
{l: lefts[left_i]}
|
265
|
+
end
|
266
|
+
else
|
267
|
+
nil
|
268
|
+
end
|
269
|
+
when 2
|
270
|
+
self[parts.first].merge(self[":#{parts.last}"])
|
271
|
+
end
|
272
|
+
end.freeze
|
266
273
|
end
|
267
274
|
|
268
275
|
# TODO, do this when orientation changes
|
@@ -272,6 +279,12 @@ module RubyMotionQuery
|
|
272
279
|
@_column_width = nil
|
273
280
|
@_usable_height = nil
|
274
281
|
@_row_height = nil
|
282
|
+
|
283
|
+
@grid_hash_landscape = {}
|
284
|
+
@_usable_width_landscape = nil
|
285
|
+
@_column_width_landscape = nil
|
286
|
+
@_usable_height_landscape = nil
|
287
|
+
@_row_height_landscape = nil
|
275
288
|
end
|
276
289
|
|
277
290
|
def to_h
|
@@ -331,11 +344,16 @@ module RubyMotionQuery
|
|
331
344
|
end
|
332
345
|
|
333
346
|
def usable_width
|
334
|
-
@_usable_width
|
347
|
+
unless @_usable_width
|
348
|
+
unusable = (@column_gutter * (@num_columns - 1)) + @content_left_margin + @content_right_margin
|
349
|
+
@_usable_width_landscape = Device.width_landscape - unusable
|
350
|
+
@_usable_width = Device.width - unusable
|
351
|
+
end
|
352
|
+
Device.landscape? ? @_usable_width_landscape : @_usable_width
|
335
353
|
end
|
336
354
|
|
337
355
|
def column_width
|
338
|
-
|
356
|
+
usable_width / @num_columns
|
339
357
|
end
|
340
358
|
|
341
359
|
def column_lefts
|
@@ -353,11 +371,16 @@ module RubyMotionQuery
|
|
353
371
|
end
|
354
372
|
|
355
373
|
def usable_height
|
356
|
-
@_usable_height
|
374
|
+
unless @_usable_height
|
375
|
+
unusable = (@row_gutter * (@num_rows - 1)) + @content_top_margin + @content_bottom_margin
|
376
|
+
@_usable_height_landscape = Device.height_landscape - unusable
|
377
|
+
@_usable_height = Device.height - unusable
|
378
|
+
end
|
379
|
+
Device.landscape? ? @_usable_height_landscape : @_usable_height
|
357
380
|
end
|
358
381
|
|
359
382
|
def row_height
|
360
|
-
|
383
|
+
usable_height / @num_rows
|
361
384
|
end
|
362
385
|
|
363
386
|
def row_tops
|
@@ -46,12 +46,12 @@ module RubyMotionQuery
|
|
46
46
|
# rmq(my_view).frame = "a1:b5"
|
47
47
|
# rmq(my_view, my_other_view).frame = {grid: "b2", w: 100, h: 200}
|
48
48
|
# rmq(my_view, my_other_view).frame = {g: "b2", w: 100, h: 200}
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# @example with padding
|
51
51
|
# rmq(my_view).frame = {grid: "b2:d14", padding: 5}
|
52
52
|
# rmq(my_view).frame = {grid: "b2:d14", padding: {l: 5, t: 0, r: 5, b:0}}
|
53
53
|
def frame=(value)
|
54
|
-
selected.each do |view|
|
54
|
+
selected.each do |view|
|
55
55
|
RubyMotionQuery::Rect.update_view_frame(view, value)
|
56
56
|
end
|
57
57
|
end
|
@@ -65,7 +65,7 @@ module RubyMotionQuery
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def bounds=(value)
|
68
|
-
selected.each do |view|
|
68
|
+
selected.each do |view|
|
69
69
|
RubyMotionQuery::Rect.bounds_for_view(view).update(value, self.grid).apply_to_bounds
|
70
70
|
end
|
71
71
|
end
|
@@ -73,7 +73,7 @@ module RubyMotionQuery
|
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
-
# RMQ Rect
|
76
|
+
# RMQ Rect
|
77
77
|
#
|
78
78
|
# *******************---*******---*************************** value options
|
79
79
|
# * | | * -------------
|
@@ -81,31 +81,31 @@ module RubyMotionQuery
|
|
81
81
|
# * | | * signed Integer
|
82
82
|
# * top | * Float
|
83
83
|
# * | | * String
|
84
|
-
# * | | *
|
85
|
-
# * --- | * also
|
84
|
+
# * | | *
|
85
|
+
# * --- | * also
|
86
86
|
# * ***************|***** --- * -----------------------
|
87
87
|
# * * view | * | * :full
|
88
|
-
# * * | * | * :right_of_prev (:rop)
|
88
|
+
# * * | * | * :right_of_prev (:rop)
|
89
89
|
# * * bottom * | * :left_of_prev (:lop)
|
90
|
-
# * * | * | * :below_prev (:bp)
|
90
|
+
# * * | * | * :below_prev (:bp)
|
91
91
|
# *|--- left ---|* | * | * :above_prev (:ap)
|
92
92
|
# * * | * height * :grid (:g)
|
93
93
|
# * * | * | * :padding (:p)
|
94
|
-
# * * | * | * int or hash: l,t,b,r
|
95
|
-
# *|-------------------- right -+---|* | *
|
96
|
-
# * * | * | * abbreviations
|
94
|
+
# * * | * | * int or hash: l,t,b,r
|
95
|
+
# *|-------------------- right -+---|* | *
|
96
|
+
# * * | * | * abbreviations
|
97
97
|
# * * | * |--+--from_right----|* -----------------------
|
98
|
-
# * * --- * | * :l, :t, :w, :h
|
98
|
+
# * * --- * | * :l, :t, :w, :h
|
99
99
|
# * ***************---*** --- * :r, :b
|
100
100
|
# * | * :fr, fb
|
101
|
-
# * |------ width - + -| *
|
101
|
+
# * |------ width - + -| *
|
102
102
|
# * | * :centered options
|
103
103
|
# * | * -----------------------
|
104
104
|
# * from_bottom * :horizontal
|
105
105
|
# * | * :vertical
|
106
|
-
# * | * :both
|
107
|
-
# * --- *
|
108
|
-
# ***********************************************************
|
106
|
+
# * | * :both
|
107
|
+
# * --- *
|
108
|
+
# ***********************************************************
|
109
109
|
#
|
110
110
|
class Rect
|
111
111
|
attr_reader :view
|
@@ -148,14 +148,14 @@ module RubyMotionQuery
|
|
148
148
|
a = rect_hash_to_rect_array(view, existing_rect, o, grid)
|
149
149
|
CGRectMake(a[0], a[1], a[2], a[3])
|
150
150
|
elsif o == :full
|
151
|
-
if view
|
152
|
-
|
151
|
+
if view && (sv = view.superview)
|
152
|
+
sv.bounds
|
153
153
|
else
|
154
|
-
rmq.
|
154
|
+
rmq.root_view.bounds
|
155
155
|
end
|
156
156
|
elsif o.is_a?(RubyMotionQuery::Rect)
|
157
157
|
o.to_cgrect
|
158
|
-
elsif grid && o.is_a?(String)
|
158
|
+
elsif grid && o.is_a?(String)
|
159
159
|
a = rect_hash_to_rect_array(view, existing_rect, {grid: o}, grid)
|
160
160
|
CGRectMake(a[0], a[1], a[2], a[3])
|
161
161
|
elsif o.is_a?(Array)
|
@@ -215,7 +215,7 @@ module RubyMotionQuery
|
|
215
215
|
|
216
216
|
# Previous
|
217
217
|
if prev_view = previous_view(view)
|
218
|
-
if params_g && (prev_sv = prev_view.superview)
|
218
|
+
if params_g && (prev_sv = prev_view.superview)
|
219
219
|
|
220
220
|
previous_root_view_point = vc.view.convertPoint(prev_view.origin, fromView: prev_sv)
|
221
221
|
|
@@ -252,13 +252,13 @@ module RubyMotionQuery
|
|
252
252
|
# Horrible horrible hack, TODO fix. This is here because
|
253
253
|
# the root_view's height isn't changed until after viewDidLoad when
|
254
254
|
# vc.edgesForExtendedLayout = UIRectEdgeNone.
|
255
|
-
# Not sure how often people use UIRectEdgeNone as I never do,
|
255
|
+
# Not sure how often people use UIRectEdgeNone as I never do,
|
256
256
|
# perhaps an edge case that should be isolated in some wayo
|
257
257
|
# I hate to have to check and calc this every time
|
258
258
|
if vc && !not_in_root_view && (vc.edgesForExtendedLayout == UIRectEdgeNone)
|
259
|
-
sv_size = CGSizeMake(sv.size.width, rmq.device.screen_height - 64)
|
259
|
+
sv_size = CGSizeMake(sv.bounds.size.width, rmq.device.screen_height - 64)
|
260
260
|
else
|
261
|
-
sv_size = sv.size
|
261
|
+
sv_size = sv.bounds.size
|
262
262
|
end
|
263
263
|
end
|
264
264
|
end
|
@@ -349,10 +349,10 @@ module RubyMotionQuery
|
|
349
349
|
end
|
350
350
|
|
351
351
|
def update(params, grid = nil)
|
352
|
-
# Doing all of the updates to the Rect in singleton for performance.
|
352
|
+
# Doing all of the updates to the Rect in singleton for performance.
|
353
353
|
# It would be better to be done inside an actual Rect instance, but that
|
354
354
|
# would require creating a lot of temporary objects.
|
355
|
-
# TODO performance and see if there is any real loss bringing
|
355
|
+
# TODO performance and see if there is any real loss bringing
|
356
356
|
# object_to_cg_rect into Rect instance
|
357
357
|
#
|
358
358
|
# If we did it that way, then we'd create a new instance, then appy the
|
@@ -404,7 +404,7 @@ module RubyMotionQuery
|
|
404
404
|
|
405
405
|
def from_bottom
|
406
406
|
if @view && (sv = @view.superview)
|
407
|
-
sv.size.height - bottom
|
407
|
+
sv.bounds.size.height - bottom
|
408
408
|
end
|
409
409
|
end
|
410
410
|
alias :fb :from_bottom
|
@@ -413,15 +413,15 @@ module RubyMotionQuery
|
|
413
413
|
@width
|
414
414
|
end
|
415
415
|
alias :w :width
|
416
|
-
|
416
|
+
|
417
417
|
def height
|
418
418
|
@height
|
419
419
|
end
|
420
420
|
alias :h :height
|
421
421
|
|
422
422
|
def z_order
|
423
|
-
if @view
|
424
|
-
|
423
|
+
if @view && (sv = @view.superview)
|
424
|
+
sv.subviews.to_a.index(@view) # is there a better way??
|
425
425
|
end
|
426
426
|
end
|
427
427
|
|
@@ -515,17 +515,17 @@ module RubyMotionQuery
|
|
515
515
|
wh = i_f_to_s(rmq.app.window.size.height.round(2))
|
516
516
|
|
517
517
|
if @view && (sv = @view.superview)
|
518
|
-
sw = i_f_to_s(sv.size.width.round(2))
|
519
|
-
sh = i_f_to_s(sv.size.height.round(2))
|
518
|
+
sw = i_f_to_s(sv.bounds.size.width.round(2))
|
519
|
+
sh = i_f_to_s(sv.bounds.size.height.round(2))
|
520
520
|
end
|
521
521
|
|
522
522
|
out = %(
|
523
|
-
*****************---*******---**************************
|
523
|
+
*****************---*******---**************************
|
524
524
|
* | | * window
|
525
525
|
* #{ t} top | * {w: #{ww}, h: #{wh}}
|
526
526
|
* | | *
|
527
|
-
* --- | * superview
|
528
|
-
* ***************|***** --- * {w: #{sw}, h: #{sh}}
|
527
|
+
* --- | * superview
|
528
|
+
* ***************|***** --- * {w: #{sw}, h: #{sh}}
|
529
529
|
* * | * | *
|
530
530
|
* * | * | *
|
531
531
|
* * #{ b} bottom * | * view
|
@@ -19,6 +19,13 @@ module RubyMotionQuery
|
|
19
19
|
@view.titleColor
|
20
20
|
end
|
21
21
|
|
22
|
+
def color_highlighted=(value)
|
23
|
+
@view.setTitleColor(value, forState: UIControlStateHighlighted)
|
24
|
+
end
|
25
|
+
def color_highlighted
|
26
|
+
@view.titleColorforState(UIControlStateHighlighted)
|
27
|
+
end
|
28
|
+
|
22
29
|
def tint_color=(value)
|
23
30
|
@view.tintColor = value
|
24
31
|
end
|
@@ -1,9 +1,20 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
|
-
class UITextViewStyler <
|
3
|
+
class UITextViewStyler < UIScrollViewStyler
|
4
4
|
|
5
|
-
def
|
6
|
-
def
|
5
|
+
def text ; view.text ; end
|
6
|
+
def text=(v) ; view.text = v ; end
|
7
|
+
|
8
|
+
def attributed_text ; view.attributedText ; end
|
9
|
+
def attributed_text=(v) ; view.attributedText = v ; end
|
10
|
+
|
11
|
+
def font ; view.font ; end
|
12
|
+
def font=(v) ; view.font = v ; end
|
13
|
+
|
14
|
+
def text_color ; view.textColor ; end
|
15
|
+
def text_color=(v) ; view.textColor = v ; end
|
16
|
+
alias :color :text_color
|
17
|
+
alias :color= :text_color=
|
7
18
|
|
8
19
|
end
|
9
20
|
end
|
@@ -77,11 +77,19 @@ module RubyMotionQuery
|
|
77
77
|
alias :parent :superview
|
78
78
|
|
79
79
|
def super_height
|
80
|
-
@view.superview
|
80
|
+
if @view.superview
|
81
|
+
@view.superview.frame.size.height
|
82
|
+
else
|
83
|
+
0
|
84
|
+
end
|
81
85
|
end
|
82
86
|
|
83
87
|
def super_width
|
84
|
-
@view.superview
|
88
|
+
if @view.superview
|
89
|
+
@view.superview.frame.size.width
|
90
|
+
else
|
91
|
+
0
|
92
|
+
end
|
85
93
|
end
|
86
94
|
|
87
95
|
def tag(tags)
|
@@ -363,6 +371,7 @@ module RubyMotionQuery
|
|
363
371
|
end
|
364
372
|
|
365
373
|
def corner_radius=(value = 2)
|
374
|
+
@view.clipsToBounds = true
|
366
375
|
@view.layer.cornerRadius = value
|
367
376
|
end
|
368
377
|
|
@@ -387,6 +396,9 @@ module RubyMotionQuery
|
|
387
396
|
@view.rmq_data.validation_errors = values
|
388
397
|
end
|
389
398
|
|
399
|
+
def alpha ; view.alpha ; end
|
400
|
+
def alpha=(v) ; view.alpha = v ; end
|
401
|
+
|
390
402
|
end
|
391
403
|
end
|
392
404
|
end
|
@@ -75,9 +75,17 @@ module RubyMotionQuery
|
|
75
75
|
when UINavigationBar then Stylers::UINavigationBarStyler.new(view)
|
76
76
|
when UIScrollView then Stylers::UIScrollViewStyler.new(view)
|
77
77
|
# TODO, all the controls are done, but missing some views, add
|
78
|
-
when UIControl then Stylers::UIControlStyler.new(view)
|
79
78
|
else
|
80
|
-
|
79
|
+
if view.respond_to?(:rmq_styler)
|
80
|
+
# If you're creating an RMQ plug-in that is a view you can set your styler by adding this method
|
81
|
+
view.rmq_styler
|
82
|
+
else
|
83
|
+
if view.is_a?(UIControl)
|
84
|
+
Stylers::UIControlStyler.new(view)
|
85
|
+
else
|
86
|
+
Stylers::UIViewStyler.new(view)
|
87
|
+
end
|
88
|
+
end
|
81
89
|
end
|
82
90
|
end
|
83
91
|
end
|
@@ -92,6 +100,7 @@ module RubyMotionQuery
|
|
92
100
|
begin
|
93
101
|
stylesheet.public_send(style_name, styler_for(view))
|
94
102
|
view.rmq_data.style_name = style_name
|
103
|
+
view.rmq_style_applied
|
95
104
|
rescue NoMethodError => e
|
96
105
|
if e.message =~ /.*#{style_name.to_s}.*/
|
97
106
|
puts "\n[RMQ ERROR] style_name :#{style_name} doesn't exist for a #{view.class.name}. Add 'def #{style_name}(st)' to #{stylesheet.class.name} class\n\n"
|
@@ -171,43 +180,45 @@ module RubyMotionQuery
|
|
171
180
|
end
|
172
181
|
|
173
182
|
def four_inch?
|
174
|
-
|
183
|
+
device.four_inch?
|
175
184
|
end
|
176
185
|
|
177
186
|
def retina?
|
178
|
-
|
187
|
+
device.retina?
|
179
188
|
end
|
180
189
|
|
181
190
|
def window
|
182
191
|
RMQ.app.window
|
183
192
|
end
|
184
193
|
|
185
|
-
#
|
194
|
+
# @deprecated - use device_width
|
186
195
|
def app_width
|
187
|
-
|
196
|
+
device.width
|
188
197
|
end
|
198
|
+
alias :device_width :app_width
|
189
199
|
|
190
|
-
#
|
200
|
+
# @deprecated - use device_height
|
191
201
|
def app_height
|
192
|
-
|
202
|
+
device.height
|
193
203
|
end
|
204
|
+
alias :device_width :app_width
|
194
205
|
|
206
|
+
# @deprecated - use device_width and device_height in your stylesheets
|
195
207
|
def app_size
|
196
|
-
device.
|
208
|
+
CGSizeMake(device.width, device.height)
|
197
209
|
end
|
198
210
|
|
199
|
-
# TODO, cache, then clear when orientation changes
|
200
211
|
def screen_width
|
201
|
-
|
212
|
+
device.screen_width
|
202
213
|
end
|
203
214
|
|
204
|
-
# TODO, cache, then clear when orientation changes
|
205
215
|
def screen_height
|
206
|
-
|
216
|
+
device.screen_height
|
207
217
|
end
|
208
218
|
|
219
|
+
# @deprecated - use screen_width and screen_height in your stylesheets
|
209
220
|
def screen_size
|
210
|
-
|
221
|
+
CGSizeMake(screen_width, screen_height)
|
211
222
|
end
|
212
223
|
|
213
224
|
def content_width
|
@@ -24,7 +24,7 @@ module RubyMotionQuery
|
|
24
24
|
selected.each do |selected_view|
|
25
25
|
created = false
|
26
26
|
appended = false
|
27
|
-
|
27
|
+
built = false
|
28
28
|
|
29
29
|
if view_or_constant.is_a?(UIView)
|
30
30
|
new_view = view_or_constant
|
@@ -33,7 +33,14 @@ module RubyMotionQuery
|
|
33
33
|
new_view = create_view(view_or_constant, opts)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
rmq_data = new_view.rmq_data
|
37
|
+
|
38
|
+
unless rmq_data.built
|
39
|
+
rmq_data.built = true # build only once
|
40
|
+
built = true
|
41
|
+
end
|
42
|
+
|
43
|
+
rmq_data.view_controller = self.weak_view_controller
|
37
44
|
|
38
45
|
subviews_added << new_view
|
39
46
|
|
@@ -53,7 +60,7 @@ module RubyMotionQuery
|
|
53
60
|
new_view.rmq_did_create(self.wrap(new_view))
|
54
61
|
new_view.rmq_created
|
55
62
|
end
|
56
|
-
new_view.rmq_build
|
63
|
+
new_view.rmq_build if built
|
57
64
|
new_view.rmq_appended if appended
|
58
65
|
|
59
66
|
if self.stylesheet
|
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.
|
4
|
+
version: 0.8.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: 2014-
|
12
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -151,4 +151,3 @@ signing_key:
|
|
151
151
|
specification_version: 4
|
152
152
|
summary: RubyMotionQuery - RMQ
|
153
153
|
test_files: []
|
154
|
-
has_rdoc:
|