mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #6584 from NativeScript/release-5.0.3
docs: cut the 5.0.3 release
This commit is contained in:
@@ -69,6 +69,11 @@ function ensureImageSource() {
|
||||
export function request(options: http.HttpRequestOptions): Promise<http.HttpResponse> {
|
||||
return new Promise<http.HttpResponse>((resolve, reject) => {
|
||||
|
||||
if (!options.url) {
|
||||
reject(new Error("Request url was empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var network = domainDebugger.getNetwork();
|
||||
var debugRequest = network && network.create();
|
||||
|
||||
@@ -31,9 +31,18 @@ export function getJSON<T>(arg: any): Promise<T> {
|
||||
}
|
||||
|
||||
export function getImage(arg: any): Promise<ImageSource> {
|
||||
return httpRequest
|
||||
.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
|
||||
.then(response => response.content.toImage());
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
|
||||
.then(r => {
|
||||
try {
|
||||
resolve(r.content.toImage());
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
}, err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getFile(arg: any, destinationFilePath?: string): Promise<any> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tns-core-modules",
|
||||
"description": "Telerik NativeScript Core Modules",
|
||||
"version": "5.0.2",
|
||||
"version": "5.1.0",
|
||||
"homepage": "https://www.nativescript.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -26,7 +26,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"typings": "tns-core-modules.d.ts",
|
||||
"dependencies": {
|
||||
"tns-core-modules-widgets": "5.0.1",
|
||||
"tns-core-modules-widgets": "next",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -190,6 +190,9 @@ export class View extends ViewCommon {
|
||||
} else if (!this._isLaidOut) {
|
||||
// Rects could be equal on the first layout and an event should be raised.
|
||||
this._raiseLayoutChangedEvent();
|
||||
// But make sure event is raised only once if rects are equal on the first layout as
|
||||
// this method is called twice with equal rects in landscape mode (vs only once in portrait)
|
||||
this._isLaidOut = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,11 +798,11 @@ export namespace ios {
|
||||
}
|
||||
|
||||
if (inWindowRight < fullscreenPosition.right && inWindowRight >= safeAreaPosition.right + fullscreenPosition.left) {
|
||||
adjustedPosition.right = fullscreenPosition.right - fullscreenPosition.left;
|
||||
adjustedPosition.right += fullscreenPosition.right - inWindowRight;
|
||||
}
|
||||
|
||||
if (inWindowBottom < fullscreenPosition.bottom && inWindowBottom >= safeAreaPosition.bottom + fullscreenPosition.top) {
|
||||
adjustedPosition.bottom = fullscreenPosition.bottom - fullscreenPosition.top;
|
||||
adjustedPosition.bottom += fullscreenPosition.bottom - inWindowBottom;
|
||||
}
|
||||
|
||||
const adjustedFrame = CGRectMake(layout.toDeviceIndependentPixels(adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.top), layout.toDeviceIndependentPixels(adjustedPosition.right - adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.bottom - adjustedPosition.top));
|
||||
@@ -850,7 +853,8 @@ export namespace ios {
|
||||
|
||||
if (parent.nativeViewProtected instanceof UIScrollView) {
|
||||
const nativeView = parent.nativeViewProtected;
|
||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||
const insets = nativeView.safeAreaInsets;
|
||||
safeArea = CGRectMake(insets.left, insets.top, nativeView.contentSize.width - insets.left - insets.right, nativeView.contentSize.height - insets.top - insets.bottom);
|
||||
fullscreen = CGRectMake(0, 0, nativeView.contentSize.width, nativeView.contentSize.height);
|
||||
} else if (parent.viewController) {
|
||||
const nativeView = parent.viewController.view;
|
||||
|
||||
@@ -31,6 +31,16 @@ export module inputType {
|
||||
* Email input type.
|
||||
*/
|
||||
export const email: string = "email";
|
||||
|
||||
/**
|
||||
* Number input type
|
||||
*/
|
||||
export const number: string = "number";
|
||||
|
||||
/**
|
||||
* Phone input type
|
||||
*/
|
||||
export const phone: string = "phone";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,6 +184,10 @@ export function prompt(arg: any): Promise<PromptResult> {
|
||||
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
} else if (options.inputType === inputType.email) {
|
||||
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||
} else if (options.inputType === inputType.number) {
|
||||
input.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
|
||||
} else if (options.inputType === inputType.phone) {
|
||||
input.setInputType(android.text.InputType.TYPE_CLASS_PHONE);
|
||||
}
|
||||
|
||||
switch (options.capitalizationType) {
|
||||
|
||||
16
tns-core-modules/ui/dialogs/dialogs.d.ts
vendored
16
tns-core-modules/ui/dialogs/dialogs.d.ts
vendored
@@ -21,6 +21,16 @@ export module inputType {
|
||||
* Email input type.
|
||||
*/
|
||||
export var email: string;
|
||||
|
||||
/**
|
||||
* Number input type.
|
||||
*/
|
||||
export var number: string;
|
||||
|
||||
/**
|
||||
* Phone input type.
|
||||
*/
|
||||
export var phone: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +91,7 @@ export function prompt(message: string, defaultText?: string): Promise<PromptRes
|
||||
|
||||
/**
|
||||
* The prompt() method displays a dialog box that prompts the visitor for input.
|
||||
* @param options The options for the dialog box.
|
||||
* @param options The options for the dialog box.
|
||||
*/
|
||||
export function prompt(options: PromptOptions): Promise<PromptResult>;
|
||||
|
||||
@@ -95,7 +105,7 @@ export function login(message: string, userName?: string, password?: string): Pr
|
||||
|
||||
/**
|
||||
* The login() method displays a login dialog box that prompts the visitor for user name and password.
|
||||
* @param options The options for the dialog box.
|
||||
* @param options The options for the dialog box.
|
||||
*/
|
||||
export function login(options: LoginOptions): Promise<LoginResult>;
|
||||
|
||||
@@ -109,7 +119,7 @@ export function action(message: string, cancelButtonText: string, actions: Array
|
||||
|
||||
/**
|
||||
* The action() method displays a action box that prompts the visitor to choose some action.
|
||||
* @param options The options for the dialog box.
|
||||
* @param options The options for the dialog box.
|
||||
*/
|
||||
export function action(options: ActionOptions): Promise<string>;
|
||||
|
||||
|
||||
@@ -104,6 +104,10 @@ export function prompt(arg: any): Promise<PromptResult> {
|
||||
|
||||
if (options && options.inputType === inputType.email) {
|
||||
arg.keyboardType = UIKeyboardType.EmailAddress;
|
||||
} else if (options && options.inputType === inputType.number) {
|
||||
arg.keyboardType = UIKeyboardType.NumberPad;
|
||||
} else if (options && options.inputType === inputType.phone) {
|
||||
arg.keyboardType = UIKeyboardType.PhonePad;
|
||||
}
|
||||
|
||||
let color = getTextFieldColor();
|
||||
|
||||
@@ -251,6 +251,18 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
private isNestedWithin(parentFrameCandidate: FrameBase): boolean {
|
||||
let frameAncestor: FrameBase = this;
|
||||
while (frameAncestor) {
|
||||
frameAncestor = <FrameBase>getAncestor(frameAncestor, FrameBase);
|
||||
if (frameAncestor === parentFrameCandidate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private raiseCurrentPageNavigatedEvents(isBack: boolean) {
|
||||
const page = this.currentPage;
|
||||
if (page) {
|
||||
@@ -410,6 +422,23 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
return null;
|
||||
}
|
||||
|
||||
public _pushInFrameStackRecursive() {
|
||||
this._pushInFrameStack();
|
||||
|
||||
// make sure nested frames order is kept intact i.e. the nested one should always be on top;
|
||||
// see https://github.com/NativeScript/nativescript-angular/issues/1596 for more information
|
||||
const framesToPush = [];
|
||||
for (const frame of frameStack) {
|
||||
if (frame.isNestedWithin(this)) {
|
||||
framesToPush.push(frame);
|
||||
}
|
||||
}
|
||||
|
||||
for (const frame of framesToPush) {
|
||||
frame._pushInFrameStack();
|
||||
}
|
||||
}
|
||||
|
||||
public _pushInFrameStack() {
|
||||
_pushInFrameStack(this);
|
||||
}
|
||||
|
||||
6
tns-core-modules/ui/frame/frame.d.ts
vendored
6
tns-core-modules/ui/frame/frame.d.ts
vendored
@@ -158,6 +158,10 @@ export class Frame extends View {
|
||||
* @private
|
||||
*/
|
||||
_pushInFrameStack();
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_pushInFrameStackRecursive();
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -253,7 +257,7 @@ export interface NavigationEntry extends ViewEntry {
|
||||
transitioniOS?: NavigationTransition;
|
||||
|
||||
/**
|
||||
* Specifies an optional navigation transition for iOS. If not specified, the default platform transition will be used.
|
||||
* Specifies an optional navigation transition for Android. If not specified, the default platform transition will be used.
|
||||
*/
|
||||
transitionAndroid?: NavigationTransition;
|
||||
|
||||
|
||||
@@ -164,16 +164,14 @@ export class ScrollView extends ScrollViewBase {
|
||||
nativeView.contentInsetAdjustmentBehavior = 2;
|
||||
}
|
||||
|
||||
let scrollWidth = width;
|
||||
let scrollHeight = height;
|
||||
let scrollWidth = width + insets.left + insets.right;
|
||||
let scrollHeight = height + insets.top + insets.bottom;
|
||||
if (this.orientation === "horizontal") {
|
||||
scrollWidth = Math.max(this._contentMeasuredWidth + insets.left + insets.right, width);
|
||||
scrollHeight = height + insets.top + insets.bottom;
|
||||
scrollWidth = Math.max(this._contentMeasuredWidth + insets.left + insets.right, scrollWidth);
|
||||
width = Math.max(this._contentMeasuredWidth, width);
|
||||
}
|
||||
else {
|
||||
scrollHeight = Math.max(this._contentMeasuredHeight + insets.top + insets.bottom, height);
|
||||
scrollWidth = width + insets.left + insets.right;
|
||||
scrollHeight = Math.max(this._contentMeasuredHeight + insets.top + insets.bottom, scrollHeight);
|
||||
height = Math.max(this._contentMeasuredHeight, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,10 +200,7 @@ function initializeNativeClasses() {
|
||||
}
|
||||
|
||||
finishUpdate(container: android.view.ViewGroup): void {
|
||||
if (this.mCurTransaction != null) {
|
||||
(<any>this.mCurTransaction).commitNowAllowingStateLoss();
|
||||
this.mCurTransaction = null;
|
||||
}
|
||||
this._commitCurrentTransaction();
|
||||
}
|
||||
|
||||
isViewFromObject(view: android.view.View, object: java.lang.Object): boolean {
|
||||
@@ -211,6 +208,9 @@ function initializeNativeClasses() {
|
||||
}
|
||||
|
||||
saveState(): android.os.Parcelable {
|
||||
// Commit the current transaction on save to prevent "No view found for id 0xa" exception on restore.
|
||||
// Related to: https://github.com/NativeScript/NativeScript/issues/6466
|
||||
this._commitCurrentTransaction();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -221,8 +221,15 @@ function initializeNativeClasses() {
|
||||
getItemId(position: number): number {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
private _commitCurrentTransaction() {
|
||||
if (this.mCurTransaction != null) {
|
||||
this.mCurTransaction.commitNowAllowingStateLoss();
|
||||
this.mCurTransaction = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PagerAdapter = FragmentPagerAdapter;
|
||||
}
|
||||
|
||||
@@ -506,7 +513,7 @@ export class TabView extends TabViewBase {
|
||||
const newItem = items[newIndex];
|
||||
const selectedView = newItem && newItem.view;
|
||||
if (selectedView instanceof Frame) {
|
||||
selectedView._pushInFrameStack();
|
||||
selectedView._pushInFrameStackRecursive();
|
||||
}
|
||||
|
||||
toLoad.forEach(index => {
|
||||
@@ -713,4 +720,4 @@ function tryCloneDrawable(value: android.graphics.drawable.Drawable, resources:
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ export class TabView extends TabViewBase {
|
||||
const selectedIndex = this.selectedIndex;
|
||||
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].view;
|
||||
if (selectedView instanceof Frame) {
|
||||
selectedView._pushInFrameStack();
|
||||
selectedView._pushInFrameStackRecursive();
|
||||
}
|
||||
|
||||
this._ios.delegate = this._delegate;
|
||||
@@ -300,7 +300,7 @@ export class TabView extends TabViewBase {
|
||||
if (newItem && this.isLoaded) {
|
||||
const selectedView = items[newIndex].view;
|
||||
if (selectedView instanceof Frame) {
|
||||
selectedView._pushInFrameStack();
|
||||
selectedView._pushInFrameStackRecursive();
|
||||
}
|
||||
|
||||
newItem.loadView(newItem.view);
|
||||
|
||||
Reference in New Issue
Block a user