mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): maxLines support for all text components (#9884)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from './text-view-common';
|
||||
import { TextViewBase as TextViewBaseCommon } from './text-view-common';
|
||||
import { CSSType } from '../core/view';
|
||||
|
||||
export * from '../text-base';
|
||||
@@ -15,20 +15,6 @@ export class TextView extends TextViewBaseCommon {
|
||||
this.nativeTextViewProtected.setGravity(android.view.Gravity.TOP | android.view.Gravity.START);
|
||||
}
|
||||
|
||||
[maxLinesProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
[maxLinesProperty.setNative](value: number) {
|
||||
if (value <= 0) {
|
||||
this.nativeTextViewProtected.setMaxLines(Number.MAX_VALUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.nativeTextViewProtected.setMaxLines(value);
|
||||
}
|
||||
|
||||
public _onReturnPress() {
|
||||
this.notify({ eventName: TextView.returnPressEvent, object: this });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ScrollEventData } from '../scroll-view';
|
||||
import { textProperty } from '../text-base';
|
||||
import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from './text-view-common';
|
||||
import { TextViewBase as TextViewBaseCommon } from './text-view-common';
|
||||
import { editableProperty, hintProperty, placeholderColorProperty, _updateCharactersInRangeReplacementString } from '../editable-text-base';
|
||||
import { CoreTypes } from '../../core-types';
|
||||
import { CSSType } from '../core/view';
|
||||
@@ -408,18 +408,6 @@ export class TextView extends TextViewBaseCommon {
|
||||
right: inset.right,
|
||||
};
|
||||
}
|
||||
[maxLinesProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
[maxLinesProperty.setNative](value: number) {
|
||||
this.nativeTextViewProtected.textContainer.maximumNumberOfLines = value;
|
||||
|
||||
if (value !== 0) {
|
||||
this.nativeTextViewProtected.textContainer.lineBreakMode = NSLineBreakMode.ByTruncatingTail;
|
||||
} else {
|
||||
this.nativeTextViewProtected.textContainer.lineBreakMode = NSLineBreakMode.ByWordWrapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextView.prototype.recycleNativeView = 'auto';
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import { TextView as TextViewDefinition } from '.';
|
||||
import { EditableTextBase } from '../editable-text-base';
|
||||
import { Property } from '../core/properties';
|
||||
|
||||
export class TextViewBase extends EditableTextBase implements TextViewDefinition {
|
||||
public static returnPressEvent = 'returnPress';
|
||||
public maxLines: number;
|
||||
}
|
||||
|
||||
export const maxLinesProperty = new Property<EditableTextBase, number>({
|
||||
name: 'maxLines',
|
||||
valueConverter: parseInt,
|
||||
});
|
||||
maxLinesProperty.register(EditableTextBase);
|
||||
}
|
||||
Reference in New Issue
Block a user