ReplayMeVC.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //
  2. // ReplayMeVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/6/11.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "ReplayMeVC.h"
  9. #import "MyTDGroupView.h"
  10. #import "ReplayMeCell.h"
  11. #import "ShowBtn.h"
  12. #import "YCMenuView.h"
  13. #import "ReplayMeLikeVC.h"
  14. #import "ReplayMeSearchVC.h"
  15. @interface ReplayMeVC ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (weak, nonatomic) IBOutlet UIView *navBar;
  17. @property (weak, nonatomic) IBOutlet UIView *HeadView;
  18. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  19. @property (strong, nonatomic) ShowBtn *titleBtn;
  20. @property (strong, nonatomic) MyTDGroupView *SearchView;
  21. @property (strong, nonatomic) NSMutableArray *taskActionArray;
  22. @property (assign, nonatomic) BOOL replayMe;
  23. @end
  24. @implementation ReplayMeVC
  25. +(ReplayMeVC *)initReplayMeVC{
  26. ReplayMeVC *controller = [StoryboardManager.shared.Source instantiateViewControllerWithIdentifier:@"ReplayMeVC"];
  27. return controller;
  28. }
  29. - (ShowBtn *)titleBtn
  30. {
  31. if (!_titleBtn) {
  32. _titleBtn = [ShowBtn new];
  33. }
  34. return _titleBtn;
  35. }
  36. - (MyTDGroupView *)SearchView
  37. {
  38. if (!_SearchView) {
  39. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  40. }
  41. return _SearchView;
  42. }
  43. - (void)autoSizeBtn:(NSString *)title
  44. {
  45. [self.titleBtn setLabelTitle:title];
  46. }
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. self.fd_prefersNavigationBarHidden = YES;
  50. self.tableView.delegate = self;
  51. self.tableView.dataSource = self;
  52. [self.HeadView addSubview:self.SearchView];
  53. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.mas_offset(6);
  55. make.left.right.mas_equalTo(self.HeadView);
  56. make.height.mas_offset(36);
  57. }];
  58. WS(weakSelf);
  59. [self.SearchView.button setAction:^{
  60. ReplayMeSearchVC * vc = [[ReplayMeSearchVC alloc] init];
  61. [weakSelf.navigationController pushViewController:vc animated:YES];
  62. }];
  63. [self.navBar addSubview:self.titleBtn];
  64. [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.center.mas_equalTo(self.navBar);
  66. }];
  67. [self autoSizeBtn:@"我回复的"];
  68. [self.titleBtn setAction:^{
  69. [weakSelf.titleBtn show];
  70. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray];
  71. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:105 relyonView:weakSelf.titleBtn];
  72. view.menuColor = UIColorHex(0xFFFFFF);
  73. view.separatorColor = UIColorHex(0xEAEAEA);
  74. view.textColor = UIColorHex(0x666666);
  75. view.textFont = [UIFont systemFontOfSize:16.0];
  76. view.menuCellHeight = 45;
  77. view.maxDisplayCount = 10;
  78. view.offset = - 6;
  79. [view show];
  80. }];
  81. [self.tableView reloadData];
  82. }
  83. -(NSMutableArray *)taskActionArray{
  84. if(!_taskActionArray){
  85. _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"回复我的",@"我回复的", nil];
  86. }
  87. return _taskActionArray;
  88. }
  89. -(NSMutableArray *)getMenuDataSource:(NSMutableArray *)titleArray{
  90. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  91. for(int i = 0;i < titleArray.count;i ++){
  92. NSString *titleStr = [titleArray objectAtIndex:i];
  93. WS(weakSelf);
  94. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  95. [weakSelf.titleBtn dismiss];
  96. [weakSelf autoSizeBtn:titleStr];
  97. if([@"回复我的" isEqualToString:action.title]){
  98. weakSelf.replayMe = YES;
  99. }else{
  100. weakSelf.replayMe = NO;
  101. }
  102. dispatch_async(dispatch_get_main_queue(), ^{
  103. [weakSelf.tableView reloadData];
  104. });
  105. }];
  106. [menuDataSourceArray addObject:actionMenu];
  107. }
  108. return menuDataSourceArray;
  109. }
  110. #pragma mark -UITableViewDelegate
  111. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  112. {
  113. return 20;
  114. }
  115. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  116. {
  117. if (self.replayMe) {
  118. return 45.f;
  119. }else{
  120. return 0.01f;
  121. }
  122. }
  123. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  124. {
  125. return 0.01f;
  126. }
  127. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  128. {
  129. UIView * view = [UIView new];
  130. if (self.replayMe) {
  131. UILabel * label = [UILabel new];
  132. label.font = Kfont(16);
  133. label.textColor = UIColorHex(0x0a0a0a);
  134. label.text = @"收到的赞";
  135. [view addSubview:label];
  136. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.mas_offset(15);
  138. make.centerY.mas_equalTo(view);
  139. }];
  140. UIImageView * imgv = [UIImageView new];
  141. imgv.image = IMG(@"right_img");
  142. [view addSubview:imgv];
  143. [imgv mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.right.mas_offset(-15);
  145. make.centerY.mas_equalTo(view);
  146. }];
  147. UILabel * redL = [UILabel new];
  148. redL.font = Kfont(11);
  149. redL.textColor = UIColorHex(0xFFFFFF);
  150. redL.backgroundColor = [UIColor redColor];
  151. redL.text = @"3";
  152. redL.textAlignment = NSTextAlignmentCenter;
  153. [view addSubview:redL];
  154. [redL mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.right.mas_equalTo(imgv.mas_left).offset(-8);
  156. make.centerY.mas_equalTo(view);
  157. make.size.mas_offset(CGSizeMake(16, 16));
  158. }];
  159. redL.layer.cornerRadius = 8.f;
  160. redL.layer.masksToBounds = YES;
  161. UIView * lineV = [UIView new];
  162. lineV.backgroundColor = LINEBGCOLOR;
  163. [view addSubview:lineV];
  164. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  165. make.left.bottom.right.mas_equalTo(view);
  166. make.height.mas_offset(0.5);
  167. }];
  168. WS(weakSelf);
  169. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  170. ReplayMeLikeVC * vc = [ReplayMeLikeVC initReplayMeLikeVC];
  171. [weakSelf.navigationController pushViewController:vc animated:YES];
  172. }];
  173. [view addGestureRecognizer:tap];
  174. }
  175. return view;
  176. }
  177. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  178. {
  179. return [UIView new];
  180. }
  181. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  182. {
  183. return UITableViewAutomaticDimension;
  184. }
  185. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  186. {
  187. ReplayMeCell * cell = [ReplayMeCell configCell:tableView indexPath:indexPath];
  188. cell.redV.hidden = YES;
  189. [cell setDatasubText];
  190. return cell;
  191. }
  192. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  193. {
  194. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  195. }
  196. @end