Tabs styling improvements (#8366)

* fix(tabs): delay loadView when animation runs

* chore: update api.md

* chore: remove unnecessary casting

* test: Added disabled test for changing tabs

* tabs(ios): added tabs styling in ios

* tabs: added iosAlignment property

* tabs: textTransform support

* tabs: iosAlignment moved to tabstrip

* test: add frame-in-tabs test

* chore: addressing PR comments

* chore: addressing PR comments

* chore: call method on the instance instead of call

* chore: move IOSAlignment property

* chore: update comments

* fix: texttransform to tabstrip in bottomnavigation

* chore: add new item to native-api-usage

* chore: remove unneeded setNativeView call

* chore: removed unneeded check

Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com>
This commit is contained in:
Vasil Trifonov
2020-03-09 15:24:26 +02:00
committed by GitHub
parent 286fcd3f75
commit 458943111e
17 changed files with 474 additions and 422 deletions

View File

@@ -248,6 +248,7 @@ export class BottomNavigation extends TabNavigationBase {
private _currentTransaction: androidx.fragment.app.FragmentTransaction;
private _attachedToWindow = false;
public _originalBackground: any;
private _textTransform: TextTransform = "none";
constructor() {
super();
@@ -567,6 +568,18 @@ export class BottomNavigation extends TabNavigationBase {
});
}
private getItemLabelTextTransform(tabStripItem: TabStripItem): TextTransform {
const nestedLabel = tabStripItem.label;
let textTransform: TextTransform = null;
if (nestedLabel && nestedLabel.style.textTransform !== "initial") {
textTransform = nestedLabel.style.textTransform;
} else if (tabStripItem.style.textTransform !== "initial") {
textTransform = tabStripItem.style.textTransform;
}
return textTransform || this._textTransform;
}
private createTabItemSpec(tabStripItem: TabStripItem): org.nativescript.widgets.TabItemSpec {
const tabItemSpec = new org.nativescript.widgets.TabItemSpec();
@@ -575,10 +588,8 @@ export class BottomNavigation extends TabNavigationBase {
let title = titleLabel.text;
// TEXT-TRANSFORM
const textTransform = titleLabel.style.textTransform;
if (textTransform) {
title = getTransformedText(title, textTransform);
}
const textTransform = this.getItemLabelTextTransform(tabStripItem);
title = getTransformedText(title, textTransform);
tabItemSpec.title = title;
// BACKGROUND-COLOR
@@ -736,6 +747,24 @@ export class BottomNavigation extends TabNavigationBase {
tabStripItem.nativeViewProtected.setText(title);
}
public getTabBarTextTransform(): TextTransform {
return this._textTransform;
}
public setTabBarTextTransform(value: TextTransform): void {
let items = this.tabStrip && this.tabStrip.items;
if (items) {
items.forEach((tabStripItem) => {
if (tabStripItem.label && tabStripItem.nativeViewProtected) {
const nestedLabel = tabStripItem.label;
const title = getTransformedText(nestedLabel.text, value);
tabStripItem.nativeViewProtected.setText(title);
}
});
}
this._textTransform = value;
}
[selectedIndexProperty.setNative](value: number) {
// const smoothScroll = false;