From ac75d3181cb21eb488c7eaad6687030bcd526622 Mon Sep 17 00:00:00 2001 From: Surdu Date: Thu, 10 Oct 2019 20:44:02 +0300 Subject: [PATCH 1/6] feat(textview): added maxLines property --- .../editable-text-base-common.ts | 4 ++++ .../editable-text-base.android.ts | 10 +++++++++- .../editable-text-base/editable-text-base.d.ts | 6 ++++++ .../editable-text-base.ios.ts | 17 ++++++++++++++++- .../text-view/text-view-tests-native.android.ts | 4 ++++ .../ui/text-view/text-view-tests-native.d.ts | 1 + .../ui/text-view/text-view-tests-native.ios.ts | 4 ++++ tests/app/ui/text-view/text-view-tests.ts | 12 ++++++++++++ 8 files changed, 56 insertions(+), 2 deletions(-) diff --git a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts index 46d6d306e6..589d82a081 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts @@ -16,6 +16,7 @@ export abstract class EditableTextBase extends TextBase implements EditableTextB public autocorrect: boolean; public hint: string; public maxLength: number; + public maxLines: number; public abstract dismissSoftInput(); public abstract _setInputType(inputType: number): void; @@ -67,3 +68,6 @@ hintProperty.register(EditableTextBase); export const maxLengthProperty = new Property({ name: "maxLength", defaultValue: Number.POSITIVE_INFINITY, valueConverter: parseInt }); maxLengthProperty.register(EditableTextBase); + +export const maxLinesProperty = new Property({ name: "maxLines", valueConverter: parseInt }); +maxLinesProperty.register(EditableTextBase); diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts index 23d40bd0e2..376a2a2dd4 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts @@ -2,7 +2,7 @@ import { EditableTextBase as EditableTextBaseCommon, keyboardTypeProperty, returnKeyTypeProperty, editableProperty, autocapitalizationTypeProperty, autocorrectProperty, hintProperty, resetSymbol, - textProperty, placeholderColorProperty, Color, textTransformProperty, maxLengthProperty + textProperty, placeholderColorProperty, Color, textTransformProperty, maxLengthProperty, maxLinesProperty } from "./editable-text-base-common"; import { ad } from "../../utils/utils"; @@ -461,4 +461,12 @@ export abstract class EditableTextBase extends EditableTextBaseCommon { this.nativeTextViewProtected.setFilters(newFilters); } } + + [maxLinesProperty.getDefault](): number { + return -1; + } + + [maxLinesProperty.setNative](value: number) { + this.nativeTextViewProtected.setMaxLines(value); + } } diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts index ca145aa1ae..96ae622215 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts @@ -52,6 +52,11 @@ export class EditableTextBase extends TextBase { */ maxLength: number; + /** + * Limits input to a certain number of lines. + */ + maxLines: number; + /** * Hides the soft input method, ususally a soft keyboard. */ @@ -79,6 +84,7 @@ export const autocorrectProperty: Property; export const hintProperty: Property; export const placeholderColorProperty: CssProperty; export const maxLengthProperty: Property; +export const maxLinesProperty: Property; //@private /** diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts b/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts index 4f74250fc4..8313b806ea 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts @@ -1,7 +1,7 @@ import { EditableTextBase as EditableTextBaseCommon, keyboardTypeProperty, returnKeyTypeProperty, - autocapitalizationTypeProperty, autocorrectProperty, FormattedString + autocapitalizationTypeProperty, autocorrectProperty, FormattedString, maxLinesProperty } from "./editable-text-base-common"; export * from "./editable-text-base-common"; @@ -193,6 +193,21 @@ export abstract class EditableTextBase extends EditableTextBaseCommon { this.nativeTextViewProtected.autocorrectionType = newValue; } + + [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; + } + } } export function _updateCharactersInRangeReplacementString(formattedText: FormattedString, rangeLocation: number, rangeLength: number, replacementString: string): void { diff --git a/tests/app/ui/text-view/text-view-tests-native.android.ts b/tests/app/ui/text-view/text-view-tests-native.android.ts index 25adc22904..a3d319f963 100644 --- a/tests/app/ui/text-view/text-view-tests-native.android.ts +++ b/tests/app/ui/text-view/text-view-tests-native.android.ts @@ -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(); +} diff --git a/tests/app/ui/text-view/text-view-tests-native.d.ts b/tests/app/ui/text-view/text-view-tests-native.d.ts index 93ba627088..d9baa6b2c1 100644 --- a/tests/app/ui/text-view/text-view-tests-native.d.ts +++ b/tests/app/ui/text-view/text-view-tests-native.d.ts @@ -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; diff --git a/tests/app/ui/text-view/text-view-tests-native.ios.ts b/tests/app/ui/text-view/text-view-tests-native.ios.ts index 790670e5b8..26f07331c6 100644 --- a/tests/app/ui/text-view/text-view-tests-native.ios.ts +++ b/tests/app/ui/text-view/text-view-tests-native.ios.ts @@ -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; +} diff --git a/tests/app/ui/text-view/text-view-tests.ts b/tests/app/ui/text-view/text-view-tests.ts index 5add67c0fc..935f224b00 100644 --- a/tests/app/ui/text-view/text-view-tests.ts +++ b/tests/app/ui/text-view/text-view-tests.ts @@ -346,6 +346,18 @@ export var testBindEditableToBindingConext = function () { }); }; +export var testSetMaxLines = function () { + helper.buildUIAndRunTest(_createTextViewFunc(), function (views: Array) { + var 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) { From c5e978b2d150774830833d0df4c29ff6013114ee Mon Sep 17 00:00:00 2001 From: Surdu Date: Wed, 6 Nov 2019 20:07:28 +0200 Subject: [PATCH 2/6] feat(text-view): moved implementation to TextView --- .../editable-text-base-common.ts | 4 ---- .../editable-text-base.android.ts | 10 +--------- .../editable-text-base.d.ts | 6 ------ .../editable-text-base.ios.ts | 17 +--------------- .../ui/text-view/text-view-common.ts | 10 ++++++++++ .../ui/text-view/text-view.android.ts | 15 ++++++++++---- nativescript-core/ui/text-view/text-view.d.ts | 8 ++++++++ .../ui/text-view/text-view.ios.ts | 20 ++++++++++++++++--- .../bundle-entry-points.js | 3 +++ 9 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 nativescript-core/ui/text-view/text-view-common.ts create mode 100644 tns-core-modules-package/bundle-entry-points.js diff --git a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts index 589d82a081..46d6d306e6 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts @@ -16,7 +16,6 @@ export abstract class EditableTextBase extends TextBase implements EditableTextB public autocorrect: boolean; public hint: string; public maxLength: number; - public maxLines: number; public abstract dismissSoftInput(); public abstract _setInputType(inputType: number): void; @@ -68,6 +67,3 @@ hintProperty.register(EditableTextBase); export const maxLengthProperty = new Property({ name: "maxLength", defaultValue: Number.POSITIVE_INFINITY, valueConverter: parseInt }); maxLengthProperty.register(EditableTextBase); - -export const maxLinesProperty = new Property({ name: "maxLines", valueConverter: parseInt }); -maxLinesProperty.register(EditableTextBase); diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts index 376a2a2dd4..23d40bd0e2 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts @@ -2,7 +2,7 @@ import { EditableTextBase as EditableTextBaseCommon, keyboardTypeProperty, returnKeyTypeProperty, editableProperty, autocapitalizationTypeProperty, autocorrectProperty, hintProperty, resetSymbol, - textProperty, placeholderColorProperty, Color, textTransformProperty, maxLengthProperty, maxLinesProperty + textProperty, placeholderColorProperty, Color, textTransformProperty, maxLengthProperty } from "./editable-text-base-common"; import { ad } from "../../utils/utils"; @@ -461,12 +461,4 @@ export abstract class EditableTextBase extends EditableTextBaseCommon { this.nativeTextViewProtected.setFilters(newFilters); } } - - [maxLinesProperty.getDefault](): number { - return -1; - } - - [maxLinesProperty.setNative](value: number) { - this.nativeTextViewProtected.setMaxLines(value); - } } diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts index 96ae622215..ca145aa1ae 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts @@ -52,11 +52,6 @@ export class EditableTextBase extends TextBase { */ maxLength: number; - /** - * Limits input to a certain number of lines. - */ - maxLines: number; - /** * Hides the soft input method, ususally a soft keyboard. */ @@ -84,7 +79,6 @@ export const autocorrectProperty: Property; export const hintProperty: Property; export const placeholderColorProperty: CssProperty; export const maxLengthProperty: Property; -export const maxLinesProperty: Property; //@private /** diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts b/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts index 8313b806ea..4f74250fc4 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.ios.ts @@ -1,7 +1,7 @@ import { EditableTextBase as EditableTextBaseCommon, keyboardTypeProperty, returnKeyTypeProperty, - autocapitalizationTypeProperty, autocorrectProperty, FormattedString, maxLinesProperty + autocapitalizationTypeProperty, autocorrectProperty, FormattedString } from "./editable-text-base-common"; export * from "./editable-text-base-common"; @@ -193,21 +193,6 @@ export abstract class EditableTextBase extends EditableTextBaseCommon { this.nativeTextViewProtected.autocorrectionType = newValue; } - - [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; - } - } } export function _updateCharactersInRangeReplacementString(formattedText: FormattedString, rangeLocation: number, rangeLength: number, replacementString: string): void { diff --git a/nativescript-core/ui/text-view/text-view-common.ts b/nativescript-core/ui/text-view/text-view-common.ts new file mode 100644 index 0000000000..83e1636a56 --- /dev/null +++ b/nativescript-core/ui/text-view/text-view-common.ts @@ -0,0 +1,10 @@ +import { TextView as TextViewDefinition } from "."; +import { EditableTextBase } from "../editable-text-base"; +import { Property } from "../text-base"; + +export class TextViewBase extends EditableTextBase implements TextViewDefinition { + public maxLines: number; +} + +export const maxLinesProperty = new Property({ name: "maxLines", valueConverter: parseInt }); +maxLinesProperty.register(EditableTextBase); diff --git a/nativescript-core/ui/text-view/text-view.android.ts b/nativescript-core/ui/text-view/text-view.android.ts index 97323a9637..4b19dc4fc0 100644 --- a/nativescript-core/ui/text-view/text-view.android.ts +++ b/nativescript-core/ui/text-view/text-view.android.ts @@ -1,11 +1,10 @@ -import { TextView as TextViewDefinition } from "."; -import { EditableTextBase, CSSType } from "../editable-text-base"; +import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from "./text-view-common"; +import { CSSType } from "../editable-text-base"; export * from "../text-base"; @CSSType("TextView") -export class TextView extends EditableTextBase implements TextViewDefinition { - +export class TextView extends TextViewBaseCommon { public _configureEditText(editText: android.widget.EditText) { editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE | android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); editText.setGravity(android.view.Gravity.TOP | android.view.Gravity.START); @@ -15,6 +14,14 @@ export class TextView extends EditableTextBase implements TextViewDefinition { super.resetNativeView(); this.nativeTextViewProtected.setGravity(android.view.Gravity.TOP | android.view.Gravity.START); } + + [maxLinesProperty.getDefault](): number { + return -1; + } + + [maxLinesProperty.setNative](value: number) { + this.nativeTextViewProtected.setMaxLines(value); + } } TextView.prototype.recycleNativeView = "auto"; diff --git a/nativescript-core/ui/text-view/text-view.d.ts b/nativescript-core/ui/text-view/text-view.d.ts index 7480d357d0..9dcecb58f9 100644 --- a/nativescript-core/ui/text-view/text-view.d.ts +++ b/nativescript-core/ui/text-view/text-view.d.ts @@ -4,6 +4,7 @@ */ /** */ import { EditableTextBase } from "../editable-text-base"; +import { Property } from "../text-base"; /** * Represents an editable multiline text view. @@ -18,4 +19,11 @@ export class TextView extends EditableTextBase { * Gets the native iOS [UITextView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ ios: any /* UITextView */; + + /** + * Limits input to a certain number of lines. + */ + maxLines: number; } + +export const maxLinesProperty: Property; diff --git a/nativescript-core/ui/text-view/text-view.ios.ts b/nativescript-core/ui/text-view/text-view.ios.ts index a45d643d90..d65b84eebe 100644 --- a/nativescript-core/ui/text-view/text-view.ios.ts +++ b/nativescript-core/ui/text-view/text-view.ios.ts @@ -1,7 +1,7 @@ import { ScrollEventData } from "../scroll-view"; -import { TextView as TextViewDefinition } from "."; +import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from "./text-view-common"; import { - EditableTextBase, editableProperty, hintProperty, textProperty, colorProperty, placeholderColorProperty, + editableProperty, hintProperty, textProperty, colorProperty, placeholderColorProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, Length, _updateCharactersInRangeReplacementString, Color, layout, @@ -110,7 +110,7 @@ class NoScrollAnimationUITextView extends UITextView { } @CSSType("TextView") -export class TextView extends EditableTextBase implements TextViewDefinition { +export class TextView extends TextViewBaseCommon { nativeViewProtected: UITextView; private _delegate: UITextViewDelegateImpl; private _isShowingHint: boolean; @@ -333,6 +333,20 @@ export class TextView extends EditableTextBase implements TextViewDefinition { let left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); this.nativeTextViewProtected.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, 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"; diff --git a/tns-core-modules-package/bundle-entry-points.js b/tns-core-modules-package/bundle-entry-points.js new file mode 100644 index 0000000000..bae275f1d4 --- /dev/null +++ b/tns-core-modules-package/bundle-entry-points.js @@ -0,0 +1,3 @@ +Object.defineProperty(exports, "__esModule", { value: true }); +require("@nativescript/core/bundle-entry-points"); +//# sourceMappingURL=bundle-entry-points.js.map \ No newline at end of file From 89fd50b4a39e1305969d959c3ddf10d512de24f7 Mon Sep 17 00:00:00 2001 From: Surdu Date: Thu, 12 Dec 2019 15:50:15 +0200 Subject: [PATCH 3/6] feat(text-view): changes based on CR --- api-reports/NativeScript.api.md | 74 ++++++++++--------- .../bundle-entry-points.js | 3 - 2 files changed, 38 insertions(+), 39 deletions(-) delete mode 100644 tns-core-modules-package/bundle-entry-points.js diff --git a/api-reports/NativeScript.api.md b/api-reports/NativeScript.api.md index d2d7d93604..bf14dcb401 100644 --- a/api-reports/NativeScript.api.md +++ b/api-reports/NativeScript.api.md @@ -170,16 +170,6 @@ export class AndroidApplication extends Observable { nativeApp: any /* android.app.Application */; - on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); - - on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: "activityResumed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); on(event: "activityStopped", callback: (args: AndroidActivityEventData) => void, thisArg?: any); @@ -194,6 +184,16 @@ export class AndroidApplication extends Observable { on(event: "activityRequestPermissions", callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + + on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + orientation: "portrait" | "landscape" | "unknown"; packageName: string; @@ -404,15 +404,15 @@ export class ChangeType { // @public export class Color { constructor(knownColor: string); + constructor(alpha: number, red: number, green: number, blue: number); constructor(hex: string); constructor(argb: number); - constructor(alpha: number, red: number, green: number, blue: number); public a: number; android: number; public argb: number; public b: number; - public equals(value: Color): boolean; public static equals(value1: Color, value2: Color): boolean; + public equals(value: Color): boolean; public g: number; public hex: string; ios: any /* UIColor */; @@ -1112,9 +1112,9 @@ export class ImageCache extends Observable { enqueue(request: DownloadRequest); get(key: string): any; maxRequests: number; + on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any); on(eventNames: string, callback: (args: EventData) => void, thisArg?: any); on(event: "downloaded", callback: (args: DownloadedData) => void, thisArg?: any); - on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any); // (undocumented) _onDownloadCompleted(key: string, image: any); // (undocumented) @@ -1144,11 +1144,11 @@ export class ImageSource { static fromBase64Sync(source: string): ImageSource; - static fromData(data: any): Promise; - // @deprecated (undocumented) fromData(data: any): Promise; + static fromData(data: any): Promise; + static fromDataSync(data: any): ImageSource; static fromFile(path: string): Promise; @@ -1372,10 +1372,10 @@ export class ListView extends View { itemTemplates: string | Array; itemTemplateSelector: string | ((item: any, index: number, items: any) => string); public static loadMoreItemsEvent: string; - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any); on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any); - on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any); refresh(); rowHeight: Length; scrollToIndex(index: number); @@ -1482,10 +1482,10 @@ export class Observable { off(eventNames: string, callback?: any, thisArg?: any); - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + once(event: string, callback: (data: EventData) => void, thisArg?: any); public static propertyChangeEvent: string; @@ -1506,10 +1506,10 @@ export class ObservableArray extends Observable { public static changeEvent: string; - concat(...items: U[]): T[]; - concat(...items: T[]): T[]; + concat(...items: U[]): T[]; + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; @@ -1558,10 +1558,10 @@ export class ObservableArray extends Observable { sort(compareFn?: (a: T, b: T) => number): T[]; - splice(start: number): T[]; - splice(start: number, deleteCount: number, ...items: T[]): T[]; + splice(start: number): T[]; + // (undocumented) toLocaleString(): string; @@ -1610,14 +1610,14 @@ export class Page extends ContentView { public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; - public on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void; - public on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any): void; public on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; public on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void; + public onNavigatedFrom(isBackNavigation: boolean): void; public onNavigatedTo(isBackNavigation: boolean): void; @@ -1779,10 +1779,10 @@ export class ScrollView extends ContentView { isScrollEnabled: boolean; - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + // (undocumented) _onOrientationChanged(); @@ -1816,11 +1816,11 @@ export class SearchBar extends View { ios: any /* UISearchBar */; - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "close", callback: (args: EventData) => void, thisArg?: any); on(event: "submit", callback: (args: EventData) => void, thisArg?: any); - on(event: "close", callback: (args: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); public static submitEvent: string; @@ -2466,6 +2466,8 @@ export class TextView extends EditableTextBase { android: any /* android.widget.EditText */; ios: any /* UITextView */; + + maxLines: number; } // @public @@ -2685,12 +2687,12 @@ export abstract class View extends ViewBase { // (undocumented) _modalParent?: View; off(eventNames: string | GestureTypes, callback?: (args: EventData) => void, thisArg?: any); - on(eventNames: string | GestureTypes, callback: (args: EventData) => void, thisArg?: any); - on(event: "loaded", callback: (args: EventData) => void, thisArg?: any); - on(event: "unloaded", callback: (args: EventData) => void, thisArg?: any); - on(event: "androidBackPressed", callback: (args: EventData) => void, thisArg?: any); on(event: "showingModally", callback: (args: ShownModallyData) => void, thisArg?: any): void; + on(event: "androidBackPressed", callback: (args: EventData) => void, thisArg?: any); on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any); + on(event: "loaded", callback: (args: EventData) => void, thisArg?: any); + on(event: "unloaded", callback: (args: EventData) => void, thisArg?: any); + on(eventNames: string | GestureTypes, callback: (args: EventData) => void, thisArg?: any); _onAttachedToWindow(): void; onBackPressed(): boolean; _onDetachedFromWindow(): void; @@ -2914,8 +2916,8 @@ export abstract class ViewBase extends Observable { // (undocumented) _setupAsRootView(context: any): void; _setupUI(context: any /* android.content.Context */, atIndex?: number): void; - showModal(moduleName: string, modalOptions: ShowModalOptions): ViewBase; showModal(view: ViewBase, modalOptions: ShowModalOptions): ViewBase; + showModal(moduleName: string, modalOptions: ShowModalOptions): ViewBase; public readonly style: Style; // (undocumented) public _styleScope: any; @@ -2958,13 +2960,13 @@ export class WebView extends View { public static loadStartedEvent: string; - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - // Warning: (ae-forgotten-export) The symbol "LoadEventData" needs to be exported by the entry point index.d.ts on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any); on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + reload(); src: string; diff --git a/tns-core-modules-package/bundle-entry-points.js b/tns-core-modules-package/bundle-entry-points.js deleted file mode 100644 index bae275f1d4..0000000000 --- a/tns-core-modules-package/bundle-entry-points.js +++ /dev/null @@ -1,3 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -require("@nativescript/core/bundle-entry-points"); -//# sourceMappingURL=bundle-entry-points.js.map \ No newline at end of file From ca7e6c4d6333419a35933b6383a8c01d864782f5 Mon Sep 17 00:00:00 2001 From: Surdu Date: Fri, 20 Dec 2019 23:44:35 +0200 Subject: [PATCH 4/6] feat(text-view): Normalize behavior in between android and iOS --- nativescript-core/ui/text-view/text-view.android.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nativescript-core/ui/text-view/text-view.android.ts b/nativescript-core/ui/text-view/text-view.android.ts index 4b19dc4fc0..8eb73e41ad 100644 --- a/nativescript-core/ui/text-view/text-view.android.ts +++ b/nativescript-core/ui/text-view/text-view.android.ts @@ -16,10 +16,15 @@ export class TextView extends TextViewBaseCommon { } [maxLinesProperty.getDefault](): number { - return -1; + return 0; } [maxLinesProperty.setNative](value: number) { + if (value <= 0) { + this.nativeTextViewProtected.setMaxLines(Number.MAX_VALUE); + return; + } + this.nativeTextViewProtected.setMaxLines(value); } } From b5e56c817cf6b0dc3f2760ef711246427cdbe93c Mon Sep 17 00:00:00 2001 From: Vasil Trifonov Date: Tue, 14 Jan 2020 11:08:00 +0200 Subject: [PATCH 5/6] chore: updated NativeScript.api.md --- api-reports/NativeScript.api.md | 72 ++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/api-reports/NativeScript.api.md b/api-reports/NativeScript.api.md index bf14dcb401..e417abea2f 100644 --- a/api-reports/NativeScript.api.md +++ b/api-reports/NativeScript.api.md @@ -170,6 +170,16 @@ export class AndroidApplication extends Observable { nativeApp: any /* android.app.Application */; + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + + on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityResumed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); on(event: "activityStopped", callback: (args: AndroidActivityEventData) => void, thisArg?: any); @@ -184,16 +194,6 @@ export class AndroidApplication extends Observable { on(event: "activityRequestPermissions", callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any); - on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); - - on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - - on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); - orientation: "portrait" | "landscape" | "unknown"; packageName: string; @@ -404,15 +404,15 @@ export class ChangeType { // @public export class Color { constructor(knownColor: string); - constructor(alpha: number, red: number, green: number, blue: number); constructor(hex: string); constructor(argb: number); + constructor(alpha: number, red: number, green: number, blue: number); public a: number; android: number; public argb: number; public b: number; - public static equals(value1: Color, value2: Color): boolean; public equals(value: Color): boolean; + public static equals(value1: Color, value2: Color): boolean; public g: number; public hex: string; ios: any /* UIColor */; @@ -1112,9 +1112,9 @@ export class ImageCache extends Observable { enqueue(request: DownloadRequest); get(key: string): any; maxRequests: number; - on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any); on(eventNames: string, callback: (args: EventData) => void, thisArg?: any); on(event: "downloaded", callback: (args: DownloadedData) => void, thisArg?: any); + on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any); // (undocumented) _onDownloadCompleted(key: string, image: any); // (undocumented) @@ -1144,11 +1144,11 @@ export class ImageSource { static fromBase64Sync(source: string): ImageSource; + static fromData(data: any): Promise; + // @deprecated (undocumented) fromData(data: any): Promise; - static fromData(data: any): Promise; - static fromDataSync(data: any): ImageSource; static fromFile(path: string): Promise; @@ -1372,10 +1372,10 @@ export class ListView extends View { itemTemplates: string | Array; itemTemplateSelector: string | ((item: any, index: number, items: any) => string); public static loadMoreItemsEvent: string; - on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any); - on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any); on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any); on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any); + on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any); refresh(); rowHeight: Length; scrollToIndex(index: number); @@ -1482,10 +1482,10 @@ export class Observable { off(eventNames: string, callback?: any, thisArg?: any); - on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any); - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any); + once(event: string, callback: (data: EventData) => void, thisArg?: any); public static propertyChangeEvent: string; @@ -1506,10 +1506,10 @@ export class ObservableArray extends Observable { public static changeEvent: string; - concat(...items: T[]): T[]; - concat(...items: U[]): T[]; + concat(...items: T[]): T[]; + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; @@ -1558,10 +1558,10 @@ export class ObservableArray extends Observable { sort(compareFn?: (a: T, b: T) => number): T[]; - splice(start: number, deleteCount: number, ...items: T[]): T[]; - splice(start: number): T[]; + splice(start: number, deleteCount: number, ...items: T[]): T[]; + // (undocumented) toLocaleString(): string; @@ -1610,14 +1610,14 @@ export class Page extends ContentView { public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + public on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any): void; public on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; public on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; - public on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void; - public onNavigatedFrom(isBackNavigation: boolean): void; public onNavigatedTo(isBackNavigation: boolean): void; @@ -1779,10 +1779,10 @@ export class ScrollView extends ContentView { isScrollEnabled: boolean; - on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any); - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any); + // (undocumented) _onOrientationChanged(); @@ -1816,11 +1816,11 @@ export class SearchBar extends View { ios: any /* UISearchBar */; - on(event: "close", callback: (args: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); on(event: "submit", callback: (args: EventData) => void, thisArg?: any); - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "close", callback: (args: EventData) => void, thisArg?: any); public static submitEvent: string; @@ -2687,12 +2687,12 @@ export abstract class View extends ViewBase { // (undocumented) _modalParent?: View; off(eventNames: string | GestureTypes, callback?: (args: EventData) => void, thisArg?: any); - on(event: "showingModally", callback: (args: ShownModallyData) => void, thisArg?: any): void; - on(event: "androidBackPressed", callback: (args: EventData) => void, thisArg?: any); - on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any); + on(eventNames: string | GestureTypes, callback: (args: EventData) => void, thisArg?: any); on(event: "loaded", callback: (args: EventData) => void, thisArg?: any); on(event: "unloaded", callback: (args: EventData) => void, thisArg?: any); - on(eventNames: string | GestureTypes, callback: (args: EventData) => void, thisArg?: any); + on(event: "androidBackPressed", callback: (args: EventData) => void, thisArg?: any); + on(event: "showingModally", callback: (args: ShownModallyData) => void, thisArg?: any): void; + on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any); _onAttachedToWindow(): void; onBackPressed(): boolean; _onDetachedFromWindow(): void; @@ -2916,8 +2916,8 @@ export abstract class ViewBase extends Observable { // (undocumented) _setupAsRootView(context: any): void; _setupUI(context: any /* android.content.Context */, atIndex?: number): void; - showModal(view: ViewBase, modalOptions: ShowModalOptions): ViewBase; showModal(moduleName: string, modalOptions: ShowModalOptions): ViewBase; + showModal(view: ViewBase, modalOptions: ShowModalOptions): ViewBase; public readonly style: Style; // (undocumented) public _styleScope: any; @@ -2960,13 +2960,13 @@ export class WebView extends View { public static loadStartedEvent: string; + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + // Warning: (ae-forgotten-export) The symbol "LoadEventData" needs to be exported by the entry point index.d.ts on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any); on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any); - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - reload(); src: string; From 8f69aba5c172f90d29d3a34a8a4c6b531456cfbb Mon Sep 17 00:00:00 2001 From: Vasil Trifonov Date: Tue, 14 Jan 2020 16:04:27 +0200 Subject: [PATCH 6/6] chore: add new line before return --- nativescript-core/ui/text-view/text-view.android.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/nativescript-core/ui/text-view/text-view.android.ts b/nativescript-core/ui/text-view/text-view.android.ts index 8eb73e41ad..d62fbe7db4 100644 --- a/nativescript-core/ui/text-view/text-view.android.ts +++ b/nativescript-core/ui/text-view/text-view.android.ts @@ -22,6 +22,7 @@ export class TextView extends TextViewBaseCommon { [maxLinesProperty.setNative](value: number) { if (value <= 0) { this.nativeTextViewProtected.setMaxLines(Number.MAX_VALUE); + return; }