mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge branch 'master' into fix_css_styles
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
"**/*.d.ts",
|
||||
"**/*.js",
|
||||
"**/platforms/ios/**",
|
||||
"**/platforms/android/**",
|
||||
"**/package.json",
|
||||
"!org.nativescript.widgets.d.ts"
|
||||
],
|
||||
@@ -59,4 +60,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user