Files
featherVoice/QXLive/Message(音信)/Controller/QXMessageViewController.m

144 lines
5.1 KiB
Mathematica
Raw Normal View History

2025-08-08 10:49:36 +08:00
//
// QXMessageViewController.m
// QXLive
//
// Created by on 2025/4/24.
//
#import "QXMessageViewController.h"
#import <ImSDK_Plus/ImSDK_Plus.h>
#import <ImSDK_Plus/V2TIMManager+Conversation.h>
#import "TUIConversationListController.h"
#import "QXChatViewController.h"
#import "QXSystemTopView.h"
#import "QXSystemNoticeViewController.h"
#import "QXMessageServices.h"
@interface QXMessageViewController ()<TUIConversationListControllerListener,QXSystemTopViewDelegate>
@property (nonatomic,strong)QXSystemTopView *topView;
@property (nonatomic,strong)QXMessageModel *model;
@property (nonatomic,strong)TUIConversationListController *vc;
@end
@implementation QXMessageViewController
-(instancetype)initWithIsFromRoom:(BOOL)isFromRoom{
if (self = [super init]) {
self.isFromRoom = isFromRoom;
if (self.isFromRoom) {
self.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429));
}
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadConversions) name:noticeTencentLogin object:nil];
// [self performSelector:@selector(chat) afterDelay:5];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self getHomeMessage];
}
-(void)initSubViews{
UILabel *tLabel = [[UILabel alloc] init];
tLabel.text = QXText(@"消息");
tLabel.font = [UIFont boldSystemFontOfSize:20];
[self.view addSubview:tLabel];
[tLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(kSafeAreaTop);
make.height.mas_equalTo(40);
}];
TUIConversationListController *vc = [[TUIConversationListController alloc] init];
vc.delegate = self;
// TUIConversationListController ViewController
// vc.tableViewForAll.backgroundColor = [UIColor clearColor];
self.vc = vc;
vc.view.backgroundColor = [UIColor clearColor];
vc.view.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, self.view.height-NavContentHeight);
if (self.isFromRoom) {
tLabel.font = [UIFont boldSystemFontOfSize:17];
[tLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.top.equalTo(self.view).offset(10);
make.height.mas_equalTo(35);
}];
vc.view.frame = CGRectMake(0, 40, SCREEN_WIDTH, self.view.height);
}else{
vc.tableViewForAll.tableHeaderView = self.topView;
}
self.vc = vc;
[self addChildViewController:vc];
[self.view addSubview:vc.view];
}
-(void)reloadConversions{
2025-12-04 14:11:00 +08:00
// [self.vc.view removeFromSuperview];
// [self.vc removeFromParentViewController];
// self.vc = nil;
// self.vc = [[TUIConversationListController alloc] init];
// self.vc.view.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, self.view.height-NavContentHeight);
// self.vc.tableViewForAll.tableHeaderView = self.topView;
// [self addChildViewController:self.vc];
// [self.view addSubview:self.vc.view];
[self.vc reloadConversationList];
2025-08-08 10:49:36 +08:00
}
- (void)conversationListController:(UIViewController *)conversationController
didSelectConversation:(TUIConversationCellData *)conversation {
//
// if (conversation.groupID.length > 0) {
//
// }else{
QXChatViewController *vc = [[QXChatViewController alloc] init];
TUIChatConversationModel *data = [[TUIChatConversationModel alloc] init];
data.conversationID = conversation.conversationID;
data.userID = conversation.userID;
data.groupID = conversation.groupID;
data.title = conversation.title;
data.faceUrl = conversation.faceUrl;
vc.data = data;
2025-12-04 14:11:00 +08:00
[self.vc.dataProvider markConversationAsRead:conversation];
2025-08-08 10:49:36 +08:00
[self.navigationController pushViewController:vc animated:YES];
// }
}
//-(void)viewDidLayoutSubviews{
// [super viewDidLayoutSubviews];
// self.vc.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429));
//}
-(void)getHomeMessage{
MJWeakSelf
[QXMessageServices getHomeMessageSuccessBlock:^(QXMessageModel * _Nonnull model) {
weakSelf.model = model;
weakSelf.topView.model = model;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
//-(void)chat{
// TUIChatConversationModel *data = [[TUIChatConversationModel alloc] init];
// data.userID = @"10086";
// QXChatViewController *vc = [[QXChatViewController alloc] init];
// vc.data = data;
// [self.navigationController pushViewController:vc animated:YES];
//}
-(void)didClickNoticeWithType:(NSInteger)type{
QXSystemNoticeViewController *vc = [[QXSystemNoticeViewController alloc] init];
vc.type = type;
[self.navigationController pushViewController:vc animated:YES];
}
-(QXSystemTopView *)topView{
if (!_topView) {
2025-10-21 10:29:06 +08:00
_topView = [[QXSystemTopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 74+8)];
2025-08-08 10:49:36 +08:00
_topView.delegate = self;
}
return _topView;
}
@end