Skip to content

Commit c017c5b

Browse files
author
alex
committed
optimize unreadNum
1 parent ceda789 commit c017c5b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/pages/tabs-notification/tabs-notification.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<ion-header>
22
<ion-navbar>
3-
<ion-title>{{ 'notification.title' | translate }}</ion-title>
3+
<ion-title (click)="add()">{{ 'notification.title' | translate }}</ion-title>
44
</ion-navbar>
55
</ion-header>
66

77
<ion-content>
8-
<!--<ion-refresher (ionRefresh)="doRefresh($event)">-->
9-
<!--<ion-refresher-content pullingIcon="arrow-dropdown" pullingText=" {{ 'todo.list.refresherPullingText' | translate }}" refreshingSpinner="circles"-->
10-
<!--refreshingText=" {{ 'todo.list.refreshingText' | translate }}">-->
11-
<!--</ion-refresher-content>-->
128
<ion-list>
139
<ion-item-sliding *ngFor="let item of currentItems">
1410
<button ion-item (click)="openItem(item)">
@@ -27,5 +23,4 @@ <h2>{{item.name}}</h2>
2723
</ion-item-options>
2824
</ion-item-sliding>
2925
</ion-list>
30-
<!--</ion-refresher>-->
3126
</ion-content>

src/pages/tabs-notification/tabs-notification.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export class TabsNotification {
7373
this.getNotifications();
7474
}
7575

76+
add(){
77+
PublicVar.setNotificationNum(PublicVar.getNotificationNum() + 1);
78+
}
79+
7680
openItem() {
7781
}
7882

src/pages/tabs/tabs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ion-tabs #myTabs>
2-
<ion-tab tabsHideOnSubPages="true" [root]="notificationRoot" tabTitle="{{ 'notification.title' | translate }}" tabIcon="list" tabBadge="{{unreadNum}}" tabBadgeStyle="danger"></ion-tab>
2+
<ion-tab tabsHideOnSubPages="true" [root]="notificationRoot" tabTitle="{{ 'notification.title' | translate }}" tabIcon="list" [tabBadge]="countNotificationItem()" tabBadgeStyle="danger"></ion-tab>
33
<ion-tab tabsHideOnSubPages="true" [root]="workRoot" tabTitle="{{ 'work.title' | translate }}" tabIcon="open"></ion-tab>
44
<ion-tab tabsHideOnSubPages="true" [root]="myRoot" tabTitle=" {{ 'mine.title' | translate }}" tabIcon="person"></ion-tab>
55
</ion-tabs>

src/pages/tabs/tabs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class TabsPage {
1515
public workRoot: any = 'work';
1616
public myRoot: any = 'my';
1717
@ViewChild('myTabs') tabRef: Tabs;
18-
public unreadNum;
1918

2019
private timer;
2120

@@ -25,6 +24,10 @@ export class TabsPage {
2524
public storage: Storage) {
2625
}
2726

27+
countNotificationItem(){
28+
return PublicVar.getNotificationNum();
29+
}
30+
2831
ionViewDidLoad() {
2932
console.log('tabs ionViewDidLoad');
3033
}
@@ -36,8 +39,6 @@ export class TabsPage {
3639

3740
ionViewDidEnter() {
3841
console.log('tabs ionViewDidEnter');
39-
this.unreadNum = PublicVar.getNotificationNum();
40-
console.log('this.unreadNum: ' + this.unreadNum);
4142
this.tabRef.select(0);
4243
}
4344

0 commit comments

Comments
 (0)