Tabs styling improvements#8366
Conversation
|
|
||
| if (!tabStripItem.iconSource) { | ||
| if (isIconAboveTitle) { | ||
| tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: -20 }; |
There was a problem hiding this comment.
Where do these magic numbers come from?
There was a problem hiding this comment.
I'm not sure. The same numbers are set in tabs-view and bottom-navigation as well. I haven't change it though.
| return "initial"; | ||
| case MDCTabBarTextTransform.Uppercase: | ||
| default: | ||
| return "uppercase"; |
There was a problem hiding this comment.
Wouldn't it be better to throw an exception in the default branch? I think it would be easier to find out if for some reason there is a new property in the enumeration.
There was a problem hiding this comment.
The thing is that this is something that is set through CSS and it works of Android for all the cases, but iOS doesn't support all, so I would prefer not to crash the app with a CSS change. On the other hand, if you cannot achieve what you want with a single style you can always use platform-specific ones.
| private getItemLabelTextTransform(tabStripItem: TabStripItem): TextTransform { | ||
| const nestedLabel = tabStripItem.label; | ||
| let textTransform: TextTransform = null; | ||
| if (nestedLabel && nestedLabel.style.textTransform && nestedLabel.style.textTransform !== "initial") { |
There was a problem hiding this comment.
Shouldn't the check be if (nestedLabel && nestedLabel.style && nestedLabel.style.textTransform !== "initial")?
The same goes a couple of lines below.
There was a problem hiding this comment.
I don't think this is needed: https://github.com/NativeScript/NativeScript/blob/master/nativescript-core/ui/core/view-base/view-base.ts#L259
There was a problem hiding this comment.
Shouldn't it be if (nestedLabel && nestedLabel.style.textTransform !== "initial") then?
| } | ||
|
|
||
| get textTransform(): TextTransform { | ||
| return this.style.textTransform; |
There was a problem hiding this comment.
Is it possible we don't have a style?
There was a problem hiding this comment.
| private getItemLabelTextTransform(tabStripItem: TabStripItem): TextTransform { | ||
| const nestedLabel = tabStripItem.label; | ||
| let textTransform: TextTransform = null; | ||
| if (nestedLabel && nestedLabel.style.textTransform && nestedLabel.style.textTransform !== "initial") { |
There was a problem hiding this comment.
Is the if check correct? Please check one of my previous comments. Also, isn't this duplicate code? Could we move it to a utility class for the TabStripItem?
There was a problem hiding this comment.
It is duplicate, I've planned to create a base Tabs/Bottom Navigation component as there's a lot of duplicate code between the two controls.
Update images after changes caused by NativeScript/NativeScript#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>
PR Checklist
What is the current behavior?
What is the new behavior?
leading,justified,centerandcenterSelectedtypes of alignment of the Tabs TabStrip items in iOS. To change the behavior set theiOSTabBarItemsAlignmentproperty to the Tabs component to one of the following:leading- tab items are aligned to the leftjustified- tab strip is split equally to all the tab itemscenter- tabs items are aligned in the centercenterSelected- tab items move to make the selected tab in the centeriOSTabBarItemsAlignmentis set to something different thanjustifyand you want to set the background of the selected item, you can achieve it by setting:activestyle to the TabStrip item, but the selection highlight indicator will not be shown in that caseFixes #8369, #8345, #8340.
BREAKING CHANGES:
The default value of the TextTransform for android is now
uppercase.Migration steps:
If you don't want to use uppercased items, you need to change the TextTransform property/style either on TabStrip, TabStripItem or Label element.