Skip to content

fix(tabs ios): selector and ripple color css #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/core/tab-navigation-base/tab-navigation-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
public setTabBarItemTextTransform(tabStripItem: TabStripItem, value: any): void {
// overridden by inheritors
}

public setTabBarRippleColor(value: Color) {
// overridden by inheritors
}

public getTabBarRippleColor() {
// overridden by inheritors
return null;
}
}

const MIN_ICON_SIZE = 24;
Expand Down
13 changes: 13 additions & 0 deletions src/core/tab-navigation-base/tab-strip/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @module @nativescript-community/ui-material-core/tab-navigation-base/tab-strip
*/
import { rippleColorProperty } from '../../cssproperties';
import { AddArrayFromBuilder, AddChildFromBuilder, CSSType, Color, CssProperty, Property, Style, View, ViewBase, booleanConverter } from '@nativescript/core';
import { backgroundColorProperty, backgroundInternalProperty, colorProperty, fontInternalProperty } from '@nativescript/core/ui/styling/style-properties';
import { textTransformProperty } from '@nativescript/core/ui/text-base';
Expand Down Expand Up @@ -172,6 +173,18 @@ export class TabStrip extends View implements TabStripDefinition, AddChildFromBu

return parent && parent.setTabBarUnSelectedItemColor(value);
}

[rippleColorProperty.getDefault](): Color {
const parent = this.parent as TabNavigationBase;

return parent && parent.getTabBarRippleColor();
}

[rippleColorProperty.setNative](value: Color) {
const parent = this.parent as TabNavigationBase;

return parent && parent.setTabBarRippleColor(value);
}
}

const itemsProperty = new Property<TabStrip, TabStripItem[]>({
Expand Down
23 changes: 15 additions & 8 deletions src/tabs/tabs.ios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rippleColorProperty, themer } from '@nativescript-community/ui-material-core';
import { themer } from '@nativescript-community/ui-material-core';
import { Color, Device, Font, Frame, IOSHelper, ImageSource, Trace, Utils, View, ViewBase } from '@nativescript/core';
import { TabsBase, swipeEnabledProperty } from './tabs-common';

Expand Down Expand Up @@ -492,6 +492,8 @@ export class Tabs extends TabsBase {

public _needsCacheUpdate = false;
public _animateNextChange = true;
private _selectionIndicatorColor: Color;
private _rippleColor: Color;

constructor() {
super();
Expand Down Expand Up @@ -1084,13 +1086,13 @@ export class Tabs extends TabsBase {
this._ios.tabBar.setImageTintColorForState(nativeColor, UIControlState.Selected);
}

public getTabBarHighlightColor(): UIColor {
return this._ios.tabBar.tintColor;
public getTabBarHighlightColor(): Color {
return this._selectionIndicatorColor;
}

public setTabBarHighlightColor(value: UIColor | Color) {
const nativeColor = value instanceof Color ? value.ios : value;
this._ios.tabBar.tintColor = nativeColor;
public setTabBarHighlightColor(value: Color) {
this._selectionIndicatorColor = value;
this._ios.tabBar.selectionIndicatorStrokeColor = value.ios;
}

public getTabBarSelectedItemColor(): Color {
Expand Down Expand Up @@ -1122,8 +1124,13 @@ export class Tabs extends TabsBase {
});
}

[rippleColorProperty.setNative](value: UIColor | Color) {
this.setTabBarHighlightColor(value);
public setTabBarRippleColor(value: Color) {
this._rippleColor = value;
this._ios.tabBar.rippleColor = value.ios;
}

public getTabBarRippleColor(): Color {
return this._rippleColor;
}

[selectedIndexProperty.setNative](value: number) {
Expand Down