MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / _setNativeText

Method _setNativeText

packages/core/ui/text-base/index.ios.ts:330–364  ·  view source on GitHub ↗
(reset = false)

Source from the content-addressed store, hash-verified

328 }
329
330 _setNativeText(reset = false): void {
331 this._animationWrap(() => {
332 if (reset) {
333 const nativeView = this.nativeTextViewProtected;
334 if (nativeView instanceof UIButton) {
335 // Clear attributedText or title won't be affected.
336 nativeView.setAttributedTitleForState(null, UIControlState.Normal);
337 nativeView.setTitleForState(null, UIControlState.Normal);
338 } else {
339 // Clear attributedText or text won't be affected.
340 nativeView.attributedText = null;
341 nativeView.text = null;
342 }
343
344 return;
345 }
346
347 const letterSpacing = this.style.letterSpacing ? this.style.letterSpacing : 0;
348 const lineHeight = this.style.lineHeight ? this.style.lineHeight : 0;
349 if (this.formattedText) {
350 this.nativeTextViewProtected.nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(this.getFormattedStringDetails(this.formattedText) as any, letterSpacing, lineHeight);
351 } else {
352 // console.log('setTextDecorationAndTransform...')
353 const text = getTransformedText(isNullOrUndefined(this.text) ? '' : `${this.text}`, this.textTransform);
354 this.nativeTextViewProtected.nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text, this.style.textDecoration || '', letterSpacing, lineHeight);
355
356 if (!this.style?.color && SDK_VERSION >= 13 && UIColor.labelColor) {
357 this._setColor(UIColor.labelColor);
358 }
359 }
360 if (this.style?.textStroke) {
361 this.nativeTextViewProtected.nativeScriptSetFormattedTextStrokeColor(Length.toDevicePixels(this.style.textStroke.width, 0), this.style.textStroke.color.ios);
362 }
363 });
364 }
365
366 createFormattedTextNative(value: FormattedString) {
367 return NativeScriptUtils.createMutableStringWithDetails(<any>this.getFormattedStringDetails(value));

Calls 5

_animationWrapMethod · 0.95
_setColorMethod · 0.95
isNullOrUndefinedFunction · 0.90
getTransformedTextFunction · 0.70

Tested by

no test coverage detected