RoomManagementVC.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // RoomManagementVC.m
  3. // yunbaolive
  4. //
  5. // Created by IOS1 on 2019/4/26.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "RoomManagementVC.h"
  9. #import "RoomUserTypeCell.h"
  10. #import "adminLists.h"
  11. #import "RoomUserListViewController.h"
  12. #import "OtherRoomViewController.h"
  13. @interface RoomManagementVC ()<UITableViewDelegate,UITableViewDataSource>{
  14. UIButton *leftBtn;
  15. UIButton *rightBtn;
  16. UIView *lineView;
  17. UITableView *leftTable;
  18. UITableView *rightTable;
  19. NSArray *leftArray;
  20. NSArray *rightArray;
  21. }
  22. @end
  23. @implementation RoomManagementVC
  24. - (void)navi{
  25. NSArray *arr = @[YZMsg(@"我的直播间"),YZMsg(@"我的房间")];
  26. for (int i = 0; i < arr.count; i++) {
  27. UIButton *btn = [UIButton buttonWithType:0];
  28. btn.frame = CGRectMake(_window_width/2-90+i*90, 24+statusbarHeight, 90, 40);
  29. [btn setTitle:arr[i] forState:0];
  30. [btn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:UIControlStateSelected];
  31. [btn setTitleColor:RGB_COLOR(@"#777777", 1) forState:UIControlStateNormal];
  32. [btn addTarget:self action:@selector(topBtnclick:) forControlEvents:UIControlEventTouchUpInside];
  33. btn.titleLabel.font = SYS_Font(15);
  34. [self.naviView addSubview:btn];
  35. if (i== 0) {
  36. btn.selected = YES;
  37. leftBtn = btn;
  38. lineView = [[UIView alloc]initWithFrame:CGRectMake(btn.centerX-7.5, 60+statusbarHeight, 15, 4)];
  39. lineView.layer.cornerRadius = 2;
  40. lineView.layer.masksToBounds = YES;
  41. [self.naviView addSubview:lineView];
  42. }else{
  43. btn.selected = NO;
  44. rightBtn = btn;
  45. }
  46. }
  47. }
  48. - (void)topBtnclick:(UIButton *)sender{
  49. if (!sender.selected) {
  50. sender.selected = YES;
  51. [UIView animateWithDuration:0.2 animations:^{
  52. lineView.centerX = sender.centerX;
  53. }];
  54. if (sender == leftBtn) {
  55. rightBtn.selected = NO;
  56. leftTable.hidden = NO;
  57. rightTable.hidden = YES;
  58. }else{
  59. leftBtn.selected = NO;
  60. leftTable.hidden = YES;
  61. rightTable.hidden = NO;
  62. if (rightArray.count == 0) {
  63. [self requestData];
  64. }
  65. }
  66. }
  67. }
  68. - (void)viewDidLoad {
  69. [super viewDidLoad];
  70. [self navi];
  71. leftArray = @[YZMsg(@"管理员列表"),YZMsg(@"禁言列表"),YZMsg(@"踢人列表")];
  72. leftTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:0];
  73. leftTable.delegate = self;
  74. leftTable.dataSource = self;
  75. leftTable.separatorStyle = 0;
  76. leftTable.backgroundColor = Normal_Color;
  77. [self.view addSubview:leftTable];
  78. rightTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:0];
  79. rightTable.delegate = self;
  80. rightTable.dataSource = self;
  81. rightTable.separatorStyle = 0;
  82. rightTable.hidden = YES;
  83. rightTable.backgroundColor = Normal_Color;
  84. [self.view addSubview:rightTable];
  85. }
  86. - (void)requestData{
  87. [YBNetworking postWithUrl:@"Livemanage.getRoomList" Dic:nil Suc:^(int code, id info, NSString *msg) {
  88. if (code == 0) {
  89. rightArray = info;
  90. if (rightArray.count<=0) {
  91. [PublicView showTextNoData:rightTable text1:@"" text2:YZMsg(@"你还不是管理员") centerY:0.8];
  92. }else{
  93. [PublicView hiddenTextNoData:rightTable];
  94. }
  95. [rightTable reloadData];
  96. }
  97. } Fail:^(id fail) {
  98. }];
  99. }
  100. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  101. if (tableView == leftTable) {
  102. return leftArray.count;
  103. }
  104. return rightArray.count;
  105. }
  106. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  107. RoomUserTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RoomUserTypeCELL"];
  108. if (!cell) {
  109. cell = [[[NSBundle mainBundle] loadNibNamed:@"RoomUserTypeCell" owner:nil options:nil] lastObject];
  110. }
  111. if (tableView == leftTable) {
  112. cell.titleL.text = leftArray[indexPath.row];
  113. }else{
  114. cell.titleL.text = [NSString stringWithFormat:@"%@ %@",minstr([rightArray[indexPath.row] valueForKey:@"user_nickname"]),YZMsg(@"的直播间")];
  115. }
  116. cell.backgroundColor = CellRow_Cor;
  117. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  118. return cell;
  119. }
  120. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  121. if (tableView == leftTable) {
  122. RoomUserListViewController *vc = [[RoomUserListViewController alloc]init];
  123. vc.type = indexPath.row;
  124. vc.titleStr = leftArray[indexPath.row];
  125. vc.liveuid = [Config getOwnID];
  126. [self.navigationController pushViewController:vc animated:YES];
  127. }else{
  128. NSDictionary *userinfo = rightArray[indexPath.row];
  129. OtherRoomViewController *vc = [[OtherRoomViewController alloc]init];
  130. vc.titleStr =[NSString stringWithFormat:@"%@ %@",minstr([userinfo valueForKey:@"user_nickname"]),YZMsg(@"的直播间")];
  131. vc.liveuid = minstr([userinfo valueForKey:@"liveuid"]);
  132. [self.navigationController pushViewController:vc animated:YES];
  133. }
  134. }
  135. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  136. return 50.0;
  137. }
  138. /*
  139. #pragma mark - Navigation
  140. // In a storyboard-based application, you will often want to do a little preparation before navigation
  141. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  142. // Get the new view controller using [segue destinationViewController].
  143. // Pass the selected object to the new view controller.
  144. }
  145. */
  146. @end