提交
This commit is contained in:
133
QXLive/Message(音信)/Controller/QXChatViewController.m
Normal file
133
QXLive/Message(音信)/Controller/QXChatViewController.m
Normal file
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// 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"
|
||||
@interface QXChatViewController ()<TUIChatConfigDelegate_Classic>
|
||||
@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];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-(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{
|
||||
QXGuildGroupSettingVC *vc = [[QXGuildGroupSettingVC alloc] init];
|
||||
vc.groupId = [self.data.groupID stringByReplacingOccurrencesOfString:@"g" withString:@""];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
|
||||
- (void)initSubViews{
|
||||
[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];
|
||||
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];
|
||||
}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
|
||||
Reference in New Issue
Block a user