Browse Source

会话列表页,title显示未读数

heavyrain2012 4 years ago
parent
commit
903506690d

+ 20 - 4
wfuikit/WFChatUIKit/ConversationList/ViewController/WFCUConversationTableViewController.m

@@ -315,7 +315,12 @@
 }
 
 - (void)updateConnectionStatus:(ConnectionStatus)status {
+    [self updateTitle];
+}
+
+- (void)updateTitle {
     UIView *title;
+    ConnectionStatus status = [WFCCNetworkService sharedInstance].currentConnectionStatus;
     if (status != kConnectionStatusConnecting && status != kConnectionStatusReceiving) {
         UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 40, 0, 80, 44)];
         
@@ -326,8 +331,19 @@
             case kConnectionStatusUnconnected:
                 navLabel.text = WFCString(@"NotConnect");
                 break;
-            case kConnectionStatusConnected:
-                navLabel.text = WFCString(@"Message");
+            case kConnectionStatusConnected: {
+                int count = 0;
+                for (WFCCConversationInfo *info in self.conversations) {
+                    if (!info.isSilent) {
+                        count += info.unreadCount.unread;
+                    }
+                }
+                if (count) {
+                    navLabel.text = [NSString stringWithFormat:WFCString(@"NumberOfMessage"), count];
+                } else {
+                    navLabel.text = WFCString(@"Message");
+                }
+            }
                 break;
                 
             default:
@@ -335,7 +351,7 @@
         }
         
         navLabel.textColor = [WFCUConfigManager globalManager].naviTextColor;
-        navLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:18];
+        navLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
         
         navLabel.textAlignment = NSTextAlignmentCenter;
         title = navLabel;
@@ -361,7 +377,6 @@
     }
     self.navigationItem.titleView = title;
 }
-
 - (void)onConnectionStatusChanged:(NSNotification *)notification {
     ConnectionStatus status = [notification.object intValue];
     [self updateConnectionStatus:status];
@@ -416,6 +431,7 @@
         }
     }
     [self.tabBarController.tabBar showBadgeOnItemIndex:0 badgeValue:count];
+    [self updateTitle];
 }
 
 - (void)updatePcSession {

+ 1 - 0
wfuikit/WFChatUIKit/Resources/en.lproj/wfc.strings

@@ -9,6 +9,7 @@
 "Ok"="Ok";
 "Cancel"="Cancel";
 "Message"="Message";
+"NumberOfMessage"="Message(%d)";
 "GroupName"="Group name";
 "Back"="Back";
 "BackMore"="Back(...)";

+ 1 - 0
wfuikit/WFChatUIKit/Resources/zh-Hans.lproj/wfc.strings

@@ -9,6 +9,7 @@
 "Ok"="确定";
 "Cancel"="取消";
 "Message"="信息";
+"NumberOfMessage"="信息(%d)";
 "GroupName"="群聊名称";
 "Back"="返回";
 "BackMore"="返回...";