under-os 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +25 -2
- data/README.md +1 -1
- data/Rakefile +2 -4
- data/lib/under-os.rb +3 -8
- data/under-os.gemspec +6 -2
- metadata +47 -191
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +0 -115
- data/lib/under_os.rb +0 -41
- data/lib/under_os/app.rb +0 -33
- data/lib/under_os/color.rb +0 -184
- data/lib/under_os/config.rb +0 -33
- data/lib/under_os/core/array.rb +0 -5
- data/lib/under_os/core/hash.rb +0 -10
- data/lib/under_os/core/json.rb +0 -19
- data/lib/under_os/core/kernel.rb +0 -16
- data/lib/under_os/core/numeric.rb +0 -23
- data/lib/under_os/core/object.rb +0 -9
- data/lib/under_os/core/string.rb +0 -80
- data/lib/under_os/delegate.rb +0 -10
- data/lib/under_os/events.rb +0 -85
- data/lib/under_os/file.rb +0 -110
- data/lib/under_os/history.rb +0 -53
- data/lib/under_os/http.rb +0 -31
- data/lib/under_os/http/cookies.rb +0 -30
- data/lib/under_os/http/receiver.rb +0 -44
- data/lib/under_os/http/request.rb +0 -106
- data/lib/under_os/http/response.rb +0 -28
- data/lib/under_os/http/session.rb +0 -49
- data/lib/under_os/page.rb +0 -169
- data/lib/under_os/page/builder.rb +0 -96
- data/lib/under_os/page/layout.rb +0 -43
- data/lib/under_os/page/matcher.rb +0 -128
- data/lib/under_os/page/stylesheet.rb +0 -67
- data/lib/under_os/parser.rb +0 -24
- data/lib/under_os/parser/css.rb +0 -37
- data/lib/under_os/parser/html.rb +0 -97
- data/lib/under_os/point.rb +0 -47
- data/lib/under_os/screen.rb +0 -9
- data/lib/under_os/timer.rb +0 -65
- data/lib/under_os/ui.rb +0 -3
- data/lib/under_os/ui/alert.rb +0 -52
- data/lib/under_os/ui/button.rb +0 -42
- data/lib/under_os/ui/collection.rb +0 -65
- data/lib/under_os/ui/collection/cell.rb +0 -21
- data/lib/under_os/ui/collection/delegate.rb +0 -70
- data/lib/under_os/ui/collection/item.rb +0 -32
- data/lib/under_os/ui/collection/layout.rb +0 -43
- data/lib/under_os/ui/collection/styles.rb +0 -15
- data/lib/under_os/ui/div.rb +0 -3
- data/lib/under_os/ui/form.rb +0 -60
- data/lib/under_os/ui/icon.rb +0 -61
- data/lib/under_os/ui/icon/awesome.rb +0 -376
- data/lib/under_os/ui/icon/engine.rb +0 -10
- data/lib/under_os/ui/image.rb +0 -31
- data/lib/under_os/ui/input.rb +0 -140
- data/lib/under_os/ui/label.rb +0 -21
- data/lib/under_os/ui/locker.rb +0 -42
- data/lib/under_os/ui/navbar.rb +0 -123
- data/lib/under_os/ui/progress.rb +0 -17
- data/lib/under_os/ui/scroll.rb +0 -41
- data/lib/under_os/ui/select.rb +0 -95
- data/lib/under_os/ui/sidebar.rb +0 -45
- data/lib/under_os/ui/slider.rb +0 -37
- data/lib/under_os/ui/spinner.rb +0 -23
- data/lib/under_os/ui/style.rb +0 -21
- data/lib/under_os/ui/style/fonts.rb +0 -54
- data/lib/under_os/ui/style/margins.rb +0 -164
- data/lib/under_os/ui/style/outlining.rb +0 -170
- data/lib/under_os/ui/style/positioning.rb +0 -169
- data/lib/under_os/ui/switch.rb +0 -26
- data/lib/under_os/ui/textarea.rb +0 -19
- data/lib/under_os/ui/utils/animation.rb +0 -99
- data/lib/under_os/ui/utils/commons.rb +0 -70
- data/lib/under_os/ui/utils/dimensions.rb +0 -37
- data/lib/under_os/ui/utils/events.rb +0 -170
- data/lib/under_os/ui/utils/manipulation.rb +0 -44
- data/lib/under_os/ui/utils/position.rb +0 -21
- data/lib/under_os/ui/utils/size.rb +0 -21
- data/lib/under_os/ui/utils/styles.rb +0 -89
- data/lib/under_os/ui/utils/traversing.rb +0 -44
- data/lib/under_os/ui/utils/wrap.rb +0 -77
- data/lib/under_os/ui/view.rb +0 -31
- data/resources/test.png +0 -0
- data/spec/assets/app.css +0 -13
- data/spec/assets/test.css +0 -7
- data/spec/assets/test.html +0 -3
- data/spec/assets/test_page.rb +0 -2
- data/spec/lib/core/hash_spec.rb +0 -19
- data/spec/lib/core/json_spec.rb +0 -32
- data/spec/lib/core/numeric_spec.rb +0 -37
- data/spec/lib/core/string_spec.rb +0 -121
- data/spec/lib/under_os/color_spec.rb +0 -133
- data/spec/lib/under_os/events_spec.rb +0 -71
- data/spec/lib/under_os/file_spec.rb +0 -98
- data/spec/lib/under_os/http/cookies_spec.rb +0 -13
- data/spec/lib/under_os/http/request_spec.rb +0 -44
- data/spec/lib/under_os/http_spec.rb +0 -20
- data/spec/lib/under_os/page/builder_spec.rb +0 -128
- data/spec/lib/under_os/page/layout_spec.rb +0 -18
- data/spec/lib/under_os/page/matcher_spec.rb +0 -260
- data/spec/lib/under_os/page/stylesheet_spec.rb +0 -83
- data/spec/lib/under_os/page_spec.rb +0 -5
- data/spec/lib/under_os/parser/css_spec.rb +0 -77
- data/spec/lib/under_os/parser/html_spec.rb +0 -152
- data/spec/lib/under_os/parser_spec.rb +0 -16
- data/spec/lib/under_os/point_spec.rb +0 -54
- data/spec/lib/under_os/screen_spec.rb +0 -11
- data/spec/lib/under_os/timer_spec.rb +0 -93
- data/spec/lib/under_os/ui/button_spec.rb +0 -50
- data/spec/lib/under_os/ui/collection_spec.rb +0 -19
- data/spec/lib/under_os/ui/div_spec.rb +0 -24
- data/spec/lib/under_os/ui/form_spec.rb +0 -156
- data/spec/lib/under_os/ui/icon_spec.rb +0 -57
- data/spec/lib/under_os/ui/image_spec.rb +0 -39
- data/spec/lib/under_os/ui/input_spec.rb +0 -109
- data/spec/lib/under_os/ui/label_spec.rb +0 -22
- data/spec/lib/under_os/ui/locker_spec.rb +0 -31
- data/spec/lib/under_os/ui/progress_spec.rb +0 -31
- data/spec/lib/under_os/ui/scroll_spec.rb +0 -40
- data/spec/lib/under_os/ui/select_spec.rb +0 -135
- data/spec/lib/under_os/ui/sidebar_spec.rb +0 -35
- data/spec/lib/under_os/ui/slider_spec.rb +0 -69
- data/spec/lib/under_os/ui/spinner_spec.rb +0 -57
- data/spec/lib/under_os/ui/style/fonts_spec.rb +0 -73
- data/spec/lib/under_os/ui/style/margins_spec.rb +0 -106
- data/spec/lib/under_os/ui/style/outlining_spec.rb +0 -101
- data/spec/lib/under_os/ui/style/positioning_spec.rb +0 -69
- data/spec/lib/under_os/ui/style_spec.rb +0 -19
- data/spec/lib/under_os/ui/switch_spec.rb +0 -60
- data/spec/lib/under_os/ui/textarea_spec.rb +0 -34
- data/spec/lib/under_os/ui/utils/commons_spec.rb +0 -81
- data/spec/lib/under_os/ui/utils/events_spec.rb +0 -87
- data/spec/lib/under_os/ui/utils/manipulation_spec.rb +0 -130
- data/spec/lib/under_os/ui/utils/styles_spec.rb +0 -140
- data/spec/lib/under_os/ui/utils/traversing_spec.rb +0 -124
- data/spec/lib/under_os/ui/utils/wrap_spec.rb +0 -69
- data/spec/lib/under_os/ui/view_spec.rb +0 -39
data/lib/under_os/ui/sidebar.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
class UnderOs::UI::Sidebar < UnderOs::UI::View
|
2
|
-
wraps UIView, tag: :sidebar
|
3
|
-
|
4
|
-
LOCATIONS = [:top, :left, :right, :bottom]
|
5
|
-
|
6
|
-
def initialize(options={})
|
7
|
-
super
|
8
|
-
|
9
|
-
self.location = options.delete(:location) if options.has_key?(:location)
|
10
|
-
end
|
11
|
-
|
12
|
-
def location
|
13
|
-
@location || :bottom
|
14
|
-
end
|
15
|
-
|
16
|
-
def location=(value)
|
17
|
-
@location = value.to_sym
|
18
|
-
@location = nil if ! LOCATIONS.include?(@location)
|
19
|
-
end
|
20
|
-
|
21
|
-
def show
|
22
|
-
class_names = self.classNames
|
23
|
-
class_names.reject!{ |n| LOCATIONS.include?(n.to_sym) }
|
24
|
-
|
25
|
-
self.classNames = class_names + [location, 'visible']
|
26
|
-
self.style = {location => -slide_distance, display: :block}
|
27
|
-
|
28
|
-
animate location => 0
|
29
|
-
end
|
30
|
-
|
31
|
-
def hide
|
32
|
-
@_class_names -= ['visible']
|
33
|
-
|
34
|
-
animate location => -slide_distance
|
35
|
-
end
|
36
|
-
|
37
|
-
def hidden
|
38
|
-
!classNames.include?('visible')
|
39
|
-
end
|
40
|
-
|
41
|
-
def slide_distance
|
42
|
-
[:top, :bottom].include?(location) ? size.y : size.x
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/lib/under_os/ui/slider.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
class UnderOs::UI::Slider < UnderOs::UI::Input
|
2
|
-
wraps UISlider, tag: 'slider'
|
3
|
-
|
4
|
-
def initialize(options={})
|
5
|
-
super
|
6
|
-
|
7
|
-
self.min = options[:min] if options[:min]
|
8
|
-
self.max = options[:max] if options[:max]
|
9
|
-
|
10
|
-
@_.continuous = options.delete(:track) || true # track the changes as they go
|
11
|
-
@_.addTarget self, action: :handle_change, forControlEvents:UIControlEventValueChanged
|
12
|
-
end
|
13
|
-
|
14
|
-
def value
|
15
|
-
@_.value
|
16
|
-
end
|
17
|
-
|
18
|
-
def value=(value)
|
19
|
-
@_.value = value.to_f
|
20
|
-
end
|
21
|
-
|
22
|
-
def min
|
23
|
-
@_.minimumValue
|
24
|
-
end
|
25
|
-
|
26
|
-
def min=(value)
|
27
|
-
@_.minimumValue = value.to_f
|
28
|
-
end
|
29
|
-
|
30
|
-
def max
|
31
|
-
@_.maximumValue
|
32
|
-
end
|
33
|
-
|
34
|
-
def max=(value)
|
35
|
-
@_.maximumValue = value.to_f
|
36
|
-
end
|
37
|
-
end
|
data/lib/under_os/ui/spinner.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class UnderOs::UI::Spinner < UnderOs::UI::View
|
2
|
-
wraps UIActivityIndicatorView, tag: :spinner
|
3
|
-
|
4
|
-
def initialize(options={})
|
5
|
-
super
|
6
|
-
show
|
7
|
-
end
|
8
|
-
|
9
|
-
def show
|
10
|
-
@_.startAnimating
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
def hide
|
15
|
-
@_.stopAnimating
|
16
|
-
self
|
17
|
-
end
|
18
|
-
|
19
|
-
def hidden
|
20
|
-
@_.isAnimating == 0
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/lib/under_os/ui/style.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# The view styles handling wrapper
|
3
|
-
#
|
4
|
-
# The idea here is to provide a DOM like `style` object,
|
5
|
-
# which can take similar to DOM properties and translate
|
6
|
-
# them into iOS equivalents
|
7
|
-
#
|
8
|
-
class UnderOs::UI::Style
|
9
|
-
include Fonts
|
10
|
-
include Margins
|
11
|
-
include Outlining
|
12
|
-
include Positioning
|
13
|
-
|
14
|
-
attr_reader :view
|
15
|
-
|
16
|
-
def initialize(view, type)
|
17
|
-
@view = view
|
18
|
-
@type = type
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This module handles all sorts of things related to fonts
|
3
|
-
# and text attributes
|
4
|
-
#
|
5
|
-
module UnderOs::UI
|
6
|
-
class Style
|
7
|
-
module Fonts
|
8
|
-
def fontFamily
|
9
|
-
end
|
10
|
-
|
11
|
-
def fontFamily=(value)
|
12
|
-
@view.font = @view.font.fontWithName(value)
|
13
|
-
end
|
14
|
-
|
15
|
-
def fontSize
|
16
|
-
end
|
17
|
-
|
18
|
-
def fontSize=(value)
|
19
|
-
@view.font = @view.font.fontWithSize(value)
|
20
|
-
@view.sizeToFit if @type == :icon
|
21
|
-
end
|
22
|
-
|
23
|
-
def textAlign
|
24
|
-
if @view.is_a?(UIButton)
|
25
|
-
BUTTONS_ALIGMENTS_MAP.key(@view.contentHorizontalAlignment)
|
26
|
-
elsif @view.respond_to?(:textAlignment)
|
27
|
-
TEXTNODES_ALIGMENTS_MAP.key(@view.textAlignment)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def textAlign=(value)
|
32
|
-
if @view.is_a?(UIButton)
|
33
|
-
@view.contentHorizontalAlignment = BUTTONS_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left']
|
34
|
-
elsif @view.respond_to?(:textAlignment)
|
35
|
-
@view.textAlignment = TEXTNODES_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left']
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
BUTTONS_ALIGMENTS_MAP = {
|
40
|
-
'right' => UIControlContentHorizontalAlignmentRight,
|
41
|
-
'center' => UIControlContentHorizontalAlignmentCenter,
|
42
|
-
'justify' => UIControlContentHorizontalAlignmentFill,
|
43
|
-
'left' => UIControlContentHorizontalAlignmentLeft
|
44
|
-
}
|
45
|
-
|
46
|
-
TEXTNODES_ALIGMENTS_MAP = {
|
47
|
-
'right' => NSTextAlignmentRight,
|
48
|
-
'center' => NSTextAlignmentCenter,
|
49
|
-
'justify' => NSTextAlignmentJustified,
|
50
|
-
'left' => NSTextAlignmentLeft
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This module handles styles related to margins and paddings
|
3
|
-
#
|
4
|
-
module UnderOs::UI
|
5
|
-
class Style
|
6
|
-
module Margins
|
7
|
-
def display
|
8
|
-
@display || :block
|
9
|
-
end
|
10
|
-
|
11
|
-
def display=(value)
|
12
|
-
@display = %w[none block inline].include?(value.to_s) ? value.to_sym : :block
|
13
|
-
@view.hidden = @display == :none
|
14
|
-
set_offsets if @display == :inline
|
15
|
-
end
|
16
|
-
|
17
|
-
def margin
|
18
|
-
[marginTop, marginRight, marginBottom, marginLeft]
|
19
|
-
end
|
20
|
-
|
21
|
-
def margin=(value)
|
22
|
-
@margin_top, @margin_right, @margin_botom, @margin_left = to_4dim_array(value)
|
23
|
-
set_offsets
|
24
|
-
end
|
25
|
-
|
26
|
-
def marginTop
|
27
|
-
@margin_top || 0
|
28
|
-
end
|
29
|
-
|
30
|
-
def marginTop=(value)
|
31
|
-
@margin_top = value
|
32
|
-
set_offsets
|
33
|
-
end
|
34
|
-
|
35
|
-
def marginLeft
|
36
|
-
@margin_left || 0
|
37
|
-
end
|
38
|
-
|
39
|
-
def marginLeft=(value)
|
40
|
-
@margin_left = value
|
41
|
-
set_offsets
|
42
|
-
end
|
43
|
-
|
44
|
-
def marginRight
|
45
|
-
@margin_right || 0
|
46
|
-
end
|
47
|
-
|
48
|
-
def marginRight=(value)
|
49
|
-
@margin_right = value
|
50
|
-
set_offsets
|
51
|
-
end
|
52
|
-
|
53
|
-
def marginBottom
|
54
|
-
@margin_botom || 0
|
55
|
-
end
|
56
|
-
|
57
|
-
def marginBottom=(value)
|
58
|
-
@margin_botom = value
|
59
|
-
set_offsets
|
60
|
-
end
|
61
|
-
|
62
|
-
def padding
|
63
|
-
[paddingTop, paddingRight, paddingBottom, paddingLeft]
|
64
|
-
end
|
65
|
-
|
66
|
-
def padding=(value)
|
67
|
-
@padding_top, @padding_right, @padding_botom, @padding_left = to_4dim_array(value)
|
68
|
-
set_offsets
|
69
|
-
end
|
70
|
-
|
71
|
-
def paddingTop
|
72
|
-
@padding_top || 0
|
73
|
-
end
|
74
|
-
|
75
|
-
def paddingTop=(value)
|
76
|
-
@padding_top = value
|
77
|
-
set_paddings
|
78
|
-
end
|
79
|
-
|
80
|
-
def paddingLeft
|
81
|
-
@padding_left || 0
|
82
|
-
end
|
83
|
-
|
84
|
-
def paddingLeft=(value)
|
85
|
-
@padding_left = value
|
86
|
-
set_paddings
|
87
|
-
end
|
88
|
-
|
89
|
-
def paddingRight
|
90
|
-
@padding_right || 0
|
91
|
-
end
|
92
|
-
|
93
|
-
def paddingRight=(value)
|
94
|
-
@padding_right = value
|
95
|
-
set_paddings
|
96
|
-
end
|
97
|
-
|
98
|
-
def paddingBottom
|
99
|
-
@padding_botom || 0
|
100
|
-
end
|
101
|
-
|
102
|
-
def paddingBottom=(value)
|
103
|
-
@padding_botom = value
|
104
|
-
set_paddings
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def to_4dim_array(value)
|
110
|
-
value = value.gsub('px', '').split.map(&:to_f) if value.is_a?(String)
|
111
|
-
value = Array(value)
|
112
|
-
case value.size
|
113
|
-
when 1 then value * 4
|
114
|
-
when 2 then [value[0], value[1], value[0], value[1]]
|
115
|
-
else value
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def set_offsets
|
120
|
-
return nil if display != :inline
|
121
|
-
|
122
|
-
position_x = marginLeft + parent_offset_x
|
123
|
-
position_y = marginTop
|
124
|
-
|
125
|
-
@view.frame = [[position_x, position_y], [
|
126
|
-
@view.frame.size.width, @view.frame.size.height
|
127
|
-
]]
|
128
|
-
end
|
129
|
-
|
130
|
-
def set_paddings
|
131
|
-
if @view.respond_to?(:contentEdgeInsets)
|
132
|
-
@view.contentEdgeInsets = UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def parent_offset_x
|
137
|
-
offset = 0
|
138
|
-
parent_frame = parent_view_frame
|
139
|
-
|
140
|
-
if parent_frame
|
141
|
-
offset += parent_frame.origin.x + parent_frame.size.width
|
142
|
-
|
143
|
-
if wrap = UnderOs::UI::View.wrap_for(@view)
|
144
|
-
offset += wrap.style.marginRight
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
offset
|
149
|
-
end
|
150
|
-
|
151
|
-
def parent_view_frame
|
152
|
-
parent_view = @view.superview
|
153
|
-
parent_frame = nil
|
154
|
-
|
155
|
-
unless parent_view.subviews[0] === @view
|
156
|
-
previous_view = parent_view.subviews[parent_view.subviews.index(@view)-1]
|
157
|
-
parent_frame = previous_view && previous_view.frame
|
158
|
-
end
|
159
|
-
|
160
|
-
parent_frame
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,170 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This module contains things like colors, borders, shadows, etc
|
3
|
-
#
|
4
|
-
module UnderOs::UI
|
5
|
-
class Style
|
6
|
-
module Outlining
|
7
|
-
def opacity
|
8
|
-
@view.alpha
|
9
|
-
end
|
10
|
-
|
11
|
-
def opacity=(value)
|
12
|
-
@view.alpha = value
|
13
|
-
end
|
14
|
-
|
15
|
-
def backgroundColor
|
16
|
-
@view.backgroundColor
|
17
|
-
end
|
18
|
-
|
19
|
-
def backgroundColor=(color, state=UIControlStateNormal)
|
20
|
-
if @view.is_a?(UIButton)
|
21
|
-
@view.setBackgroundColor convert_color(color), forState:state
|
22
|
-
else
|
23
|
-
@view.backgroundColor = convert_color(color)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def backgroundImage
|
28
|
-
@background_image
|
29
|
-
end
|
30
|
-
|
31
|
-
def backgroundImage=(image)
|
32
|
-
image = UIImage.UIImage.imageNamed(image) if image.is_a?(String)
|
33
|
-
|
34
|
-
if @view.is_a?(UIButton)
|
35
|
-
@view.setBackgroundImage(image, forState:UIControlStateNormal)
|
36
|
-
else
|
37
|
-
@background_image = UnderOs::UI::Image.new(src: image, class: 'uos-background-image')
|
38
|
-
@background_image._.frame = [[0, 0], [@view.frame.size.width, @view.frame.size.height]]
|
39
|
-
@view.insertSubview(@background_image._, atIndex: 0)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
alias :background :backgroundColor
|
44
|
-
alias :background= :backgroundColor=
|
45
|
-
|
46
|
-
def color(state=UIControlStateNormal)
|
47
|
-
if @view.is_a?(UIButton)
|
48
|
-
@view.titleColorForState(state)
|
49
|
-
elsif @view.respond_to?(:textColor)
|
50
|
-
@view.textColor
|
51
|
-
elsif @view.respond_to?(:color)
|
52
|
-
@view.color
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def color=(color, state=UIControlStateNormal)
|
57
|
-
if @view.is_a?(UIButton)
|
58
|
-
@view.setTitleColor convert_color(color), forState:state
|
59
|
-
elsif @view.respond_to?(:textColor)
|
60
|
-
@view.textColor = convert_color(color)
|
61
|
-
elsif @view.respond_to?(:color)
|
62
|
-
@view.color = convert_color(color)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def borderRadius
|
67
|
-
@view.layer.cornerRadius
|
68
|
-
end
|
69
|
-
|
70
|
-
def borderRadius=(radius)
|
71
|
-
@view.clipsToBounds = true
|
72
|
-
@view.layer.cornerRadius = radius
|
73
|
-
end
|
74
|
-
|
75
|
-
def borderColor
|
76
|
-
@view.layer.borderColor
|
77
|
-
end
|
78
|
-
|
79
|
-
def borderColor=(color)
|
80
|
-
@view.layer.borderColor = convert_color(color).CGColor
|
81
|
-
end
|
82
|
-
|
83
|
-
def borderWidth
|
84
|
-
@view.layer.borderWidth
|
85
|
-
end
|
86
|
-
|
87
|
-
def borderWidth=(width)
|
88
|
-
@view.layer.borderWidth = width
|
89
|
-
end
|
90
|
-
|
91
|
-
def boxShadow
|
92
|
-
get_layer_shadow @view.layer
|
93
|
-
end
|
94
|
-
|
95
|
-
def boxShadow=(value)
|
96
|
-
set_layer_shadow @view.layer, value
|
97
|
-
end
|
98
|
-
|
99
|
-
def textShadow
|
100
|
-
get_layer_shadow text_layer
|
101
|
-
end
|
102
|
-
|
103
|
-
def textShadow=(value)
|
104
|
-
set_layer_shadow text_layer, value
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def convert_color(color)
|
110
|
-
UnderOs::Color.new(color).ui
|
111
|
-
end
|
112
|
-
|
113
|
-
def text_layer
|
114
|
-
@view.is_a?(UIButton) ? @view.titleLabel : @view.layer
|
115
|
-
end
|
116
|
-
|
117
|
-
def get_layer_shadow(layer)
|
118
|
-
[
|
119
|
-
layer.shadowOffset.width,
|
120
|
-
layer.shadowOffset.height,
|
121
|
-
layer.shadowRadius,
|
122
|
-
layer.shadowOpacity,
|
123
|
-
UnderOs::Color.new(layer.shadowColor).to_hex
|
124
|
-
].compact.join(" ")
|
125
|
-
end
|
126
|
-
|
127
|
-
def set_layer_shadow(layer, value)
|
128
|
-
x, y, radius, opacity, color = parse_shadow_params(value)
|
129
|
-
|
130
|
-
layer.shadowOffset = CGSizeMake(x, y) if x && y
|
131
|
-
layer.shadowColor = color.CGColor if color
|
132
|
-
layer.shadowRadius = radius if radius
|
133
|
-
layer.shadowOpacity = opacity if opacity
|
134
|
-
layer.shadowPath = UIBezierPath.bezierPathWithRect(@view.layer.bounds).CGPath
|
135
|
-
end
|
136
|
-
|
137
|
-
def parse_shadow_params(string)
|
138
|
-
x, y, radius, opacity, color = string.strip.split
|
139
|
-
|
140
|
-
x = x.gsub /px$/, ''
|
141
|
-
y = y.gsub /px$/, ''
|
142
|
-
radius = radius.gsub /px$/, '' if radius
|
143
|
-
opacity = opacity.gsub /px$/, '' if opacity
|
144
|
-
|
145
|
-
if ! color
|
146
|
-
if opacity
|
147
|
-
unless opacity =~ /^[\d\.]+$/
|
148
|
-
color = opacity
|
149
|
-
opacity = nil
|
150
|
-
end
|
151
|
-
elsif radius
|
152
|
-
unless radius =~ /^[\d\.]+$/
|
153
|
-
color = radius
|
154
|
-
radius = nil
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
x = x.to_f if x
|
160
|
-
y = y.to_f if y
|
161
|
-
|
162
|
-
radius = radius.to_f if radius
|
163
|
-
opacity = opacity.to_f if opacity
|
164
|
-
color = convert_color(color) if color
|
165
|
-
|
166
|
-
[x, y, radius, opacity, color]
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|