CYActiveTitleViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // CYActiveTitleViewController.m
  3. // shiku_im
  4. //
  5. // Created by Ron on 2019/11/14.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "CYActiveTitleViewController.h"
  9. #import "CYActiveTieleTableViewCell.h"
  10. #import "CYEditTitleViewController.h"
  11. @interface CYActiveTitleViewController ()
  12. @property (nonatomic,copy) NSArray *rankArr;
  13. @property (nonatomic,copy) NSArray *nameArr;
  14. @end
  15. @implementation CYActiveTitleViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. [g_notify addObserver:self selector:@selector(refresh:) name:kgroupLevelNameRefresh object:nil];
  19. self.isGotoBack = YES;
  20. UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP+0.5, JX_SCREEN_WIDTH, .5)];
  21. lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
  22. self.tableView.tableHeaderView = lineView2;
  23. self.title = @"活跃头衔";
  24. self.heightHeader = JX_SCREEN_TOP;
  25. self.heightFooter = 0;
  26. self.isGotoBack = YES;
  27. self.isShowFooterPull = NO;
  28. self.isShowHeaderPull = NO;
  29. [self createHeadAndFoot];
  30. // 获取头衔
  31. // act_roomGetRoom
  32. [g_server roomGetRoom:_room.roomId toView:self];
  33. }
  34. - (NSArray *)rankArr {
  35. if (_rankArr == nil) {
  36. _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"];
  37. }
  38. return _rankArr;
  39. }
  40. - (NSArray *)nameArr {
  41. if (_nameArr == nil) {
  42. // _nameArr = @[@"潜水",@"冒泡",@"吐槽",@"活跃",@"话痨",@"传说"];
  43. _nameArr = @[@"传说",@"话痨",@"活跃",@"吐槽",@"冒泡",@"潜水"];
  44. }
  45. return _nameArr;
  46. }
  47. - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1 {
  48. if ([aDownload.action isEqualToString:act_roomGetRoom]) {
  49. NSString *groupLevelName = [dict objectForKey:@"groupLevelName"];
  50. NSArray *arr = [groupLevelName componentsSeparatedByString:@","];
  51. // 数组翻转
  52. _nameArr = [[arr reverseObjectEnumerator] allObjects];
  53. _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"];
  54. [self.tableView reloadData];
  55. }
  56. }
  57. - (void)refresh:(NSNotification *)note {
  58. [SVProgressHUD setMaximumDismissTimeInterval:2.0];
  59. [SVProgressHUD showSuccessWithStatus:@"修改成功"];
  60. NSArray *newArray = note.object;
  61. // 数组翻转
  62. _nameArr = [[newArray reverseObjectEnumerator] allObjects];
  63. _rankArr = @[@"LV6",@"LV5",@"LV4",@"LV3",@"LV2",@"LV1"];
  64. [self.tableView reloadData];
  65. }
  66. - (void)dealloc {
  67. [g_notify removeObserver:self];
  68. }
  69. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  70. {
  71. return 1;
  72. }
  73. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  74. return self.nameArr.count;
  75. }
  76. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  77. {
  78. static NSString * identifier = @"CYMusicTypeTableViewCell";
  79. CYActiveTieleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  80. if (!cell) {
  81. cell = [[CYActiveTieleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  82. }
  83. cell.title.text = self.rankArr[indexPath.row];
  84. cell.subtitleText = self.nameArr[indexPath.row];
  85. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  86. return cell;
  87. }
  88. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  89. {
  90. return 40;
  91. }
  92. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  93. CYEditTitleViewController *vc = [[CYEditTitleViewController alloc] init];
  94. vc.room = self.room;
  95. vc.num = _nameArr.count - indexPath.row;
  96. vc.rankTitle = _nameArr[indexPath.row];
  97. vc.nameArr = self.nameArr;
  98. [g_navigation pushViewController:vc animated:YES];
  99. }
  100. @end