mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(textview): added maxLines property (#7943)
* feat(textview): added maxLines property * feat(text-view): moved implementation to TextView * feat(text-view): changes based on CR * feat(text-view): Normalize behavior in between android and iOS * chore: updated NativeScript.api.md * chore: add new line before return Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com> Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:
@@ -63,3 +63,7 @@ export function typeTextNatively(textView: textViewModule.TextView, text: string
|
||||
textView.android.setText(text);
|
||||
textView.android.clearFocus();
|
||||
}
|
||||
|
||||
export function getNativeMaxLines(textView: textViewModule.TextView): number {
|
||||
return textView.android.getMaxLines();
|
||||
}
|
||||
|
||||
@@ -10,3 +10,4 @@ export declare function getNativeColor(textView: textViewModule.TextView): color
|
||||
export declare function getNativeBackgroundColor(textView: textViewModule.TextView): colorModule.Color;
|
||||
export declare function getNativeTextAlignment(textView: textViewModule.TextView): string;
|
||||
export declare function typeTextNatively(textView: textViewModule.TextView, text: string): void;
|
||||
export declare function getNativeMaxLines(textView: textViewModule.TextView): number;
|
||||
|
||||
@@ -51,3 +51,7 @@ export function typeTextNatively(textView: textViewModule.TextView, text: string
|
||||
// Setting the text will not trigger the delegate method, so we have to do it by hand.
|
||||
textView.ios.delegate.textViewDidEndEditing(textView.ios);
|
||||
}
|
||||
|
||||
export function getNativeMaxLines(textView: textViewModule.TextView): number {
|
||||
return textView.ios.textContainer.maximumNumberOfLines;
|
||||
}
|
||||
|
||||
@@ -346,6 +346,18 @@ export var testBindEditableToBindingConext = function () {
|
||||
});
|
||||
};
|
||||
|
||||
export var testSetMaxLines = function () {
|
||||
helper.buildUIAndRunTest(_createTextViewFunc(), function (views: Array<viewModule.View>) {
|
||||
var textView = <textViewModule.TextView>views[0];
|
||||
|
||||
textView.maxLines = 3;
|
||||
|
||||
var expectedValue = 3;
|
||||
var actualValue = textViewTestsNative.getNativeMaxLines(textView);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
});
|
||||
};
|
||||
|
||||
var expectedFontSize = 42;
|
||||
export var testLocalFontSizeFromCss = function () {
|
||||
helper.buildUIAndRunTest(_createTextViewFunc(), function (views: Array<viewModule.View>) {
|
||||
|
||||
Reference in New Issue
Block a user