Files
NativeScript/text/formatted-string.ios.ts
Hristo Deshev 77838ae9c6 Change from "classic" TS 1.6 imports to the default resolution scheme.
- Use relative imports in place of most of our absolute ones.
- Add "private" ambient modules for modules that we need to import using
an absolute path (e.g. when app/.../test-something.ts needs to import
ui/styling/style-scope)
2015-09-29 16:25:49 +03:00

30 lines
1.2 KiB
TypeScript

import formattedStringCommon = require("./formatted-string-common");
import spanModule = require("text/span");
global.moduleMerge(formattedStringCommon, exports);
export class FormattedString extends formattedStringCommon.FormattedString {
public createFormattedStringCore() {
var mas = NSMutableAttributedString.alloc().init();
var i;
var spanStart = 0;
var spanLength = 0;
var spanText = "";
for (i = 0; i < this.spans.length; i++) {
var span = <spanModule.Span>this.spans.getItem(i);
spanText = span.text || "";
spanLength = spanText.length;
span.updateSpanModifiers(this);
var attrDict = NSMutableDictionary.alloc().init();
var p;
for (p = 0; p < span.spanModifiers.length; p++) {
attrDict.setObjectForKey(span.spanModifiers[p].value, span.spanModifiers[p].key);
}
var nsAttributedString = NSMutableAttributedString.alloc().initWithStringAttributes(String(spanText), attrDict);
mas.insertAttributedStringAtIndex(nsAttributedString, spanStart);
spanStart += spanLength;
}
this._formattedText = mas;
}
}