Merge branch 'master' into merge-6.2.1-release-in-master

This commit is contained in:
Manol Donev
2019-11-20 10:21:48 +02:00
committed by GitHub
6 changed files with 111 additions and 45 deletions

View File

@ -1159,7 +1159,7 @@ A full list of breaking changes could be found [here](https://github.com/NativeS
- [(#2834)](https://github.com/NativeScript/NativeScript/issues/2834) Animations: scale() syntax does not support only one argument - [(#2834)](https://github.com/NativeScript/NativeScript/issues/2834) Animations: scale() syntax does not support only one argument
- [(#2813)](https://github.com/NativeScript/NativeScript/issues/2813) The Camera module in Android doesn't handle pemissions for you - [(#2813)](https://github.com/NativeScript/NativeScript/issues/2813) The Camera module in Android doesn't handle permissions for you
- [(#2789)](https://github.com/NativeScript/NativeScript/issues/2789) CSS border-width causes text to overflow TextView - [(#2789)](https://github.com/NativeScript/NativeScript/issues/2789) CSS border-width causes text to overflow TextView

View File

@ -170,6 +170,16 @@ export class AndroidApplication extends Observable {
nativeApp: any /* android.app.Application */; 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: "activityResumed", callback: (args: AndroidActivityEventData) => void, thisArg?: any);
on(event: "activityStopped", 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(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"; orientation: "portrait" | "landscape" | "unknown";
packageName: string; packageName: string;
@ -404,15 +404,15 @@ export class ChangeType {
// @public // @public
export class Color { export class Color {
constructor(knownColor: string); constructor(knownColor: string);
constructor(alpha: number, red: number, green: number, blue: number);
constructor(hex: string); constructor(hex: string);
constructor(argb: number); constructor(argb: number);
constructor(alpha: number, red: number, green: number, blue: number);
public a: number; public a: number;
android: number; android: number;
public argb: number; public argb: number;
public b: number; public b: number;
public static equals(value1: Color, value2: Color): boolean;
public equals(value: Color): boolean; public equals(value: Color): boolean;
public static equals(value1: Color, value2: Color): boolean;
public g: number; public g: number;
public hex: string; public hex: string;
ios: any /* UIColor */; ios: any /* UIColor */;
@ -1112,9 +1112,9 @@ export class ImageCache extends Observable {
enqueue(request: DownloadRequest); enqueue(request: DownloadRequest);
get(key: string): any; get(key: string): any;
maxRequests: number; maxRequests: number;
on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any);
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any); on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
on(event: "downloaded", callback: (args: DownloadedData) => void, thisArg?: any); on(event: "downloaded", callback: (args: DownloadedData) => void, thisArg?: any);
on(event: "downloadError", callback: (args: DownloadError) => void, thisArg?: any);
// (undocumented) // (undocumented)
_onDownloadCompleted(key: string, image: any); _onDownloadCompleted(key: string, image: any);
// (undocumented) // (undocumented)
@ -1144,11 +1144,11 @@ export class ImageSource {
static fromBase64Sync(source: string): ImageSource; static fromBase64Sync(source: string): ImageSource;
static fromData(data: any): Promise<ImageSource>;
// @deprecated (undocumented) // @deprecated (undocumented)
fromData(data: any): Promise<boolean>; fromData(data: any): Promise<boolean>;
static fromData(data: any): Promise<ImageSource>;
static fromDataSync(data: any): ImageSource; static fromDataSync(data: any): ImageSource;
static fromFile(path: string): Promise<ImageSource>; static fromFile(path: string): Promise<ImageSource>;
@ -1372,10 +1372,10 @@ export class ListView extends View {
itemTemplates: string | Array<KeyedTemplate>; itemTemplates: string | Array<KeyedTemplate>;
itemTemplateSelector: string | ((item: any, index: number, items: any) => string); itemTemplateSelector: string | ((item: any, index: number, items: any) => string);
public static loadMoreItemsEvent: 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(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: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any);
on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any);
refresh(); refresh();
rowHeight: Length; rowHeight: Length;
scrollToIndex(index: number); scrollToIndex(index: number);
@ -1482,10 +1482,10 @@ export class Observable {
off(eventNames: string, callback?: any, thisArg?: any); 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(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); once(event: string, callback: (data: EventData) => void, thisArg?: any);
public static propertyChangeEvent: string; public static propertyChangeEvent: string;
@ -1506,10 +1506,10 @@ export class ObservableArray<T> extends Observable {
public static changeEvent: string; public static changeEvent: string;
concat(...items: T[]): T[];
concat<U extends T[]>(...items: U[]): T[]; concat<U extends T[]>(...items: U[]): T[];
concat(...items: T[]): T[];
every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
@ -1558,10 +1558,10 @@ export class ObservableArray<T> extends Observable {
sort(compareFn?: (a: T, b: T) => number): T[]; sort(compareFn?: (a: T, b: T) => number): T[];
splice(start: number, deleteCount: number, ...items: T[]): T[];
splice(start: number): T[]; splice(start: number): T[];
splice(start: number, deleteCount: number, ...items: T[]): T[];
// (undocumented) // (undocumented)
toLocaleString(): string; toLocaleString(): string;
@ -1610,14 +1610,14 @@ export class Page extends ContentView {
public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; 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: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any): void;
public on(event: "navigatingFrom", 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: "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 onNavigatedFrom(isBackNavigation: boolean): void;
public onNavigatedTo(isBackNavigation: boolean): void; public onNavigatedTo(isBackNavigation: boolean): void;
@ -1779,10 +1779,10 @@ export class ScrollView extends ContentView {
isScrollEnabled: boolean; isScrollEnabled: boolean;
on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any);
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any);
// (undocumented) // (undocumented)
_onOrientationChanged(); _onOrientationChanged();
@ -1816,11 +1816,11 @@ export class SearchBar extends View {
ios: any /* UISearchBar */; 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(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; public static submitEvent: string;
@ -2304,6 +2304,9 @@ export class TabStripItem extends View {
image: Image; image: Image;
// (undocumented)
_index: number;
label: Label; label: Label;
on(eventNames: string, callback: (data: EventData) => void); on(eventNames: string, callback: (data: EventData) => void);
@ -2678,12 +2681,12 @@ export abstract class View extends ViewBase {
// (undocumented) // (undocumented)
_modalParent?: View; _modalParent?: View;
off(eventNames: string | GestureTypes, callback?: (args: EventData) => void, thisArg?: any); off(eventNames: string | GestureTypes, callback?: (args: EventData) => void, thisArg?: any);
on(event: "showingModally", callback: (args: ShownModallyData) => void, thisArg?: any): void; on(eventNames: string | GestureTypes, callback: (args: EventData) => void, thisArg?: any);
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: "loaded", callback: (args: EventData) => void, thisArg?: any);
on(event: "unloaded", 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; _onAttachedToWindow(): void;
onBackPressed(): boolean; onBackPressed(): boolean;
_onDetachedFromWindow(): void; _onDetachedFromWindow(): void;
@ -2949,13 +2952,13 @@ export class WebView extends View {
public static loadStartedEvent: string; 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 // 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: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any);
on(event: "loadStarted", 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(); reload();
src: string; src: string;

View File

@ -83,10 +83,15 @@ export interface ShowModalOptions {
} }
android?: { android?: {
/** /**
* @deprecated Use ShowModalOptions.cancelable instead.
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode. * An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
*/ */
cancelable?: boolean cancelable?: boolean
} }
/**
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.
*/
cancelable?: boolean
} }
export abstract class ViewBase extends Observable { export abstract class ViewBase extends Observable {

View File

@ -640,12 +640,21 @@ export class View extends ViewCommon {
args.putInt(DOMID, this._domId); args.putInt(DOMID, this._domId);
df.setArguments(args); df.setArguments(args);
let cancelable = true;
if (options.android && (<any>options).android.cancelable !== undefined) {
cancelable = !!(<any>options).android.cancelable;
console.log("ShowModalOptions.android.cancelable is deprecated. Use ShowModalOptions.cancelable instead.");
}
cancelable = options.cancelable !== undefined ? !!options.cancelable : cancelable;
const dialogOptions: DialogOptions = { const dialogOptions: DialogOptions = {
owner: this, owner: this,
fullscreen: !!options.fullscreen, fullscreen: !!options.fullscreen,
animated: !!options.animated, animated: !!options.animated,
stretched: !!options.stretched, stretched: !!options.stretched,
cancelable: options.android ? !!options.android.cancelable : true, cancelable: cancelable,
shownCallback: () => this._raiseShownModallyEvent(), shownCallback: () => this._raiseShownModallyEvent(),
dismissCallback: () => this.closeModal() dismissCallback: () => this.closeModal()
}; };

View File

@ -30,6 +30,7 @@ export class View extends ViewCommon {
nativeViewProtected: UIView; nativeViewProtected: UIView;
viewController: UIViewController; viewController: UIViewController;
private _popoverPresentationDelegate: ios.UIPopoverPresentationControllerDelegateImp; private _popoverPresentationDelegate: ios.UIPopoverPresentationControllerDelegateImp;
private _adaptivePresentationDelegate: ios.UIAdaptivePresentationControllerDelegateImp;
private _isLaidOut = false; private _isLaidOut = false;
private _hasTransfrom = false; private _hasTransfrom = false;
@ -422,14 +423,19 @@ export class View extends ViewCommon {
controller.modalPresentationStyle = presentationStyle; controller.modalPresentationStyle = presentationStyle;
if (presentationStyle === UIModalPresentationStyle.Popover) { if (presentationStyle === UIModalPresentationStyle.Popover) {
const popoverPresentationController = controller.popoverPresentationController; this._setupPopoverControllerDelegate(controller, parent);
this._popoverPresentationDelegate = ios.UIPopoverPresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback); }
popoverPresentationController.delegate = this._popoverPresentationDelegate; }
const view = parent.nativeViewProtected;
// Note: sourceView and sourceRect are needed to specify the anchor location for the popover. const cancelable = options.cancelable !== undefined ? !!options.cancelable : true;
// Note: sourceView should be the button triggering the modal. If it the Page the popover might appear "behind" the page content
popoverPresentationController.sourceView = view; if (majorVersion >= 13) {
popoverPresentationController.sourceRect = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height); if (cancelable) {
// Listen for dismiss modal callback.
this._setupAdaptiveControllerDelegate(controller);
} else {
// Prevent users from dismissing the modal.
(<any>controller).modalInPresentation = true;
} }
} }
@ -644,6 +650,22 @@ export class View extends ViewCommon {
backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderWidth() ||
backgroundInternal.hasBorderRadius(); backgroundInternal.hasBorderRadius();
} }
private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) {
const popoverPresentationController = controller.popoverPresentationController;
this._popoverPresentationDelegate = ios.UIPopoverPresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback);
popoverPresentationController.delegate = this._popoverPresentationDelegate;
const view = parent.nativeViewProtected;
// Note: sourceView and sourceRect are needed to specify the anchor location for the popover.
// Note: sourceView should be the button triggering the modal. If it the Page the popover might appear "behind" the page content
popoverPresentationController.sourceView = view;
popoverPresentationController.sourceRect = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height);
}
private _setupAdaptiveControllerDelegate(controller: UIViewController) {
this._adaptivePresentationDelegate = ios.UIAdaptivePresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback);
controller.presentationController.delegate = this._adaptivePresentationDelegate;
}
} }
View.prototype._nativeBackgroundState = "unset"; View.prototype._nativeBackgroundState = "unset";
@ -1019,6 +1041,28 @@ export namespace ios {
} }
} }
export class UIAdaptivePresentationControllerDelegateImp extends NSObject implements UIAdaptivePresentationControllerDelegate {
public static ObjCProtocols = [UIAdaptivePresentationControllerDelegate];
private owner: WeakRef<View>;
private closedCallback: Function;
public static initWithOwnerAndCallback(owner: WeakRef<View>, whenClosedCallback: Function): UIAdaptivePresentationControllerDelegateImp {
const instance = <UIAdaptivePresentationControllerDelegateImp>super.new();
instance.owner = owner;
instance.closedCallback = whenClosedCallback;
return instance;
}
public presentationControllerDidDismiss(presentationController: UIPresentationController) {
const owner = this.owner.get();
if (owner && typeof this.closedCallback === "function") {
this.closedCallback();
}
}
}
export class UIPopoverPresentationControllerDelegateImp extends NSObject implements UIPopoverPresentationControllerDelegate { export class UIPopoverPresentationControllerDelegateImp extends NSObject implements UIPopoverPresentationControllerDelegate {
public static ObjCProtocols = [UIPopoverPresentationControllerDelegate]; public static ObjCProtocols = [UIPopoverPresentationControllerDelegate];

View File

@ -205,6 +205,11 @@ function showUIAlertController(alertController: UIAlertController) {
if (currentView) { if (currentView) {
currentView = currentView.modal || currentView; currentView = currentView.modal || currentView;
//get to the top most view controller on the stack
while (currentView && currentView.modal) {
currentView = currentView.modal;
}
let viewController: UIViewController = currentView.ios; let viewController: UIViewController = currentView.ios;
if (viewController.presentedViewController) { if (viewController.presentedViewController) {