ruby_motion_query 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/rmq +2 -2
- data/motion/ruby_motion_query/app.rb +14 -1
- data/motion/ruby_motion_query/color.rb +128 -28
- data/motion/ruby_motion_query/debug.rb +51 -42
- data/motion/ruby_motion_query/device.rb +10 -0
- data/motion/ruby_motion_query/format.rb +75 -7
- data/motion/ruby_motion_query/rect.rb +21 -1
- data/motion/ruby_motion_query/stylesheet.rb +9 -11
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/collection_view_controller/spec/controllers/{name_controller.rb → name_controller_spec.rb} +0 -0
- data/templates/controller/spec/controllers/{name_controller.rb → name_controller_spec.rb} +0 -0
- data/templates/table_view_controller/app/stylesheets/name_controller_stylesheet.rb +13 -2
- data/templates/table_view_controller/spec/controllers/{name_controller.rb → name_controller_spec.rb} +0 -0
- metadata +5 -6
- data/templates/table_view_controller/app/stylesheets/name_cell_stylesheet.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e90368cbe7056ffc25cfe7f6a0ce0aaaf540248
|
4
|
+
data.tar.gz: 4808129ea2c00202d834e7e8f9ba7fadc22531c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f12f17778cf3e88812e9b9b63fe0d3e1c0eb1608077f854a03692d07011ce9342b3d211f6bf6ace12a269f55129c6a0e906c40976fd15308250880085dae460
|
7
|
+
data.tar.gz: 12b96cc830cb55e3ec93fd07fd37d231a68e48da919e312b74c278e747c09a0b798252a3330be01ca42f2582410f7622acd7ecab4cb5612abacdacc14c29a4ca
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
A fast, non-polluting, chaining, front-end library. It’s like jQuery for [RubyMotion](http://rubymotion.com) plus templates, stylesheets, events, animations, etc.
|
11
11
|
|
12
|
-
One of RMQ's
|
12
|
+
One of RMQ's goals is to have the best [documentation][1] of any RubyMotion UI library.
|
13
13
|
|
14
14
|
<br />
|
15
15
|
|
@@ -35,7 +35,7 @@ bundle
|
|
35
35
|
rake
|
36
36
|
```
|
37
37
|
|
38
|
-
rbenv rehash after gem install if you use rbenv
|
38
|
+
`rbenv rehash` after gem install if you use rbenv
|
39
39
|
|
40
40
|
<br />
|
41
41
|
|
data/bin/rmq
CHANGED
@@ -123,13 +123,13 @@ class RmqCommandLine
|
|
123
123
|
@in_app_path = File.dirname(template_file_path_and_name).gsub(@template_path, '')
|
124
124
|
@ext = File.extname(template_file_path_and_name)
|
125
125
|
@file_name = File.basename(template_file_path_and_name, @ext)
|
126
|
-
|
126
|
+
|
127
127
|
@new_file_name = @file_name.gsub('name', @name)
|
128
128
|
@new_file_path_name = "#{Dir.pwd}/#{@in_app_path}/#{@new_file_name}#{@ext}"
|
129
129
|
|
130
130
|
if @dry_run
|
131
131
|
puts "\n Instance vars:"
|
132
|
-
self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
|
132
|
+
self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
|
133
133
|
puts
|
134
134
|
end
|
135
135
|
|
@@ -21,8 +21,14 @@ module RubyMotionQuery
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def windows
|
25
|
+
if shared_application = UIApplication.sharedApplication
|
26
|
+
shared_application.windows
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
# @return [UIApplicationDelegate]
|
25
|
-
def delegate
|
31
|
+
def delegate
|
26
32
|
UIApplication.sharedApplication.delegate
|
27
33
|
end
|
28
34
|
|
@@ -52,6 +58,11 @@ module RubyMotionQuery
|
|
52
58
|
NSBundle.mainBundle.infoDictionary['CFBundleVersion']
|
53
59
|
end
|
54
60
|
|
61
|
+
# @return [String] Short version
|
62
|
+
def short_version
|
63
|
+
NSBundle.mainBundle.infoDictionary['CFBundleShortVersionString']
|
64
|
+
end
|
65
|
+
|
55
66
|
# @return [String] Name of app
|
56
67
|
def name
|
57
68
|
NSBundle.mainBundle.objectForInfoDictionaryKey 'CFBundleDisplayName'
|
@@ -92,6 +103,8 @@ module RubyMotionQuery
|
|
92
103
|
current_view_controller(root_view_controller.topViewController)
|
93
104
|
elsif root_view_controller.respond_to?(:frontViewController)
|
94
105
|
current_view_controller(root_view_controller.frontViewController)
|
106
|
+
elsif root_view_controller.respond_to?(:center)
|
107
|
+
current_view_controller(root_view_controller.center)
|
95
108
|
elsif root_view_controller.childViewControllers.count > 0
|
96
109
|
current_view_controller(root_view_controller.childViewControllers.first)
|
97
110
|
else
|
@@ -1,13 +1,37 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
class RMQ
|
3
|
-
# @
|
4
|
-
|
5
|
-
|
3
|
+
# @param color value options
|
4
|
+
# @return [UIColor]
|
5
|
+
# @example
|
6
|
+
# color('#ffffff')
|
7
|
+
# color('ffffff')
|
8
|
+
# color('#336699cc')
|
9
|
+
# color('369c')
|
10
|
+
# color(255,255,255,0.5)
|
11
|
+
# color(r: 255,g: 255,b: 255,a: 0.5)
|
12
|
+
# color(red: 255,green: 255,blue: 255,alpha: 0.5)
|
13
|
+
# color.from_hsva(h: 100,s: 140,b: 80,a: 1.0)
|
14
|
+
def self.color(*params)
|
15
|
+
if params.empty?
|
16
|
+
Color
|
17
|
+
else
|
18
|
+
ColorFactory.build(params)
|
19
|
+
end
|
6
20
|
end
|
7
21
|
|
8
|
-
# @
|
9
|
-
|
10
|
-
|
22
|
+
# @param color value options
|
23
|
+
# @return [UIColor]
|
24
|
+
# @example
|
25
|
+
# color('#ffffff')
|
26
|
+
# color('ffffff')
|
27
|
+
# color('#336699cc')
|
28
|
+
# color('369c')
|
29
|
+
# color(255,255,255,0.5)
|
30
|
+
# color(r: 255,g: 255,b: 255,a: 0.5)
|
31
|
+
# color(red: 255,green: 255,blue: 255,alpha: 0.5)
|
32
|
+
# color.from_hsva(h: 100,s: 140,b: 80,a: 1.0)
|
33
|
+
def color(*params)
|
34
|
+
self.class.color(*params)
|
11
35
|
end
|
12
36
|
end
|
13
37
|
|
@@ -76,7 +100,7 @@ module RubyMotionQuery
|
|
76
100
|
# my_label.color = rmq.color.foo # or just color.foo in a stylesheet
|
77
101
|
def add_named(key, hex_or_color)
|
78
102
|
color = if hex_or_color.is_a?(String)
|
79
|
-
|
103
|
+
ColorFactory.from_hex(hex_or_color)
|
80
104
|
else
|
81
105
|
hex_or_color
|
82
106
|
end
|
@@ -86,30 +110,17 @@ module RubyMotionQuery
|
|
86
110
|
end
|
87
111
|
end
|
88
112
|
|
89
|
-
# Creates a color from a hex triplet
|
90
|
-
#
|
91
|
-
# Thanks bubblewrap for this method
|
113
|
+
# Creates a color from a hex triplet (rgb) or quartet (rgba)
|
92
114
|
#
|
93
115
|
# @param hex with or without the #
|
94
116
|
# @return [UIColor]
|
95
117
|
# @example
|
96
118
|
# color.from_hex('#ffffff')
|
97
119
|
# color.from_hex('ffffff')
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
colors = hex_color.scan(%r{[0-9A-Fa-f]}).map{ |el| (el * 2).to_i(16) }
|
103
|
-
when 6
|
104
|
-
colors = hex_color.scan(%r<[0-9A-Fa-f]{2}>).map{ |el| el.to_i(16) }
|
105
|
-
else
|
106
|
-
raise ArgumentError
|
107
|
-
end
|
108
|
-
if colors.size == 3
|
109
|
-
from_rgba(colors[0], colors[1], colors[2], 1.0)
|
110
|
-
else
|
111
|
-
raise ArgumentError
|
112
|
-
end
|
120
|
+
# color.from_hex('#336699cc')
|
121
|
+
# color.from_hex('369c')
|
122
|
+
def from_hex(str)
|
123
|
+
ColorFactory.from_hex(str)
|
113
124
|
end
|
114
125
|
|
115
126
|
# @return [UIColor]
|
@@ -117,7 +128,7 @@ module RubyMotionQuery
|
|
117
128
|
# @example
|
118
129
|
# rmq.color.from_rgba(255,255,255,0.5)
|
119
130
|
def from_rgba(r,g,b,a)
|
120
|
-
|
131
|
+
ColorFactory.from_rgba(r,g,b,a)
|
121
132
|
end
|
122
133
|
|
123
134
|
# @return [UIColor]
|
@@ -125,13 +136,102 @@ module RubyMotionQuery
|
|
125
136
|
# @example
|
126
137
|
# rmq.color.from_hsva(100,140,80,1.0)
|
127
138
|
def from_hsva(h,s,v,a)
|
128
|
-
|
139
|
+
ColorFactory.from_hsva(h,s,v,a)
|
129
140
|
end
|
130
141
|
|
131
142
|
def random
|
132
|
-
from_rgba(rand(255), rand(255), rand(255), 1.0)
|
143
|
+
ColorFactory.from_rgba(rand(255), rand(255), rand(255), 1.0)
|
133
144
|
end
|
134
145
|
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class ColorFactory
|
149
|
+
def self.build(params)
|
150
|
+
return Color if params.empty?
|
151
|
+
return from_rgba(*params) if params.count > 1
|
152
|
+
|
153
|
+
param = params.first
|
154
|
+
return from_hex(params.join) if param.is_a?(String)
|
155
|
+
|
156
|
+
return from_base_color(param) if base_values(param)
|
157
|
+
return try_rgba(param) if rgba_values(param)
|
158
|
+
return try_hsva(param) if hsva_values(param)
|
159
|
+
return try_hex(param) if hex_values(param)
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.from_base_color(values)
|
163
|
+
base = values[:base] || values[:color]
|
164
|
+
r, g, b, a = Pointer.new('d'), Pointer.new('d'), Pointer.new('d'), Pointer.new('d')
|
165
|
+
base.getRed(r, green: g, blue: b, alpha: a)
|
166
|
+
|
167
|
+
r = values[:r] || values[:red] || r.value
|
168
|
+
g = values[:g] || values[:green] || g.value
|
169
|
+
b = values[:b] || values[:blue] || b.value
|
170
|
+
a = values[:a] || values[:alpha] || a.value
|
171
|
+
|
172
|
+
UIColor.colorWithRed(r, green: g, blue: b, alpha: a)
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.try_rgba(values)
|
176
|
+
r = values[:red] || values[:r]
|
177
|
+
g = values[:green] || values[:g]
|
178
|
+
b = values[:blue] || values[:b]
|
179
|
+
a = values[:alpha] || values[:a] || 1.0
|
180
|
+
raise ArgumentError unless r && g && b && a
|
181
|
+
|
182
|
+
from_rgba(r, g, b, a)
|
183
|
+
end
|
184
|
+
|
185
|
+
def self.try_hsva(values)
|
186
|
+
h = values[:hue] || values[:h]
|
187
|
+
s = values[:saturation] || values[:s]
|
188
|
+
v = values[:brightness] || values[:b]
|
189
|
+
a = values[:alpha] || values[:a] || 1.0
|
190
|
+
raise ArgumentError unless h && s && s && v && a
|
191
|
+
|
192
|
+
Color.from_hsva(h, s, v, a)
|
193
|
+
end
|
194
|
+
|
195
|
+
def self.try_hex(values)
|
196
|
+
hex = values[:hex] || values[:x]
|
197
|
+
alpha = values[:alpha] || values[:a]
|
198
|
+
|
199
|
+
color = from_hex(hex)
|
200
|
+
color = color.colorWithAlphaComponent(alpha) if alpha
|
201
|
+
color
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.rgba_values(values)
|
205
|
+
values[:red] || values[:r] || values[:green] || values[:g] || values[:blue]
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.base_values(values)
|
209
|
+
values[:base] || values[:color]
|
210
|
+
end
|
135
211
|
|
212
|
+
def self.hsva_values(values)
|
213
|
+
values[:hue] || values[:h] || values[:saturation] || values[:s] || values[:brightness]
|
214
|
+
end
|
215
|
+
|
216
|
+
def self.hex_values(values)
|
217
|
+
values[:hex] || values[:x]
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.from_rgba(r,g,b,a=1.0)
|
221
|
+
UIColor.colorWithRed((r/255.0), green: (g/255.0), blue: (b/255.0), alpha: a)
|
222
|
+
end
|
223
|
+
|
224
|
+
def self.from_hex(str)
|
225
|
+
r,g,b,a = case (str =~ /^#?(\h{3,8})$/ && $1.size)
|
226
|
+
when 3, 4 then $1.scan(/./ ).map {|c| (c*2).to_i(16) }
|
227
|
+
when 6, 8 then $1.scan(/../).map {|c| c.to_i(16) }
|
228
|
+
else raise ArgumentError
|
229
|
+
end
|
230
|
+
from_rgba(r, g, b, a ? (a/255.0) : 1.0)
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.from_hsva(h,s,v,a)
|
234
|
+
UIColor.alloc.initWithHue(h, saturation: s, brightness: v, alpha: a)
|
235
|
+
end
|
136
236
|
end
|
137
237
|
end
|
@@ -14,8 +14,9 @@ module RubyMotionQuery
|
|
14
14
|
|
15
15
|
# @return [Debug]
|
16
16
|
def debug
|
17
|
-
Debug
|
17
|
+
Debug.new(self)
|
18
18
|
end
|
19
|
+
|
19
20
|
end
|
20
21
|
|
21
22
|
# Notes:
|
@@ -26,61 +27,69 @@ module RubyMotionQuery
|
|
26
27
|
# /usr/bin/malloc_history 89032 0x9508da0
|
27
28
|
# /usr/bin/malloc_history 47706 0x937e5c0 | grep "rb_scope__.+?__"
|
28
29
|
class Debug
|
29
|
-
|
30
|
+
def initialize(rmq_object)
|
31
|
+
@rmq_parent = rmq_object
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
# @return [Debug]
|
35
|
+
def colorize
|
36
|
+
rmq(@rmq_parent.selected).style { |st| st.background_color = rmq.color.random}
|
37
|
+
self
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
40
|
+
# Warning, this is very slow
|
41
|
+
def log_detailed(label, params = {})
|
42
|
+
return unless RMQ.app.development? || RMQ.app.test?
|
37
43
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
44
|
+
objects = params[:objects]
|
45
|
+
skip_first_caller = params[:skip_first_caller]
|
41
46
|
|
42
|
-
|
43
|
-
|
47
|
+
if block_given? && !objects
|
48
|
+
objects = yield
|
49
|
+
end
|
44
50
|
|
45
|
-
|
51
|
+
callers = caller
|
52
|
+
callers = callers.drop(1) if skip_first_caller
|
46
53
|
|
47
|
-
|
48
|
-
Deep log - #{label}
|
49
|
-
At: #{Time.now.to_s}
|
54
|
+
out = %(
|
50
55
|
|
51
|
-
|
52
|
-
|
56
|
+
------------------------------------------------
|
57
|
+
Deep log - #{label}
|
58
|
+
At: #{Time.now.to_s}
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
------------------------------------------------
|
60
|
+
Callers:
|
61
|
+
#{callers.join("\n - ")}
|
57
62
|
|
58
|
-
|
63
|
+
Objects:
|
64
|
+
#{objects.map{|k, v| "#{k.to_s}: #{v.inspect}" }.join("\n\n")}
|
65
|
+
------------------------------------------------
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
67
|
+
).gsub(/^ +/, '')
|
68
|
+
|
69
|
+
NSLog out
|
70
|
+
label
|
71
|
+
end
|
63
72
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
log_detailed label, objects: objects, skip_first_caller: true
|
73
|
+
# Warning, this is very slow to output log, checking truthy however is
|
74
|
+
# basically as performant as an if statement
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
#
|
78
|
+
# # foo and bar are objects we want to inspect
|
79
|
+
# rmq.debug.assert(1==2, 'Bad stuff happened', {
|
80
|
+
# foo: foo,
|
81
|
+
# bar: bar
|
82
|
+
# })
|
83
|
+
def self.assert(truthy, label = nil, objects = nil)
|
84
|
+
if (RMQ.app.development? || RMQ.app.test?) && !truthy
|
85
|
+
label ||= 'Assert failed'
|
86
|
+
if block_given? && !objects
|
87
|
+
objects = yield
|
81
88
|
end
|
89
|
+
log_detailed label, objects: objects, skip_first_caller: true
|
82
90
|
end
|
83
91
|
end
|
92
|
+
|
84
93
|
end
|
85
94
|
end
|
86
95
|
|
@@ -26,6 +26,16 @@ module RubyMotionQuery
|
|
26
26
|
UIDevice.currentDevice.systemVersion
|
27
27
|
end
|
28
28
|
|
29
|
+
# Identify if current version is at least that of what is passed.
|
30
|
+
# Will not work if apple ever does semantic versions like 8.2.1
|
31
|
+
# `rmq.device.ios_at_least? 8`
|
32
|
+
# `rmq.device.ios_at_least? 7.1`
|
33
|
+
#
|
34
|
+
# @return [Boolean]
|
35
|
+
def ios_at_least? version
|
36
|
+
version.to_f.round(3) <= ios_version.to_f.round(3)
|
37
|
+
end
|
38
|
+
|
29
39
|
# @return [UIScreen]
|
30
40
|
def screen
|
31
41
|
UIScreen.mainScreen
|
@@ -16,7 +16,7 @@ module RubyMotionQuery
|
|
16
16
|
|
17
17
|
# rmq.format.number(1232, '#,##0.##')
|
18
18
|
def numeric(number, format)
|
19
|
-
RubyMotionQuery::Format.
|
19
|
+
RubyMotionQuery::Format::Numeric.formatter(format).stringFromNumber(number)
|
20
20
|
end
|
21
21
|
alias :number :numeric
|
22
22
|
|
@@ -24,30 +24,98 @@ module RubyMotionQuery
|
|
24
24
|
#
|
25
25
|
# See <http://www.unicode.org/reports/tr35/tr35-19.html#Date_Format_Patterns>
|
26
26
|
# for more information about date format strings.
|
27
|
-
def date(date,
|
28
|
-
RubyMotionQuery::Format.
|
27
|
+
def date(date, *format_or_styles)
|
28
|
+
RubyMotionQuery::Format::Date.formatter(*format_or_styles).stringFromDate(date)
|
29
29
|
end
|
30
30
|
|
31
31
|
def numeric_formatter(format)
|
32
|
+
RubyMotionQuery::Format::Numeric.formatter(format)
|
33
|
+
end
|
34
|
+
|
35
|
+
def date_formatter(*format_or_styles)
|
36
|
+
RubyMotionQuery::Format::Date.formatter(*format_or_styles)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Format::Numeric
|
42
|
+
class << self
|
43
|
+
|
44
|
+
def formatter(format)
|
32
45
|
@_numeric_formatter ||= {}
|
33
46
|
|
34
47
|
# Caching here is very important for performance
|
35
48
|
@_numeric_formatter[format] ||= begin
|
36
49
|
number_formater = NSNumberFormatter.alloc.init
|
37
50
|
number_formater.setPositiveFormat(format)
|
38
|
-
number_formater
|
51
|
+
number_formater
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Format::Date
|
59
|
+
|
60
|
+
DATE_STYLES = {
|
61
|
+
short_date: NSDateFormatterShortStyle,
|
62
|
+
medium_date: NSDateFormatterMediumStyle,
|
63
|
+
long_date: NSDateFormatterLongStyle,
|
64
|
+
full_date: NSDateFormatterFullStyle
|
65
|
+
}
|
66
|
+
|
67
|
+
TIME_STYLES = {
|
68
|
+
short_time: NSDateFormatterShortStyle,
|
69
|
+
medium_time: NSDateFormatterMediumStyle,
|
70
|
+
long_time: NSDateFormatterLongStyle,
|
71
|
+
full_time: NSDateFormatterFullStyle
|
72
|
+
}
|
73
|
+
|
74
|
+
class << self
|
75
|
+
|
76
|
+
def formatter(*format_or_styles)
|
77
|
+
raise(ArgumentError, "formatter requires at least one parameter") if format_or_styles.first.nil?
|
78
|
+
|
79
|
+
if format_or_styles.first.is_a?(String)
|
80
|
+
formatter_from_format(format_or_styles.first)
|
81
|
+
else
|
82
|
+
formatter_from_styles(*format_or_styles)
|
39
83
|
end
|
40
84
|
end
|
41
85
|
|
42
|
-
def
|
86
|
+
def formatter_from_format(format)
|
43
87
|
@_date_formatters ||= {}
|
44
88
|
|
45
89
|
# Caching here is very important for performance
|
46
90
|
@_date_formatters[format] ||= begin
|
47
|
-
format_template = NSDateFormatter.dateFormatFromTemplate(format, options:0,
|
48
|
-
locale: NSLocale.currentLocale)
|
49
91
|
date_formatter = NSDateFormatter.alloc.init
|
92
|
+
|
93
|
+
format_template = NSDateFormatter.dateFormatFromTemplate(
|
94
|
+
format,
|
95
|
+
options:0,
|
96
|
+
locale: NSLocale.currentLocale
|
97
|
+
)
|
50
98
|
date_formatter.setDateFormat(format_template)
|
99
|
+
|
100
|
+
date_formatter
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def formatter_from_styles(*styles)
|
105
|
+
@_date_formatters ||= {}
|
106
|
+
|
107
|
+
# Caching here is very important for performance
|
108
|
+
@_date_formatters[styles.to_s] ||= begin
|
109
|
+
date_formatter = NSDateFormatter.alloc.init
|
110
|
+
|
111
|
+
styles.each do |style|
|
112
|
+
if DATE_STYLES.has_key?(style)
|
113
|
+
date_formatter.setDateStyle(DATE_STYLES.fetch(style))
|
114
|
+
elsif TIME_STYLES.has_key?(style)
|
115
|
+
date_formatter.setTimeStyle(TIME_STYLES.fetch(style))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
51
119
|
date_formatter
|
52
120
|
end
|
53
121
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
|
3
3
|
class RMQ
|
4
|
+
RECT_WHITELIST = [:grid, :g, :l, :left, :x, :fl, :top, :t, :y, :w, :width, :h, :height, :below_prev, :bp, :below_previous, :left_of_prev, :lop, :left_of_previous, :r, :right, :b, :bottom, :from_right, :fr, :from_bottom, :fb, :centered, :padding, :p, :above_prev, :ap, :above_previous, :rop, :right_of_prev, :right_of_previous, :left_of_prev, :lop, :left_of_previous]
|
5
|
+
|
4
6
|
# @return RubyMotionQuery::Rect or array of RubyMotionQuery::Rect
|
5
7
|
#
|
6
8
|
# @example
|
@@ -179,6 +181,12 @@ module RubyMotionQuery
|
|
179
181
|
not_in_root_view = !(vc.view == sv)
|
180
182
|
end
|
181
183
|
|
184
|
+
# performant warn if hash has keys that are not whitelisted
|
185
|
+
unknown_keys = params.keys - RMQ::RECT_WHITELIST
|
186
|
+
unless unknown_keys.empty?
|
187
|
+
puts "\n[RMQ ERROR] rect keys #{unknown_keys} don't exist. Verify your hash for #{view.class.name} uses approved keys - #{RMQ::RECT_WHITELIST}\n\n"
|
188
|
+
end
|
189
|
+
|
182
190
|
# Grid
|
183
191
|
if grid
|
184
192
|
if params_g = params[:grid] || params[:g]
|
@@ -190,7 +198,7 @@ module RubyMotionQuery
|
|
190
198
|
end
|
191
199
|
end
|
192
200
|
|
193
|
-
params_l = params[:l] || params[:left] || params[:x]
|
201
|
+
params_l = params[:l] || params[:left] || params[:x] || params[:fl]
|
194
202
|
params_t = params[:t] || params[:top] || params[:y]
|
195
203
|
params_w = params[:w] || params[:width]
|
196
204
|
params_h = params[:h] || params[:height]
|
@@ -244,6 +252,18 @@ module RubyMotionQuery
|
|
244
252
|
l = prev_view.frame.origin.x - left_of_prev - w
|
245
253
|
end
|
246
254
|
end
|
255
|
+
else
|
256
|
+
if below_prev
|
257
|
+
t = below_prev
|
258
|
+
elsif above_prev
|
259
|
+
t = above_prev - h
|
260
|
+
end
|
261
|
+
|
262
|
+
if right_of_prev
|
263
|
+
l = right_of_prev
|
264
|
+
elsif left_of_prev
|
265
|
+
l = left_of_prev - w
|
266
|
+
end
|
247
267
|
end
|
248
268
|
|
249
269
|
if sv
|
@@ -189,16 +189,14 @@ module RubyMotionQuery
|
|
189
189
|
|
190
190
|
# Convenience methods -------------------
|
191
191
|
def rmq(*working_selectors)
|
192
|
-
|
193
|
-
RubyMotionQuery::RMQ.
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
if working_selectors.length > 0
|
199
|
-
q.wrap(working_selectors)
|
192
|
+
if @controller.nil?
|
193
|
+
if (app = RubyMotionQuery::RMQ.app) && (window = app.window) && (cvc = app.current_view_controller)
|
194
|
+
cvc.rmq(working_selectors)
|
195
|
+
else
|
196
|
+
RubyMotionQuery::RMQ.create_with_array_and_selectors([], working_selectors, self)
|
197
|
+
end
|
200
198
|
else
|
201
|
-
|
199
|
+
RubyMotionQuery::RMQ.create_with_selectors(working_selectors, @controller)
|
202
200
|
end
|
203
201
|
end
|
204
202
|
|
@@ -284,8 +282,8 @@ module RubyMotionQuery
|
|
284
282
|
RMQ.image
|
285
283
|
end
|
286
284
|
|
287
|
-
def color
|
288
|
-
RMQ.color
|
285
|
+
def color(*params)
|
286
|
+
RMQ.color(*params)
|
289
287
|
end
|
290
288
|
|
291
289
|
def font
|
File without changes
|
File without changes
|
@@ -1,7 +1,5 @@
|
|
1
1
|
class <%= @name_camel_case %>ControllerStylesheet < ApplicationStylesheet
|
2
2
|
|
3
|
-
include <%= @name_camel_case %>CellStylesheet
|
4
|
-
|
5
3
|
def setup
|
6
4
|
# Add stylesheet specific setup stuff here.
|
7
5
|
# Add application specific setup stuff in application_stylesheet.rb
|
@@ -10,4 +8,17 @@ class <%= @name_camel_case %>ControllerStylesheet < ApplicationStylesheet
|
|
10
8
|
def table(st)
|
11
9
|
st.background_color = color.gray
|
12
10
|
end
|
11
|
+
|
12
|
+
def <%= @name %>_cell_height
|
13
|
+
80
|
14
|
+
end
|
15
|
+
|
16
|
+
def <%= @name %>_cell(st)
|
17
|
+
# Style overall cell here
|
18
|
+
st.background_color = color.random
|
19
|
+
end
|
20
|
+
|
21
|
+
def cell_label(st)
|
22
|
+
st.color = color.black
|
23
|
+
end
|
13
24
|
end
|
data/templates/table_view_controller/spec/controllers/{name_controller.rb → name_controller_spec.rb}
RENAMED
File without changes
|
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: 1.0.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-12-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -106,11 +106,11 @@ files:
|
|
106
106
|
- templates/collection_view_controller/app/stylesheets/name_cell_stylesheet.rb
|
107
107
|
- templates/collection_view_controller/app/stylesheets/name_controller_stylesheet.rb
|
108
108
|
- templates/collection_view_controller/app/views/name_cell.rb
|
109
|
-
- templates/collection_view_controller/spec/controllers/
|
109
|
+
- templates/collection_view_controller/spec/controllers/name_controller_spec.rb
|
110
110
|
- templates/collection_view_controller/spec/views/name_cell.rb
|
111
111
|
- templates/controller/app/controllers/name_controller.rb
|
112
112
|
- templates/controller/app/stylesheets/name_controller_stylesheet.rb
|
113
|
-
- templates/controller/spec/controllers/
|
113
|
+
- templates/controller/spec/controllers/name_controller_spec.rb
|
114
114
|
- templates/lib/lib/name.rb
|
115
115
|
- templates/lib/spec/lib/name.rb
|
116
116
|
- templates/model/app/models/name.rb
|
@@ -118,10 +118,9 @@ files:
|
|
118
118
|
- templates/shared/app/shared/name.rb
|
119
119
|
- templates/shared/spec/shared/name.rb
|
120
120
|
- templates/table_view_controller/app/controllers/name_controller.rb
|
121
|
-
- templates/table_view_controller/app/stylesheets/name_cell_stylesheet.rb
|
122
121
|
- templates/table_view_controller/app/stylesheets/name_controller_stylesheet.rb
|
123
122
|
- templates/table_view_controller/app/views/name_cell.rb
|
124
|
-
- templates/table_view_controller/spec/controllers/
|
123
|
+
- templates/table_view_controller/spec/controllers/name_controller_spec.rb
|
125
124
|
- templates/table_view_controller/spec/views/name_cell.rb
|
126
125
|
- templates/view/app/stylesheets/name_stylesheet.rb
|
127
126
|
- templates/view/app/views/name.rb
|