ruby_motion_query 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/motion/ext.rb +0 -4
- data/motion/ruby_motion_query/actions.rb +1 -1
- data/motion/ruby_motion_query/animations.rb +1 -1
- data/motion/ruby_motion_query/data.rb +0 -1
- data/motion/ruby_motion_query/deprecation.rb +7 -0
- data/motion/ruby_motion_query/device.rb +17 -0
- data/motion/ruby_motion_query/position.rb +23 -23
- data/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb +3 -3
- data/motion/ruby_motion_query/stylers/ui_button_styler.rb +8 -0
- data/motion/ruby_motion_query/stylers/ui_table_view_styler.rb +8 -1
- data/motion/ruby_motion_query/stylers/ui_text_field_styler.rb +1 -1
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +189 -140
- data/motion/ruby_motion_query/stylesheet.rb +2 -16
- data/motion/ruby_motion_query/subviews.rb +0 -1
- data/motion/ruby_motion_query/utils.rb +0 -8
- data/motion/ruby_motion_query/validation.rb +1 -1
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/collection_view_controller/app/controllers/name_controller.rb +1 -2
- data/templates/controller/app/controllers/name_controller.rb +1 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9913c04791559fa0a0408ca563e38d8eea89c38d
|
4
|
+
data.tar.gz: 2a523d42844327abfe26e233697045ef1294049c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf40b66623205cb835426352ad33a2103bb37cbfea6dc4541a793711d6778052141d48e502767a01196fb6b8c27224413589f2fd3da94abf8dfd1ed56dc3b592
|
7
|
+
data.tar.gz: 474192216610a6115742b429c76d142f11fc99148e63823fe99567f077c3bda60ac3f4238b87d4b8df041cfafca128f000201564f9495039f1793ccdea54d13a
|
data/motion/ext.rb
CHANGED
@@ -24,7 +24,7 @@ module RubyMotionQuery
|
|
24
24
|
when UIButton then view.setTitle(new_data, forState: UIControlStateNormal)
|
25
25
|
when UIImageView then view.image = new_data
|
26
26
|
#when UITableView then
|
27
|
-
|
27
|
+
when UISwitch then view.setOn(new_data)
|
28
28
|
#when UIDatePicker then
|
29
29
|
#when UISegmentedControl then
|
30
30
|
#when UIRefreshControl then
|
@@ -181,7 +181,7 @@ module RubyMotionQuery
|
|
181
181
|
options: UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionBeginFromCurrentState,
|
182
182
|
animations: ->(cq) {
|
183
183
|
cq.style do |st|
|
184
|
-
st.
|
184
|
+
st.frame = {t: @rmq.device.height + st.frame.height}
|
185
185
|
st.rotation = 180 + rand(50)
|
186
186
|
end
|
187
187
|
},
|
@@ -176,6 +176,23 @@ module RubyMotionQuery
|
|
176
176
|
UIDeviceOrientationFaceDown => :face_down
|
177
177
|
}
|
178
178
|
|
179
|
+
def log
|
180
|
+
puts "Device Info:\n" << "-" * 12
|
181
|
+
[:simulator?, :orientation, :retina?, :screen_height, :screen_width, :ios_version].each do |method|
|
182
|
+
puts "#{method}: #{self.send(method)}"
|
183
|
+
end
|
184
|
+
|
185
|
+
if five_point_five_inch?
|
186
|
+
puts "screen size: 5.5\""
|
187
|
+
elsif four_point_seven_inch?
|
188
|
+
puts "screen size: 4.7\""
|
189
|
+
elsif four_inch?
|
190
|
+
puts "screen size: 4\""
|
191
|
+
elsif three_point_five_inch?
|
192
|
+
puts "screen size: 3.5\""
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
179
196
|
end
|
180
197
|
end
|
181
198
|
end
|
@@ -29,13 +29,13 @@ module RubyMotionQuery
|
|
29
29
|
# rmq(my_view).layout("a1:b5").show
|
30
30
|
# rmq(my_view, my_other_view).layout grid: "b2", w: 100, h: 200
|
31
31
|
# rmq(my_view, my_other_view).layout g: "b2", w: 100, h: 200
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# @example with padding
|
34
34
|
# mq(my_view).layout(grid: "b2:d14", padding: 5)
|
35
35
|
# mq(my_view).layout(grid: "b2:d14", padding: {l: 5, t: 0, r: 5, b:0})
|
36
36
|
#
|
37
37
|
# @return [RMQ]
|
38
|
-
def layout(params)
|
38
|
+
def layout(params)
|
39
39
|
selected.each do |view|
|
40
40
|
RubyMotionQuery::Rect.update_view_frame(view, params)
|
41
41
|
end
|
@@ -47,7 +47,7 @@ module RubyMotionQuery
|
|
47
47
|
|
48
48
|
# @return [RMQ]
|
49
49
|
# TODO move nudge implementation into Rect
|
50
|
-
def nudge(params)
|
50
|
+
def nudge(params)
|
51
51
|
left = params[:left] || params[:l] || 0
|
52
52
|
right = params[:right] || params[:r] || 0
|
53
53
|
up = params[:up] || params[:u] || 0
|
@@ -79,13 +79,7 @@ module RubyMotionQuery
|
|
79
79
|
current_end = nil
|
80
80
|
|
81
81
|
selected.each_with_index do |view, i|
|
82
|
-
|
83
|
-
|
84
|
-
if type == :vertical
|
85
|
-
next if st.height == 0
|
86
|
-
else
|
87
|
-
next if st.width == 0
|
88
|
-
end
|
82
|
+
rect = view.rmq.frame
|
89
83
|
|
90
84
|
view_margin = if (margins && margins[i])
|
91
85
|
margins[i]
|
@@ -93,15 +87,20 @@ module RubyMotionQuery
|
|
93
87
|
margin
|
94
88
|
end
|
95
89
|
|
90
|
+
t = rect.top
|
91
|
+
l = rect.left
|
92
|
+
|
96
93
|
if type == :vertical
|
97
|
-
current_end = (
|
98
|
-
|
99
|
-
current_end =
|
94
|
+
current_end = (rect.top - view_margin) unless current_end
|
95
|
+
t = current_end + view_margin
|
96
|
+
current_end = t + rect.height
|
100
97
|
else
|
101
|
-
current_end = (
|
102
|
-
|
103
|
-
current_end =
|
98
|
+
current_end = (rect.left - view_margin) unless current_end
|
99
|
+
l = current_end + view_margin
|
100
|
+
current_end = l + rect.width
|
104
101
|
end
|
102
|
+
|
103
|
+
view.rmq.layout(l: l, t: t)
|
105
104
|
end
|
106
105
|
|
107
106
|
self
|
@@ -109,19 +108,20 @@ module RubyMotionQuery
|
|
109
108
|
|
110
109
|
def resize_to_fit_subviews
|
111
110
|
selected.each do |view|
|
112
|
-
st = self.styler_for(view)
|
113
|
-
|
114
111
|
w = 0
|
115
112
|
h = 0
|
116
113
|
|
117
114
|
view.subviews.each do |subview|
|
118
|
-
|
119
|
-
w = [
|
120
|
-
h = [
|
115
|
+
rect = subview.rmq.frame
|
116
|
+
w = [rect.right, w].max
|
117
|
+
h = [rect.bottom, h].max
|
121
118
|
end
|
122
119
|
|
123
|
-
|
124
|
-
|
120
|
+
rect = view.rmq.frame
|
121
|
+
w = rect.width if w == 0
|
122
|
+
h = rect.height if h == 0
|
123
|
+
|
124
|
+
view.rmq.layout(w: w, h: h)
|
125
125
|
end
|
126
126
|
|
127
127
|
self
|
@@ -17,16 +17,16 @@ module RubyMotionQuery
|
|
17
17
|
def keyboard_appearance=(v) ; view.keyboardAppearance = v ; end
|
18
18
|
|
19
19
|
def keyboard_type ; view.keyboardType ; end
|
20
|
-
def keyboard_type=(v) ; view.
|
20
|
+
def keyboard_type=(v) ; view.setKeyboardType(KEYBOARD_TYPES[v] || v) ; end
|
21
21
|
|
22
22
|
def return_key_type ; view.returnKeyType ; end
|
23
|
-
def return_key_type=(v) ; view.
|
23
|
+
def return_key_type=(v) ; view.setReturnKeyType(RETURN_KEY_TYPES[v] || v) ; end
|
24
24
|
|
25
25
|
def secure_text_entry ; view.secureTextEntry ; end
|
26
26
|
def secure_text_entry=(v) ; view.secureTextEntry = v ; end
|
27
27
|
|
28
28
|
def spell_checking_type ; view.spellCheckingType ; end
|
29
|
-
def spell_checking_type=(v) ; view.
|
29
|
+
def spell_checking_type=(v) ; view.setSpellCheckingType(SPELL_CHECKING_TYPES[v] || v) ; end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -78,6 +78,14 @@ module RubyMotionQuery
|
|
78
78
|
@view.imageEdgeInsets
|
79
79
|
end
|
80
80
|
|
81
|
+
def text_highlighted value
|
82
|
+
@view.setTitle(value, forState:UIControlStateHighlighted)
|
83
|
+
end
|
84
|
+
|
85
|
+
def text_highlighted= value
|
86
|
+
@view.setTitle(value, forState:UIControlStateHighlighted)
|
87
|
+
end
|
88
|
+
|
81
89
|
end
|
82
90
|
end
|
83
91
|
end
|
@@ -14,6 +14,14 @@ module RubyMotionQuery
|
|
14
14
|
def allows_selection=(value) ; @view.allowsSelection = value ; end
|
15
15
|
def allows_selection ; @view.allowsSelection ; end
|
16
16
|
|
17
|
+
def separator_inset=(value)
|
18
|
+
@view.separatorInset = value
|
19
|
+
end
|
20
|
+
|
21
|
+
def row_height=(value)
|
22
|
+
@view.rowHeight = value
|
23
|
+
end
|
24
|
+
|
17
25
|
SEPARATOR_STYLES = {
|
18
26
|
none: UITableViewCellSeparatorStyleNone,
|
19
27
|
single: UITableViewCellSeparatorStyleSingleLine,
|
@@ -21,6 +29,5 @@ module RubyMotionQuery
|
|
21
29
|
}
|
22
30
|
|
23
31
|
end
|
24
|
-
|
25
32
|
end
|
26
33
|
end
|
@@ -54,7 +54,7 @@ module RubyMotionQuery
|
|
54
54
|
|
55
55
|
# Setting the View's Background Appearance
|
56
56
|
def border_style ; view.borderStyle ; end
|
57
|
-
def border_style=(v) ; view.
|
57
|
+
def border_style=(v) ; view.setBorderStyle(BORDER_STYLES[v] || v) ; end
|
58
58
|
|
59
59
|
def background ; view.background ; end
|
60
60
|
def background=(v) ; view.background = v ; end
|
@@ -9,6 +9,50 @@ module RubyMotionQuery
|
|
9
9
|
natural: NSTextAlignmentNatural
|
10
10
|
}
|
11
11
|
|
12
|
+
KEYBOARD_TYPES = {
|
13
|
+
default: UIKeyboardTypeDefault,
|
14
|
+
ascii: UIKeyboardTypeASCIICapable,
|
15
|
+
numbers_punctuation: UIKeyboardTypeNumbersAndPunctuation,
|
16
|
+
url: UIKeyboardTypeURL,
|
17
|
+
number_pad: UIKeyboardTypeNumberPad,
|
18
|
+
phone_pad: UIKeyboardTypePhonePad,
|
19
|
+
name_phone_pad: UIKeyboardTypeNamePhonePad,
|
20
|
+
email_address: UIKeyboardTypeEmailAddress,
|
21
|
+
email: UIKeyboardTypeEmailAddress, # Duplicate to help developers
|
22
|
+
decimal_pad: UIKeyboardTypeDecimalPad,
|
23
|
+
twitter: UIKeyboardTypeTwitter,
|
24
|
+
web_search: UIKeyboardTypeWebSearch,
|
25
|
+
alphabet: UIKeyboardTypeASCIICapable
|
26
|
+
}
|
27
|
+
|
28
|
+
RETURN_KEY_TYPES = {
|
29
|
+
default: UIReturnKeyDefault,
|
30
|
+
go: UIReturnKeyGo,
|
31
|
+
google: UIReturnKeyGoogle,
|
32
|
+
join: UIReturnKeyJoin,
|
33
|
+
next: UIReturnKeyNext,
|
34
|
+
route: UIReturnKeyRoute,
|
35
|
+
search: UIReturnKeySearch,
|
36
|
+
send: UIReturnKeySend,
|
37
|
+
yahoo: UIReturnKeyYahoo,
|
38
|
+
done: UIReturnKeyDone,
|
39
|
+
emergency_call: UIReturnKeyEmergencyCall
|
40
|
+
}
|
41
|
+
|
42
|
+
SPELL_CHECKING_TYPES = {
|
43
|
+
default: UITextSpellCheckingTypeDefault,
|
44
|
+
no: UITextSpellCheckingTypeNo,
|
45
|
+
yes: UITextSpellCheckingTypeYes
|
46
|
+
}
|
47
|
+
|
48
|
+
BORDER_STYLES = {
|
49
|
+
none: UITextBorderStyleNone,
|
50
|
+
line: UITextBorderStyleLine,
|
51
|
+
bezel: UITextBorderStyleBezel,
|
52
|
+
rounded_rect: UITextBorderStyleRoundedRect,
|
53
|
+
rounded: UITextBorderStyleRoundedRect
|
54
|
+
}
|
55
|
+
|
12
56
|
# When you create a styler, always inherit UIViewStyler
|
13
57
|
class UIViewStyler
|
14
58
|
def initialize(view)
|
@@ -96,130 +140,6 @@ module RubyMotionQuery
|
|
96
140
|
rmq.wrap(@view).tag(tags)
|
97
141
|
end
|
98
142
|
|
99
|
-
# @deprecated - use frame or bounds
|
100
|
-
def padded=(value)
|
101
|
-
if value.is_a?(Hash)
|
102
|
-
h = value
|
103
|
-
h[:l] ||= (h[:left] || 0)
|
104
|
-
h[:t] ||= (h[:top] || 0)
|
105
|
-
h[:r] ||= (h[:right] || 0)
|
106
|
-
h[:b] ||= (h[:bottom] || 0)
|
107
|
-
|
108
|
-
sbounds = self.superview.bounds
|
109
|
-
|
110
|
-
value = [
|
111
|
-
[h[:l], h[:t]],
|
112
|
-
[
|
113
|
-
sbounds.size.width - h[:l] - h[:r],
|
114
|
-
sbounds.size.height - h[:t] - h[:b]
|
115
|
-
]]
|
116
|
-
|
117
|
-
@view.frame = value
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# @deprecated - use frame or bounds
|
122
|
-
def left=(value)
|
123
|
-
f = @view.frame
|
124
|
-
f.origin.x = value
|
125
|
-
@view.frame = f
|
126
|
-
end
|
127
|
-
|
128
|
-
# @deprecated - use frame or bounds
|
129
|
-
def left
|
130
|
-
@view.origin.x
|
131
|
-
end
|
132
|
-
|
133
|
-
# @deprecated - use frame or bounds
|
134
|
-
alias :x :left
|
135
|
-
|
136
|
-
# @deprecated - use frame or bounds
|
137
|
-
def top=(value)
|
138
|
-
f = @view.frame
|
139
|
-
f.origin.y = value
|
140
|
-
@view.frame = f
|
141
|
-
end
|
142
|
-
|
143
|
-
# @deprecated - use frame or bounds
|
144
|
-
def top
|
145
|
-
@view.origin.y
|
146
|
-
end
|
147
|
-
|
148
|
-
# @deprecated - use frame or bounds
|
149
|
-
alias :y :top
|
150
|
-
|
151
|
-
# @deprecated - use frame or bounds
|
152
|
-
def width=(value)
|
153
|
-
f = @view.frame
|
154
|
-
f.size.width = value
|
155
|
-
@view.frame = f
|
156
|
-
end
|
157
|
-
|
158
|
-
# @deprecated - use frame or bounds
|
159
|
-
def width
|
160
|
-
@view.size.width
|
161
|
-
end
|
162
|
-
|
163
|
-
# @deprecated - use frame or bounds
|
164
|
-
def height=(value)
|
165
|
-
f = @view.frame
|
166
|
-
f.size.height = value
|
167
|
-
@view.frame = f
|
168
|
-
end
|
169
|
-
|
170
|
-
# @deprecated - use frame or bounds
|
171
|
-
def height
|
172
|
-
@view.size.height
|
173
|
-
end
|
174
|
-
|
175
|
-
# @deprecated - use frame or bounds
|
176
|
-
def bottom=(value)
|
177
|
-
self.top = value - self.height
|
178
|
-
end
|
179
|
-
|
180
|
-
# @deprecated - use frame or bounds
|
181
|
-
def bottom
|
182
|
-
self.top + self.height
|
183
|
-
end
|
184
|
-
|
185
|
-
# @deprecated - use frame or bounds
|
186
|
-
def from_bottom=(value)
|
187
|
-
if sv = @view.superview
|
188
|
-
self.top = sv.bounds.size.height - self.height - value
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
# @deprecated - use frame or bounds
|
193
|
-
def from_bottom
|
194
|
-
if sv = @view.superview
|
195
|
-
sv.bounds.size.height - self.top
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# @deprecated - use frame or bounds
|
200
|
-
def right=(value)
|
201
|
-
self.left = value - self.width
|
202
|
-
end
|
203
|
-
|
204
|
-
# @deprecated - use frame or bounds
|
205
|
-
def right
|
206
|
-
self.left + self.width
|
207
|
-
end
|
208
|
-
|
209
|
-
# @deprecated - use frame or bounds
|
210
|
-
def from_right=(value)
|
211
|
-
if superview = @view.superview
|
212
|
-
self.left = superview.bounds.size.width - self.width - value
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# @deprecated - use frame or bounds
|
217
|
-
def from_right
|
218
|
-
if superview = @view.superview
|
219
|
-
superview.bounds.size.width - self.left
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
143
|
def center=(value)
|
224
144
|
@view.center = value
|
225
145
|
end
|
@@ -245,22 +165,6 @@ module RubyMotionQuery
|
|
245
165
|
@view.center.y
|
246
166
|
end
|
247
167
|
|
248
|
-
# @deprecated - use frame or bounds
|
249
|
-
# param can be :horizontal, :vertical, :both
|
250
|
-
def centered=(option)
|
251
|
-
if parent = @view.superview
|
252
|
-
case option
|
253
|
-
when :horizontal
|
254
|
-
# Not using parent.center.x here for orientation
|
255
|
-
self.center_x = parent.bounds.size.width / 2
|
256
|
-
when :vertical
|
257
|
-
self.center_y = parent.bounds.size.height / 2
|
258
|
-
else
|
259
|
-
@view.center = [parent.bounds.size.width / 2, parent.bounds.size.height / 2]
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
168
|
def background_color=(value)
|
265
169
|
@view.setBackgroundColor value
|
266
170
|
end
|
@@ -321,6 +225,13 @@ module RubyMotionQuery
|
|
321
225
|
@view.transform = CGAffineTransformMakeRotation(radians)
|
322
226
|
end
|
323
227
|
|
228
|
+
def transform=(transformation)
|
229
|
+
@view.transform = transformation
|
230
|
+
end
|
231
|
+
def transform
|
232
|
+
@view.transform
|
233
|
+
end
|
234
|
+
|
324
235
|
def content_mode=(value)
|
325
236
|
@view.setContentMode value
|
326
237
|
end
|
@@ -405,6 +316,144 @@ module RubyMotionQuery
|
|
405
316
|
def alpha ; view.alpha ; end
|
406
317
|
def alpha=(v) ; view.alpha = v ; end
|
407
318
|
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
# @deprecated - use frame hashs
|
323
|
+
def left=(value)
|
324
|
+
Deprecation.warn(:left=, "Set `left` with the frame hash.")
|
325
|
+
f = @view.frame
|
326
|
+
f.origin.x = value
|
327
|
+
@view.frame = f
|
328
|
+
end
|
329
|
+
|
330
|
+
# @deprecated - use st.frame.left
|
331
|
+
def left
|
332
|
+
Deprecation.warn(:left, "Use `st.frame.left`.")
|
333
|
+
@view.origin.x
|
334
|
+
end
|
335
|
+
|
336
|
+
# @deprecated - use st.frame.x
|
337
|
+
alias :x :left
|
338
|
+
|
339
|
+
# @deprecated - use frame hash
|
340
|
+
def top=(value)
|
341
|
+
Deprecation.warn(:top=, "Set `top` with the frame hash.")
|
342
|
+
f = @view.frame
|
343
|
+
f.origin.y = value
|
344
|
+
@view.frame = f
|
345
|
+
end
|
346
|
+
|
347
|
+
# @deprecated - use st.frame.top
|
348
|
+
def top
|
349
|
+
Deprecation.warn(:top, "Use `st.frame.top`.")
|
350
|
+
@view.origin.y
|
351
|
+
end
|
352
|
+
|
353
|
+
# @deprecated - use st.frame.y
|
354
|
+
alias :y :top
|
355
|
+
|
356
|
+
# @deprecated - use frame hash
|
357
|
+
def width=(value)
|
358
|
+
Deprecation.warn(:width=, "Set `width` with the frame hash.")
|
359
|
+
f = @view.frame
|
360
|
+
f.size.width = value
|
361
|
+
@view.frame = f
|
362
|
+
end
|
363
|
+
|
364
|
+
# @deprecated - use st.frame.width
|
365
|
+
def width
|
366
|
+
Deprecation.warn(:width, "Use `st.frame.width`.")
|
367
|
+
@view.size.width
|
368
|
+
end
|
369
|
+
|
370
|
+
# @deprecated - use frame hash
|
371
|
+
def height=(value)
|
372
|
+
Deprecation.warn(:height=, "Set `height` with the frame hash.")
|
373
|
+
f = @view.frame
|
374
|
+
f.size.height = value
|
375
|
+
@view.frame = f
|
376
|
+
end
|
377
|
+
|
378
|
+
# @deprecated - use st.frame.height
|
379
|
+
def height
|
380
|
+
Deprecation.warn(:height, "Use `st.frame.height`.")
|
381
|
+
@view.size.height
|
382
|
+
end
|
383
|
+
|
384
|
+
# @deprecated - use frame hash
|
385
|
+
def bottom=(value)
|
386
|
+
Deprecation.warn(:bottom=, "Set `bottom` with the frame hash.")
|
387
|
+
self.top = value - self.height
|
388
|
+
end
|
389
|
+
|
390
|
+
# @deprecated - st.frame.bottom
|
391
|
+
def bottom
|
392
|
+
Deprecation.warn(:bottom, "Use `st.frame.bottom`.")
|
393
|
+
self.top + self.height
|
394
|
+
end
|
395
|
+
|
396
|
+
# @deprecated - use frame hash
|
397
|
+
def from_bottom=(value)
|
398
|
+
Deprecation.warn(:from_bottom=, "Set `from_bottom` with the frame hash.")
|
399
|
+
if sv = @view.superview
|
400
|
+
self.top = sv.bounds.size.height - self.height - value
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
# @deprecated - st.frame.from_bottom
|
405
|
+
def from_bottom
|
406
|
+
Deprecation.warn(:from_bottom, "Use `st.frame.from_bottom`.")
|
407
|
+
if sv = @view.superview
|
408
|
+
sv.bounds.size.height - self.top
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
# @deprecated - use frame hash
|
413
|
+
def right=(value)
|
414
|
+
Deprecation.warn(:right=, "Set `right` with the frame hash.")
|
415
|
+
self.left = value - self.width
|
416
|
+
end
|
417
|
+
|
418
|
+
# @deprecated - st.frame.right
|
419
|
+
def right
|
420
|
+
Deprecation.warn(:right, "Use `st.frame.right`.")
|
421
|
+
self.left + self.width
|
422
|
+
end
|
423
|
+
|
424
|
+
# @deprecated - use frame hash
|
425
|
+
def from_right=(value)
|
426
|
+
Deprecation.warn(:from_right=, "Set `from_right` with the frame hash.")
|
427
|
+
if superview = @view.superview
|
428
|
+
self.left = superview.bounds.size.width - self.width - value
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
# @deprecated - st.frame.from_right
|
433
|
+
def from_right
|
434
|
+
Deprecation.warn(:from_right, "Use `st.frame.from_right`.")
|
435
|
+
if superview = @view.superview
|
436
|
+
superview.bounds.size.width - self.left
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
# @deprecated - use frame hash
|
441
|
+
# param can be :horizontal, :vertical, :both
|
442
|
+
def centered=(option)
|
443
|
+
Deprecation.warn(:centered=, "Use the frame hash to center a view.")
|
444
|
+
if parent = @view.superview
|
445
|
+
case option
|
446
|
+
when :horizontal
|
447
|
+
# Not using parent.center.x here for orientation
|
448
|
+
self.center_x = parent.bounds.size.width / 2
|
449
|
+
when :vertical
|
450
|
+
self.center_y = parent.bounds.size.height / 2
|
451
|
+
else
|
452
|
+
@view.center = [parent.bounds.size.width / 2, parent.bounds.size.height / 2]
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
408
457
|
private
|
409
458
|
|
410
459
|
def is_color(value)
|
@@ -230,22 +230,13 @@ module RubyMotionQuery
|
|
230
230
|
RMQ.app.window
|
231
231
|
end
|
232
232
|
|
233
|
-
|
234
|
-
def app_width
|
233
|
+
def device_width
|
235
234
|
device.width
|
236
235
|
end
|
237
|
-
alias :device_width :app_width
|
238
236
|
|
239
|
-
|
240
|
-
def app_height
|
237
|
+
def device_height
|
241
238
|
device.height
|
242
239
|
end
|
243
|
-
alias :device_width :app_width
|
244
|
-
|
245
|
-
# @deprecated - use device_width and device_height in your stylesheets
|
246
|
-
def app_size
|
247
|
-
CGSizeMake(device.width, device.height)
|
248
|
-
end
|
249
240
|
|
250
241
|
def screen_width
|
251
242
|
device.screen_width
|
@@ -255,11 +246,6 @@ module RubyMotionQuery
|
|
255
246
|
device.screen_height
|
256
247
|
end
|
257
248
|
|
258
|
-
# @deprecated - use screen_width and screen_height in your stylesheets
|
259
|
-
def screen_size
|
260
|
-
CGSizeMake(screen_width, screen_height)
|
261
|
-
end
|
262
|
-
|
263
249
|
def content_width
|
264
250
|
content_size.width
|
265
251
|
end
|
@@ -72,14 +72,6 @@ module RubyMotionQuery
|
|
72
72
|
o.respond_to?(:weakref_alive?) # This is the only way to do this currently
|
73
73
|
end
|
74
74
|
|
75
|
-
# @deprecated this has been fixed in RubyMotion 2.17, so this method is no longer needed.
|
76
|
-
def weak_ref_is_same_object?(a, b)
|
77
|
-
# This was the workaround that isn't needed anymore, for your reference:
|
78
|
-
#(a.class == b.class) && (a.object_id == b.object_id)
|
79
|
-
|
80
|
-
a == b
|
81
|
-
end
|
82
|
-
|
83
75
|
# Gives you the value of a weakref, if the object it wraps no longer exists, returns nil
|
84
76
|
def weak_ref_value(o)
|
85
77
|
if o && o.weakref_alive?
|
@@ -120,7 +120,7 @@ module RubyMotionQuery
|
|
120
120
|
|
121
121
|
class << self
|
122
122
|
# Validation Regex from jQuery validation -> https://github.com/jzaefferer/jquery-validation/blob/master/src/core.js#L1094-L1200
|
123
|
-
EMAIL = Regexp.new('^[a-
|
123
|
+
EMAIL = Regexp.new('^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$')
|
124
124
|
URL = Regexp.new('^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)|\/|\?)*)?$')
|
125
125
|
DATEISO = Regexp.new('^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$')
|
126
126
|
NUMBER = Regexp.new('^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$')
|
@@ -68,8 +68,7 @@ __END__
|
|
68
68
|
# another way to do it is tag the views you need to restyle in your stylesheet,
|
69
69
|
# then only reapply the tagged views, like so:
|
70
70
|
def logo(st)
|
71
|
-
st.frame = {t: 10, w: 200, h: 96}
|
72
|
-
st.centered = :horizontal
|
71
|
+
st.frame = {t: 10, w: 200, h: 96, centered: :horizontal}
|
73
72
|
st.image = image.resource('logo')
|
74
73
|
st.tag(:reapply_style)
|
75
74
|
end
|
@@ -27,8 +27,7 @@ __END__
|
|
27
27
|
# another way to do it is tag the views you need to restyle in your stylesheet,
|
28
28
|
# then only reapply the tagged views, like so:
|
29
29
|
def logo(st)
|
30
|
-
st.frame = {t: 10, w: 200, h: 96}
|
31
|
-
st.centered = :horizontal
|
30
|
+
st.frame = {t: 10, w: 200, h: 96, centered: :horizontal}
|
32
31
|
st.image = image.resource('logo')
|
33
32
|
st.tag(:reapply_style)
|
34
33
|
end
|
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.
|
4
|
+
version: 1.1.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:
|
12
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- motion/ruby_motion_query/color.rb
|
60
60
|
- motion/ruby_motion_query/data.rb
|
61
61
|
- motion/ruby_motion_query/debug.rb
|
62
|
+
- motion/ruby_motion_query/deprecation.rb
|
62
63
|
- motion/ruby_motion_query/device.rb
|
63
64
|
- motion/ruby_motion_query/enumerablish.rb
|
64
65
|
- motion/ruby_motion_query/event.rb
|