动态消息列表

This commit is contained in:
fengshuo
2022-05-20 20:50:35 +08:00
parent 465e73b6f1
commit fe8747ce5e
21 changed files with 638 additions and 18 deletions

View File

@@ -8,21 +8,28 @@
#import "XPMonentsViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
///Tool
#import "AttachMentModel.h"
#import "MonentsUnReadModel.h"
///View
#import "XPMonentsRecommendViewController.h"
#import "XPMonentsAttentionViewController.h"
#import "XPMonentsLatestViewController.h"
#import "XPMonentsInteractiveViewController.h"
@interface XPMonentsViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
///
@property (nonatomic,strong) NSArray<NSString *> *titles;
///
@property (nonatomic,strong) UIView * navView;
///
@property (nonatomic,strong) UIView * dotView;
///
@property (nonatomic,strong) UIButton *messageButton;
///
@@ -32,12 +39,17 @@
@implementation XPMonentsViewController
- (void)dealloc {
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
[self initSubViews];
[self initSubViewConstraints];
}
@@ -49,6 +61,7 @@
[self.navView addSubview:self.titleView];
[self.navView addSubview:self.messageButton];
[self.navView addSubview:self.dotView];
}
- (void)initSubViewConstraints {
@@ -69,6 +82,12 @@
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
[self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10, 10));
make.centerY.mas_equalTo(self.messageButton.mas_top);
make.centerX.mas_equalTo(self.messageButton.mas_right);
}];
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.view);
make.top.mas_equalTo(self.navView.mas_bottom);
@@ -99,6 +118,29 @@
}
#pragma mark -NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
if (notification.receiverType == NIMSessionTypeP2P) {
if (notification.content != nil) {
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
if (attachment.first == CustomMessageType_Monents && attachment.second == Custom_Message_Sub_Monents_Unread_Update) {
MonentsUnReadModel * unreadModel = [MonentsUnReadModel modelWithDictionary:attachment.data];
if (unreadModel.total > 0) {
self.dotView.hidden = NO;
} else {
self.dotView.hidden = YES;
}
}
}
}
}
#pragma mark - Event Response
- (void)messageButtonAction:(UIButton *)sender {
XPMonentsInteractiveViewController * messageVC = [[XPMonentsInteractiveViewController alloc] init];
[self.navigationController pushViewController:messageVC animated:YES];
}
#pragma mark - Getters And Setters
- (JXCategoryListContainerView *)listContainerView {
if (!_listContainerView) {
@@ -147,4 +189,25 @@
return _titles;
}
- (UIButton *)messageButton {
if (!_messageButton) {
_messageButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateNormal];
[_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateSelected];
[_messageButton addTarget:self action:@selector(messageButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _messageButton;
}
- (UIView *)dotView {
if (!_dotView) {
_dotView = [[UIView alloc] init];
_dotView.backgroundColor = UIColorFromRGB(0xFF2D55);
_dotView.layer.masksToBounds = YES;
_dotView.layer.cornerRadius = 5;
_dotView.hidden = YES;
}
return _dotView;
}
@end