// // QXChatViewController.m // QXLive // // Created by 启星 on 2025/5/22. // #import "QXChatViewController.h" #import "QXChatTitleView.h" #import "TUIGroupChatViewController.h" #import "TUIChatConfig_Classic.h" #import "QXUserHomePageViewController.h" #import "QXGuildGroupSettingVC.h" #import "QXMenuPopView.h" #import "QXReportViewController.h" #import "QXMineNetwork.h" @interface QXChatViewController () @property (nonatomic,strong)QXChatTitleView *titleView; @end @implementation QXChatViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. // 创建会话信息 // TUIC2CChatViewController } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)setNavgationItems{ [super setNavgationItems]; UIButton*backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; [backBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)]; // backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading; [backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; UIButton*moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; [moreBtn setImage:[UIImage imageNamed:@"dynamic_more"] forState:(UIControlStateNormal)]; // backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading; [moreBtn addTarget:self action:@selector(moreAction) forControlEvents:(UIControlEventTouchUpInside)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:moreBtn]; } -(BOOL)onUserAvatarClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata{ QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init]; NSString *userId = [celldata.identifier stringByReplacingOccurrencesOfString:@"u" withString:@""]; vc.user_id = userId; [self.navigationController pushViewController:vc animated:YES]; return YES; } //-(BOOL)onUserAvatarLongPressed:(UIView *)view messageCellData:(TUIMessageCellData *)celldata{ // return YES; //} // //- (BOOL)onMessageClicked:(nonnull UIView *)view messageCellData:(nonnull TUIMessageCellData *)celldata { // return YES; //} // // //- (BOOL)onMessageLongPressed:(nonnull UIView *)view messageCellData:(nonnull TUIMessageCellData *)celldata { // return YES; //} -(void)backAction{ if (self.navigationController.viewControllers.count > 1) { [self.navigationController popViewControllerAnimated:YES]; return; }else{ [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } } -(void)moreAction{ if (self.data.groupID.length>0) { QXGuildGroupSettingVC *vc = [[QXGuildGroupSettingVC alloc] init]; vc.groupId = self.data.groupID; [self.navigationController pushViewController:vc animated:YES]; }else{ QXMenuPopView *menuView = [[QXMenuPopView alloc] initWithPoint:CGPointMake(SCREEN_WIDTH-60, NavContentHeight+10)]; menuView.dataArray = @[QXText(@"举报"),QXText(@"拉黑")]; menuView.delegate = self; [menuView showInView:KEYWINDOW]; } } -(void)didSelectedIndex:(NSInteger)index menuTitle:(NSString*)menuTitle{ NSString *userId = [self.data.userID substringFromIndex:1]; if ([menuTitle isEqualToString:QXText(@"举报")]) { QXReportViewController *reportVC = [[QXReportViewController alloc] init]; reportVC.reportType = @"1"; reportVC.fromId = userId; [self.navigationController pushViewController:reportVC animated:YES]; }else if ([menuTitle isEqualToString:QXText(@"拉黑")]) { [QXMineNetwork addOrRemoveBlackListIsAdd:YES userId:userId successBlock:^(NSDictionary * _Nonnull dict) { showToast(@"操作成功"); } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } } - (void)initSubViews{ // TUIConversationListBaseDataProvider markConversationAsRead [TUIChatConfig_Classic sharedConfig].delegate = self; if (self.data.groupID.length>0) { TUIGroupChatViewController *vc = [[TUIGroupChatViewController alloc] init]; [vc setConversationData:self.data]; // 把 TUIC2CChatViewController 添加到自己的 ViewController vc.view.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight); [self addChildViewController:vc]; [self.view addSubview:vc.view]; }else{ TUIC2CChatViewController *vc = [[TUIC2CChatViewController alloc] init]; [vc setConversationData:self.data]; // 把 TUIC2CChatViewController 添加到自己的 ViewController vc.view.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight); [self addChildViewController:vc]; [self.view addSubview:vc.view]; } } -(void)setData:(TUIChatConversationModel *)data{ _data = data; self.navigationItem.title = data.title; // self.titleView.nameLabel.text = data.title; // if (data.avatarImage != nil) { // self.titleView.imageView.image = data.avatarImage; // }else{ // [self.titleView.imageView sd_setImageWithURL:[NSURL URLWithString:data.faceUrl] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]]; // } // // self.titleView.timeLabel.text = @"刚刚"; } -(QXChatTitleView *)titleView{ if (!_titleView) { _titleView = [[QXChatTitleView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-100, 44)]; } return _titleView; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end