Skip to content

Commit ae4130d

Browse files
committed
Merge branch 'master' of github.com:nativescript-community/ui-material-components
2 parents 39db0a2 + e0fbd59 commit ae4130d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/bottomnavigationbar/bottomnavigationbar-common.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface TabSelectedEventData extends EventData {
3434
export interface TabReselectedEventData extends EventData {
3535
index: number;
3636
}
37+
3738
/**
3839
* Enum for Title Visibility options
3940
*
@@ -59,6 +60,7 @@ export abstract class BottomNavigationBarBase extends View {
5960

6061
selectedTabIndex = 0;
6162
titleVisibility: TitleVisibility = TitleVisibility.always;
63+
autoClearBadge: boolean;
6264

6365
protected _items: BottomNavigationTabBase[] = [];
6466

@@ -89,7 +91,10 @@ export abstract class BottomNavigationBarBase extends View {
8991
index,
9092
};
9193
this.notify(eventData);
92-
this.removeBadge(index);
94+
95+
if (this.autoClearBadge) {
96+
this.removeBadge(index);
97+
}
9398
}
9499

95100
_emitTabSelected(index: number) {
@@ -101,7 +106,10 @@ export abstract class BottomNavigationBarBase extends View {
101106
};
102107
this.selectedTabIndex = index;
103108
this.notify(eventData);
104-
this.removeBadge(index);
109+
110+
if (this.autoClearBadge) {
111+
this.removeBadge(index);
112+
}
105113
}
106114

107115
_emitTabReselected(index: number) {
@@ -150,6 +158,14 @@ export const titleVisibilityProperty = new Property<BottomNavigationBarBase, Tit
150158

151159
titleVisibilityProperty.register(BottomNavigationBarBase);
152160

161+
export const autoClearBadgeProperty = new Property<BottomNavigationBarBase, boolean>({
162+
name: 'autoClearBadge',
163+
defaultValue: true,
164+
valueConverter: booleanConverter,
165+
});
166+
167+
autoClearBadgeProperty.register(BottomNavigationBarBase);
168+
153169
export const activeColorCssProperty = new CssProperty<Style, Color>({
154170
name: 'activeColor',
155171
cssName: 'active-color',

src/bottomnavigationbar/bottomnavigationbar.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export declare class BottomNavigationBar extends BottomNavigationBarBase {
2121
activeColor: Color;
2222
inactiveColor: Color;
2323
backgroundColor: Color;
24+
autoClearBadge: Boolean;
2425
selectTab(index: number): void;
2526
showBadge(index: number, value?: number): void;
2627
removeBadge(index: number): void;

0 commit comments

Comments
 (0)