Module: MotionPrime::ElementContentTextMixin
Instance Method Summary
collapse
#attributed_string, #html_string
Instance Method Details
#attributed_text? ⇒ Boolean
53
54
55
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 53
def attributed_text?
computed_options.slice(:html, :line_spacing, :line_height, :underline, :fragment_color).any? || computed_options[:attributed_text_options]
end
|
#cached_content_height ⇒ Object
49
50
51
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 49
def cached_content_height
@content_height ||= content_height
end
|
#cached_content_width ⇒ Object
38
39
40
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 38
def cached_content_width
@content_width ||= content_width
end
|
#content_attributed_text ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 14
def content_attributed_text
if view.try(:is_a?, UITextView) && view.text.present?
text = view.attributedText
text += ' ' if text.to_s.end_with?("\n") return text
end
options = {
text: content_text,
font: content_font,
line_spacing: computed_options[:line_spacing],
line_height: computed_options[:line_height]
}
computed_options[:html].present? ? html_string(options) : attributed_string(options)
end
|
#content_font ⇒ Object
10
11
12
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 10
def content_font
(is_a?(ButtonElement) ? button_content_font : input_content_font) || :system.uifont
end
|
#content_height ⇒ Object
42
43
44
45
46
47
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 42
def content_height
min, max = computed_options[:min_height].to_f, computed_options[:max_height]
return min if content_text.blank?
rect = get_content_rect(computed_options[:width] - content_padding_width)
@content_height = [[rect.size.height.ceil, max].compact.min, min].max.ceil
end
|
#content_text ⇒ Object
6
7
8
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 6
def content_text
is_a?(ButtonElement) ? button_content_text : input_content_text
end
|
#content_width ⇒ Object
30
31
32
33
34
35
36
|
# File 'motion-prime/elements/_content_text_mixin.rb', line 30
def content_width
min, max = computed_options[:min_width].to_f, computed_options[:max_width]
return min if content_text.blank?
rect = get_content_rect(Float::MAX)
@content_width = [[rect.size.width.ceil, max].compact.min, min].max.ceil
end
|