@nativescript-community/text 1.5.30 → 1.5.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/text",
3
- "version": "1.5.30",
3
+ "version": "1.5.31",
4
4
  "description": "Expands the capabilities of NativeScript's text property.",
5
5
  "main": "./index",
6
6
  "sideEffects": false,
@@ -37,5 +37,5 @@
37
37
  },
38
38
  "license": "Apache-2.0",
39
39
  "readmeFilename": "README.md",
40
- "gitHead": "39240d60c316285de95b958eb5d93fc8ffd96358"
40
+ "gitHead": "0cf16bfa047e15879e49ea1e3e22fb0ac57c924e"
41
41
  }
@@ -49,7 +49,7 @@ class NSTextUtils: NSObject {
49
49
  }
50
50
  attrDict[NSAttributedString.Key.paragraphStyle] = paragraphStyle
51
51
  }
52
-
52
+
53
53
  if attrDict.count > 0 {
54
54
  if isTextView && ((view as! UITextView).font != nil) {
55
55
  // UITextView's font seems to change inside.
@@ -66,24 +66,27 @@ class NSTextUtils: NSObject {
66
66
  if (view is UIButton) {
67
67
  (view as! UIButton).setAttributedTitle(result, for:UIControl.State.normal)
68
68
  }
69
- else if(view is UILabel) {
70
- (view as! UILabel).attributedText = result
71
- } else if(view is UITextView) {
72
- (view as! UITextView).attributedText = result
69
+ else {
70
+ var attributedTextProperty = class_getProperty(type(of: view), "attributedText");
71
+ if (attributedTextProperty != nil) {
72
+ view.setValue(result, forKey: "attributedText")
73
+ }
73
74
  }
74
75
  } else {
75
76
  if (view is UIButton) {
76
77
  // Clear attributedText or title won't be affected.
77
78
  (view as! UIButton).setAttributedTitle(nil, for:UIControl.State.normal)
78
79
  (view as! UIButton).setTitle(text, for:UIControl.State.normal)
79
- } else if(view is UILabel) {
80
- // Clear attributedText or text won't be affected.
81
- (view as! UILabel).attributedText = nil
82
- (view as! UILabel).text = text
83
- } else if(view is UITextView) {
84
- // Clear attributedText or text won't be affected.
85
- (view as! UITextView).attributedText = nil
86
- (view as! UITextView).text = text
80
+ } else {
81
+ var attributedTextProperty = class_getProperty(type(of: view), "attributedText");
82
+ var textProperty = class_getProperty(type(of: view), "text");
83
+ if (attributedTextProperty != nil) {
84
+ // Clear attributedText or text won't be affected.
85
+ view.setValue(nil, forKey: "attributedText")
86
+ }
87
+ if (textProperty != nil) {
88
+ view.setValue(text, forKey: "text")
89
+ }
87
90
  }
88
91
  }
89
92
  }