Skip to content

Commit b6b0125

Browse files
committed
fix(tabs ios): selector and ripple color css
1 parent 0e0c20d commit b6b0125

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/core/tab-navigation-base/tab-navigation-base/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
255255
public setTabBarItemTextTransform(tabStripItem: TabStripItem, value: any): void {
256256
// overridden by inheritors
257257
}
258+
259+
public setTabBarRippleColor(value: Color) {
260+
// overridden by inheritors
261+
}
262+
263+
public getTabBarRippleColor() {
264+
// overridden by inheritors
265+
return null;
266+
}
258267
}
259268

260269
const MIN_ICON_SIZE = 24;

src/core/tab-navigation-base/tab-strip/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module @nativescript-community/ui-material-core/tab-navigation-base/tab-strip
33
*/
4+
import { rippleColorProperty } from '../../cssproperties';
45
import { AddArrayFromBuilder, AddChildFromBuilder, CSSType, Color, CssProperty, Property, Style, View, ViewBase, booleanConverter } from '@nativescript/core';
56
import { backgroundColorProperty, backgroundInternalProperty, colorProperty, fontInternalProperty } from '@nativescript/core/ui/styling/style-properties';
67
import { textTransformProperty } from '@nativescript/core/ui/text-base';
@@ -172,6 +173,18 @@ export class TabStrip extends View implements TabStripDefinition, AddChildFromBu
172173

173174
return parent && parent.setTabBarUnSelectedItemColor(value);
174175
}
176+
177+
[rippleColorProperty.getDefault](): Color {
178+
const parent = this.parent as TabNavigationBase;
179+
180+
return parent && parent.getTabBarRippleColor();
181+
}
182+
183+
[rippleColorProperty.setNative](value: Color) {
184+
const parent = this.parent as TabNavigationBase;
185+
186+
return parent && parent.setTabBarRippleColor(value);
187+
}
175188
}
176189

177190
const itemsProperty = new Property<TabStrip, TabStripItem[]>({

src/tabs/tabs.ios.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rippleColorProperty, themer } from '@nativescript-community/ui-material-core';
1+
import { themer } from '@nativescript-community/ui-material-core';
22
import { Color, Device, Font, Frame, IOSHelper, ImageSource, Trace, Utils, View, ViewBase } from '@nativescript/core';
33
import { TabsBase, swipeEnabledProperty } from './tabs-common';
44

@@ -492,6 +492,8 @@ export class Tabs extends TabsBase {
492492

493493
public _needsCacheUpdate = false;
494494
public _animateNextChange = true;
495+
private _selectionIndicatorColor: Color;
496+
private _rippleColor: Color;
495497

496498
constructor() {
497499
super();
@@ -1084,13 +1086,13 @@ export class Tabs extends TabsBase {
10841086
this._ios.tabBar.setImageTintColorForState(nativeColor, UIControlState.Selected);
10851087
}
10861088

1087-
public getTabBarHighlightColor(): UIColor {
1088-
return this._ios.tabBar.tintColor;
1089+
public getTabBarHighlightColor(): Color {
1090+
return this._selectionIndicatorColor;
10891091
}
10901092

1091-
public setTabBarHighlightColor(value: UIColor | Color) {
1092-
const nativeColor = value instanceof Color ? value.ios : value;
1093-
this._ios.tabBar.tintColor = nativeColor;
1093+
public setTabBarHighlightColor(value: Color) {
1094+
this._selectionIndicatorColor = value;
1095+
this._ios.tabBar.selectionIndicatorStrokeColor = value.ios;
10941096
}
10951097

10961098
public getTabBarSelectedItemColor(): Color {
@@ -1122,8 +1124,13 @@ export class Tabs extends TabsBase {
11221124
});
11231125
}
11241126

1125-
[rippleColorProperty.setNative](value: UIColor | Color) {
1126-
this.setTabBarHighlightColor(value);
1127+
public setTabBarRippleColor(value: Color) {
1128+
this._rippleColor = value;
1129+
this._ios.tabBar.rippleColor = value.ios;
1130+
}
1131+
1132+
public getTabBarRippleColor(): Color {
1133+
return this._rippleColor;
11271134
}
11281135

11291136
[selectedIndexProperty.setNative](value: number) {

0 commit comments

Comments
 (0)