mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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:
@@ -373,6 +373,7 @@ export class Tabs extends TabsBase {
|
||||
private _pagerAdapter: androidx.viewpager.widget.PagerAdapter;
|
||||
private _androidViewId: number = -1;
|
||||
public _originalBackground: any;
|
||||
private _textTransform: TextTransform = "uppercase";
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -637,6 +638,18 @@ export class Tabs extends TabsBase {
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -645,10 +658,8 @@ export class Tabs extends TabsBase {
|
||||
let title = nestedLabel.text;
|
||||
|
||||
// TEXT-TRANSFORM
|
||||
const textTransform = nestedLabel.style.textTransform;
|
||||
if (textTransform) {
|
||||
title = getTransformedText(title, textTransform);
|
||||
}
|
||||
const textTransform = this.getItemLabelTextTransform(tabStripItem);
|
||||
title = getTransformedText(title, textTransform);
|
||||
tabItemSpec.title = title;
|
||||
|
||||
// BACKGROUND-COLOR
|
||||
@@ -817,7 +828,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -828,12 +839,34 @@ export class Tabs extends TabsBase {
|
||||
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
|
||||
}
|
||||
|
||||
public getTabBarItemTextTransform(tabStripItem: TabStripItem): TextTransform {
|
||||
return this.getItemLabelTextTransform(tabStripItem);
|
||||
}
|
||||
|
||||
public setTabBarItemTextTransform(tabStripItem: TabStripItem, value: TextTransform): void {
|
||||
const nestedLabel = tabStripItem.label;
|
||||
const title = getTransformedText(nestedLabel.text, value);
|
||||
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 = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user