Files
NativeScript/tns-core-modules/ui/label/label.android.ts
Alexander Vakrilov e33eca63d6 Implement custom measure for ios btn when textWrap is true (#4326)
Implement custom measure for ios btn when textWrap is true
2017-06-08 10:29:50 +03:00

45 lines
1.3 KiB
TypeScript

import { Label as LabelDefinition } from ".";
import { TextBase, WhiteSpace, whiteSpaceProperty, booleanConverter } from "../text-base";
import { profile } from "../../profiling";
export * from "../text-base";
let TextView: typeof android.widget.TextView;
export class Label extends TextBase implements LabelDefinition {
nativeView: android.widget.TextView;
get textWrap(): boolean {
return this.style.whiteSpace === "normal";
}
set textWrap(value: boolean) {
if (typeof value === "string") {
value = booleanConverter(value)
}
this.style.whiteSpace = value ? "normal" : "nowrap";
}
@profile
public createNativeView() {
if (!TextView) {
TextView = android.widget.TextView;
}
return new TextView(this._context);
}
public initNativeView(): void {
super.initNativeView();
const textView = this.nativeView;
textView.setSingleLine(true);
textView.setEllipsize(android.text.TextUtils.TruncateAt.END);
}
[whiteSpaceProperty.setNative](value: WhiteSpace) {
// Label initial value is no-wrap. set in initNativeView
const newValue = value === "initial" ? "nowrap" : value;
super[whiteSpaceProperty.setNative](newValue);
}
}
// Label.prototype.recycleNativeView = true;