diff --git a/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/Contents.json b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/Contents.json new file mode 100644 index 00000000..81182a21 --- /dev/null +++ b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "sessionList_clear@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "sessionList_clear@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@2x.png b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@2x.png new file mode 100644 index 00000000..5d310608 Binary files /dev/null and b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@2x.png differ diff --git a/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@3x.png b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@3x.png new file mode 100644 index 00000000..cf8076e7 Binary files /dev/null and b/xplan-ios/Assets.xcassets/SessionMessage/sessionList_clear.imageset/sessionList_clear@3x.png differ diff --git a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m index 3184dad3..17d2053e 100644 --- a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m +++ b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m @@ -18,6 +18,7 @@ #import "UserInfoModel.h" ///View #import "XPSessionFindNewViewController.h" +#import "TTPopUp.h" NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; @@ -29,6 +30,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; @property (nonatomic,strong) UILabel *titleLabel; +@property (nonatomic, strong) UIButton *allReadButton; /** * 会话列表 */ @@ -98,6 +100,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; if (self.openType == SessionListOpenTypeDefault) { [self.customNavigationBar addSubview:self.titleLabel]; [self.view addSubview:self.customNavigationBar]; + [self.customNavigationBar addSubview:self.allReadButton]; } [self.view addSubview:self.sessionListView]; } @@ -107,6 +110,11 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(self.customNavigationBar); }]; + [self.allReadButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(-16); + make.width.height.mas_equalTo(30); + make.centerY.mas_equalTo(self.customNavigationBar); + }]; } [self.sessionListView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -319,6 +327,26 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; } } +#pragma mark - action +- (void)allReadButtonClick:(UIButton *)sender { + NSInteger count = [NIMSDK sharedSDK].conversationManager.allUnreadCount; + if (count<1) { + [self showErrorToast:@"暂无未读消息需要清理"]; + return; + } + TTAlertConfig * config = [[TTAlertConfig alloc] init]; + config.confirmButtonConfig.title = @"清除"; + config.message =@"清除当前未读消息提醒?"; + [TTPopup alertWithConfig:config confirmHandler:^{ + [[NIMSDK sharedSDK].conversationManager markAllMessagesRead]; + [self setTabBarItemBadge:0]; + [self.sessionListView reloadData]; + } cancelHandler:^{ + + }]; +} + + - (UIView *)customNavigationBar { if (!_customNavigationBar) { CGRect frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 44); @@ -357,4 +385,13 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; return _recentSessions; } +- (UIButton *)allReadButton { + if (!_allReadButton) { + _allReadButton = [[UIButton alloc] init]; + [_allReadButton setImage:[UIImage imageNamed:@"sessionList_clear"] forState:UIControlStateNormal]; + [_allReadButton addTarget:self action:@selector(allReadButtonClick:) forControlEvents:UIControlEventTouchUpInside]; + } + return _allReadButton; +} + @end