@@ -12,6 +12,7 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
1212 private let textView = NitroTextView ( )
1313 var view : UIView { textView }
1414 let nitroTextImpl : NitroTextImpl
15+ private var needsApply : Bool = false
1516
1617 override init ( ) {
1718 self . nitroTextImpl = NitroTextImpl ( textView)
@@ -30,9 +31,7 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
3031 // Props
3132
3233 var fragments : [ Fragment ] ? {
33- didSet {
34- applyFragmentsAndProps ( )
35- }
34+ didSet { markNeedsApply ( ) }
3635 }
3736
3837 var selectable : Bool ? {
@@ -44,7 +43,7 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
4443 var allowFontScaling : Bool ? {
4544 didSet {
4645 nitroTextImpl. setAllowFontScaling ( allowFontScaling)
47- applyFragmentsAndProps ( )
46+ markNeedsApply ( )
4847 }
4948 }
5049
@@ -56,72 +55,60 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
5655 var fontSize : Double ? {
5756 didSet {
5857 nitroTextImpl. setFontSize ( fontSize)
59- applyFragmentsAndProps ( )
58+ markNeedsApply ( )
6059 }
6160 }
6261
6362 var fontWeight : FontWeight ? {
64- didSet {
65- applyFragmentsAndProps ( )
66- }
63+ didSet { markNeedsApply ( ) }
6764 }
6865
6966 var fontColor : String ? {
7067 didSet {
7168 textView. textColor = ColorParser . parse ( fontColor)
72- applyFragmentsAndProps ( )
69+ markNeedsApply ( )
7370 }
7471 }
7572
7673 var fragmentBackgroundColor : String ? {
77- didSet {
78- applyFragmentsAndProps ( )
79- }
74+ didSet { markNeedsApply ( ) }
8075 }
8176
8277 var fontStyle : FontStyle ? {
83- didSet {
84- applyFragmentsAndProps ( )
85- }
78+ didSet { markNeedsApply ( ) }
8679 }
8780
8881 var fontFamily : String ? {
8982 didSet {
9083 nitroTextImpl. setFontFamily ( fontFamily)
91- applyFragmentsAndProps ( )
84+ markNeedsApply ( )
9285 }
9386 }
9487
9588 var textAlign : TextAlign ? {
9689 didSet {
9790 nitroTextImpl. setTextAlign ( textAlign)
98- applyFragmentsAndProps ( )
91+ markNeedsApply ( )
9992 }
10093 }
10194
10295 var textTransform : TextTransform ? {
10396 didSet {
10497 nitroTextImpl. setTextTransform ( textTransform)
105- applyFragmentsAndProps ( )
98+ markNeedsApply ( )
10699 }
107100 }
108101
109102 var textDecorationLine : TextDecorationLine ? {
110- didSet {
111- applyFragmentsAndProps ( )
112- }
103+ didSet { markNeedsApply ( ) }
113104 }
114105
115106 var textDecorationColor : String ? {
116- didSet {
117- applyFragmentsAndProps ( )
118- }
107+ didSet { markNeedsApply ( ) }
119108 }
120109
121110 var textDecorationStyle : TextDecorationStyle ? {
122- didSet {
123- applyFragmentsAndProps ( )
124- }
111+ didSet { markNeedsApply ( ) }
125112 }
126113
127114 var selectionColor : String ? {
@@ -133,21 +120,15 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
133120 }
134121
135122 var lineHeight : Double ? {
136- didSet {
137- applyFragmentsAndProps ( )
138- }
123+ didSet { markNeedsApply ( ) }
139124 }
140125
141126 var letterSpacing : Double ? {
142- didSet {
143- applyFragmentsAndProps ( )
144- }
127+ didSet { markNeedsApply ( ) }
145128 }
146129
147130 var text : String ? {
148- didSet {
149- applyFragmentsAndProps ( )
150- }
131+ didSet { markNeedsApply ( ) }
151132 }
152133
153134 var numberOfLines : Double ? {
@@ -165,35 +146,35 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
165146 var dynamicTypeRamp : DynamicTypeRamp ? {
166147 didSet {
167148 nitroTextImpl. setDynamicTypeRamp ( dynamicTypeRamp)
168- applyFragmentsAndProps ( )
149+ markNeedsApply ( )
169150 }
170151 }
171152
172153 var lineBreakStrategyIOS : LineBreakStrategyIOS ? {
173154 didSet {
174155 nitroTextImpl. setLineBreakStrategyIOS ( lineBreakStrategyIOS)
175- applyFragmentsAndProps ( )
156+ markNeedsApply ( )
176157 }
177158 }
178159
179160 var maxFontSizeMultiplier : Double ? {
180161 didSet {
181162 nitroTextImpl. setMaxFontSizeMultiplier ( maxFontSizeMultiplier)
182- applyFragmentsAndProps ( )
163+ markNeedsApply ( )
183164 }
184165 }
185166
186167 var adjustsFontSizeToFit : Bool ? {
187168 didSet {
188169 nitroTextImpl. setAdjustsFontSizeToFit ( adjustsFontSizeToFit)
189- applyFragmentsAndProps ( )
170+ markNeedsApply ( )
190171 }
191172 }
192173
193174 var minimumFontScale : Double ? {
194175 didSet {
195176 nitroTextImpl. setMinimumFontScale ( minimumFontScale)
196- applyFragmentsAndProps ( )
177+ markNeedsApply ( )
197178 }
198179 }
199180
@@ -218,6 +199,12 @@ class HybridNitroText: HybridNitroTextSpec, NitroTextViewDelegate {
218199 }
219200
220201 func afterUpdate( ) {
202+ if needsApply {
203+ applyFragmentsAndProps ( )
204+ needsApply = false
205+ }
221206 textView. setNeedsLayout ( )
222207 }
208+
209+ private func markNeedsApply( ) { needsApply = true }
223210}
0 commit comments