ruby_motion_query 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/motion/ruby_motion_query/actions.rb +16 -0
- data/motion/ruby_motion_query/app.rb +11 -0
- data/motion/ruby_motion_query/color.rb +7 -2
- data/motion/ruby_motion_query/data.rb +10 -0
- data/motion/ruby_motion_query/format.rb +13 -1
- data/motion/ruby_motion_query/position.rb +38 -12
- data/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb +3 -3
- data/motion/ruby_motion_query/stylers/ui_activity_indicator_view.rb +50 -0
- data/motion/ruby_motion_query/stylers/ui_button_styler.rb +20 -0
- data/motion/ruby_motion_query/stylers/ui_label_styler.rb +18 -1
- data/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb +10 -0
- data/motion/ruby_motion_query/stylers/ui_segmented_control_styler.rb +15 -3
- data/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb +43 -1
- data/motion/ruby_motion_query/stylers/ui_table_view_styler.rb +11 -0
- data/motion/ruby_motion_query/stylers/ui_text_field_styler.rb +5 -2
- data/motion/ruby_motion_query/stylers/ui_text_view_styler.rb +3 -0
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +92 -6
- data/motion/ruby_motion_query/stylesheet.rb +19 -18
- data/motion/ruby_motion_query/subviews.rb +5 -0
- data/motion/ruby_motion_query/tags.rb +7 -0
- data/motion/ruby_motion_query/validation.rb +6 -0
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/collection_view_controller/spec/views/{name_cell.rb → name_cell_spec.rb} +0 -0
- data/templates/lib/spec/lib/{name.rb → name_spec.rb} +0 -0
- data/templates/model/spec/models/{name.rb → name_spec.rb} +0 -0
- data/templates/shared/spec/shared/{name.rb → name_spec.rb} +0 -0
- data/templates/table_view_controller/spec/views/{name_cell.rb → name_cell_spec.rb} +0 -0
- data/templates/view/spec/views/{name.rb → name_spec.rb} +0 -0
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076402a0a8e41d928b775cb8319a0f0ba942c7a9
|
4
|
+
data.tar.gz: 3a41cd46bdc0deb04b462372d1390e41f4868621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfa05daa2ca2013f0402ec58ecc6ef0a9e4d0e3a7e656a43aaf8e3e75f74fd587a8d1fb31d3e8291f1a09bf03a150224abdf3ea3d08d3dce20bdebf382820db
|
7
|
+
data.tar.gz: 9eb821d64590ef1670c3dc4b97b0beb49ade5aecd765e8a75baee54953f1142a5cb93019eca3587f305b105dc7f7778f7d4574a7027dd20319b11ee3b58a67e6
|
@@ -155,5 +155,21 @@ module RubyMotionQuery
|
|
155
155
|
self
|
156
156
|
end
|
157
157
|
|
158
|
+
# For UIActivityIndicatorViews
|
159
|
+
def start_animating
|
160
|
+
selected.each do |view|
|
161
|
+
view.startAnimating if view.respond_to?(:startAnimating)
|
162
|
+
end
|
163
|
+
self
|
164
|
+
end
|
165
|
+
|
166
|
+
# For UIActivityIndicatorViews
|
167
|
+
def stop_animating
|
168
|
+
selected.each do |view|
|
169
|
+
view.stopAnimating if view.respond_to?(:startAnimating)
|
170
|
+
end
|
171
|
+
self
|
172
|
+
end
|
173
|
+
|
158
174
|
end
|
159
175
|
end
|
@@ -83,6 +83,17 @@ module RubyMotionQuery
|
|
83
83
|
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
|
84
84
|
end
|
85
85
|
|
86
|
+
# @return [NSTimer] NSTimer instance, fires once after <seconds>
|
87
|
+
def after(seconds, &callback)
|
88
|
+
NSTimer.scheduledTimerWithTimeInterval(seconds, target: callback, selector: 'call:', userInfo: nil, repeats: false)
|
89
|
+
end
|
90
|
+
alias delay after
|
91
|
+
|
92
|
+
# @return [NSTimer] NSTimer instance, set to repeat every <seconds>
|
93
|
+
def every(seconds, &callback)
|
94
|
+
NSTimer.scheduledTimerWithTimeInterval(seconds, target: callback, selector: 'call:', userInfo: nil, repeats: true)
|
95
|
+
end
|
96
|
+
|
86
97
|
# Returns the current view controller in the app. If the current controller is a tab or
|
87
98
|
# navigation controller, then it gets the current tab or topmost controller in the nav, etc
|
88
99
|
#
|
@@ -161,8 +161,13 @@ module RubyMotionQuery
|
|
161
161
|
|
162
162
|
def self.from_base_color(values)
|
163
163
|
base = values[:base] || values[:color]
|
164
|
-
|
165
|
-
|
164
|
+
begin
|
165
|
+
r, g, b, a = Pointer.new('d'), Pointer.new('d'), Pointer.new('d'), Pointer.new('d')
|
166
|
+
base.getRed(r, green: g, blue: b, alpha: a)
|
167
|
+
rescue
|
168
|
+
r, g, b, a = Pointer.new('f'), Pointer.new('f'), Pointer.new('f'), Pointer.new('f')
|
169
|
+
base.getRed(r, green: g, blue: b, alpha: a)
|
170
|
+
end
|
166
171
|
|
167
172
|
r = values[:r] || values[:red] || r.value
|
168
173
|
g = values[:g] || values[:green] || g.value
|
@@ -32,6 +32,16 @@ module RubyMotionQuery
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
# *Do not* use this, use {RMQ#untag} instead:
|
36
|
+
# @example
|
37
|
+
# rmq(my_view).untag(:foo, :bar)
|
38
|
+
# Do nothing if no tag supplied or tag not present
|
39
|
+
def untag(*tag_or_tags)
|
40
|
+
tag_or_tags.flatten.each do |tag_name|
|
41
|
+
tags.delete tag_name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
35
45
|
# Check if this view contains a specific tag
|
36
46
|
#
|
37
47
|
# @param tag_name name of tag to check
|
@@ -24,7 +24,7 @@ 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, *format_or_styles)
|
27
|
+
def date(date = nil, *format_or_styles)
|
28
28
|
RubyMotionQuery::Format::Date.formatter(*format_or_styles).stringFromDate(date)
|
29
29
|
end
|
30
30
|
|
@@ -35,6 +35,10 @@ module RubyMotionQuery
|
|
35
35
|
def date_formatter(*format_or_styles)
|
36
36
|
RubyMotionQuery::Format::Date.formatter(*format_or_styles)
|
37
37
|
end
|
38
|
+
|
39
|
+
def add_datetime_style(style, format)
|
40
|
+
RubyMotionQuery::Format::Date.add_datetime_style(style, format)
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -108,6 +112,9 @@ module RubyMotionQuery
|
|
108
112
|
@_date_formatters[styles.to_s] ||= begin
|
109
113
|
date_formatter = NSDateFormatter.alloc.init
|
110
114
|
|
115
|
+
date_formatter.setDateStyle(NSDateFormatterNoStyle)
|
116
|
+
date_formatter.setDateStyle(NSDateFormatterNoStyle)
|
117
|
+
|
111
118
|
styles.each do |style|
|
112
119
|
if DATE_STYLES.has_key?(style)
|
113
120
|
date_formatter.setDateStyle(DATE_STYLES.fetch(style))
|
@@ -120,6 +127,11 @@ module RubyMotionQuery
|
|
120
127
|
end
|
121
128
|
end
|
122
129
|
|
130
|
+
def add_datetime_style(style_name, format)
|
131
|
+
@_date_formatters ||= {}
|
132
|
+
|
133
|
+
@_date_formatters[[style_name].to_s] ||= formatter_from_format(format)
|
134
|
+
end
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
@@ -106,22 +106,26 @@ module RubyMotionQuery
|
|
106
106
|
self
|
107
107
|
end
|
108
108
|
|
109
|
-
def
|
109
|
+
def resize_frame_to_fit_subviews(args = {})
|
110
110
|
selected.each do |view|
|
111
|
-
|
112
|
-
|
111
|
+
view.rmq.layout(subviews_bottom_right(view, args))
|
112
|
+
end
|
113
113
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
h = [rect.bottom, h].max
|
118
|
-
end
|
114
|
+
self
|
115
|
+
end
|
116
|
+
alias :resize_to_fit_subviews :resize_frame_to_fit_subviews
|
119
117
|
|
120
|
-
|
121
|
-
|
122
|
-
|
118
|
+
def resize_content_to_fit_subviews(args = {})
|
119
|
+
selected.each do |view|
|
120
|
+
unless view.respond_to?(:contentSize)
|
121
|
+
puts "\n[RMQ ERROR] resize_content_to_fit_subviews must be called on a view that supports `contentSize`. Called on #{view}\n\n"
|
122
|
+
next
|
123
|
+
end
|
123
124
|
|
124
|
-
view.rmq.
|
125
|
+
view.rmq.style do |st|
|
126
|
+
bottom_right = subviews_bottom_right(view, args)
|
127
|
+
st.content_size = CGSizeMake(bottom_right[:w], bottom_right[:h])
|
128
|
+
end
|
125
129
|
end
|
126
130
|
|
127
131
|
self
|
@@ -142,5 +146,27 @@ module RubyMotionQuery
|
|
142
146
|
out
|
143
147
|
end
|
144
148
|
|
149
|
+
private
|
150
|
+
|
151
|
+
# Calculates the bottom right of a view using its subviews
|
152
|
+
#
|
153
|
+
# @return [Hash]
|
154
|
+
def subviews_bottom_right(view, args = {})
|
155
|
+
w = 0
|
156
|
+
h = 0
|
157
|
+
|
158
|
+
view.subviews.each do |subview|
|
159
|
+
rect = subview.rmq.frame
|
160
|
+
w = [rect.right, w].max
|
161
|
+
h = [rect.bottom, h].max
|
162
|
+
end
|
163
|
+
|
164
|
+
rect = view.rmq.frame
|
165
|
+
w = rect.width if (w == 0 || args[:only_height])
|
166
|
+
h = rect.height if (h == 0 || args[:only_width])
|
167
|
+
|
168
|
+
{w: (w + (args[:right] || 0)), h: (h + (args[:bottom] || 0))}
|
169
|
+
end
|
170
|
+
|
145
171
|
end
|
146
172
|
end
|
@@ -5,16 +5,16 @@ module RubyMotionQuery
|
|
5
5
|
# UITExtInputTraits protocol
|
6
6
|
module UITextInputTraits
|
7
7
|
def autocapitalization_type ; view.autocapitalizationType ; end
|
8
|
-
def autocapitalization_type=(v) ; view.autocapitalizationType = v ; end
|
8
|
+
def autocapitalization_type=(v) ; view.autocapitalizationType = AUTO_CAPITALIZATION_TYPES[v] || v ; end
|
9
9
|
|
10
10
|
def autocorrection_type ; view.autocorrectionType ; end
|
11
|
-
def autocorrection_type=(v) ; view.autocorrectionType = v ; end
|
11
|
+
def autocorrection_type=(v) ; view.autocorrectionType = AUTO_CORRECTION_TYPES[v] || v ; end
|
12
12
|
|
13
13
|
def enables_return_key_automatically ; view.enablesReturnKeyAutomatically ; end
|
14
14
|
def enables_return_key_automatically=(v) ; view.enablesReturnKeyAutomatically = v ; end
|
15
15
|
|
16
16
|
def keyboard_appearance ; view.keyboardAppearance ; end
|
17
|
-
def keyboard_appearance=(v) ; view.keyboardAppearance = v ; end
|
17
|
+
def keyboard_appearance=(v) ; view.keyboardAppearance = KEYBOARD_APPEARANCES[v] || v ; end
|
18
18
|
|
19
19
|
def keyboard_type ; view.keyboardType ; end
|
20
20
|
def keyboard_type=(v) ; view.setKeyboardType(KEYBOARD_TYPES[v] || v) ; end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module RubyMotionQuery
|
2
|
+
module Stylers
|
3
|
+
class UIActivityIndicatorViewStyler < UIViewStyler
|
4
|
+
|
5
|
+
UI_ACTIVITY_INDICATOR_VIEW_STYLES = {
|
6
|
+
large: UIActivityIndicatorViewStyleWhiteLarge,
|
7
|
+
white_large: UIActivityIndicatorViewStyleWhiteLarge,
|
8
|
+
default: UIActivityIndicatorViewStyleWhite,
|
9
|
+
white: UIActivityIndicatorViewStyleWhite,
|
10
|
+
gray: UIActivityIndicatorViewStyleGray
|
11
|
+
}
|
12
|
+
|
13
|
+
def start_animating
|
14
|
+
@view.startAnimating
|
15
|
+
end
|
16
|
+
alias :start :start_animating
|
17
|
+
|
18
|
+
def stop_animating
|
19
|
+
@view.stopAnimating
|
20
|
+
end
|
21
|
+
alias :stop :stop_animating
|
22
|
+
|
23
|
+
def is_animating?
|
24
|
+
@view.isAnimating
|
25
|
+
end
|
26
|
+
alias :animating? :is_animating?
|
27
|
+
|
28
|
+
def hides_when_stopped=(value)
|
29
|
+
@view.hidesWhenStopped = value
|
30
|
+
end
|
31
|
+
def hides_when_stopped
|
32
|
+
@view.hidesWhenStopped
|
33
|
+
end
|
34
|
+
|
35
|
+
def activity_indicator_style=(value)
|
36
|
+
@view.activityIndicatorViewStyle = UI_ACTIVITY_INDICATOR_VIEW_STYLES[value] || value
|
37
|
+
end
|
38
|
+
def activity_indicator_style
|
39
|
+
@view.activityIndicatorViewStyle
|
40
|
+
end
|
41
|
+
|
42
|
+
def color=(value)
|
43
|
+
@view.color = value
|
44
|
+
end
|
45
|
+
def color
|
46
|
+
@view.color
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -52,6 +52,26 @@ module RubyMotionQuery
|
|
52
52
|
@view.setBackgroundImage value, forState: UIControlStateHighlighted
|
53
53
|
end
|
54
54
|
|
55
|
+
def background_image_selected=(value)
|
56
|
+
@view.setBackgroundImage value, forState: UIControlStateSelected
|
57
|
+
end
|
58
|
+
|
59
|
+
def adjust_image_when_highlighted=(value)
|
60
|
+
@view.adjustsImageWhenHighlighted = value
|
61
|
+
end
|
62
|
+
|
63
|
+
def adjust_image_when_highlighted
|
64
|
+
@view.adjustsImageWhenHighlighted
|
65
|
+
end
|
66
|
+
|
67
|
+
def selected=(value)
|
68
|
+
@view.setSelected(value)
|
69
|
+
end
|
70
|
+
|
71
|
+
def selected
|
72
|
+
@view.isSelected
|
73
|
+
end
|
74
|
+
|
55
75
|
# Accepts UIEdgeInsetsMake OR and array of values to be the inset.
|
56
76
|
# st.title_edge_insets = UIEdgeInsetsMake(0, 10.0, 0, 0)
|
57
77
|
# OR
|
@@ -13,6 +13,8 @@ module RubyMotionQuery
|
|
13
13
|
|
14
14
|
def color=(value) ; @view.setTextColor value ; end
|
15
15
|
def color ; @view.textColor ; end
|
16
|
+
alias :text_color :color
|
17
|
+
alias :text_color= :color=
|
16
18
|
|
17
19
|
def number_of_lines=(value)
|
18
20
|
value = 0 if value == :unlimited
|
@@ -27,7 +29,7 @@ module RubyMotionQuery
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def line_break_mode=(value)
|
30
|
-
@view.lineBreakMode = value
|
32
|
+
@view.lineBreakMode = LINE_BREAK_MODES[value] || value
|
31
33
|
end
|
32
34
|
def line_break_mode
|
33
35
|
@view.lineBreakMode
|
@@ -39,6 +41,8 @@ module RubyMotionQuery
|
|
39
41
|
def text_alignment
|
40
42
|
@view.textAlignment
|
41
43
|
end
|
44
|
+
alias :text_align= :text_alignment=
|
45
|
+
alias :text_align :text_alignment
|
42
46
|
|
43
47
|
def resize_to_fit_text
|
44
48
|
@view.sizeToFit
|
@@ -54,6 +58,19 @@ module RubyMotionQuery
|
|
54
58
|
def adjusts_font_size
|
55
59
|
@view.adjustsFontSizeToFitWidth
|
56
60
|
end
|
61
|
+
alias :adjusts_font_size_to_fit_width= :adjusts_font_size=
|
62
|
+
alias :adjusts_font_size_to_fit_width :adjusts_font_size
|
63
|
+
|
64
|
+
def resize_height_to_fit
|
65
|
+
@view.lineBreakMode = UILineBreakModeWordWrap
|
66
|
+
@view.numberOfLines = 0
|
67
|
+
|
68
|
+
attributed_text = NSAttributedString.alloc.initWithString(@view.text, attributes:{NSFontAttributeName => @view.font})
|
69
|
+
rect = attributed_text.boundingRectWithSize([@view.frame.size.width, Float::MAX], options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading), context:nil)
|
70
|
+
|
71
|
+
expected_label_size = [@view.frame.size.width, rect.size.height.ceil]
|
72
|
+
@view.frame = [@view.frame.origin, expected_label_size]
|
73
|
+
end
|
57
74
|
end
|
58
75
|
|
59
76
|
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
3
|
|
4
|
+
INDICATOR_STYLES = {
|
5
|
+
default: UIScrollViewIndicatorStyleDefault,
|
6
|
+
black: UIScrollViewIndicatorStyleBlack,
|
7
|
+
dark: UIScrollViewIndicatorStyleBlack,
|
8
|
+
white: UIScrollViewIndicatorStyleWhite,
|
9
|
+
light: UIScrollViewIndicatorStyleWhite
|
10
|
+
}
|
11
|
+
|
4
12
|
class UIScrollViewStyler < UIViewStyler
|
5
13
|
def paging=(value) ; @view.pagingEnabled = value ; end
|
6
14
|
def paging ; @view.isPagingEnabled ; end
|
@@ -32,6 +40,8 @@ module RubyMotionQuery
|
|
32
40
|
def scroll_indicator_insets=(value); @view.scrollIndicatorInsets = value; end
|
33
41
|
def scroll_indicator_insets; @view.scrollIndicatorInsets; end
|
34
42
|
|
43
|
+
def indicator_style=(value); @view.indicatorStyle = INDICATOR_STYLES[value] || value; end
|
44
|
+
def indicator_style; @view.indicatorStyle; end
|
35
45
|
|
36
46
|
end
|
37
47
|
|
@@ -1,8 +1,20 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
|
+
class UISegmentedControlStyler < UIControlStyler
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def prepend_segments=(value)
|
6
|
+
if value.class == Array
|
7
|
+
value.each_with_index do |title, index|
|
8
|
+
@view.insertSegmentWithTitle(title, atIndex:index, animated:false)
|
9
|
+
end
|
10
|
+
elsif value.class == String
|
11
|
+
@view.insertSegmentWithTitle(value, atIndex:0, animated:false)
|
12
|
+
else
|
13
|
+
raise "#{__method__} takes an array or string."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
alias :unshift= :prepend_segments=
|
6
17
|
|
18
|
+
end
|
7
19
|
end
|
8
|
-
end
|
20
|
+
end
|
@@ -19,7 +19,49 @@ module RubyMotionQuery
|
|
19
19
|
@view.accessoryView
|
20
20
|
end
|
21
21
|
|
22
|
+
def text_color ; @view.textLabel.textColor ; end
|
23
|
+
def text_color=(v) ; @view.textLabel.textColor = v ; end
|
24
|
+
alias :color :text_color
|
25
|
+
alias :color= :text_color=
|
26
|
+
|
27
|
+
def detail_text_color
|
28
|
+
if @view.detailTextLabel
|
29
|
+
@view.detailTextLabel.textColor
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def detail_text_color=(v)
|
34
|
+
if @view.detailTextLabel
|
35
|
+
@view.detailTextLabel.textColor = v
|
36
|
+
end
|
37
|
+
end
|
38
|
+
alias :detail_color :text_color
|
39
|
+
alias :detail_color= :text_color=
|
40
|
+
|
41
|
+
def font ; @view.textLabel.font ; end
|
42
|
+
def font=(v) ; @view.textLabel.font = v ; end
|
43
|
+
|
44
|
+
def detail_font
|
45
|
+
@view.detailTextLabel.font if @view.detailTextLabel
|
46
|
+
end
|
47
|
+
|
48
|
+
def detail_font=(v)
|
49
|
+
if @view.detailTextLabel
|
50
|
+
@view.detailTextLabel.font = v
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def selection_style ; @view.selectionStyle ; end
|
55
|
+
def selection_style=(v) ; @view.selectionStyle = v ; end
|
56
|
+
|
57
|
+
def separator_inset=(value)
|
58
|
+
@view.separatorInset = value
|
59
|
+
end
|
60
|
+
def separator_inset
|
61
|
+
@view.separatorInset
|
62
|
+
end
|
63
|
+
|
22
64
|
end
|
23
65
|
|
24
66
|
end
|
25
|
-
end
|
67
|
+
end
|
@@ -22,6 +22,17 @@ module RubyMotionQuery
|
|
22
22
|
@view.rowHeight = value
|
23
23
|
end
|
24
24
|
|
25
|
+
def background_image=(value)
|
26
|
+
@view.backgroundView = UIImageView.alloc.initWithImage(value)
|
27
|
+
end
|
28
|
+
def background_image
|
29
|
+
if @view.backgroundView
|
30
|
+
@view.backgroundView.image
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
SEPARATOR_STYLES = {
|
26
37
|
none: UITableViewCellSeparatorStyleNone,
|
27
38
|
single: UITableViewCellSeparatorStyleSingleLine,
|
@@ -25,6 +25,7 @@ module RubyMotionQuery
|
|
25
25
|
def text_color ; view.textColor ; end
|
26
26
|
def text_color=(v) ; view.textColor = v ; end
|
27
27
|
alias :color :text_color
|
28
|
+
alias :color= :text_color=
|
28
29
|
|
29
30
|
def text_alignment ; view.textAlignment ; end
|
30
31
|
def text_alignment=(v) ; view.textAlignment = TEXT_ALIGNMENTS[v] || v ; end
|
@@ -35,6 +36,8 @@ module RubyMotionQuery
|
|
35
36
|
# Sizing the Text Field's Text
|
36
37
|
def adjusts_font_size_to_fit_width ; view.adjustsFontSizeToFitWidth ; end
|
37
38
|
def adjusts_font_size_to_fit_width=(v) ; view.adjustsFontSizeToFitWidth = v ; end
|
39
|
+
alias :adjusts_font_size= :adjusts_font_size_to_fit_width=
|
40
|
+
alias :adjusts_font_size :adjusts_font_size_to_fit_width
|
38
41
|
|
39
42
|
def minimum_font_size ; view.minimumFontSize ; end
|
40
43
|
def minimum_font_size=(v) ; view.minimumFontSize = v ; end
|
@@ -70,13 +73,13 @@ module RubyMotionQuery
|
|
70
73
|
def left_view=(v) ; view.leftView = v ; end
|
71
74
|
|
72
75
|
def left_view_mode ; view.leftViewMode ; end
|
73
|
-
def left_view_mode=(v)
|
76
|
+
def left_view_mode=(v); view.leftViewMode = TEXT_FIELD_MODES[v] || v ; end
|
74
77
|
|
75
78
|
def right_view ; view.rightView ; end
|
76
79
|
def right_view=(v) ; view.rightView = v ; end
|
77
80
|
|
78
81
|
def right_view_mode ; view.rightViewMode ; end
|
79
|
-
def right_view_mode=(v)
|
82
|
+
def right_view_mode=(v); view.rightViewMode = TEXT_FIELD_MODES[v] || v ; end
|
80
83
|
end
|
81
84
|
end
|
82
85
|
end
|
@@ -20,6 +20,9 @@ module RubyMotionQuery
|
|
20
20
|
def font ; view.font ; end
|
21
21
|
def font=(v) ; view.font = v ; end
|
22
22
|
|
23
|
+
def text_alignment ; view.textAlignment ; end
|
24
|
+
def text_alignment=(v) ; view.textAlignment = TEXT_ALIGNMENTS[v] || v ; end
|
25
|
+
|
23
26
|
def text_color ; view.textColor ; end
|
24
27
|
def text_color=(v) ; view.textColor = v ; end
|
25
28
|
alias :color :text_color
|
@@ -4,6 +4,7 @@ module RubyMotionQuery
|
|
4
4
|
TEXT_ALIGNMENTS = {
|
5
5
|
left: NSTextAlignmentLeft,
|
6
6
|
center: NSTextAlignmentCenter,
|
7
|
+
centered: NSTextAlignmentCenter,
|
7
8
|
right: NSTextAlignmentRight,
|
8
9
|
justified: NSTextAlignmentJustified,
|
9
10
|
natural: NSTextAlignmentNatural
|
@@ -25,6 +26,13 @@ module RubyMotionQuery
|
|
25
26
|
alphabet: UIKeyboardTypeASCIICapable
|
26
27
|
}
|
27
28
|
|
29
|
+
KEYBOARD_APPEARANCES = {
|
30
|
+
default: UIKeyboardAppearanceDefault,
|
31
|
+
dark: UIKeyboardAppearanceDark,
|
32
|
+
light: UIKeyboardAppearanceLight,
|
33
|
+
alert: UIKeyboardAppearanceAlert
|
34
|
+
}
|
35
|
+
|
28
36
|
RETURN_KEY_TYPES = {
|
29
37
|
default: UIReturnKeyDefault,
|
30
38
|
go: UIReturnKeyGo,
|
@@ -53,6 +61,53 @@ module RubyMotionQuery
|
|
53
61
|
rounded: UITextBorderStyleRoundedRect
|
54
62
|
}
|
55
63
|
|
64
|
+
TEXT_FIELD_MODES = {
|
65
|
+
never: UITextFieldViewModeNever,
|
66
|
+
while_editing: UITextFieldViewModeWhileEditing,
|
67
|
+
unless_editing: UITextFieldViewModeUnlessEditing,
|
68
|
+
always: UITextFieldViewModeAlways
|
69
|
+
}
|
70
|
+
|
71
|
+
LINE_BREAK_MODES = {
|
72
|
+
word_wrapping: NSLineBreakByWordWrapping,
|
73
|
+
word_wrap: NSLineBreakByWordWrapping,
|
74
|
+
char_wrapping: NSLineBreakByCharWrapping,
|
75
|
+
char_wrap: NSLineBreakByCharWrapping,
|
76
|
+
clipping: NSLineBreakByClipping,
|
77
|
+
truncating_head: NSLineBreakByTruncatingHead,
|
78
|
+
truncating_tail: NSLineBreakByTruncatingTail,
|
79
|
+
truncating_middle: NSLineBreakByTruncatingMiddle
|
80
|
+
}
|
81
|
+
|
82
|
+
AUTO_CORRECTION_TYPES = {
|
83
|
+
default: UITextAutocorrectionTypeDefault,
|
84
|
+
no: UITextAutocorrectionTypeNo,
|
85
|
+
yes: UITextAutocorrectionTypeYes,
|
86
|
+
}
|
87
|
+
|
88
|
+
AUTO_CAPITALIZATION_TYPES = {
|
89
|
+
none: UITextAutocapitalizationTypeNone,
|
90
|
+
words: UITextAutocapitalizationTypeWords,
|
91
|
+
sentences: UITextAutocapitalizationTypeSentences,
|
92
|
+
all: UITextAutocapitalizationTypeAllCharacters
|
93
|
+
}
|
94
|
+
|
95
|
+
CONTENT_MODE_TYPES = {
|
96
|
+
scale_to_fill: UIViewContentModeScaleToFill,
|
97
|
+
scale_aspect_fit: UIViewContentModeScaleAspectFit,
|
98
|
+
scale_aspect_fill: UIViewContentModeScaleAspectFill,
|
99
|
+
redraw: UIViewContentModeRedraw,
|
100
|
+
center: UIViewContentModeCenter,
|
101
|
+
top: UIViewContentModeTop,
|
102
|
+
bottom: UIViewContentModeBottom,
|
103
|
+
left: UIViewContentModeLeft,
|
104
|
+
right: UIViewContentModeRight,
|
105
|
+
top_left: UIViewContentModeTopLeft,
|
106
|
+
top_right: UIViewContentModeTopRight,
|
107
|
+
bottom_left: UIViewContentModeBottomLeft,
|
108
|
+
bottom_right: UIViewContentModeBottomRight
|
109
|
+
}
|
110
|
+
|
56
111
|
# When you create a styler, always inherit UIViewStyler
|
57
112
|
class UIViewStyler
|
58
113
|
def initialize(view)
|
@@ -233,7 +288,7 @@ module RubyMotionQuery
|
|
233
288
|
end
|
234
289
|
|
235
290
|
def content_mode=(value)
|
236
|
-
@view.setContentMode value
|
291
|
+
@view.setContentMode(CONTENT_MODE_TYPES[value] || value)
|
237
292
|
end
|
238
293
|
def content_mode
|
239
294
|
@view.contentMode
|
@@ -271,10 +326,10 @@ module RubyMotionQuery
|
|
271
326
|
end
|
272
327
|
|
273
328
|
def border_color=(value)
|
274
|
-
if
|
329
|
+
if value.is_a?(UIColor)
|
275
330
|
@view.layer.setBorderColor(value.CGColor)
|
276
331
|
else
|
277
|
-
@view.layer.setBorderColor
|
332
|
+
@view.layer.setBorderColor(value)
|
278
333
|
end
|
279
334
|
end
|
280
335
|
|
@@ -316,7 +371,26 @@ module RubyMotionQuery
|
|
316
371
|
def alpha ; view.alpha ; end
|
317
372
|
def alpha=(v) ; view.alpha = v ; end
|
318
373
|
|
374
|
+
def shadow_color=(c)
|
375
|
+
c = c.CGColor if c.kind_of?(UIColor)
|
376
|
+
@view.layer.shadowColor = c
|
377
|
+
end
|
378
|
+
def shadow_color ; @view.layer.shadowColor ; end
|
379
|
+
|
380
|
+
def shadow_offset=(offset)
|
381
|
+
@view.layer.shadowOffset = offset
|
382
|
+
end
|
383
|
+
def shadow_offset ; @view.layer.shadowOffset ; end
|
319
384
|
|
385
|
+
def shadow_opacity=(opacity)
|
386
|
+
@view.layer.shadowOpacity = opacity
|
387
|
+
end
|
388
|
+
def shadow_opacity ; @view.layer.shadowOpacity ; end
|
389
|
+
|
390
|
+
def shadow_path=(path)
|
391
|
+
@view.layer.shadowPath = path
|
392
|
+
end
|
393
|
+
def shadow_path ; @view.layer.shadowPath ; end
|
320
394
|
|
321
395
|
|
322
396
|
# @deprecated - use frame hashs
|
@@ -454,11 +528,23 @@ module RubyMotionQuery
|
|
454
528
|
end
|
455
529
|
end
|
456
530
|
|
457
|
-
|
531
|
+
#param is a hash of locations and colors: { locations: [], colors: [] }
|
532
|
+
def background_gradient=(options)
|
533
|
+
colors = options.fetch(:colors).collect { |c| c.CGColor }
|
534
|
+
locations = options.fetch(:locations)
|
458
535
|
|
459
|
-
|
460
|
-
|
536
|
+
CAGradientLayer.alloc.init.tap do |layer|
|
537
|
+
layer.colors = colors
|
538
|
+
layer.locations = locations
|
539
|
+
if view.layer.sublayers
|
540
|
+
view.layer.replaceSublayer(view.layer.sublayers[0], with: layer)
|
541
|
+
else
|
542
|
+
view.layer.insertSublayer(layer, atIndex: 0)
|
543
|
+
end
|
544
|
+
view.layer.sublayers[0].frame = view.bounds
|
545
|
+
end
|
461
546
|
end
|
547
|
+
|
462
548
|
end
|
463
549
|
end
|
464
550
|
end
|
@@ -97,24 +97,25 @@ module RubyMotionQuery
|
|
97
97
|
# memoize this, however if you do that, make sure the dev doesn't retain them in a var
|
98
98
|
custom_stylers(view) || begin
|
99
99
|
case view
|
100
|
-
when UILabel
|
101
|
-
when UIButton
|
102
|
-
when
|
103
|
-
when
|
104
|
-
when
|
105
|
-
when
|
106
|
-
when
|
107
|
-
when
|
108
|
-
when
|
109
|
-
when
|
110
|
-
when
|
111
|
-
when
|
112
|
-
when
|
113
|
-
when
|
114
|
-
when
|
115
|
-
when
|
116
|
-
when
|
117
|
-
when
|
100
|
+
when UILabel then Stylers::UILabelStyler.new(view)
|
101
|
+
when UIButton then Stylers::UIButtonStyler.new(view)
|
102
|
+
when UIActivityIndicatorView then Stylers::UIActivityIndicatorViewStyler.new(view)
|
103
|
+
when UIImageView then Stylers::UIImageViewStyler.new(view)
|
104
|
+
when UITableView then Stylers::UITableViewStyler.new(view)
|
105
|
+
when UISwitch then Stylers::UISwitchStyler.new(view)
|
106
|
+
when UIDatePicker then Stylers::UIDatePickerStyler.new(view)
|
107
|
+
when UISegmentedControl then Stylers::UISegmentedControlStyler.new(view)
|
108
|
+
when UIRefreshControl then Stylers::UIRefreshControlStyler.new(view)
|
109
|
+
when UIPageControl then Stylers::UIPageControlStyler.new(view)
|
110
|
+
when UIProgressView then Stylers::UIProgressViewStyler.new(view)
|
111
|
+
when UISlider then Stylers::UISliderStyler.new(view)
|
112
|
+
when UIStepper then Stylers::UIStepperStyler.new(view)
|
113
|
+
when UITabBar then Stylers::UITabBarStyler.new(view)
|
114
|
+
when UITableViewCell then Stylers::UITableViewCellStyler.new(view)
|
115
|
+
when UITextView then Stylers::UITextViewStyler.new(view)
|
116
|
+
when UITextField then Stylers::UITextFieldStyler.new(view)
|
117
|
+
when UINavigationBar then Stylers::UINavigationBarStyler.new(view)
|
118
|
+
when UIScrollView then Stylers::UIScrollViewStyler.new(view)
|
118
119
|
# TODO, all the controls are done, but missing some views, add
|
119
120
|
else
|
120
121
|
if view.respond_to?(:rmq_styler)
|
@@ -199,6 +199,11 @@ module RubyMotionQuery
|
|
199
199
|
#o.setTitle('Ok', forState: UIControlStateNormal)
|
200
200
|
o.opaque = true
|
201
201
|
end
|
202
|
+
elsif (klass == UIActivityIndicatorView) || klass < UIActivityIndicatorView
|
203
|
+
klass.alloc.initWithActivityIndicatorStyle(UIActivityIndicatorViewStyleWhite).tap do |o|
|
204
|
+
o.hidden = false
|
205
|
+
o.opaque = true
|
206
|
+
end
|
202
207
|
elsif reuse_identifier = opts[:reuse_identifier]
|
203
208
|
style = opts[:cell_style] || UITableViewCellStyleDefault
|
204
209
|
klass.alloc.initWithStyle(style, reuseIdentifier: reuse_identifier).tap do |o|
|
@@ -130,8 +130,12 @@ module RubyMotionQuery
|
|
130
130
|
TIME = Regexp.new('^(20|21|22|23|[01]\d|\d)((:[0-5]\d){1,2})$')
|
131
131
|
# Future Password strength validations -> http://stackoverflow.com/questions/5142103/regex-for-password-strength
|
132
132
|
USZIP = Regexp.new('^\d{5}(-\d{4})?$')
|
133
|
+
# UK Postal Code regex from: http://stackoverflow.com/a/7259020/814123
|
134
|
+
UKZIP = Regexp.new('^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2})$')
|
133
135
|
# 7 or 10 digit number, delimiters are spaces, dashes, or periods
|
134
136
|
USPHONE = Regexp.new('^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$')
|
137
|
+
# International Phone numbers
|
138
|
+
INTLPHONE = Regexp.new('^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$')
|
135
139
|
# Strong password (at least [8 chars, 1 upper, 1 lower, 1 number])
|
136
140
|
STRONGPW = Regexp.new('^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{8,}$')
|
137
141
|
# Has at least 1 uppercase letter
|
@@ -150,7 +154,9 @@ module RubyMotionQuery
|
|
150
154
|
:ipv4 => lambda { |value, opts| Validation.regex_match?(value, IPV4)},
|
151
155
|
:time => lambda { |value, opts| Validation.regex_match?(value, TIME)},
|
152
156
|
:uszip => lambda { |value, opts| Validation.regex_match?(value, USZIP)},
|
157
|
+
:ukzip => lambda { |value, opts| Validation.regex_match?(value.upcase, UKZIP)},
|
153
158
|
:usphone => lambda { |value, opts| Validation.regex_match?(value, USPHONE)},
|
159
|
+
:intlphone => lambda { |value, opts| Validation.regex_match?(value, INTLPHONE)},
|
154
160
|
:strong_password => lambda { |value, opts| Validation.regex_match?(value, STRONGPW)},
|
155
161
|
:has_upper => lambda { |value, opts| Validation.regex_match?(value, HASUPPER)},
|
156
162
|
:has_lower => lambda { |value, opts| Validation.regex_match?(value, HASLOWER)},
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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: 1.
|
4
|
+
version: 1.2.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-
|
12
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- motion/ruby_motion_query/rect.rb
|
76
76
|
- motion/ruby_motion_query/selectors.rb
|
77
77
|
- motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb
|
78
|
+
- motion/ruby_motion_query/stylers/ui_activity_indicator_view.rb
|
78
79
|
- motion/ruby_motion_query/stylers/ui_button_styler.rb
|
79
80
|
- motion/ruby_motion_query/stylers/ui_control_styler.rb
|
80
81
|
- motion/ruby_motion_query/stylers/ui_date_picker_styler.rb
|
@@ -108,24 +109,24 @@ files:
|
|
108
109
|
- templates/collection_view_controller/app/stylesheets/name_controller_stylesheet.rb
|
109
110
|
- templates/collection_view_controller/app/views/name_cell.rb
|
110
111
|
- templates/collection_view_controller/spec/controllers/name_controller_spec.rb
|
111
|
-
- templates/collection_view_controller/spec/views/
|
112
|
+
- templates/collection_view_controller/spec/views/name_cell_spec.rb
|
112
113
|
- templates/controller/app/controllers/name_controller.rb
|
113
114
|
- templates/controller/app/stylesheets/name_controller_stylesheet.rb
|
114
115
|
- templates/controller/spec/controllers/name_controller_spec.rb
|
115
116
|
- templates/lib/lib/name.rb
|
116
|
-
- templates/lib/spec/lib/
|
117
|
+
- templates/lib/spec/lib/name_spec.rb
|
117
118
|
- templates/model/app/models/name.rb
|
118
|
-
- templates/model/spec/models/
|
119
|
+
- templates/model/spec/models/name_spec.rb
|
119
120
|
- templates/shared/app/shared/name.rb
|
120
|
-
- templates/shared/spec/shared/
|
121
|
+
- templates/shared/spec/shared/name_spec.rb
|
121
122
|
- templates/table_view_controller/app/controllers/name_controller.rb
|
122
123
|
- templates/table_view_controller/app/stylesheets/name_controller_stylesheet.rb
|
123
124
|
- templates/table_view_controller/app/views/name_cell.rb
|
124
125
|
- templates/table_view_controller/spec/controllers/name_controller_spec.rb
|
125
|
-
- templates/table_view_controller/spec/views/
|
126
|
+
- templates/table_view_controller/spec/views/name_cell_spec.rb
|
126
127
|
- templates/view/app/stylesheets/name_stylesheet.rb
|
127
128
|
- templates/view/app/views/name.rb
|
128
|
-
- templates/view/spec/views/
|
129
|
+
- templates/view/spec/views/name_spec.rb
|
129
130
|
homepage: http://rubymotionquery.com
|
130
131
|
licenses:
|
131
132
|
- MIT
|
@@ -146,8 +147,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
149
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.4.
|
150
|
+
rubygems_version: 2.4.5
|
150
151
|
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: RubyMotionQuery - RMQ
|
153
154
|
test_files: []
|
155
|
+
has_rdoc:
|