// // TXMessageVC.m // romantic // // Created by bj_szd on 2022/9/5. // Copyright © 2022 romantic. All rights reserved. // #import "TXMessageVC.h" #import "TUIConversation.h" #import "TXSingleChatVC.h" #import #import "SPSystemListVC.h" @interface TXMessageVC () @property (nonatomic, assign)BOOL isCanUseSideBack; // 手势是否启动 @end @implementation TXMessageVC - (void)viewDidLoad { [super viewDidLoad]; if (self.isFromRoom) { self.contentSizeInPop = CGSizeMake(ScreenWidth, 400); }else { // [self loadBar:YES needBack:NO needBackground:NO]; // self.titleLabel.text = @"消息"; // UILabel *titleLab = [ControlCreator createLabel:self.view rect:CGRectZero text:@"消息" font:[UIFont systemFontOfSize:17 weight:UIFontWeightHeavy] color:HEXCOLOR(0x333333) backguoundColor:nil align:NSTextAlignmentLeft lines:1]; // [titleLab mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.view).offset(yb_StatusBar_H); // make.left.equalTo(self.view).offset(14); //// make.right.equalTo(self.view); // make.height.mas_equalTo(17); // }]; // // UIImageView *zhishiImgV = [ControlCreator createImageView:self.view rect:CGRectZero imageName:@"common_zhishi" backguoundColor:nil]; // [self.view sendSubviewToBack:zhishiImgV]; // [zhishiImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(titleLab).offset(-3); // make.right.equalTo(titleLab).offset(7); // }]; UIImageView *topIMG = [[UIImageView alloc] init]; topIMG.image = ImageNamed(@"message_nav_top_icon"); [self.view addSubview:topIMG]; [topIMG mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(14); make.top.mas_equalTo(yb_StatusBar_H+5); }]; } self.view.backgroundColor = self.barView.backgroundColor = HEXCOLOR(0xFFFFFF); self.titleLabel.textColor = kWhiteColor; UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"home_bg")]; [self.view addSubview:bgImgV]; [self.view sendSubviewToBack:bgImgV]; [bgImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.equalTo(self.view); make.height.mas_equalTo(ScreenWidth/375*812); }]; // 创建 TUIConversationListController TUIConversationListController *conv = [[TUIConversationListController alloc] init]; conv.delegate = self; conv.isFromRoom = self.isFromRoom; // 把 TUIConversationListController 添加到自己的 ViewController [self addChildViewController:conv]; [self.view addSubview:conv.view]; [conv.view mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.isFromRoom ? 15 : yb_NavigationBar_H+10); make.left.right.bottom.equalTo(self.view); }]; SPSystemListVC *systemVC = [[SPSystemListVC alloc] init]; conv.onSystemMsgBlock = ^{ if (self.isFromRoom) { [self.popController dismiss]; [self.naviVC pushViewController:systemVC animated:YES]; }else { [self.navigationController pushViewController:systemVC animated:YES]; } }; } - (void)conversationListController:(UIViewController *)conversationController didSelectConversation:(TUIConversationCellData *)conversation { TXSingleChatVC *vc = [[TXSingleChatVC alloc] init]; vc.userId = conversation.userID; vc.titleStr = conversation.title; if (self.isFromRoom) { [self.popController dismiss]; [self.naviVC pushViewController:vc animated:YES]; }else { [self.navigationController pushViewController:vc animated:YES]; } } - (void)conversationAvatarClick:(TUIConversationCellData *)conversation { SPHomepageVC *vc = [[SPHomepageVC alloc] init]; vc.userId = conversation.userID; if (self.isFromRoom) { [self.popController dismiss]; [self.naviVC pushViewController:vc animated:YES]; }else { [self.navigationController pushViewController:vc animated:YES]; } } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self cancelSideBack]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [self startSideBack]; } /** * 关闭ios右滑返回 */ -(void)cancelSideBack{ self.isCanUseSideBack = NO; if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.delegate=self; } } /* 开启ios右滑返回 */ - (void)startSideBack { self.isCanUseSideBack=YES; if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.delegate = nil; } } - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer { return self.isCanUseSideBack; } @end