// // CYGroupSendMsgViewController.m // shiku_im // // Created by Ron on 2019/11/16. // Copyright © 2019 Reese. All rights reserved. // #import "CYGroupSendMsgViewController.h" #import "CYsendmsgFriendViewController.h" #import "CYSendMSGGroupViewController.h" #import "CYSelGroupListView.h" #import "CYSelFriendyListView.h" #import "CYManager.h" #import "CYModel.h" #import "JXCell.h" #import "JXChatViewController.h" #import "JXChatViewC.h" @interface CYGroupSendMsgViewController () @property (nonatomic,strong)CYSelFriendyListView *friendView; @property (nonatomic,strong)CYSelGroupListView *groupView; @property (nonatomic,strong)CYModel *mode; @property (nonatomic, strong) UIButton *nextBtn; @end @implementation CYGroupSendMsgViewController - (void)dealloc { // 清空数组 CYModel *mode = CYManager.sharedManager.getModel; mode.selLableIdArr = @[]; mode.selGroupIdArr = @[]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:YES]; // [_friendView reloadData]; // [_groupView reloadData]; [self.tableView reloadData]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.isGotoBack = YES; self.title = @"选择收信人"; // self.heightFooter = 0; self.isShowFooterPull = NO; self.heightHeader = JX_SCREEN_TOP; [self createHeadAndFoot]; self.nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.tableFooter.frame.size.width, 48)]; self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:15.0]; [self.nextBtn setTitle:Localized(@"JX_NextStep") forState:UIControlStateNormal]; [self.nextBtn setTitleColor:THEMECOLOR forState:UIControlStateNormal]; [self.nextBtn addTarget:self action:@selector(nextBtnAction:) forControlEvents:UIControlEventTouchUpInside]; [self.tableFooter addSubview:self.nextBtn]; self.mode = CYManager.sharedManager.getModel; // UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, <#CGFloat height#>)] // self.tableBody.scrollEnabled = YES; // self.tableBody.contentSize = CGSizeMake(self_width, JX_SCREEN_HEIGHT - JX_SCREEN_TOP); // self.tableBody.showsVerticalScrollIndicator = YES; // int h = 0; /* UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, h, 100, 40)]; [button setTitle:@"+添加好友" forState:UIControlStateNormal]; [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [button addTarget:self action:@selector(addFriendClick) forControlEvents:UIControlEventTouchUpInside]; [self.tableBody addSubview:button]; h += button.frame.size.height; int viewH = (self.tableBody.frame.size.height - button.frame.size.height * 3 - 20) / 2; _friendView = [[CYSelFriendyListView alloc] init]; _friendView.view.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, viewH); [self.tableBody addSubview:_friendView.view]; h += _friendView.view.frame.size.height; UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, h, 100, 40)]; [button2 setTitle:@"+添加群组" forState:UIControlStateNormal]; [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [button2 addTarget:self action:@selector(addGroupClick) forControlEvents:UIControlEventTouchUpInside]; [self.tableBody addSubview:button2]; h += button2.frame.size.height; _groupView = [[CYSelGroupListView alloc] init]; _groupView.view.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, viewH); [self.tableBody addSubview:_groupView.view]; h += _groupView.view.frame.size.height; UIButton *nextbutton = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH * 0.5 -40, self.tableBody.frame.size.height - 60, 80, 40)]; [nextbutton setTitle:@"下一步" forState:UIControlStateNormal]; [nextbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [nextbutton addTarget:self action:@selector(nextClick) forControlEvents:UIControlEventTouchUpInside]; [self.tableBody addSubview:nextbutton]; */ } -(void)addFriendClick{ CYsendmsgFriendViewController *vc = [[CYsendmsgFriendViewController alloc] init]; [g_navigation pushViewController:vc animated:YES]; } -(void)addGroupClick{ CYSendMSGGroupViewController *vc = [[CYSendMSGGroupViewController alloc] init]; [g_navigation pushViewController:vc animated:YES]; } -(void)nextClick{ } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0) { return self.mode.selLableIdArr.count; } return self.mode.selGroupIdArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { JXCell *cell=nil; NSString* cellName = [NSString stringWithFormat:@"selVC_%d",(int)indexPath.row]; CYModel *model = CYManager.sharedManager.getModel; if (indexPath.section == 0) { cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.title = model.selFriendyNameArr[indexPath.row]; // cell.headImageView.image = model.selGroupIMGArr[indexPath.row]; // cell.roomId = model.selGroupIdArr[indexPath.row]; cell.userId = model.selLableIdArr[indexPath.row]; // [cell headImageViewImageWithUserId:model.selFriendyIdArr[indexPath.row] roomId:model.selFriendyIdArr[indexPath.row]]; [cell headImageViewImageWithUserId:nil roomId:nil]; }else if(indexPath.section == 1){ cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.title = model.selGroupNameArr[indexPath.row]; cell.userId = model.selGroupIdArr[indexPath.row]; [cell headImageViewImageWithUserId:model.selGroupIdArr[indexPath.row] roomId:model.selGroupIdArr[indexPath.row]]; } return cell; } //下面是设置分组的头部和底部间距 //section头部间距 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 40;//section头部高度 } //section头部视图 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; [view addSubview:button]; if (section == 0) { [button setTitle:@"+ 标签" forState:UIControlStateNormal]; [button addTarget:self action:@selector(addFriendClick) forControlEvents:UIControlEventTouchUpInside]; }else if (section == 1){ [button setTitle:@"+ 群组" forState:UIControlStateNormal]; [button addTarget:self action:@selector(addGroupClick) forControlEvents:UIControlEventTouchUpInside]; } return view; } //section底部间距 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.001; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 64; } - (void)nextBtnAction:(UIButton *)btn { JXChatViewC *vc = [[JXChatViewC alloc] init]; vc.groundSendHelp=100; NSMutableArray *idArr = [NSMutableArray arrayWithArray:_mode.selFriendyIdArr]; NSMutableArray *nameArr = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr]; NSMutableArray *nameArrGroup = [NSMutableArray arrayWithArray:self.mode.selGroupNameArr]; vc.userNmaesWithFriend = [NSMutableArray arrayWithArray:_mode.selFriendyNameArr]; [idArr addObjectsFromArray:self.mode.selGroupIdArr]; [nameArr addObjectsFromArray:self.mode.selGroupNameArr]; if (idArr.count < 1) { [SVProgressHUD setMinimumDismissTimeInterval:2.0]; [SVProgressHUD showInfoWithStatus:@"请选择收信人"]; return; } vc.userIds = idArr; vc.userNames = nameArr; vc.userNamesWithGroup = nameArrGroup; vc.isGroupMessages = YES; vc.isCYMSGgroupANDFriendy = YES; [g_navigation pushViewController:vc animated:YES]; // [g_navigation popToViewController:[CYGroupSendMsgViewController class] animated:YES]; } /* #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