motion-prime 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/files/Gemfile +1 -1
- data/motion-prime/elements/_text_mixin.rb +21 -17
- data/motion-prime/elements/draw/label.rb +2 -1
- data/motion-prime/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQ0MTllNzk1MTE2ODViNTZjMDE0NzFhMTU2Nzk1ZjI1Njg3MDhjZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzQ0YTk2NjA2NWUxOGE5N2NjMjFkZTA2YjJlZTlhNzVkMDQ0M2I2ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGY3OWE1OTNkNGVjMWQ4NjFiNjgzOGNjMjhiNTQ5ZTUwODEyNmMwMGVlNGIz
|
10
|
+
NTg2OTM3ZmMyNzcxMDE2YTNkNDJhNTg1MGEzNjE1YjAwNTNlMzljMzdlNjM2
|
11
|
+
ZTU2NzZlZWNkYmIzZWUxMjMwODg2MWQ1OWYxZjIyOTA2ZjdiNmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2QxNWVhMGRkZTBlMTE2YWM5NzU4MjJhNjMwNGI0ODAwYWVmNTU3NzY2NTU3
|
14
|
+
YzM2NzJmZGU3ODczYjQ1ZGJlNzllNDgzYmE1OGQ3NjQzY2IyZDdiMjBmOGYx
|
15
|
+
MDg1YTVmOWM1MGUyMGMwNTkwYTQ4ZmU2N2JhYzIyNjcyOTUyZjI=
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/files/Gemfile
CHANGED
@@ -28,6 +28,26 @@ module MotionPrime
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def attributed_string(options)
|
31
|
+
attributes, paragrah_style = extract_attributed_string_options(options)
|
32
|
+
|
33
|
+
prepared_text = NSMutableAttributedString.alloc.initWithString(options[:text].to_s, attributes: attributes)
|
34
|
+
underline_range = options[:underline]
|
35
|
+
fragment_color = options[:fragment_color]
|
36
|
+
if paragrah_style && (underline_range || fragment_color) && options.fetch(:number_of_lines, 1) == 1
|
37
|
+
Prime.logger.debug "If attributed text has paragraph style and underline - you must set number of lines != 1"
|
38
|
+
end
|
39
|
+
|
40
|
+
if underline_range
|
41
|
+
underline_range = [0, options[:text].length] if underline_range === true
|
42
|
+
prepared_text.addAttributes({NSUnderlineStyleAttributeName => NSUnderlineStyleSingle}, range: underline_range)
|
43
|
+
end
|
44
|
+
if fragment_color
|
45
|
+
prepared_text.addAttributes({NSForegroundColorAttributeName => fragment_color[:color].uicolor}, range: fragment_color[:range])
|
46
|
+
end
|
47
|
+
prepared_text
|
48
|
+
end
|
49
|
+
|
50
|
+
def extract_attributed_string_options(options)
|
31
51
|
attributes = {}
|
32
52
|
line_height = options[:line_height]
|
33
53
|
line_spacing = options[:line_spacing]
|
@@ -51,25 +71,9 @@ module MotionPrime
|
|
51
71
|
end
|
52
72
|
attributes[NSParagraphStyleAttributeName] = paragrah_style
|
53
73
|
end
|
54
|
-
|
55
74
|
attributes[NSForegroundColorAttributeName] = options[:text_color].uicolor if options[:text_color]
|
56
75
|
attributes[NSFontAttributeName] = options[:font].uifont if options[:font]
|
57
|
-
|
58
|
-
prepared_text = NSMutableAttributedString.alloc.initWithString(options[:text].to_s, attributes: attributes)
|
59
|
-
underline_range = options[:underline]
|
60
|
-
fragment_color = options[:fragment_color]
|
61
|
-
if paragrah_style && (underline_range || fragment_color) && options.fetch(:number_of_lines, 1) == 1
|
62
|
-
Prime.logger.debug "If attributed text has paragraph style and underline - you must set number of lines != 1"
|
63
|
-
end
|
64
|
-
|
65
|
-
if underline_range
|
66
|
-
underline_range = [0, options[:text].length] if underline_range === true
|
67
|
-
prepared_text.addAttributes({NSUnderlineStyleAttributeName => NSUnderlineStyleSingle}, range: underline_range)
|
68
|
-
end
|
69
|
-
if fragment_color
|
70
|
-
prepared_text.addAttributes({NSForegroundColorAttributeName => fragment_color[:color].uicolor}, range: fragment_color[:range])
|
71
|
-
end
|
72
|
-
prepared_text
|
76
|
+
[attributes, paragrah_style]
|
73
77
|
end
|
74
78
|
end
|
75
79
|
end
|
@@ -52,7 +52,8 @@ module MotionPrime
|
|
52
52
|
|
53
53
|
UIGraphicsPushContext(context)
|
54
54
|
options = draw_options
|
55
|
-
if options[:is_html] || options[:line_spacing] ||
|
55
|
+
if options[:is_html] || options[:line_spacing] ||
|
56
|
+
options[:line_height] || options[:underline] || options[:force_attributed]
|
56
57
|
prepared_text = options[:is_html] ? html_string(options) : attributed_string(options)
|
57
58
|
|
58
59
|
CGContextSaveGState(context)
|
data/motion-prime/version.rb
CHANGED