Merge branch 'master' into doubleTap-location

This commit is contained in:
Luke Curran
2020-02-27 09:04:56 -06:00
committed by GitHub
21 changed files with 151 additions and 67 deletions

View File

@@ -3,7 +3,7 @@
"main": "index",
"types": "index.d.ts",
"description": "Telerik NativeScript Core Modules",
"version": "6.3.0",
"version": "6.5.0",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
@@ -13,6 +13,7 @@
"**/*.d.ts",
"**/*.js",
"**/platforms/ios/**",
"**/platforms/android/**",
"**/package.json",
"!org.nativescript.widgets.d.ts"
],
@@ -59,4 +60,4 @@
}
}
}
}
}

View File

@@ -391,7 +391,7 @@ export class BottomNavigation extends TabNavigationBase {
if (this._manager && this._manager.isDestroyed()) {
return;
}
this._attachedToWindow = true;
this.changeTab(this.selectedIndex);
}
@@ -614,6 +614,9 @@ export class BottomNavigation extends TabNavigationBase {
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
const iconSource = tabStripItem.image && tabStripItem.image.src;
if (!iconSource) {
return null;
}
let is: ImageSource;
if (isFontIconURI(iconSource)) {
@@ -705,7 +708,10 @@ export class BottomNavigation extends TabNavigationBase {
}
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
if (value.fontSize) {
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
}
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
}

View File

@@ -377,7 +377,7 @@ export class BottomNavigation extends TabNavigationBase {
public setTabBarItemColor(tabStripItem: TabStripItem, value: UIColor | Color): void {
const states = getTitleAttributesForStates(tabStripItem.label);
applyStatesToItem(tabStripItem.nativeView, states);
applyStatesToItem(tabStripItem.nativeView, states, this.viewController.tabBar);
}
public setTabBarIconColor(tabStripItem: TabStripItem, value: UIColor | Color): void {
@@ -389,7 +389,7 @@ export class BottomNavigation extends TabNavigationBase {
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
const states = getTitleAttributesForStates(tabStripItem.label);
applyStatesToItem(tabStripItem.nativeView, states);
applyStatesToItem(tabStripItem.nativeView, states, this.viewController.tabBar);
}
public setTabBarItemTextTransform(tabStripItem: TabStripItem, value: TextTransform): void {
@@ -519,7 +519,7 @@ export class BottomNavigation extends TabNavigationBase {
updateTitleAndIconPositions(tabStripItem, tabBarItem, controller);
const states = getTitleAttributesForStates(tabStripItem.label);
applyStatesToItem(tabBarItem, states);
applyStatesToItem(tabBarItem, states, this.viewController.tabBar);
controller.tabBarItem = tabBarItem;
tabStripItem._index = i;
@@ -719,11 +719,20 @@ function getTitleAttributesForStates(view: View): TabStates {
return result;
}
function applyStatesToItem(item: UITabBarItem, states: TabStates) {
function applyStatesToItem(item: UITabBarItem, states: TabStates, tabBar: UITabBar) {
if (!states) {
return;
}
item.setTitleTextAttributesForState(states.normalState, UIControlState.Normal);
item.setTitleTextAttributesForState(states.selectedState, UIControlState.Selected);
// there's a bug when setting the item color on ios 13 if there's no background set to the tabstrip
// https://books.google.bg/books?id=99_BDwAAQBAJ&q=tabBar.unselectedItemTintColor
// to fix the above issue we are applying the selected fix only for the case, when there is no background set
// in that case we have the following known issue:
// we will set the color to all unselected items, so you won't be able to set different colors for the different not selected items
if (!tabBar.barTintColor && states.normalState[UITextAttributeTextColor] && (majorVersion > 9)) {
tabBar.unselectedItemTintColor = states.normalState[UITextAttributeTextColor];
}
}

View File

@@ -474,7 +474,7 @@ export abstract class ViewBase extends Observable {
* When returning true the callLoaded method will be run in setTimeout
* Method is intended to be overridden by inheritors and used as "protected"
*/
_shouldDelayLoad(): boolean;
_shouldDelayLayout(): boolean;
/**
* @private

View File

@@ -561,12 +561,24 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
}
private performLayout(currentRun = 0) {
// if there's an animation in progress we need to delay the layout
// we've added a guard of 5000 milliseconds execution
// to make sure that the layout will happen even if the animation haven't finished in 5 seconds
if (this._shouldDelayLayout() && currentRun < 100) {
setTimeout(() => this.performLayout(currentRun), currentRun);
currentRun++;
} else {
this.parent.requestLayout();
}
}
@profile
public requestLayout(): void {
// Default implementation for non View instances (like TabViewItem).
const parent = this.parent;
if (parent) {
parent.requestLayout();
this.performLayout();
}
}
@@ -615,15 +627,11 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
public loadView(view: ViewBase): void {
if (view && !view.isLoaded) {
if (this._shouldDelayLoad()) {
setTimeout(() => view.callLoaded());
} else {
view.callLoaded();
}
view.callLoaded();
}
}
public _shouldDelayLoad(): boolean {
public _shouldDelayLayout(): boolean {
return false;
}

View File

@@ -145,7 +145,7 @@ export function _setAndroidFragmentTransitions(
if (currentFragmentNeedsDifferentAnimation) {
setupCurrentFragmentExplodeTransition(navigationTransition, currentEntry);
}
} else if (name === "flip") {
} else if (name.indexOf("flip") === 0) {
const direction = name.substr("flip".length) || "right"; //Extract the direction from the string
const flipTransition = new FlipTransition(direction, navigationTransition.duration, navigationTransition.curve);

View File

@@ -348,7 +348,7 @@ export class Page extends PageBase {
//
}
public _shouldDelayLoad(): boolean {
public _shouldDelayLayout(): boolean {
return this._frame && this._frame._animationInProgress;
}

View File

@@ -127,7 +127,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
const parent = <TabStrip>this.parent;
const tabStripParent = parent && <TabNavigationBase>parent.parent;
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
});
this.image.style.on("colorChange", this._imageColorHandler);
@@ -135,7 +135,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
const parent = <TabStrip>this.parent;
const tabStripParent = parent && <TabNavigationBase>parent.parent;
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
});
this.image.style.on("fontInternalChange", this._imageFontHandler);
@@ -143,7 +143,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
const parent = <TabStrip>this.parent;
const tabStripParent = parent && <TabNavigationBase>parent.parent;
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
});
this.image.on("srcChange", this._imageSrcHandler);
}

View File

@@ -689,6 +689,9 @@ export class Tabs extends TabsBase {
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
const iconSource = tabStripItem.image && tabStripItem.image.src;
if (!iconSource) {
return null;
}
let is: ImageSource;
if (isFontIconURI(iconSource)) {
@@ -814,12 +817,14 @@ export class Tabs extends TabsBase {
const tabBarItem = this._tabsBar.getViewForItemAt(index);
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
const drawable = this.getIcon(tabStripItem);
imgView.setImageDrawable(drawable);
}
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
if (value.fontSize) {
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
}
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
}

View File

@@ -2,7 +2,7 @@
import { TabContentItem } from "../tab-navigation-base/tab-content-item";
import { TabStrip } from "../tab-navigation-base/tab-strip";
import { TabStripItem } from "../tab-navigation-base/tab-strip-item";
import { TextTransform } from "../text-base";
import { TextTransform, ViewBase } from "../text-base";
// Requires
import { Color } from "../../color";
@@ -873,6 +873,9 @@ export class Tabs extends TabsBase {
// TODO: investigate why this call is necessary to actually toggle item appearance
this.viewController.tabBar.sizeToFit();
this.tabStrip.setNativeView(this.viewController.tabBar);
if (this.selectedIndex) {
this.viewController.tabBar.setSelectedItemAnimated(this.tabBarItems[this.selectedIndex], false);
}
}
// const length = items ? items.length : 0;
@@ -1066,6 +1069,17 @@ export class Tabs extends TabsBase {
this._ios.tabBar.tintColor = nativeColor;
}
private visitFrames(view: ViewBase, operation: (frame: Frame) => {}) {
if (view instanceof Frame) {
operation(view);
}
view.eachChild(child => {
this.visitFrames(child, operation);
return true;
});
}
[selectedIndexProperty.setNative](value: number) {
// TODO
// if (traceEnabled()) {
@@ -1092,17 +1106,11 @@ export class Tabs extends TabsBase {
this._currentNativeSelectedIndex = value;
let itemControllerOwner = null;
if (itemController._owner) {
let itemControllerOwner = <Frame>itemController._owner.get();
// do not load new views while the animation is in progress https://stackoverflow.com/a/47031524/613113
itemControllerOwner._animationInProgress = true;
}
// do not make layout changes while the animation is in progress https://stackoverflow.com/a/47031524/613113
this.visitFrames(item, frame => frame._animationInProgress = true);
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
if (itemControllerOwner) {
itemControllerOwner._animationInProgress = false;
}
this.visitFrames(item, frame => frame._animationInProgress = false);
if (finished) {
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));

View File

@@ -177,7 +177,7 @@ export class XMLHttpRequest {
}
public addEventListener(eventName: string, handler: Function) {
if (["abort", "error", "load", "loadend", "loadstart", "progress"].indexOf(eventName) === -1) {
if (["abort", "error", "load", "loadend", "loadstart", "progress", "readystatechange"].indexOf(eventName) === -1) {
throw new Error("Event not supported: " + eventName);
}