CYGroupSendMsgViewController.m 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. //
  2. // CYGroupSendMsgViewController.m
  3. // shiku_im
  4. //
  5. // Created by Ron on 2019/11/16.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "CYGroupSendMsgViewController.h"
  9. #import "CYsendmsgFriendViewController.h"
  10. #import "CYSendMSGGroupViewController.h"
  11. #import "CYSelGroupListView.h"
  12. #import "CYSelFriendyListView.h"
  13. #import "CYManager.h"
  14. #import "CYModel.h"
  15. #import "JXCell.h"
  16. #import "JXChatViewController.h"
  17. #import "JXChatViewC.h"
  18. @interface CYGroupSendMsgViewController ()
  19. @property (nonatomic,strong)CYSelFriendyListView *friendView;
  20. @property (nonatomic,strong)CYSelGroupListView *groupView;
  21. @property (nonatomic,strong)CYModel *mode;
  22. @property (nonatomic, strong) UIButton *nextBtn;
  23. @end
  24. @implementation CYGroupSendMsgViewController
  25. - (void)dealloc {
  26. // 清空数组
  27. CYModel *mode = CYManager.sharedManager.getModel;
  28. mode.selLableIdArr = @[];
  29. mode.selGroupIdArr = @[];
  30. }
  31. - (void)viewDidDisappear:(BOOL)animated {
  32. [super viewDidDisappear:animated];
  33. }
  34. -(void)viewWillAppear:(BOOL)animated{
  35. [super viewWillAppear:YES];
  36. // [_friendView reloadData];
  37. // [_groupView reloadData];
  38. [self.tableView reloadData];
  39. }
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. // Do any additional setup after loading the view.
  43. self.isGotoBack = YES;
  44. self.title = @"选择收信人";
  45. // self.heightFooter = 0;
  46. self.isShowFooterPull = NO;
  47. self.heightHeader = JX_SCREEN_TOP;
  48. [self createHeadAndFoot];
  49. self.nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.tableFooter.frame.size.width, 48)];
  50. self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
  51. [self.nextBtn setTitle:Localized(@"JX_NextStep") forState:UIControlStateNormal];
  52. [self.nextBtn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
  53. [self.nextBtn addTarget:self action:@selector(nextBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  54. [self.tableFooter addSubview:self.nextBtn];
  55. self.mode = CYManager.sharedManager.getModel;
  56. // UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, <#CGFloat height#>)]
  57. // self.tableBody.scrollEnabled = YES;
  58. // self.tableBody.contentSize = CGSizeMake(self_width, JX_SCREEN_HEIGHT - JX_SCREEN_TOP);
  59. // self.tableBody.showsVerticalScrollIndicator = YES;
  60. // int h = 0;
  61. /*
  62. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, h, 100, 40)];
  63. [button setTitle:@"+添加好友" forState:UIControlStateNormal];
  64. [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  65. [button addTarget:self action:@selector(addFriendClick) forControlEvents:UIControlEventTouchUpInside];
  66. [self.tableBody addSubview:button];
  67. h += button.frame.size.height;
  68. int viewH = (self.tableBody.frame.size.height - button.frame.size.height * 3 - 20) / 2;
  69. _friendView = [[CYSelFriendyListView alloc] init];
  70. _friendView.view.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, viewH);
  71. [self.tableBody addSubview:_friendView.view];
  72. h += _friendView.view.frame.size.height;
  73. UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, h, 100, 40)];
  74. [button2 setTitle:@"+添加群组" forState:UIControlStateNormal];
  75. [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  76. [button2 addTarget:self action:@selector(addGroupClick) forControlEvents:UIControlEventTouchUpInside];
  77. [self.tableBody addSubview:button2];
  78. h += button2.frame.size.height;
  79. _groupView = [[CYSelGroupListView alloc] init];
  80. _groupView.view.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, viewH);
  81. [self.tableBody addSubview:_groupView.view];
  82. h += _groupView.view.frame.size.height;
  83. UIButton *nextbutton = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH * 0.5 -40, self.tableBody.frame.size.height - 60, 80, 40)];
  84. [nextbutton setTitle:@"下一步" forState:UIControlStateNormal];
  85. [nextbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  86. [nextbutton addTarget:self action:@selector(nextClick) forControlEvents:UIControlEventTouchUpInside];
  87. [self.tableBody addSubview:nextbutton];
  88. */
  89. }
  90. -(void)addFriendClick{
  91. CYsendmsgFriendViewController *vc = [[CYsendmsgFriendViewController alloc] init];
  92. [g_navigation pushViewController:vc animated:YES];
  93. }
  94. -(void)addGroupClick{
  95. CYSendMSGGroupViewController *vc = [[CYSendMSGGroupViewController alloc] init];
  96. [g_navigation pushViewController:vc animated:YES];
  97. }
  98. -(void)nextClick{
  99. }
  100. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  101. return 2;
  102. }
  103. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  104. if (section == 0) {
  105. return self.mode.selLableIdArr.count;
  106. }
  107. return self.mode.selGroupIdArr.count;
  108. }
  109. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  110. {
  111. JXCell *cell=nil;
  112. NSString* cellName = [NSString stringWithFormat:@"selVC_%d",(int)indexPath.row];
  113. CYModel *model = CYManager.sharedManager.getModel;
  114. if (indexPath.section == 0) {
  115. cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
  116. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  117. cell.title = model.selFriendyNameArr[indexPath.row];
  118. // cell.headImageView.image = model.selGroupIMGArr[indexPath.row];
  119. // cell.roomId = model.selGroupIdArr[indexPath.row];
  120. cell.userId = model.selLableIdArr[indexPath.row];
  121. // [cell headImageViewImageWithUserId:model.selFriendyIdArr[indexPath.row] roomId:model.selFriendyIdArr[indexPath.row]];
  122. [cell headImageViewImageWithUserId:nil roomId:nil];
  123. }else if(indexPath.section == 1){
  124. cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
  125. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  126. cell.title = model.selGroupNameArr[indexPath.row];
  127. cell.userId = model.selGroupIdArr[indexPath.row];
  128. [cell headImageViewImageWithUserId:model.selGroupIdArr[indexPath.row] roomId:model.selGroupIdArr[indexPath.row]];
  129. }
  130. return cell;
  131. }
  132. //下面是设置分组的头部和底部间距
  133. //section头部间距
  134. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  135. return 40;//section头部高度
  136. }
  137. //section头部视图
  138. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  139. {
  140. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
  141. [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  142. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
  143. [view addSubview:button];
  144. if (section == 0) {
  145. [button setTitle:@"+ 标签" forState:UIControlStateNormal];
  146. [button addTarget:self action:@selector(addFriendClick) forControlEvents:UIControlEventTouchUpInside];
  147. }else if (section == 1){
  148. [button setTitle:@"+ 群组" forState:UIControlStateNormal];
  149. [button addTarget:self action:@selector(addGroupClick) forControlEvents:UIControlEventTouchUpInside];
  150. }
  151. return view;
  152. }
  153. //section底部间距
  154. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  155. {
  156. return 0.001;
  157. }
  158. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  159. {
  160. return 64;
  161. }
  162. - (void)nextBtnAction:(UIButton *)btn {
  163. JXChatViewC *vc = [[JXChatViewC alloc] init];
  164. NSMutableArray *idArr = [NSMutableArray arrayWithArray:self.mode.selFriendyIdArr];
  165. NSMutableArray *nameArr = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr];
  166. NSMutableArray *nameArrGroup = [NSMutableArray arrayWithArray:self.mode.selGroupNameArr];
  167. vc.userNmaesWithFriend = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr];
  168. [idArr addObjectsFromArray:self.mode.selGroupIdArr];
  169. [nameArr addObjectsFromArray:self.mode.selGroupNameArr];
  170. if (idArr.count < 1) {
  171. [SVProgressHUD setMinimumDismissTimeInterval:2.0];
  172. [SVProgressHUD showInfoWithStatus:@"请选择收信人"];
  173. return;
  174. }
  175. vc.userIds = idArr;
  176. vc.userNames = nameArr;
  177. vc.userNamesWithGroup = nameArrGroup;
  178. vc.isGroupMessages = YES;
  179. vc.isCYMSGgroupANDFriendy = YES;
  180. [g_navigation pushViewController:vc animated:YES];
  181. // [g_navigation popToViewController:[CYGroupSendMsgViewController class] animated:YES];
  182. }
  183. /*
  184. #pragma mark - Navigation
  185. // In a storyboard-based application, you will often want to do a little preparation before navigation
  186. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  187. // Get the new view controller using [segue destinationViewController].
  188. // Pass the selected object to the new view controller.
  189. }
  190. */
  191. @end